text:
Q: How to focus on the ListRow Item which is not focusable on Firestick 3rd Generation( Android API 28) via the remote I am developing an app using leanback architecture where a certain custom view is not focused using the dpad of remote.
The onFocus() of the custom view doesn't get called in FireStick version 3(Android API 28) .
The same code gets triggered on lower versions( < Android API 28)
The custom view is a ListRow for showing genres of movies which is being fed data by GenrePresenter.
genrePresenter = new GenrePresenter(new GenrePresenter.viewListener() {
            @Override
            public void onClick(View view, String selected) {
                ((HomeFYCActivity) getActivity()).showAdapter(viewModel.genreList, selected);
            }

//THIS DOES NOT GET TRIGGERED ON API 28
            @Override
            public void onFocus(View view, Boolean hasFocus) {
                // NEED TO SET FOCUS HERE
            }
        }, "ALL GENRES");

        header = new HeaderItem("NOW PLAYING");
        genreRow = new ListRow(header, genreRowAdapter);

But instead the HeaderItem gets the focus.
Same code works on < Android API 28
The remote trackpad is used to select the other views
EDIT genrePresenter listener code
    public interface viewListener {
        void onClick(View view, String selected);
        void onFocus(View view, Boolean hasFocus);
    }

And how i invoke the listener
        ((ShowCard) viewHolder).tvGenre.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                viewListener.onFocus(v, hasFocus);
            }
        });

A: Hi After days of rigorous trial and error i found out that my XML's parent LinearLayout had to be set as
    android:clickable="false"
    android:focusable="false"

and the element which is inside the parent in my case a textview had to be defined as
   android:clickable="true"
   android:focusable="true"
   android:focusableInTouchMode="true"

I hope this answer saves your time.
Amen


text:
Q: Hibernate dialect Issues with update to Oracle 12.2 C database when using Grails We are running Grails 2.3.11 on JRE 1.8_211.  We have Hibernate version - 3.6.10.6.
When we were working with Oracle 11, it was working fine but when I upgrade to 12.2C, we get following error:-

org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [Oracle]!

On reverting back to Oracle 11, the issue gets resolved.
Can anyone please suggest a solution for migrating my application to Oracle 12.2C.

A: We had not specified the hibernate dialect in one of the datasources in datasource.groovy.
It seems that in oracle 12C, it is mandatory to specify the dialect for each data source even though it is not mandatory for Oracle 11g.
Hence, during migrating from Oracle 11g to Oracle 12C, please add verifying that dialects are explicitly specified in your checklist.
Hope this helps others.

redpajama_set_name: RedPajamaStackExchange


text:
Q: create-react-app installs with reported NPM vulnerabilities, should I do something? I am new to ReactJs and started setting up a new project with
$ npx create-react-app <app-name>

It completed but reported some vulnerabilities like following, could anyone help me with what would be the best practice to handle this or we could ignore these vulnerabilities?
What would be the best practices for setting up a ReactJS project?

found 81 vulnerabilities (21 low, 35 moderate, 24 high, 1 critical)

A: Try recommended command
the vulnerabilities may reduce.
npm audit fix

Since you don't use it in prod, in most situation it can be ignored.


text:
Q: Is my dad hacking my phone? My friend and I both have iphones. My dad has a blackberry. For some reason, my friend and I are getting the same messages from my dad every once in a while always on the same subject. This has happened twice now. My dad has never met my friend before nor does he have her number. Why is this happening?
He tends to be very protective... I'm wondering if he's monitoring my messages and there was a glitch in the system?
For the record, I don't think I have an iCloud account... so it's not as though my friend and I are sharing that or have any relation (therefore no link in Apple ID)
I've researched why this is and can't find anything! Please help!

A: No your dad isn't hacking your phone...
If your dad was using an iPhone I would suggest that you've accidentally linked yours or your friends iMessage settings to each others phones... I've putt instructions for that further down incase anyone else has this question...
It's possible but unlikely that you've got Text Message Forwarding setup, but seems strange that it would be just your dad who this was happening with. You can check in Settings > Messages > Text Message Forwarding and verify that if there are any other devices listed they are all yours.
The other possibility very likely possibility is that he does have your friends number and has sent you a group text in the past to both of you, and is now using that same group text thinking it's just you...
There is no way for him to have hacked you phone to get your messages, and frankly if he had, there is no reason why it would have accidentally sent a text from his phone to your friends as a clone. I think you are being somewhat paranoid. There is no easy way to run software that would allow this on a normal iPhone, if you did Jailbreak it then perhaps, but you dad would have to be seriously computer literate to even have a clue, and would also have to be okay with breaking the law, as most countries forbid this kind of activity.
I think this is extremely unlikely your dad is monitoring your texts, and you should just approach your dad and let him know that he sent the same text to you as your friend, could he have a look at it because it could be embarrassing in future.
Linked iMessage
It's very likely that at some point you've logged into your friends iPhone some how or they've logged into yours and left iMessage logged in on one device or another...

*

*Go to Settings on both iPhones.

*Messages

*Send & Receive

Here check that:

*

*The Apple ID on both phones is your's not your friends, and that both phones have different Apple IDs.

*The list of 'You can be reached by iMessage at' addresses only displays phone numbers and email addresses that are yours.

*Check that the 'Start new conversations from' list has that iPhone's phone number selected.


text:
Q: Custom MSBuild target not including files in a directory
I've added a custom msbuild target to include all the files from a certain directory however after doing a build they are still not included.
  <Target Name="BeforeBuild">
    <ItemGroup>
      <!--<Content Include="Content\lib\**\*.js" />
      <Content Include="Content\lib\**\*.css" />-->
      <Content Include="Content\lib\**" />
    </ItemGroup>
  </Target>

Background
(Trying to use bower to get components then include them in the project without having to manually add them)
[Asp.net 4.5.2, mvc 5, visual studio 2015 (update 3)]

A: First Create a custom Task like below
<Target Name="CustomCollectAngularFiles">
    <ItemGroup>
      <WebFiles Include="Content\lib\**\*" />
      <FilesForPackagingFromProject Include="%(WebFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
 </Target>

And then  add a property group after   <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> which is available in your csproj file and it will look like below. Key here is CopyAllFilesToSingleFolderForMsdeployDependsOn
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectAngularFiles
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>

You should be able to see the files getting copied to the build.
For more details refer https://blog.samstephens.co.nz/2010/10/18/msbuild-including-extra-files-multiple-builds/

A: Based on your description, it seems that you want to include files into project by using msbuild, as far as I know, if it is the case, I think you need to use custom build task like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
  <Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

  <UsingTask TaskName="Hello" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
    <ParameterGroup />
    <Task>
      <Reference Include="System.Xml" />
      <Reference Include="Microsoft.Build" />
      <Using Namespace="Microsoft.Build" />
      <Using Namespace="Microsoft.Build.Evaluation" />
      <Using Namespace="Microsoft.Build.Utilities" />
      <Code Type="Fragment" Language="cs">
          <![CDATA[
        string appPath = @"C:\Projects\MsBuild\App2\App2\App2.csproj";
        var project = new Project(appPath);
        var loc = "test";
        project.AddItem("Folder", loc);
        project.Save();
        Log.LogMessage("Hello, world!", MessageImportance.High);
         ]]>
        </Code>
    </Task>
  </UsingTask>

  ……
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.  -->
  <Target Name="BeforeBuild">
    <Hello />
  </Target>
  <!--<Target Name="AfterBuild">
    <Message Text="About to run MsBuildTask" Importance="high" />
    <App2.MsBuildTask/>
  </Target>
  -->
</Project>


text:
Q: How to find all object which will be dropped by CASCADE? When I DROP something like this
ALTER TABLE "order_bt" DROP COLUMN "billed_to"

the command will list dependencies of the billed_to column:
DETAIL:  view "order" depends on column billed_to of table order_bt

But, this view order also has associated triggers, which would also be dropped when adding CASCADE to the above DROP command.
Is there an option that will allow me to see the full list of what would be dropped with DROP ... CASCADE?

A: I created an example structure to check dependencies. You can try it on your database, of course objects ID will be different.
CREATE TABLE parents (
  id_parent integer NOT NULL,
  name_parent varchar(100),
  CONSTRAINT pk_parents_id PRIMARY KEY (id_parent)
);

CREATE TABLE childs (
  id_child integer NOT NULL,
  name_child varchar(100),
  parent_id integer,
  CONSTRAINT pk_childs_id PRIMARY KEY (id_child),
  CONSTRAINT fk_childs_parent_id__parents FOREIGN KEY (parent_id)
      REFERENCES parents (id_parent) MATCH SIMPLE
      ON UPDATE CASCADE ON DELETE CASCADE
);

CREATE OR REPLACE VIEW public.parents_view AS
 SELECT parents.id_parent,
    parents.name_parent
   FROM parents;

CREATE FUNCTION test_trigger() RETURNS TRIGGER AS $$
BEGIN
    IF TG_OP = 'INSERT' then
        raise notice 'INSERT trigger, NEW = [%]', NEW;
    ELSIF TG_OP = 'UPDATE' then
        raise notice 'UPDATE trigger, OLD = [%], NEW = [%]', OLD, NEW;
    ELSE
        raise notice 'DELETE trigger, OLD = [%]', OLD;
    END IF;
    RETURN NULL;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER parents_view_trigger INSTEAD OF INSERT OR UPDATE OR DELETE ON parents_view FOR EACH ROW EXECUTE PROCEDURE test_trigger();

Objects that depend of table "parents":
SELECT
    refclassid, refobjid, refobjsubid,
    pg_describe_object(refclassid, refobjid, refobjsubid),
    --pg_identify_object (refclassid, refobjid, refobjsubid) ,

    classid, objid, objsubid,
    pg_describe_object(classid, objid, objsubid),
    --pg_identify_object (classid, objid, objsubid) ,
    pg_get_constraintdef(objid),

    deptype

FROM pg_depend
WHERE refobjid IN ('parents'::regclass) -- and deptype IN ('n', 'a')
ORDER BY classid, refobjid;

Output:

refclassid
refobjid
refobjsubid
pg_describe_object refobject
classid
objid
objsubid
pg_describe_object object
pg_get_constraintdef
deptype

1259
2305241
0
table parents
1247
2305243
0
type parents

i

1259
2305241
1
table parents column id_parent
2606
2305245
0
constraint pk_parents_id on table parents
PRIMARY KEY (id_parent)
a

1259
2305241
1
table parents column id_parent
2606
2305251
0
constraint fk_childs_parent_id__parents on table childs
FOREIGN KEY (parent_id) REFERENCES parents(id_parent) ON UPDATE CASCADE ON DELETE CASCADE
n

1259
2305241
1
table parents column id_parent
2618
2305259
0
rule _RETURN on view parents_view

n

1259
2305241
2
table parents column name_parent
2618
2305259
0
rule _RETURN on view parents_view

n

Objects that depend of view "parents_view":
SELECT
    refclassid, refobjid, refobjsubid,
    pg_describe_object(refclassid, refobjid, refobjsubid),
    --pg_identify_object (refclassid, refobjid, refobjsubid),

    classid, objid, objsubid,
    pg_describe_object(classid, objid, objsubid),
    --pg_identify_object (classid, objid, objsubid) ,
    pg_get_constraintdef(objid),

    deptype

FROM pg_depend
WHERE refobjid IN ('parents_view'::regclass) -- and deptype IN ('n', 'a')
ORDER BY classid, refobjid;

Output:

refclassid
refobjid
refobjsubid
pg_describe_object refobj
classid
objid
objsubid
pg_describe_object obj
pg_get_constraintdef
deptype

1259
2305256
0
view parents_view
1247
2305258
0
type parents_view

i

1259
2305256
0
view parents_view
2618
2305259
0
rule _RETURN on view parents_view

i

1259
2305256
0
view parents_view
2618
2305259
0
rule _RETURN on view parents_view

n

1259
2305256
0
view parents_view
2620
2305260
0
trigger parents_view_trigger on view parents_view

a

You can check that view "parents_view" (object ID: 2305256) not depend of table parents but rule "rule _RETURN on view parents_view" (object ID: 2305259) does, and "trigger parents_view_trigger on view parents_view" depends on parents_view, this is the reason why recursive query do not return view dependent information.
Triggers are DEPENDENCY_AUTO type (a): The dependent object can be dropped separately from the referenced object, and should be automatically dropped (regardless of RESTRICT or CASCADE mode) if the referenced object is dropped. Example: a named constraint on a table is made auto-dependent on the table, so that it will go away if the table is dropped.
You can try a query like this, but you should try to improve it:
You can restrict the result filtering by deptype.

WITH RECURSIVE pg_depend_recursive AS (
                SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                FROM pg_depend d
                where refobjid = 'parents'::regclass

                UNION

                SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                FROM pg_depend d
                INNER JOIN pg_depend_recursive dr ON d.refobjid = dr.objid),

        pg_depend_recursive2 AS (SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                    FROM pg_depend_recursive d

                    UNION

                    SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                    FROM pg_depend d
                    INNER JOIN pg_depend_recursive2 dr ON d.objid = dr.objid AND pg_describe_object(dr.classid, dr.objid, dr.objsubid) ilike 'rule%'),

        pg_depend_recursive3 AS (SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                    FROM pg_depend_recursive2 d

                    UNION

                    SELECT d.refclassid, d.refobjid, d.refobjsubid, d.classid, d.objid, d.objsubid, d.deptype
                    FROM pg_depend d
                    INNER JOIN pg_depend_recursive3 dr ON d.refobjid = dr.refobjid)

SELECT refclassid, refobjid, refobjsubid, pg_describe_object(refclassid, refobjid, refobjsubid),
       classid, objid, objsubid, pg_describe_object(classid, objid, objsubid),
       deptype
FROM pg_depend_recursive3;


text:
Q: Any easy way to specify default value of arguments in Python class constructor without writing inheritance? Is there any easy to get a new class based on an old class which is just set some default arguments value of the old class? Code like this:
class DB():
    def __init__(self, ip, port, dbname, table):
        self.ip = ip
        self.port = port
        self.dbname = dbname
        self.table = table

    def process(self):
        print self.ip, self.port, self.dbname, self.table

Now I need to get a set of new classes with some default values of OldClass.a, OldClass.b, OldClass.c, I will do like below:
class UserDB(DB):
    def __init__(self, dbname, table):
        OldClass.__init__(self, ip='user.db.com', port='1234', dbname=dbname, table=table)

class ProdDB(DB):
    def __init__(self, dbname, table):
        OldClass.__init__(self, ip='prod.db.com', port='1314', dbname=dbname, table=table)

class CommentDB(DB):
    def __init__(self, dbname, table):
        OldClass.__init__(self, ip='comment.db.com', port='1024', dbname=dbname, table=table)

class MeetingDB(DB):
    def __init__(self, dbname, table):
        OldClass.__init__(self, ip='meeting.db.com', port='8888', dbname=dbname, table=table)

userDB = UserDB('user', 'new')
userDB.process()
prodDB = ProdDB('prod', 'lala')
prodDB.process()
commentDB = UserDB('comm', 'gg')
commentDB.process()
meetingDB = MeetingDB('met', 'ok')
meetingDB.process()

I remember there are some tricks to simplify these child class verbosity codes. Any advice is welcome. Thanks in advance.

A: You do not need to call parent's class' __init__ as you just want to set the values to the instance properties. You may simply do:
class DB():
    def __init__(self, dbname, table):
        self.dbname = dbname
        self.table = table
        self.ip = 'user.db.com'
        self.port = '1234'

I think it is much cleaner. In fact you do not need 4 child classes. You may do it within single class using parameter to differentiate the category of each db as:
class DB():

    # Database type configuration
    db_type_conf = {
        'user': {
            'ip': 'xx.xx.xx',
            'port': 'xxxx',
        },
        'comment': {
            'ip': 'xx.xx.xx',
            'port': 'xxxx',
        },
        'prod': {
            'ip': 'xx.xx.xx',
            'port': 'xxxx',
        },
        'meeting': {
            'ip': 'xx.xx.xx',
            'port': 'xxxx',
        }
    }

    def __init__(self, db_type, dbname, table):
        self.dbname = dbname
        self.table = table
        self.port, self.ip = self._get_port_and_ip_from_db_type(db_type)
        #                    return port and ip based on `db_type` ^

    @staticmethod
    def _get_port_and_ip_from_db_type(db_type):
       db_type_conf = self.__class__.db_type_conf[db_type]
       return db_type_conf['port'], db_type_conf['ip']

    def process(self):
        print self.ip, self.port, self.dbname, self.table

For creating the objects, you may simply do:
user_db = DB('user', 'user', 'new')
user_db.process()

A: Inheritance is an awesome thing:
class DB():
    def __init__(self, ip, port, dbname, table):
        self.ip = ip
        self.port = port
        self.dbname = dbname
        self.table = table

    def process(self):
        print self.ip, self.port, self.dbname, self.table

class UserDB(DB):
    def child_func(self):
        print "We Dont share Email Ids :)"

a = UserDB("151.101.1.69", 1999, "UsersInfo", "user_log")
a.process()
a.child_func()

b = UserDB("151.101.1.69", 2001, "ClickInfo", "click_log")
b.process()
b.child_func()

A: You can solve any problem with another level of indirection.;)
How about having another class in between MyDB?:
from __future__ import print_function  # for legacy Python

class DB():
    def __init__(self, ip, port, dbname, table):
        self.ip = ip
        self.port = port
        self.dbname = dbname
        self.table = table

    def process(self):
        print(self.ip, self.port, self.dbname, self.table)

Add your class that overrides the __init__():
class MyDB(DB):
    def __init__(self, dbname, table):
        super(MyDB, self).__init__(self.ip, self.port, dbname, table)

Now use with class attributes. These classes do not need an __init__() anymore::
class UserDB(MyDB):
    ip = 'user.db.com'
    port = '1234'

class ProdDB(MyDB):
    ip = 'prod.db.com'
    port = '1314'

Making two test instances:
user_db = UserDB('user', 'new')
user_db.process()

prod_db = ProdDB('prod', 'lala')
prod_db.process()

Output:
user.db.com 1234 user new
prod.db.com 1314 prod lala

This provides a rather declarative way of doing things.
It should pretty readable, especially if the classes UserDB and ProdDB don't have an methods.
Since self.ip and self.port, do not exist in the instance self, the search will proceed to the class attributes of the current class, i.e. UserDB if we work with UserDB.


text:
Q: will or be v-ing? This is one of the questions used in the ongoing national exam in my country. Although suggested answers have come out, I'd like to confirm the correct answer.
"The headmaster has decided that three lecture halls ___________ in our school."
A. will be built
B. are being built
C. will be building
D. will build

A: The correct answer here is A:

The headmaster has decided that three lecture halls will be built in our school.

This is because the "has decided" part of the sentence indicates a decision prior to further action, so the rest of the sentence is a subordinate clause. As the buildings are the subject of the subordinate clause, you can only refer to them as complete because they aren't building themselves.

There seems to be some debate about the tense of answer B, "are being built" is the present progressive tense; something that is currently happening. For example, to extract the subordinate clause:

"Three lecture halls are being built in our school."

As it's own sentence this makes perfect sense, but it means that the action is ongoing.
The important distinction is the decision of the Headmaster, and a perfect demonstration of why context is important. The second part of the sentence is dependent upon the first half, and while it makes sense by itself, it doesn't make sense in conjunction with the first half.
If you are relatively new to English (I'm a native English speaker, and grammar enthusiast) then you might read this ELL page and see if it helps.


text:
Q: Environment Variables not picked up by code through plist In my main target .plist file I have this:
<key>HIHomePage</key>
<string>$(MY_BASE_URL)</string>

I'm using a build schema per each environment I have (development, staging, production), so I set MY_BASE_URL in Environment Variables in the build step of the schema.
Then in code I have this:
NSString *baseURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"HIHomePage"];

That turns out to be an empty string, however stuff such as CFBundleName is being picked up.
What am I missing here?

A: To get values from environment variables use the following code
NSString *baseURL = [[[NSProcessInfo processInfo] environment] objectForKey:@"MY_BASE_URL"];

Ref : http://rosettacode.org/wiki/Environment_variables#Objective-C
To add items in plist from scheme, you should dd a user defined build settings with name MY_BASE_URL and enter values as per your scheme. Then use it in .plist file.
For adding user defined build settings,
Select target
From Editor menu > Add Settings > User defined Settings


text:
Q: How to overflow content in one direction for a custom Menu? What I am trying to do ?

*

*I have a custom Menu in my app with some options (say 8 options)

*Based on some logic I need to disable some options in the menu (say last 4 options)

*If the user hovers over any disabled option, I need to show a popup explaining why the option was disabled

Issue :

*

*Since the number of options in the menu are not known before-hand, the menu should be scrollable to accommodate for more options (if required)

*However, the popup upon hovering on a disabled option should overflow the menu boundaries (if required)

*This basically boils down to having overflow-x: visible and overflow-y: auto which is not possible as per the specs

*Some of the posts that I referred use absolute positioning to get around this issue but that does not seem to help here

References :

*

*How do I enable scrolling only in one direction in CSS?

*Break out of overflow:hidden

*CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue
I tried to create my dummy custom menu that reproduces the issue : https://codepen.io/adiltan/pen/BaJJzOb
I have tried using absolute positioning but I could not get it to work

A: A DOM method getboundingclientrect will solve this for you.
This method returns selected element's placement so you don't need to nest the tooltip inside your menu.
Make a wrapper that will contain your tooltips as direct child of body and give them placement you got from getboundingclientrect.


text:
Q: How to find the eigen values and eigen vectors of the system How to find the eigen values and eigen vectors of the system
$ \begin{align}  \frac{dx}{dt}=-ax+ay \\ \ \frac{dy}{dt}=bx-y \ \ \ \ \  \end{align} $
Where $ a>0 \ $. Discuss the cases $ \ \ b=1 , \ \ b< 1 , \ \ b>1 \ $. Further sketch the direction field .
Answer:
I found the Eigen values as follows :
$ \lambda=\frac{-(1+a) \pm \sqrt{(1+a)^2-4(1-b)}}{2} \ $
For $ \ b=1 \ $ , we have
$ \lambda=0 , \ \ -(1+a) \ $
But how can I discuss the other cases and find the Eigen vectors?
It becomes complicated .
I need help doing this.

A: Hint: Use the eigenvalues $\lambda_i$ that you calculated for
$$\left[\boldsymbol{A}-\lambda_i\boldsymbol{I}\right]\boldsymbol{v}_i=\boldsymbol{0}.$$
And solve for the components of $\boldsymbol{v}_i$.


text:
Q: Data used in WhatsApp If I am sending a text message of 100 letters/digits over WhatsApp then how can I measure the size of the text message in mb and what is its connection with the MB required for sending that message.
Similarly if I am sending an image of size x mb then how much of data will be used for it?

A: you can use 3G watchdog Here . To monitoring data usages, after send message just back to 3G watchdog app and see how many data are used


text:
Q: Touchpad not working on Acer Travelmate 4740 after applying recent updates in Ubuntu 12.04 My touchpad stopped working on my Acer Travelmate 4740 after I've applied updates through the Update Manager on Precise Pangolin. It is working when on the (LightDM) login screen, but not after logging in. I've tried everything that was suggested in the following threads to no avail:

*

*https://askubuntu.com/questions/129849/touchpad-not-working-occasionally-in-compaq-presario-cq45

* Keyboard and touch pad is not working on a Dell XPS 15z

*Touchpad stops working after restart on a Compaq Presario CQ-40 324la
Any help would be much appreciated. Thanks.
More Information:

*

*It is working when I log into LXDE (Installed "lubuntu-desktop"), but not in Unity.

A: This exact thing append to me to after upgrading to ubuntu 12.04 from 12.04 beta
and i found a working solution here.

*

*sudo apt-get install dconf-tools

*press alt+f2 or open terminal and launch dconf-editor

*go to /org/gnome/settings-daemon/peripherals/touchpad and check touchpad-enable

A: Though the robot warn me that I should edit my answer rather than posting a new one, I thought new answer helps separation between each of them. I'd like to tell that my touchpad problem was solved. What I did was press Fn-F7 at the login screen and I found that the touchpad worked. I then input my password to login and the touchpad continued to work. Now the whole system works flawlessly. Very happy now. However, I'm not sure this happening relates to what I have followed other suggestion or not. I'm creating my blog and I'll put all my steps there and back to this post to make a link to it. Thanks people. You all are good friends.


text:
Q: Maven not downloading jars behind proxy Maven is unable to download jar (s) (Dependency) behind proxy.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/xsd/maven-4.0.0.xsd">

     <modelVersion>4.0.0</modelVersion>

<groupId>com.faizan.firstbootapp.group1</groupId>
<artifactId>com-faizan-firstbootapp-group-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FirstBootApp</name>
<description>Test app for Maven build system</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

</project>

Here is my settings.xml at path C:\Users\faizanmubasher\.m2\settings.xml. I have added proxies in it.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
 <proxies>
  <proxy>
    <id>skm--http-proxy</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>my.proxy.ip.here</host>
    <port>8080</port>
    <username>faizanmubasher</username>
    <password>*****</password>
  </proxy>
  <proxy>
    <id>skm--https-proxy</id>
    <active>true</active>
    <protocol>https</protocol>
    <host>my.proxy.ip.here</host>
    <port>8080</port>
    <username>faizanmubasher</username>
    <password>*****</password>
  </proxy>
 </proxies>
</settings>

Username and password are correct.
Is it due to my office's proxy that is not allowing to download jar or is it some Maven settings that I need to configure?
I am facing this error on STS IDE.
The container 'Maven Dependencies' references non existing library 'C:\Users\faizanmubasher\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE\spring-boot-autoconfigure-2.0.2.RELEASE.jar'    FirstBootApp        Build path  Build Path Problem

My Maven version is Apache Maven 3.5.3.
EDIT
The command set MAVEN_OPTS="-DhttpProxyHost=xxx.xx.xx.xx -DsocksProxyPort=8080" doesn't work as well.

A: Try this, if 1 does not work try 2, then 3:
1) First update the project, Alt-F5

2) Then go to your repo and blow away the directory for that dependency which should be in the directory C:\Users\faizanmubasher.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE Then do an Alt-F5 again.

3) If this fails try a mvn clean install -U from the command line.

You can test your maven to maven central repo connectivity with the following command:
mvn archetype:generate

You should see over 2000 archetypes returned

A: *

*I have encountered the same problem.

*And I turned back to older versions of maven which is 3.1.0.

*I was trying to use a http proxy to    get reached to maven https
repository.
Here, there is a issue for newer versions in maven's jira.
https://issues.apache.org/jira/browse/PROXY-27


text:
Q: Extract part of a path I have a variable that is a path of a windows folder.
I would like to handle the way with SED .
Example:
Input:
\\computer1\folder$

Output:
computer1

I would always pick the host name that is between \\ and \
Could someone give me a light?

A: You can do this in a POSIX compatible shell:
% folder='\\computer1\folder$'
% folder="${folder/\\\\/}" # Remove leading '\\'
% printf "%s\n" "${folder%%\\*}"
computer1

Alternative with Bashism:
% folder='\\computer1\folder$'
% [[ "$folder" =~ '\\'([^\\]*) ]]
% printf "%s\n" "${BASH_REMATCH[1]}"
computer1

A: For this scenario, awk is a better option. Use awk -F'\' '{print $2}'
Example
$> echo "\\computer1\folder$"|awk -F'\' '{print $2}'

Output
computer1

Or you can try putting it with a variable.
$> export val="\\computer1\folder$"

$> echo $val|awk -F'\' '{print $2}'
computer1

A: With sed :
$ sed 's/\\\\\([^\]*\)\\.*/\1/' <<< '\\computer1\folder$'
computer1

The basic syntax for sed substitution command is s/oldtext/newtext/.

*

*s is for substitution command

*in the path string, every \ must be escaped so it becomes \\

*\([^\]*\)\ captures every non \ character until next \

*the captured string is output with backreference \1

A: With awk. s stands for "separator" and a stands for "any".
echo '\\computer1\folder$' | \
awk '{s="\\\\"; a=".*"; sub(a s s, ""); sub(s a, ""); print}'


text:
Q: Details on Clairvoyance? What are the specifics on the Clairvoyance spell? I know it shows a path, but like what does dual-casting it do? How do you use it to raise your Illusion skill?

A: I don't think it serves any purpose at all other than giving you a direction towards your next marker, as far as leveling, I would assume you would get a few minor points for using the spell, but not necessarily for the spell affecting anything and giving you a damage bonus

A: Duel casting just increases the range of the path shown to your objective. Its probably about twice as long. Doesn't really make all that much difference however, 1 handed does the job fine.

A: It displays a path to an objective. It is illusion school, and I have never unlocked illusion dual-casting. It is very inefficient at raising illusion, if at all it does so. I have never noticed it raise a skill level for illusion - but I have never explicitly checked. It is a more immersive way of playing, with quest markers toggled off, but is naturally less powerful.
It can only display a path when...it can calculate a path, and will not be able to do so when far from basic ground terrain - boulders are not ground terrain. In this case it will fizz and pffft and a message will display that no path was found.
There is an order of priority for the path:
1) A player defined map marker overrides all others. So, be careful to ensure you are following the quest marker and not one you accidentally placed when checking the map
2) When multiple quests are active, I believe it chooses the most recently updated quest.
3) When a quest has multiple different types (e.g. two different NPC) targets only one path (unfortunately) will display. I believe this gives precedence to a lower queststage id of the target. Be careful as, unlike with quest markers on the map, you may not realise that there are alternative ways of completing a quest - even when reading the details of the quest in the journal. Todd's "Morrowind level of quest text detail" claim was nonsense.
4) When a quest has multiple specific objects, e.g. 3 unique books, then it will target the closest. It will not show a path to a non-unique item required (e.g. 10 fire salts) -  the item instance must be explicitly defined for the quest (somewhere in the quest files).
I know nothing else about it, and my observations are probably imperfect =)
EDIT: I forgot to add a point about water. It will try and circumvent water, even if a short swim is quicker, but if it cannot find a path around then it will lead you to the water - but not through the water.


text:
Q: select nested query CodeIgniter Please help. How to query this in CodeIgniter query builder. I don't know how to nested queries in codeigniter
select * from customer aa
   left join (select a.customerId,
          max(case
                 when b.domainValue = 'CEDC' then
                       IFNULL(b.value, 0)
          end) 'CEDC',
          max(case
                 when b.domainValue = 'PEDC' then
                       IFNULL(b.value, 0)
          end) 'PEDC',
          max(case
                 when b.domainValue = 'TPC' then
                       IFNULL(b.value, 0)
          end) 'TPC',
          max(case
                 when b.domainValue = 'SUAL' then
                       IFNULL(b.value, 0)
          end) 'SUAL',
          max(case
                 when b.domainValue = 'PAGBILAO' then
                       IFNULL(b.value, 0)
          end) 'PAGBILAO'
          from customer a
          left join salescontractdetail b
                 on a.customerId = b.salesContractId
    group by a.customerId) bb
   on aa.customerId = bb.customerId

Thanks

A: Use db->query
$sql = "SELECT * ....."; # your formatted SQL query
$this->db->query($sql);

Read Regular Queries in codeigniter.com

A: You can rewrite your query as below
SELECT c.*,
    MAX(CASE WHEN s.domainValue = 'CEDC' THEN IFNULL(s.value, 0) ELSE 0 END) as CEDC,
    MAX(CASE WHEN s.domainValue = 'PEDC' THEN IFNULL(s.value, 0) ELSE 0  END) PEDC,
    MAX(CASE WHEN s.domainValue = 'TPC' THEN IFNULL(s.value, 0)  ELSE 0  END) TPC,
    MAX(CASE WHEN s.domainValue = 'SUAL' THEN IFNULL(s.value, 0) ELSE 0  END) SUAL,
    MAX(CASE WHEN s.domainValue = 'PAGBILAO' THEN IFNULL(s.value, 0) ELSE 0 END) PAGBILAO
FROM customer c
LEFT JOIN salescontractdetail s ON c.customerId = s.salesContractId
GROUP BY c.customerId

Using active record it can be written something like below
$this->db->select("c.*,
    MAX(CASE WHEN s.domainValue = 'CEDC' THEN IFNULL(s.value, 0) ELSE 0 END) as CEDC,
    MAX(CASE WHEN s.domainValue = 'PEDC' THEN IFNULL(s.value, 0) ELSE 0  END) PEDC,
    MAX(CASE WHEN s.domainValue = 'TPC' THEN IFNULL(s.value, 0)  ELSE 0  END) TPC,
    MAX(CASE WHEN s.domainValue = 'SUAL' THEN IFNULL(s.value, 0) ELSE 0  END) SUAL,
    MAX(CASE WHEN s.domainValue = 'PAGBILAO' THEN IFNULL(s.value, 0) END ELSE 0 ) PAGBILAO", FALSE)
            ->from('customer as c')
            ->join("salescontractdetail as s", "c.customerId = s.salesContractId", "left")
            ->group_by("c.customerId")
            ->get()
;

A: $this->db->select('"c.*,
    MAX(CASE WHEN s.domainValue = 'CEDC' THEN IFNULL(s.value, 0) ELSE 0 END) as CEDC,
    MAX(CASE WHEN s.domainValue = 'PEDC' THEN IFNULL(s.value, 0) ELSE 0  END) PEDC,
    MAX(CASE WHEN s.domainValue = 'TPC' THEN IFNULL(s.value, 0)  ELSE 0  END) TPC,
    MAX(CASE WHEN s.domainValue = 'SUAL' THEN IFNULL(s.value, 0) ELSE 0  END) SUAL,
    MAX(CASE WHEN s.domainValue = 'PAGBILAO' THEN IFNULL(s.value, 0) END ELSE 0 )
    PAGBILAO", FALSE);
        $this->db->FROM('customer as c');
        $this->db->join('salescontractdetail s', 'c.customerId =
        s.salesContractId','left');
        $this->db->group_by("c.customerId");

        $query = $this->db->get()->result_array();

        return $query;


text:
Q: scipy: How to minimize the minimum residual sum of squares with constraint? When using Ordinary Least Squares linear regression method to fit x and y, it will get a function y = a*x + b, but in my case I need to make b <= 0.
x = [139, 162, 147, 110, 145, 144, 131, 132, 135, 85, 77, 90, 103, 163, 102, 31, 71, 95, 143, 94, 81, 82, 79, 64, 102, 122, 130, 117, 109, 46, 26, 26, 36, 105, 135, 14, 63, 93, 75, 128, 86, 107, 137, 49, 99, 96, 112, 124, 129, 68, 111, 128, 11, 13, 63, 104, 127, 98, 95, 85, 87, 98, 76, 119, 69, 103, 86, 87, 91, 90, 100, 102, 105, 116, 127, 127, 82, 126, 99, 116, 61, 64, 83, 85, 83, 83, 82, 97, 105, 116, 130, 91, 120, 102, 124, 66, 79, 83, 82, 80, 80, 91, 91, 122, 99, 126, 49, 92, 76, 80, 97, 107, 109, 117, 62, 120, 111, 75, 130, 75, 105, 118, 115, 97, 62, 123, 98, 57, 109, 104, 51, 102, 60, 65, 113, 117, 18, 83, 88, 93, 31, 57, 39, 25, 37, 26, 27, 36, 109, 113, 68, 100, 110, 108, 109, 109, 96, 61, 55, 78, 97, 115, 109, 105, 107, 50, 98, 99, 89, 68, 107, 112, 119, 126, 117, 112, 104, 72, 38, 35, 30, 82, 101, 92, 98, 103, 97, 85, 37, 33, 73, 56, 49, 100, 63, 24]

y = [151, 170, 53, 182, 188, 181, 137, 186, 149, 76, 149, 156, 168, 147, 102, 107, 132, 150, 148, 57, 109, 110, 87, 151, 163, 152, 109, 131, 85, 63, 73, 102, 129, 155, 49, 89, 151, 157, 126, 136, 72, 150, 78, 142, 45, 171, 127, 132, 67, 139, 131, 73, 77, 34, 162, 131, 159, 61, 132, 100, 116, 106, 152, 164, 127, 104, 125, 100, 111, 122, 140, 139, 139, 160, 159, 91, 159, 150, 136, 122, 22, 100, 109, 108, 116, 115, 115, 147, 169, 167, 51, 143, 100, 145, 110, 89, 103, 98, 99, 102, 140, 153, 156, 88, 178, 168, 89, 105, 27, 152, 154, 60, 179, 129, 122, 146, 44, 157, 91, 142, 118, 155, 138, 72, 140, 146, 59, 168, 138, 74, 108, 121, 28, 141, 159, 172, 69, 112, 126, 103, 127, 95, 86, 79, 65, 43, 66, 71, 155, 139, 132, 139, 139, 161, 141, 73, 122, 97, 126, 77, 156, 141, 161, 169, 145, 116, 148, 141, 83, 138, 94, 120, 137, 149, 164, 139, 116, 94, 92, 79, 79, 134, 129, 110, 130, 138, 156, 129, 74, 128, 104, 50, 127, 107, 48, 58]

# Define the Model
f = lambda x, a, b: a * x + b

# The objective Function to minimize (least-squares regression)
obj = lambda x, y, a, b: np.sum(np.abs(y - f(x, a, b))**2)

I'm not sure the f and obj is right. How to define the condition of constraint that will make the b less than zero?

A: Like sascha already mentioned in the comments, there's no need for the abs function since (y - f(x,a,b))**2 is always positive. By using scipy.optimize.minimize, you could do it like this:
from scipy.optimize import minimize
import numpy as np

# x = np.array([139, ...])
# y = np.array([151, ...])

# Define the Model
def f(x, a, b): return a * x + b

# The objective Function to minimize (least-squares regression)
def obj(x, y, a, b): return np.sum((y - f(x, a, b))**2)

# define the bounds -infty < a < infty,  b <= 0
bounds = [(None, None), (None, 0)]

# res.x contains your coefficients
res = minimize(lambda coeffs: obj(x, y, *coeffs), x0=np.zeros(2), bounds=bounds)


text:
Q: Single app mode enterprise app update I have kiosk application installed on iPad in Supervised ASAM mode. I am shipping/installing this iPad to my customer's site. This way customer can use only my kiosk application. I am distributing my app using Enterprise Distribution Process.
Now I want to update my application in all those iPads. I want to update the app in such a way that it don't show popup for update. I want to force update my application in background that does't require user input.
How can i do that?
Can I programmatically call for an update to an enterprise app installed via mdm in the background? Or is this something I have to push through the MDM and can't be called on from an app within the iPad?


text:
Q: Out of memory when trying to get drawable resources from other apps From my app I am trying to get from other installed apps a specific drawable resources. The resource always exist. I use :
Resources resources = activity.getPackageManager().getResourcesForApplication(packageName);
int previewResID = resources.getIdentifier("image", "drawable", packageName);
Drawable myThemePreview = resources.getDrawable(previewResID);

I get the out of memory on the last line before drawable converted to bitmap and shows up to user

A: You could use BitmapFactory::decodeResource using with a BitmapFactory.Options with a specified inSampleSize to reduce memory.
It would look something like this:
Resources resources = activity.getPackageManager().getResourcesForApplication(packageName);
int previewResID = resources.getIdentifier("image", "drawable", packageName);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeResource(resources,previewResId,options);


text:
Q: Difficulty passing object from one controller to anothher I am trying to pass an object from one controller to another controller, but it is not behaving in the way that I would like it to. In the following ApplicantMainController, I am instantiating an object called ApplicationQuestions (which contains a List<ApplicationQuestion> object as one of its members) and then attempting to pass it via the RedirectToAction method call:
public ActionResult FormAction(FormCollection collection)
{
    if (collection["cmdSearch"] != null)
    {
        // more code above...

        ApplicationQuestions questions = new ApplicationQuestions();

        MultipleChoiceQuestion q1 = new MultipleChoiceQuestion("Can you lift 50 pounds?");
        MultipleChoiceQuestion q2 = new MultipleChoiceQuestion("Are you at least 18 years of age?");
        MultipleChoiceQuestion q3 = new MultipleChoiceQuestion("Are you legally able to work in the US?");
        MultipleChoiceQuestion q4 = new MultipleChoiceQuestion("Have you ever been convicted of a felony?");

        q1.AddPossibleAnswer(1, new Answer("Yes", true));
        q1.AddPossibleAnswer(2, new Answer("No", false));
        q2.AddPossibleAnswer(1, new Answer("Yes", true));
        q2.AddPossibleAnswer(2, new Answer("No", false));
        q3.AddPossibleAnswer(1, new Answer("Yes", true));
        q3.AddPossibleAnswer(2, new Answer("No", false));
        q4.AddPossibleAnswer(1, new Answer("Yes", false));
        q4.AddPossibleAnswer(2, new Answer("No", true));

        questions.AddQuestion(q1);
        questions.AddQuestion(q2);
        questions.AddQuestion(q3);
        questions.AddQuestion(q4);

        // not sure how to pass the object here??
        return RedirectToAction("Apply", "ApplicantApply", new { model = questions });
    }
}

When I redirect to the controller, it appears to make it:
private ApplicationQuestions m_questions;

// more code ...

public ActionResult Apply(ApplicationQuestions questions)
{
    m_questions = questions;
    return RedirectToAction("NextQuestion", "ApplicantApply");
}

However, though the reference is now bound to the parameter passed to the Apply method, the debugger tells me that the reference to the collection questions does not contain any elements, though clearly the caller passed a collection with four elements. I think I am misunderstanding how this works -- what is the proper way to communicate objects between controllers like this?

A: One option is to use TempData to hold the object during the redirect.
TempData["MyCoolData"] = questions;
return RedirectToAction("Apply", "ApplicantApply");

Then grab the object out of TempData in the other action:
m_questions = (ApplicationQuestions)TempData["MyCoolData"];

See this question and its answers for more information.


text:
Q: Video as background parallax CSS I'm more backend guy than frontend, so if you consider my question as dummy, sorry for that, but I couldn't find answer :)
My aim is to have background video with parallax using CSS. In general I did manage to do that, but result is not good enough. Because of some reason, video which is in background is under all sections, instead of being in just one section where it supposed to be...
HTML:

  <video autoplay poster="" class="video-parallax" loop muted>
    <source src="https://showbox-tr.dropbox.com/transcode_video/t/1qz2fy47wt9ay7i/header_background.mp4" type="video/webm">
    <source src="https://showbox-tr.dropbox.com/transcode_video/t/1qz2fy47wt9ay7i/header_background.mp4" type="video/mp4">
  </video>

CSS:
body{
  margin: 0;
  padding:0
}

.fullScreenPhoto{
  width: 100%;
  margin:0;
  height:300px;
  background-color: red;
}

.fullScreenPhoto2{
  width: 100%;
  height:300px;
    margin:0;
  background-color: green;
}
.fullScreenPhoto3{
  width: 100%;
    margin:0;
  height:300px;
  background-color: yellow;
}

video {
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    transform: translateX(-50%) translateY(-50%);
    background-size: cover;
    transition: 1s opacity;
}

.video-container {
    height: 600px;
}

.video-parallax {
    -webkit-transition-position: fixed;
    position: fixed;
}

Here you can fiddle:
Fiddle
where I've duplicated my issue. If you will hide one section, or change z-index for higher, you are able to see, that video is all over the page...
BTW. I know about plugin jQuery -> https://github.com/linnett/backgroundVideo, but I would like to use just CSS.

A: You can easily do this as you do with image parallax.
The HTML:

  <video autoplay muted loop>
  <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
  </video>

Video Background

The CSS
.ParallaxVideo{
    height: 300px;
    padding-bottom: 50px;
    padding-top: 50px;
}
.ParallaxVideo video{
    min-width: 100%;
    position: fixed;
    top:0;
    z-index: -999;
}
.ParallaxVideo h1 {
  color: #fff;
  font-size: 76px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

You can also take a look this tutorial for more details:
https://codeconvey.com/video-parallax-background-using-css3/
Here is demo version:
http://codeconvey.com/Tutorials/VideoParallaxBackground/

A: You need to set a css height for the video element, or on the element itself like  <video height="400">. Updated Fiddle.

A: If you want video to be background only for this one div then you couldn't have parallax effect, because then you need remove position: fixed for .video-parallax (so all styles for this class as I see) and change styles for video to that:
video {
    margin:0 auto;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    background-size: cover;
    transition: 1s opacity;
}

A: For this purpose I am using Materialize CSS. It is straightforward. We want a video as background parallax CSS.
HTML WITH MATERIALIZE CSS

    <video autoplay muted loop id="anyvideo">
        <source src="somevideo.mp4" type="video/mp4">
    </video>

We can also make our video responsive i.e. adjust to screen size accordingly.

    <video autoplay muted loop id="anyvideo" class="responsive-video">
        <source src="somevideo.mp4" type="video/mp4">
    </video>

In the above code only the class="responsive-video" has been added and that makes the video responsive.


text:
Q: TypeScript failes to infer return type of constrained generic function in some cases, why is this happening? I have this code, which works just fine in a simple case, meaning the "permissionList" const is type inferred, VSCode can suggest me the properties, such as "permission_1". Also inside the "constraintFn", when I declare the object from which the type is inferred, it suggests me "code" and "id", since these are the valid properties that you can use based on the generic type "T".
type PropType<T> = {
    [key: string]: T;
};

type Codes = 'code1' | 'code2';

class PermissionType {
    code: string;
    id: number;
}

const constraintFn = <T, TRe extends PropType<T>>(t: { new(): T; }, obj: TRe): TRe => {

    return obj;
};

export const permissionList = constraintFn(PermissionType, ({
    permission_1: {
        code: 'code1',
        id: 1,
    },
    permission_2: {
        code: 'code2',
        id: 2,
    },
}));

Now, if I change one thing:
class PermissionType {
    code: Codes; // this changed from string, to Codes
    id: number;
}

The inference still works when I declare the object in the function param, I can chose from a list of Codes, BUT the inference of the const "permissionList" disappears, and it only displays:
PropType<PermissionType>

Instaead of:
{
    permission_1: {
        code: string;
        id: number;
    };
    permission_2: {
        code: string;
        id: number;
    };
}

Thanks, I hope there's a solution to this. It would be fun to create these kind of types.

A: My solution so far is this. I don't really consider this as a perfect one, since it involves some kind of weird type recursion (see how TRe is constrained by a type that accepts TRe as a generic parameter), which feels like a hack. Anyways, if it helps someone, this compiles fine.
[edit]: reflecting on the answer containing "as const", that's something I don't want to write on the end of each object that I supply as parameter to the "constraintFn". I much rather find a solution that does this inside the function.
type PropConstraintType<TObj, TProp> = {
    [K in keyof TObj]: TProp;
};

type Codes = 'code1' | 'code2';

class PermissionType {
    code: Codes;
    id: number;
}

const constraintFn = <T, TRe extends PropConstraintType<TRe, T>>(t: { new(): T; }, obj: TRe): TRe => {

    return obj;
};

export const permissionList = constraintFn(PermissionType, ({
    permission_1: {
        code: 'code1',
        id: 1,
    },
    permission_2: {
        code: 'code2',
        id: 2,
    },
}));

A: Odd that using as const here makes TypeScript give you the whole type...
export const permissionList = constraintFn(PermissionType, {
    permission_1: {
        code: "code1",
        id: 1,
    },
    permission_2: {
        code: 'code2',
        id: 2,
    },
} as const); // added here

Playground

A: When we use generics for type alias, the Typescript compiler generally doesn't go to infer types at each of the levels, hence we just see the alias PropType<PermissionType>
There is a trick using which we can make this type expand with a custom type alias Id<T>
type Id<T> = {} & {[k in keyof T]: T[k]}

// This type allows the expansion of other type
type Id<T> = {} & {[k in keyof T]: T[k]}

const constraintFn = <T, TRe extends PropType<T>>(t: { new(): T; }, obj: TRe): Id<TRe> => {
    return obj;
};

export const permissionList = constraintFn(PermissionType, {
    permission_1: {
        code: "code1",
        id: 1,
    },
    permission_2: {
        code: 'code2',
        id: 2,
    },
});

// Now permission list has types => { [x: string]: PermissionType }

Code Playground


text:
Q: touchSwipe jquery click issue i am using touchSwipe plugin of jquery to convert swipe into click .
it seems to be working as when i swipe pages refresh or try to reach next page but same content is being displayed.
i have doubt in this line of code for next click/swipe.
         window.location.href='http://something.com/aakarsha/2559277';

here is my fiddle.Any help will be great
https://jsfiddle.net/bydbest/9gsgLqst/
here is direct link
http://something.com/aakarsha/2559277

0 Likes

i have gone through github and aware about the blocking of anchor tag so excluded the same in javascript. then also its not working

A: Solved the problem. it was the link which was causing problem. it works just fine now.enjoy


text:
Q: Locking down remote desktop using AD GPO I am currently locking down a companies remote desktop access via a VPN.  What I need to do is disable remote printing, file transfer and clipboard via active directory for the workstations that will be accessed.  I am having trouble figuring out which GPO's are used to restrict this.
My basic approach is to restrict VPN users to port 3389 so the will be able to access their work computers remotely but nothing else (I will look into layer 7 scanning later).  With this I want to ensure they are unable to transfer and data via files, printing or the clipboard.
The environment is Windows Server 2003

A: So if I understand your requirements, you have the VPN setup so when users connect, they are behind a firewall that restricts all traffic except for 3389 which is used for MS RDP to their desktops to do their work. You also want to restrict users from printing from their work PC's to any external printers, prevent them from cutting and pasting via the RDP session clipboard and transferring files off their PC's.
I think you need to look at this from a network perspective as well as policy settings.
You can create a policy and prevent LPT port redirection under the GPO computer setting "Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Device and Resource Redirection\Do Not Allow LPT Port Redirection". You can also configure the clipboard in the same location.
As far as transferring files from that PC to somewhere else, you will have to restrict protocols at the network layer to prevent SMB, HTTP, HTTPS, FTP, etc from your internal network to anywhere external. If that is already in place then nothing related to the RDP should change that. AFAIK, cutting and pasting of files via RDP is not supported.
Remember if you allow them to access email from their desktop, they can always email files and such out unless you block it on the email server.

A: Have you considered adding a 2008 server and setting up the Remote Desktop Gateway?  In the Remote Desktop Gateway policy you can disable devices redirection.
With A Remote Desktop Gateway the users will not need a VPN client, and you won't have to do anything to the workstations.

A: The vpn should be established prior to connection to rdp, so rdp should not be exposed to the internet so you don't have to worry about rdp's port useage.
as far as gpo settings look within gpmc
computer/admin templates/windows components/terminal services etc...


text:
Q: Convert Generic Collection to JSON in C# I'm facing a scenario while adding data into a collection. I need to add some data into a collection and then convert into json in a required format.
The problem is i'm not getting my required json output, only dictionary collection giving me my required output but dictionary doesn't allow duplicate keys in it, and i need to add duplicate data.
I've tried different collection but unable to get required out put.
Please look at the following code snippets and suggest me a proper solution.
//with distinct emails
var dict = new Dictionary<string, object>();
dict.Add("user1@company.com", new { id = 1, first = "FirstName", last = "LastName" });
dict.Add("user2@company.com", new { id = 2, first = "FirstName", last = "LastName" });
dict.Add("user3@company.com", new { id = 3, first = "FirstName", last = "LastName" });
dict.Add("user4@company.com", new { id = 4, first = "FirstName", last = "LastName" });
string dictJson = new JavaScriptSerializer().Serialize(dict);
//json result (requires output)
//{"user1@company.com":{"id":1,"first":"FirstName","last":"LastName"},"user2@company.com":{"id":2,"first":"FirstName","last":"LastName"},"user3@company.com":{"id":3,"first":"FirstName","last":"LastName"},"user4@company.com":{"id":4,"first":"FirstName","last":"LastName"}}

//Snippet - I: with duplicate emails
var list = new List<KeyValuePair<string, object>>();
list.Add(new KeyValuePair<string, object>("user1@company.com", new { id = 1, first = "FirstName", last = "LastName" }));
list.Add(new KeyValuePair<string, object>("user1@company.com", new { id = 2, first = "FirstName", last = "LastName" }));
list.Add(new KeyValuePair<string, object>("user2@company.com", new { id = 3, first = "FirstName", last = "LastName" }));
list.Add(new KeyValuePair<string, object>("user2@company.com", new { id = 4, first = "FirstName", last = "LastName" }));
string listJson = new JavaScriptSerializer().Serialize(list);
//json result
//[{"Key":"user1@company.com","Value":{"id":1,"first":"FirstName","last":"LastName"}},{"Key":"user1@company.com","Value":{"id":2,"first":"FirstName","last":"LastName"}},{"Key":"user2@company.com","Value":{"id":3,"first":"FirstName","last":"LastName"}},{"Key":"user2@company.com","Value":{"id":4,"first":"FirstName","last":"LastName"}}]

//Snippet - II: with duplicate emails
var tupleList = new List<Tuple<string, CustomClass>>();
tupleList.Add(Tuple.Create("user1@company.com", new CustomClass { id = 1, first = "FirstName", last = "LastName" }));
tupleList.Add(Tuple.Create("user1@company.com", new CustomClass { id = 2, first = "FirstName", last = "LastName" }));
tupleList.Add(Tuple.Create("user2@company.com", new CustomClass { id = 3, first = "FirstName", last = "LastName" }));
tupleList.Add(Tuple.Create("user2@company.com", new CustomClass { id = 4, first = "FirstName", last = "LastName" }));
string tupleListJson = new JavaScriptSerializer().Serialize(tupleList);
//json result
//[{"Item1":"user1@company.com","Item2":{"id":1,"first":"FirstName","last":"LastName"}},{"Item1":"user1@company.com","Item2":{"id":2,"first":"FirstName","last":"LastName"}},{"Item1":"user2@company.com","Item2":{"id":3,"first":"FirstName","last":"LastName"}},{"Item1":"user2@company.com","Item2":{"id":4,"first":"FirstName","last":"LastName"}}]

//Snippet - III: with duplicate emails
var genericList = new List<MainClass>();
genericList.Add(new MainClass { email = "user1@company.com", details = new CustomClass { id = 1, first = "FirstName", last = "LastName" } });
genericList.Add(new MainClass { email = "user1@company.com", details = new CustomClass { id = 2, first = "FirstName", last = "LastName" } });
genericList.Add(new MainClass { email = "user2@company.com", details = new CustomClass { id = 3, first = "FirstName", last = "LastName" } });
genericList.Add(new MainClass { email = "user2@company.com", details = new CustomClass { id = 4, first = "FirstName", last = "LastName" } });
string genericListJson = new JavaScriptSerializer().Serialize(genericList);
//json result
//[{"email":"user1@company.com","details":{"id":1,"first":"FirstName","last":"LastName"}},{"email":"user1@company.com","details":{"id":2,"first":"FirstName","last":"LastName"}},{"email":"user2@company.com","details":{"id":3,"first":"FirstName","last":"LastName"}},{"email":"user2@company.com","details":{"id":4,"first":"FirstName","last":"LastName"}}]

I dont want key name in json result. I just need email as key and object as its value.
Like this
{"user1@company.com":{"id":1,"first":"FirstName","last":"LastName"}}

A: First, use a List<KeyValuePair<string, object>> since you need to allow duplicates.
var list = new List<KeyValuePair<string, object>>();
list.Add(new KeyValuePair<string, object>("foo", new { id = 1, first = "FirstName", last = "LastName" }));
list.Add(new KeyValuePair<string, object>("foo", new { id = 1, first = "FirstName", last = "LastName" }));
list.Add(new KeyValuePair<string, object>("foo", new { id = 1, first = "FirstName", last = "LastName" }));

Serialize with JsonConvert.
JsonSerializerSettings settings = new JsonSerializerSettings { Converters = new[] { new MyConverter() } };
string json = JsonConvert.SerializeObject(list, settings);

And use a custom converter inspired from this answer:
public class MyConverter : JsonConverter
{

    public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
    {
        List<KeyValuePair<string, object>> list = value as List<KeyValuePair<string, object>>;
        writer.WriteStartArray();
        foreach (var item in list)
        {
            writer.WriteStartObject();
            writer.WritePropertyName(item.Key);
            // Needed because of the dynamic object.
            var jsonValue = JsonConvert.SerializeObject(item.Value);
            writer.WriteValue(jsonValue);
            writer.WriteEndObject();
        }
        writer.WriteEndArray();
    }

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
    {
        throw new NotImplementedException();
    }

    public override bool CanConvert(Type objectType)
    {
        return objectType == typeof(List<KeyValuePair<string, object>>);
    }
}

Output:
[
    {"foo":"{\"id\":1,\"first\":\"FirstName\",\"last\":\"LastName\"}"},
    {"foo":"{\"id\":1,\"first\":\"FirstName\",\"last\":\"LastName\"}"},
    {"foo":"{\"id\":1,\"first\":\"FirstName\",\"last\":\"LastName\"}"}
]

A: In order to that you need to store your data in list of dictionary. It is not perfect solution but you can get your desired output in this way
class ValueHolder {
public string id { get; set; }
public string otherProp { get; set; }
}

var dic1 = new Dictionary<string, ValueHolder>();
dic1.Add("b@b.com", new ValueHolder { id = "1", otherProp = "Lorem" });
dic1.Add("a@a.com", new ValueHolder { id = "1", otherProp = "Lorem" });

var dic2 = new Dictionary<string, ValueHolder>();
dic2.Add("b@b.com", new ValueHolder { id = "2", otherProp = "Lorem" });
dic2.Add("a@a.com", new ValueHolder { id = "2", otherProp = "Lorem" });

var listOfDic = new List<Dictionary<string, ValueHolder>> { dic1, dic2 };
var result = JsonConvert.SerializeObject(listOfDic, Formatting.Indented);

[
  {
    "b@b.com": {
      "id": "1",
      "otherProp": "lorem"
    },
    "a@a.com": {
      "id": "1",
      "otherProp": "lorem"
    }
  },
  {
    "b@b.com": {
      "id": "2",
      "otherProp": "lorem"
    },
    "a@a.com": {
      "id": "2",
      "otherProp": "lorem"
    }
  }
]


text:
Q: missing output from serialize with hashMap, YAML Hi I'm trying to learn how to use snakeYAML.
I want to save a Library object so I can load it again when I start my application.
Simply I want to store my library with books in it. Internet told me yaml was a good way to do this.
I have to following class:
public class Library {
private HashMap<String, List<Book>> library;

public Library() {
    library = new HashMap<String, List<Book>>();
}

//getter
public HashMap<String, List<Book>> getHashMap() {
    return library;
}

//setter
public void setHashMap(HashMap<String, List<Book>> library) {
    this.library = library;
}
}

and now I want to serialize it using a main method:
public static void main(String[] args) {

    Library library = new Library();
    LinkedList<Book> books = new LinkedList<Book>();

    books.add(new Book("Some title", false));
    books.add(new Book("Other Title", true));

    library.putMany("books", books);

    System.out.println(new Yaml().dump(books));

but I only get the output:
- !!model.Book {done: false, title: Some title}
- !!model.Book {done: true, title: Other Title}

and something tells me I'm missing out on something like the Library itself.

A: That must be because you are only dump()ing the list of two books, not the entire Library.


text:
Q: MYSQL fill table with select from another table I have a table (table_attachments) with the below structure

parent_id
url
display_name
filename

1
fileurl
file for article 1
file1.pdf

2
fileurl2
file for article 2
file2.pdf

2
fileurl3
second file for article 2
file3.pdf

I have a second table (table_content) with the blow structure

id
title
fulltext

1
record 1
content...

2
record 2
content...

3
record 3
content...

parent_id from table_attachments is a column that matches with table_content and corresponts to the list of attachment files that the record has.
if i write a select
SELECT
 att.parent_id
,GROUP_CONCAT(
    CONCAT ("", if(display_name IS NULL OR display_name='',filename,display_name), "")
    ) AS url
,con.fulltext FROM table_attachments att JOIN table_content con ON att.parent_id = con.id GROUP BY att.parent_id, con.fulltext ORDER BY att.parent_id

I get a list of attachments grouped correctly.
a sample is the below

parent_id
url
fulltext

2
href links for file1 and file2
content...

1
href link for file 3
content...

So my question is this... how can update table_content fulltext field with these values?


text:
Q: Use ProjectName when building an entire solution with MSBuild Rather than building to the default folder structure, which is like
Solution.sln
Project1
    bin    <- project 1 output
    obj    <- project 1 intermediate output
Project2
    bin    <- project 2 output
    obj    <- project 2 intermediate output

I instead want to build it like
Solution.sln
bin    <- project 1 AND 2 output
obj
    Project1   <- project 1 intermediate output
    Project2   <- project 2 intermediate output

I can do
msbuild "/p:OutputPath=../bin" "/p:IntermediateOutputPath=../obj/" Test123.sln

However, using "/p:IntermediateOutputPath=../obj/$(ProjectName)/" does not work. Instead of creating a folder for each project, it creates one folder literally called $(ProjectName) (I've read that most, but not all of these macros are actually a Visual Studio thing, rather than MSBuild magic).
How can I use a project-specific value (such as ProjectName) in a property value (such as IntermediateOutputPath) when building?
(Some background information:
Having one bin folder on the solution level saves unnecessary copying of output files, which quickly amass over 100 MB in large solutions. Furthermore, it keeps the source folders clean so they can be read-only.
I still want separate obj folders though, because who knows what goes in there - might be the same file names for different projects.)

A: You can override the CustomAfterMicrosoftCommonTargets property of the Microsoft.Common.targets file. It's allowing injecting custom targets into projects and performs some actions.

The entry point of the build process is Make.targets:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"; DefaultTargets="EntryMSBuild">

    <ItemGroup>
        <Project Include="**\*.csproj"/>
    </ItemGroup>

    <Target Name="EntryMSBuild">

        <Message Text="-----Entry-----" Importance="high"/>
        <Message Text="    Rebuild    " Importance="high"/>
        <Message Text="-----Entry-----" Importance="high"/>

        <MSBuild Projects="@(Project)" Targets="rebuild" Properties="CustomBeforeMicrosoftCommonTargets=$(MSBuildThisFileDirectory)Setting.targets"/>
    </Target>

</Project>

In Setting.targets defined IntermediateOutputPath and OutputPath for each projects:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <IntermediateOutputPath>..\Global\obj\$(MSBuildProjectName)</IntermediateOutputPath>
    </PropertyGroup>

    <PropertyGroup>
        <OutputPath>..\Global\bin\</OutputPath>
    </PropertyGroup>

</Project>

*

*IntermediateOutputPath - depend on $(MSBuildProjectName);

*OutputPath - common for all projects.

As a result, you get the desired structure:
Solution.sln
bin    <- project 1 AND 2 output
obj
    Project1   <- project 1 intermediate output
    Project2   <- project 2 intermediate output

Tested on solution with two projects under .net46 and .netstandard2.0. MSBuild 15.6.82.30579

You don't need store custom targets under C:\Program Files[(x86)]\microsoft visual studio\2017\xxx\msbuild\15.0 or any predefined path. You override CustomBeforeMicrosoftCommonTargets property that already defined in Microsoft.Common.targets and injected in the project by default.
From Microsoft.Common.targets comment:

This file defines the steps in the standard build process for .NET
projects. It contains all the steps that are common among the
different .NET languages, such as Visual Basic, and Visual C#.