text:
Q: Knockout Custom Binding for jQuery .is(':checked') or $(..).prop('checked') In Dom I have a toggle input type checkbox switch, where it can be switched on or off.
I am using knockout to databind to bind its checked to knockout model. But it is showing as undefined while debugging.
My Dom HTML is,
<div class="make-switch switch-large">
    <input type="checkbox" checked class="toggle" data-bind="checked: myvar" />
</div>

The data-bind for checked is undefined and not working, because the DOM HTML template I am using looks like a switch. And the value checked is undefined, rather its value is storing in .is(':checked') or $(..).prop('checked')
I am not sure how to bind this using knokcout!
So I tried to implement a custom binding,
 ko.bindingHandlers.isChecked = {
            init: function (element) {
                debugger;
                return ($(element).is(':checked'));
            },
            update: function (element) {
                debugger;
                return ($(element).is(':checked'));
            }
        };

But this is not updating model, any quick ideas will be much appreciated


text:
Q: ChildAdded with LimitToLast triggers ChildRemoved Regarding Firebase documentation if you limit your query with "toLast" then when a child is added, if you already exceed the value (in my case f.e. 50) then child removed is also triggered because the first child is deleted from the scope.
The following listeners are the ones I have on the code:
firebaseReference.queryOrderedByKey().queryLimited(toLast: 50).observe(.childAdded...
firebaseReference.queryOrderedByKey().queryLimited(toLast: 50).observe(.childRemoved...

I would like to know if there is some way to differenciate when a child is really deleted or a child is just deleted from the scope.
Thank you so much,
any further information don't hestiate to ask.

A: Firebase does not send along information on why you're receiving the .childRemoved event, so there's no way to know it based on that.
The only thing I can quickly think of is adding a .value listener for each child, which will then fire with null when the child gets deleted.
You'll want to remove the .value listener after you receive the .childRemoved handler, to not have dangling listeners for each child you've ever seen, so this may become more work than it's worth.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Across list calculations taking the average and dividing by the diag of a cov matrix in R I have two separate lists I would like to make a calculation over:
How can I make the calculation mu / diag(sigma) ?
Each list contains 6 lists:
Mu[1]
$`2013 Jul`
         AAPL           AMD           ADI          ABBV             A           APD            AA            CF
-0.0025241390  0.0038538523  0.0003136588  0.0014847319  0.0002313723  0.0006444116 -0.0010699941 -0.0013681154
         NVDA           HOG           WMT          AMZN
 0.0008864361  0.0008060513  0.0006894905  0.0006147082

Sigma[1]
$`2013 Jul`
               AAPL           AMD           ADI          ABBV             A           APD              AA
AAPL  0.00041664389 0.00005752017 0.00007896389 0.00002200239 0.00001116395 0.00003895595  0.000052761161
AMD   0.00005752017 0.00119570936 0.00015508211 0.00004257827 0.00013015826 0.00008786124  0.000110874525
ADI   0.00007896389 0.00015508211 0.00016835164 0.00007886595 0.00010277878 0.00006578803  0.000059832091
ABBV  0.00002200239 0.00004257827 0.00007886595 0.00031277839 0.00004903964 0.00003939989  0.000013730574
A     0.00001116395 0.00013015826 0.00010277878 0.00004903964 0.00020605392 0.00007191518  0.000074100691
APD   0.00003895595 0.00008786124 0.00006578803 0.00003939989 0.00007191518 0.00009965092  0.000052131656
AA    0.00005276116 0.00011087452 0.00005983209 0.00001373057 0.00007410069 0.00005213166  0.000148494256
CF    0.00002769930 0.00009567907 0.00008538958 0.00004723808 0.00008854491 0.00006873004  0.000087412041
NVDA  0.00004080288 0.00014291555 0.00009863768 0.00005111435 0.00009301417 0.00005779923  0.000068540074
HOG   0.00001155955 0.00014300610 0.00010598492 0.00007319286 0.00011746490 0.00007427693  0.000067448450
WMT  -0.00000378780 0.00002282687 0.00002100417 0.00002575448 0.00003714578 0.00001069815 -0.000001207622
AMZN -0.00003663661 0.00011805891 0.00010175071 0.00002949141 0.00011385205 0.00005096968  0.000038319282
                 CF          NVDA           HOG             WMT           AMZN
AAPL  0.00002769930 0.00004080288 0.00001155955 -0.000003787800 -0.00003663661
AMD   0.00009567907 0.00014291555 0.00014300610  0.000022826874  0.00011805891
ADI   0.00008538958 0.00009863768 0.00010598492  0.000021004172  0.00010175071
ABBV  0.00004723808 0.00005111435 0.00007319286  0.000025754484  0.00002949141
A     0.00008854491 0.00009301417 0.00011746490  0.000037145777  0.00011385205
APD   0.00006873004 0.00005779923 0.00007427693  0.000010698153  0.00005096968
AA    0.00008741204 0.00006854007 0.00006744845 -0.000001207622  0.00003831928
CF    0.00022714265 0.00007056718 0.00008999676 -0.000011176475  0.00006059772
NVDA  0.00007056718 0.00020920079 0.00007058210  0.000012709646  0.00008526335
HOG   0.00008999676 0.00007058210 0.00023925429  0.000021431042  0.00008949032
WMT  -0.00001117648 0.00001270965 0.00002143104  0.000068197626  0.00002355657
AMZN  0.00006059772 0.00008526335 0.00008949032  0.000023556575  0.00031175723

I want to divide each list by its corresponding list, such that mu[1] / diag Sigma[1]
Using mus[1] / diag(Sigmas[1]) doesn't seem to work.
I am trying to divide all mu by diag(Sigma)
My Data:
Mu
mu <- list(`2013 Jul` = c(AAPL = -0.00252413896048252, AMD = 0.00385385230384388,
ADI = 0.000313658814841043, ABBV = 0.00148473194650269, A = 0.000231372267065186,
APD = 0.000644411609229898, AA = -0.00106999405402468, CF = -0.00136811540143579,
NVDA = 0.000886436095375894, HOG = 0.000806051331850114, WMT = 0.000689490484865284,
AMZN = 0.000614708184565435), `2013 Aug` = c(AAPL = 0.0000471064768722691,
AMD = 0.00297250845145986, ADI = 0.00110927645875706, ABBV = 0.00186505842086247,
A = 0.0000542259939665846, APD = 0.00186178155179209, AA = -0.000794925865044543,
CF = -0.00109320436559941, NVDA = 0.00139874293303574, HOG = 0.000699507074667968,
WMT = 0.000964557826996342, AMZN = 0.00100980845937234), `2013 Sep` = c(AAPL = 0.000874550640770086,
AMD = 0.00212896308150426, ADI = 0.000297401899798995, ABBV = 0.00126327568847214,
A = 0.00097767693668047, APD = 0.00143416399096666, AA = -0.000734440361937234,
CF = -0.000254998800234454, NVDA = 0.00127259109916125, HOG = 0.00105093597431519,
WMT = 0.00038339075327491, AMZN = 0.000479002073488143), `2013 Oct` = c(AAPL = 0.000682565466572836,
AMD = 0.00313699867162714, ADI = 0.000209923665516306, ABBV = 0.000865756791407934,
A = 0.00161631482825611, APD = 0.00168294315897343, AA = -0.000319519044240903,
CF = 0.00096163857613333, NVDA = 0.00158604314072248, HOG = 0.00151424115101764,
WMT = 0.00000265229900199134, AMZN = 0.00124777917896926), `2013 Nov` = c(AAPL = 0.00138847413611967,
AMD = 0.00131189086851618, ADI = 0.000998905149605624, ABBV = 0.00053428429850944,
A = 0.0016278252466143, APD = 0.0018596391559994, AA = 0.000727945791304539,
CF = 0.00128641077503917, NVDA = 0.000839077531026809, HOG = 0.00128443125529569,
WMT = -0.00000406995915300601, AMZN = 0.00279573900270221), `2013 Dec` = c(AAPL = 0.00176889092052374,
AMD = -0.000742603775364103, ADI = 0.00044132637464973, ABBV = 0.00113925715965696,
A = 0.00135042334177499, APD = 0.00122867453428789, AA = 0.00102055404174894,
CF = 0.00128611035428346, NVDA = 0.000674203471055744, HOG = 0.00164877495332821,
WMT = 0.000671450466059644, AMZN = 0.00299158521138261))

Sigma:
Sigma <- list(`2013 Jul` = structure(c(0.000416643886758763, 0.0000575201746765611,
0.0000789638920855847, 0.0000220023900018263, 0.0000111639502490768,
0.0000389559475190128, 0.0000527611613642388, 0.0000276992964194271,
0.0000408028782885074, 0.0000115595509868784, -0.0000037878002746425,
-0.0000366366098987774, 0.0000575201746765611, 0.00119570936132192,
0.000155082111688544, 0.0000425782714446992, 0.000130158263810212,
0.0000878612354816402, 0.000110874524552274, 0.0000956790721355811,
0.000142915553968933, 0.000143006102651394, 0.0000228268738459166,
0.000118058907654786, 0.0000789638920855847, 0.000155082111688544,
0.000168351643640767, 0.0000788659479307403, 0.000102778784483304,
0.0000657880339646833, 0.0000598320912919172, 0.0000853895841140346,
0.0000986376834952542, 0.000105984917456237, 0.0000210041724262002,
0.000101750712552628, 0.0000220023900018263, 0.0000425782714446992,
0.0000788659479307403, 0.000312778387971074, 0.000049039640960627,
0.0000393998916621414, 0.000013730573676239, 0.0000472380756047525,
0.0000511143483915833, 0.0000731928556977193, 0.0000257544841976242,
0.0000294914069933314, 0.0000111639502490768, 0.000130158263810212,
0.000102778784483304, 0.000049039640960627, 0.000206053920651814,
0.0000719151829814278, 0.0000741006909963334, 0.0000885449139074768,
0.0000930141655227777, 0.00011746490314149, 0.0000371457765331769,
0.000113852047489411, 0.0000389559475190128, 0.0000878612354816402,
0.0000657880339646833, 0.0000393998916621414, 0.0000719151829814278,
0.0000996509203523389, 0.0000521316564566408, 0.000068730039255043,
0.0000577992258000496, 0.0000742769306657648, 0.0000106981527050766,
0.0000509696753371964, 0.0000527611613642388, 0.000110874524552274,
0.0000598320912919172, 0.000013730573676239, 0.0000741006909963334,
0.0000521316564566408, 0.000148494256109656, 0.0000874120413581227,
0.0000685400738576454, 0.0000674484501661069, -0.0000012076222555024,
0.0000383192820636322, 0.0000276992964194271, 0.0000956790721355811,
0.0000853895841140346, 0.0000472380756047525, 0.0000885449139074768,
0.000068730039255043, 0.0000874120413581227, 0.000227142652461996,
0.0000705671796000693, 0.0000899967556869206, -0.0000111764754144841,
0.0000605977195804694, 0.0000408028782885074, 0.000142915553968933,
0.0000986376834952542, 0.0000511143483915833, 0.0000930141655227777,
0.0000577992258000496, 0.0000685400738576454, 0.0000705671796000693,
0.000209200789691729, 0.0000705821034434308, 0.0000127096462767631,
0.0000852633525054778, 0.0000115595509868784, 0.000143006102651394,
0.000105984917456237, 0.0000731928556977193, 0.00011746490314149,
0.0000742769306657648, 0.0000674484501661069, 0.0000899967556869206,
0.0000705821034434308, 0.000239254290396505, 0.0000214310415786661,
0.0000894903234052336, -0.0000037878002746425, 0.0000228268738459166,
0.0000210041724262002, 0.0000257544841976242, 0.0000371457765331769,
0.0000106981527050766, -0.0000012076222555024, -0.0000111764754144841,
0.0000127096462767631, 0.0000214310415786661, 0.0000681976259943942,
0.0000235565746471074, -0.0000366366098987774, 0.000118058907654786,
0.000101750712552628, 0.0000294914069933314, 0.000113852047489411,
0.0000509696753371964, 0.0000383192820636322, 0.0000605977195804694,
0.0000852633525054778, 0.0000894903234052336, 0.0000235565746471074,
0.000311757230578142), .Dim = c(12L, 12L), .Dimnames = list(c("AAPL",
"AMD", "ADI", "ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG",
"WMT", "AMZN"), c("AAPL", "AMD", "ADI", "ABBV", "A", "APD", "AA",
"CF", "NVDA", "HOG", "WMT", "AMZN"))), `2013 Aug` = structure(c(0.000266376810665656,
0.000102646024469171, 0.0000750036597074999, -0.000000303995751271217,
0.0000360100939425462, 0.0000378275353266367, 0.0000487484045862342,
0.0000679946834461002, 0.0000500355701292832, 0.0000507336994179233,
-0.00000792202496149912, 0.0000202469346414574, 0.000102646024469171,
0.00132219539700646, 0.000176670885152745, 0.0000177889285130277,
0.000136829989253102, 0.0000915957333247249, 0.000156124581818093,
0.000113028117036578, 0.000158288454634329, 0.000155303358942779,
0.0000225031359083731, 0.000121225099187987, 0.0000750036597074999,
0.000176670885152745, 0.000166442527755379, 0.000069321830090922,
0.000105787648289648, 0.0000802700835436298, 0.0000702926464122741,
0.0000895483758133964, 0.000103478440044946, 0.000101589989608093,
0.0000239852712211574, 0.000104018111503834, -0.000000303995751271217,
0.0000177889285130277, 0.000069321830090922, 0.000293537070159334,
0.0000543866034716202, 0.0000417070926485985, 0.0000230691125545005,
0.0000553376914990916, 0.0000510257421229842, 0.000060135187112579,
0.0000295028613341954, 0.000047259365960046, 0.0000360100939425462,
0.000136829989253102, 0.000105787648289648, 0.0000543866034716202,
0.000205602999677141, 0.0000761036455995998, 0.0000707222282933177,
0.0000694550719063977, 0.0000861543657806432, 0.000109249602356004,
0.000040415940369965, 0.000105845873229971, 0.0000378275353266367,
0.0000915957333247249, 0.0000802700835436298, 0.0000417070926485985,
0.0000761036455995998, 0.000166028134604713, 0.0000479369600434621,
0.000070691358275638, 0.0000618900157227336, 0.0000653327169735,
0.0000108692715624005, 0.0000538240646020979, 0.0000487484045862342,
0.000156124581818093, 0.0000702926464122741, 0.0000230691125545005,
0.0000707222282933177, 0.0000479369600434621, 0.000146676471399529,
0.000087392319122003, 0.0000655668563463606, 0.0000764851514895254,
-0.000000224667419708207, 0.000053333277012164, 0.0000679946834461002,
0.000113028117036578, 0.0000895483758133964, 0.0000553376914990916,
0.0000694550719063977, 0.000070691358275638, 0.000087392319122003,
0.000334870074175067, 0.0000627866889615617, 0.0000903387885383747,
-0.00000629306068193906, 0.0000443509252452586, 0.0000500355701292832,
0.000158288454634329, 0.000103478440044946, 0.0000510257421229842,
0.0000861543657806432, 0.0000618900157227336, 0.0000655668563463606,
0.0000627866889615617, 0.000179641006950314, 0.0000862200068484314,
0.0000127362921237457, 0.0000783747511330152, 0.0000507336994179233,
0.000155303358942779, 0.000101589989608093, 0.000060135187112579,
0.000109249602356004, 0.0000653327169735, 0.0000764851514895254,
0.0000903387885383747, 0.0000862200068484314, 0.000210265957289963,
0.0000227561029363191, 0.0000932334678023935, -0.00000792202496149912,
0.0000225031359083731, 0.0000239852712211574, 0.0000295028613341954,
0.000040415940369965, 0.0000108692715624005, -0.000000224667419708207,
-0.00000629306068193906, 0.0000127362921237457, 0.0000227561029363191,
0.0000690290825179544, 0.0000410742698618627, 0.0000202469346414574,
0.000121225099187987, 0.000104018111503834, 0.000047259365960046,
0.000105845873229971, 0.0000538240646020979, 0.000053333277012164,
0.0000443509252452586, 0.0000783747511330152, 0.0000932334678023935,
0.0000410742698618627, 0.000250913116610334), .Dim = c(12L, 12L
), .Dimnames = list(c("AAPL", "AMD", "ADI", "ABBV", "A", "APD",
"AA", "CF", "NVDA", "HOG", "WMT", "AMZN"), c("AAPL", "AMD", "ADI",
"ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG", "WMT", "AMZN"))),
    `2013 Sep` = structure(c(0.000260185752934072, 0.000103619179723936,
    0.0000634795578548089, 0.0000100133552182317, 0.0000220250262024592,
    0.0000219494081789225, 0.0000346942329143775, 0.0000575809377776677,
    0.000041367145802818, 0.0000428076635165902, -0.0000158244437835025,
    0.00000521865227452806, 0.000103619179723936, 0.0012673944241585,
    0.000152976472733384, 0.0000378005016314996, 0.0000969685986015979,
    0.0000737105823747991, 0.000142354321778133, 0.0000872222619268461,
    0.000160096241353327, 0.000150088371960102, 0.0000308837560859658,
    0.000108745598470934, 0.0000634795578548089, 0.000152976472733384,
    0.000150408462743999, 0.000079759247660213, 0.0000885138969845252,
    0.0000649836671352587, 0.0000584827231799672, 0.0000660930447584937,
    0.0000844784678844367, 0.0000972584036669882, 0.0000256969474722734,
    0.000098647493933917, 0.0000100133552182317, 0.0000378005016314996,
    0.000079759247660213, 0.000274864169047915, 0.0000615682328851307,
    0.0000470770901037539, 0.0000219282663068747, 0.0000475234958829655,
    0.0000413072390199246, 0.0000731363896455753, 0.0000450443965576894,
    0.0000573762356666793, 0.0000220250262024592, 0.0000969685986015979,
    0.0000885138969845252, 0.0000615682328851307, 0.000176523662087773,
    0.0000561686602155714, 0.0000664236361079563, 0.0000549692117098347,
    0.000075741136659798, 0.0000965156598525872, 0.000026184697750621,
    0.0000875440746344027, 0.0000219494081789225, 0.0000737105823747991,
    0.0000649836671352587, 0.0000470770901037539, 0.0000561686602155714,
    0.000166054877845329, 0.0000339760860009175, 0.0000531837705032797,
    0.0000471605746480224, 0.0000598296627422445, 0.0000136034121909981,
    0.0000485667771924023, 0.0000346942329143775, 0.000142354321778133,
    0.0000584827231799672, 0.0000219282663068747, 0.0000664236361079563,
    0.0000339760860009175, 0.000142575079902111, 0.0000693519052764993,
    0.0000480094665590939, 0.000065347903136645, -0.00000327996456112743,
    0.0000485182296507297, 0.0000575809377776677, 0.0000872222619268461,
    0.0000660930447584937, 0.0000475234958829655, 0.0000549692117098347,
    0.0000531837705032797, 0.0000693519052764993, 0.000310110134263049,
    0.0000536511563357689, 0.0000754259552089199, -0.0000000811097667034523,
    0.0000319649620985031, 0.000041367145802818, 0.000160096241353327,
    0.0000844784678844367, 0.0000413072390199246, 0.000075741136659798,
    0.0000471605746480224, 0.0000480094665590939, 0.0000536511563357689,
    0.000171636148180971, 0.0000773510800565517, 0.00000884649959783945,
    0.0000663738861523176, 0.0000428076635165902, 0.000150088371960102,
    0.0000972584036669882, 0.0000731363896455753, 0.0000965156598525872,
    0.0000598296627422445, 0.000065347903136645, 0.0000754259552089199,
    0.0000773510800565517, 0.000214876758784993, 0.0000204948618049359,
    0.0000893062594512058, -0.0000158244437835025, 0.0000308837560859658,
    0.0000256969474722734, 0.0000450443965576894, 0.000026184697750621,
    0.0000136034121909981, -0.00000327996456112743, -0.0000000811097667034523,
    0.00000884649959783945, 0.0000204948618049359, 0.000064164048233367,
    0.0000392366498881419, 0.00000521865227452806, 0.000108745598470934,
    0.000098647493933917, 0.0000573762356666793, 0.0000875440746344027,
    0.0000485667771924023, 0.0000485182296507297, 0.0000319649620985031,
    0.0000663738861523176, 0.0000893062594512058, 0.0000392366498881419,
    0.000224379194881233), .Dim = c(12L, 12L), .Dimnames = list(
        c("AAPL", "AMD", "ADI", "ABBV", "A", "APD", "AA", "CF",
        "NVDA", "HOG", "WMT", "AMZN"), c("AAPL", "AMD", "ADI",
        "ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG", "WMT",
        "AMZN"))), `2013 Oct` = structure(c(0.000292123566686645,
    0.0000969406988711502, 0.0000668893836007142, 0.0000099274065186816,
    0.0000284748215721311, 0.000022882750235075, 0.0000380633101574885,
    0.0000411314728499623, 0.0000376688663077442, 0.0000474111003863584,
    -0.00000112460418681563, 0.0000327000595372511, 0.0000969406988711502,
    0.00127398532527367, 0.000149899215119524, 0.0000561979053940955,
    0.0000865668501178837, 0.0000768090890301578, 0.000151259584531874,
    0.000098026542181471, 0.000168404003363686, 0.000144156521079913,
    0.000046259566194545, 0.000121608074675472, 0.0000668893836007142,
    0.000149899215119524, 0.000136062535457606, 0.0000787249805446538,
    0.0000797109525596907, 0.0000636352119601489, 0.0000608786020845465,
    0.0000644347320981682, 0.000080503298414156, 0.0000917704812771963,
    0.00002414276794745, 0.0000913721078266012, 0.0000099274065186816,
    0.0000561979053940955, 0.0000787249805446538, 0.00027826724146937,
    0.0000593461162278662, 0.0000463129963695562, 0.0000297355282473298,
    0.0000556516465430997, 0.0000455674784183562, 0.0000732219992108158,
    0.0000500390266254118, 0.0000679178213870244, 0.0000284748215721311,
    0.0000865668501178837, 0.0000797109525596907, 0.0000593461162278662,
    0.000178397899402941, 0.0000570672015532892, 0.0000627026855464551,
    0.0000553729019737477, 0.0000699019344580214, 0.0000864322316421009,
    0.0000273472143499778, 0.000090297038726938, 0.000022882750235075,
    0.0000768090890301578, 0.0000636352119601489, 0.0000463129963695562,
    0.0000570672015532892, 0.000179924651242272, 0.0000421754283487237,
    0.0000560379031005859, 0.0000492880175681861, 0.0000537272986851459,
    0.000020549624631709, 0.0000553564435211498, 0.0000380633101574885,
    0.000151259584531874, 0.0000608786020845465, 0.0000297355282473298,
    0.0000627026855464551, 0.0000421754283487237, 0.000157230636370053,
    0.0000774402039605599, 0.0000552961992549884, 0.0000645328431120124,
    0.00000956783507784561, 0.0000653641276604258, 0.0000411314728499623,
    0.000098026542181471, 0.0000644347320981682, 0.0000556516465430997,
    0.0000553729019737477, 0.0000560379031005859, 0.0000774402039605599,
    0.000322827779721126, 0.0000538089350371367, 0.0000643129683101824,
    0.00000529886707100804, 0.0000361157062516189, 0.0000376688663077442,
    0.000168404003363686, 0.000080503298414156, 0.0000455674784183562,
    0.0000699019344580214, 0.0000492880175681861, 0.0000552961992549884,
    0.0000538089350371367, 0.00017224210711261, 0.000074693861135644,
    0.0000114889622234819, 0.0000610186281427242, 0.0000474111003863584,
    0.000144156521079913, 0.0000917704812771963, 0.0000732219992108158,
    0.0000864322316421009, 0.0000537272986851459, 0.0000645328431120124,
    0.0000643129683101824, 0.000074693861135644, 0.000198810640523596,
    0.0000238295219137444, 0.0000923659186771322, -0.00000112460418681563,
    0.000046259566194545, 0.00002414276794745, 0.0000500390266254118,
    0.0000273472143499778, 0.000020549624631709, 0.00000956783507784561,
    0.00000529886707100804, 0.0000114889622234819, 0.0000238295219137444,
    0.0000624585357149499, 0.00003210811638617, 0.0000327000595372511,
    0.000121608074675472, 0.0000913721078266012, 0.0000679178213870244,
    0.000090297038726938, 0.0000553564435211498, 0.0000653641276604258,
    0.0000361157062516189, 0.0000610186281427242, 0.0000923659186771322,
    0.00003210811638617, 0.000219858293621821), .Dim = c(12L,
    12L), .Dimnames = list(c("AAPL", "AMD", "ADI", "ABBV", "A",
    "APD", "AA", "CF", "NVDA", "HOG", "WMT", "AMZN"), c("AAPL",
    "AMD", "ADI", "ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG",
    "WMT", "AMZN"))), `2013 Nov` = structure(c(0.000239845257172422,
    0.0000430979663815108, 0.0000187598651641953, -0.000016732587760101,
    0.00000464906103006429, 0.0000118579396522232, 0.0000241230467151989,
    0.0000362117393188716, 0.00000811507483268281, 0.0000193221912090245,
    -0.00000193990644116803, 0.00000772681272043948, 0.0000430979663815108,
    0.00131183305071473, 0.000123176150213028, 0.0000564929803660581,
    0.0000993407262674518, 0.0000723767575309024, 0.0000614465585411526,
    0.0000280834997043418, 0.000134185307800594, 0.000112244916626239,
    0.0000518968505332216, 0.0000666329543339265, 0.0000187598651641953,
    0.000123176150213028, 0.000124336778338181, 0.0000810694373153876,
    0.0000672881389274563, 0.0000567937106095726, 0.0000581914285246649,
    0.0000603338496140982, 0.000063688151843495, 0.0000716492770320877,
    0.0000306075625680701, 0.0000770811620590006, -0.000016732587760101,
    0.0000564929803660581, 0.0000810694373153876, 0.000258972823560562,
    0.0000733042050699425, 0.0000556898688363073, 0.0000593085778997206,
    0.0000724056027829302, 0.0000434125083916276, 0.0000690583750121357,
    0.0000500799015020124, 0.000110202401523764, 0.00000464906103006429,
    0.0000993407262674518, 0.0000672881389274563, 0.0000733042050699425,
    0.000149160152643546, 0.0000509318099691717, 0.0000442179088484315,
    0.0000420059347818132, 0.0000466671412106007, 0.0000711001673690489,
    0.0000272989808814339, 0.0000747698504890309, 0.0000118579396522232,
    0.0000723767575309024, 0.0000567937106095726, 0.0000556898688363073,
    0.0000509318099691717, 0.000190497742088657, 0.0000427155956885336,
    0.0000455879073778912, 0.0000406067558275263, 0.0000481520953440217,
    0.000028804091895449, 0.0000619418456274028, 0.0000241230467151989,
    0.0000614465585411526, 0.0000581914285246649, 0.0000593085778997206,
    0.0000442179088484315, 0.0000427155956885336, 0.000218937085600004,
    0.0000622607413966496, 0.0000411612198000009, 0.0000462606255087507,
    0.0000386566541194825, 0.0000696421027542441, 0.0000362117393188716,
    0.0000280834997043418, 0.0000603338496140982, 0.0000724056027829302,
    0.0000420059347818132, 0.0000455879073778912, 0.0000622607413966496,
    0.000292307573843276, 0.000051248406858989, 0.0000429793810662635,
    0.0000196535662668962, 0.0000366850439658631, 0.00000811507483268281,
    0.000134185307800594, 0.000063688151843495, 0.0000434125083916276,
    0.0000466671412106007, 0.0000406067558275263, 0.0000411612198000009,
    0.000051248406858989, 0.000138088873051221, 0.000048543400005292,
    0.0000127871064306087, 0.0000407488425255562, 0.0000193221912090245,
    0.000112244916626239, 0.0000716492770320877, 0.0000690583750121357,
    0.0000711001673690489, 0.0000481520953440217, 0.0000462606255087507,
    0.0000429793810662635, 0.000048543400005292, 0.000172578085376382,
    0.0000242831193760889, 0.0000843255212989068, -0.00000193990644116803,
    0.0000518968505332216, 0.0000306075625680701, 0.0000500799015020124,
    0.0000272989808814339, 0.000028804091895449, 0.0000386566541194825,
    0.0000196535662668962, 0.0000127871064306087, 0.0000242831193760889,
    0.0000634573641892999, 0.0000298029168593479, 0.00000772681272043948,
    0.0000666329543339265, 0.0000770811620590006, 0.000110202401523764,
    0.0000747698504890309, 0.0000619418456274028, 0.0000696421027542441,
    0.0000366850439658631, 0.0000407488425255562, 0.0000843255212989068,
    0.0000298029168593479, 0.000256350587783924), .Dim = c(12L,
    12L), .Dimnames = list(c("AAPL", "AMD", "ADI", "ABBV", "A",
    "APD", "AA", "CF", "NVDA", "HOG", "WMT", "AMZN"), c("AAPL",
    "AMD", "ADI", "ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG",
    "WMT", "AMZN"))), `2013 Dec` = structure(c(0.000230279463157106,
    0.0000739874936861984, 0.0000157280663131775, 0.00000462987828026726,
    0.0000206114218910319, 0.0000129611761359842, 0.0000389868173653423,
    0.0000414858992643652, 0.0000323648578897082, 0.0000320710411790726,
    0.00000891806347848395, 0.000031776016013169, 0.0000739874936861984,
    0.000910358217087931, 0.0000973473104148583, 0.0000786211093814387,
    0.0000653194055474513, 0.0000546391533207029, 0.0000603159653147439,
    0.0000520804639585331, 0.000115675426147555, 0.0000973841080273414,
    0.0000270941372962445, 0.0000654357141791052, 0.0000157280663131775,
    0.0000973473104148583, 0.000129259278163821, 0.000084766348569258,
    0.0000705126777081524, 0.0000561208896292504, 0.0000564091828675966,
    0.0000530626623671728, 0.0000681075016869934, 0.0000674990402393286,
    0.0000302291874116155, 0.0000763106937643134, 0.00000462987828026726,
    0.0000786211093814387, 0.000084766348569258, 0.000212054778179789,
    0.0000730554453461247, 0.0000657161439915535, 0.0000771684445452577,
    0.0000840720405561332, 0.0000434773785729679, 0.000052855750123031,
    0.0000478448251540904, 0.000117763955052939, 0.0000206114218910319,
    0.0000653194055474513, 0.0000705126777081524, 0.0000730554453461247,
    0.000187456397292226, 0.0000565202597841519, 0.0000498686589892799,
    0.0000439946769604166, 0.000039988500672083, 0.0000609151503959029,
    0.0000211929081591001, 0.0000766197699124352, 0.0000129611761359842,
    0.0000546391533207029, 0.0000561208896292504, 0.0000657161439915535,
    0.0000565202597841519, 0.00018602182742731, 0.0000468595062795141,
    0.0000475169732357435, 0.0000362503848754728, 0.0000419252324694322,
    0.0000291488611134949, 0.0000594723603879329, 0.0000389868173653423,
    0.0000603159653147439, 0.0000564091828675966, 0.0000771684445452577,
    0.0000498686589892799, 0.0000468595062795141, 0.000304097769076748,
    0.0000700460175967659, 0.0000488003174518793, 0.000052762294765492,
    0.0000492369153360001, 0.0000928979456706546, 0.0000414858992643652,
    0.0000520804639585331, 0.0000530626623671728, 0.0000840720405561332,
    0.0000439946769604166, 0.0000475169732357435, 0.0000700460175967659,
    0.000304866512848356, 0.0000738215916107247, 0.0000465489851285226,
    0.0000271263843128049, 0.0000501269682073041, 0.0000323648578897082,
    0.000115675426147555, 0.0000681075016869934, 0.0000434773785729679,
    0.000039988500672083, 0.0000362503848754728, 0.0000488003174518793,
    0.0000738215916107247, 0.000162233752690276, 0.0000502553368280014,
    0.0000137595510705426, 0.0000512113620658841, 0.0000320710411790726,
    0.0000973841080273414, 0.0000674990402393286, 0.000052855750123031,
    0.0000609151503959029, 0.0000419252324694322, 0.000052762294765492,
    0.0000465489851285226, 0.0000502553368280014, 0.00013718772750878,
    0.0000228350667384559, 0.0000758234480474619, 0.00000891806347848395,
    0.0000270941372962445, 0.0000302291874116155, 0.0000478448251540904,
    0.0000211929081591001, 0.0000291488611134949, 0.0000492369153360001,
    0.0000271263843128049, 0.0000137595510705426, 0.0000228350667384559,
    0.0000576228386874623, 0.0000322290121890619, 0.000031776016013169,
    0.0000654357141791052, 0.0000763106937643134, 0.000117763955052939,
    0.0000766197699124352, 0.0000594723603879329, 0.0000928979456706546,
    0.0000501269682073041, 0.0000512113620658841, 0.0000758234480474619,
    0.0000322290121890619, 0.000269472977855512), .Dim = c(12L,
    12L), .Dimnames = list(c("AAPL", "AMD", "ADI", "ABBV", "A",
    "APD", "AA", "CF", "NVDA", "HOG", "WMT", "AMZN"), c("AAPL",
    "AMD", "ADI", "ABBV", "A", "APD", "AA", "CF", "NVDA", "HOG",
    "WMT", "AMZN"))))

A: An option is Map where we pass the input as the 'mu' and 'Sigma' and divide the corresponding list element of 'mu' with diag of the element of 'Sigma'
Map(function(x, y) x/diag(y), mu, Sigma)

Or another option is to loop over the sequence of 'mu' in lapply, extract ([[) the elements and divide
lapply(seq_along(mu), function(i) mu[[i]]/diag(Sigma[[i]]))

Or with base R
out <- vector('list' length(mu))
for(i in seq_along(out)) out[[i]] <- mu[[i]]/diag(Sigma[[i]])

Or using map2 from purrr.  All the above mentioned functions are from base R
library(purrr)
map2(mu, Sigma, ~ .x/diag(.y))


text:
Q: Is it possible using one git repo to manage several git repos? I have one and only one git repo in a remote server named, say, allinone, but I actually have several projects, say proj1, proj2, proj3, and I store all these projects into allinone, like this:
allinone
 |- .git
 |-  proj1/
 |-  proj2/
 |-  proj3/

Here is how things go(if it is possible):

*

*I created allinone git repo

*I created proj1 git repos, do some developing, committing, and done.

*I created a proj1 branch in allinone repo, and 'import' proj1 into allinone's proj1 branch with all commit logs.

*Same for proj2, proj3.

*Later I can checkout proj1 branch out into an independent directory.

Is it possible? Or are there any suggestions? I dont want to buy another repo.

A: Git itself doesn't require that there be any relation between branches in a repository. So, you could create as many local repositories that you want and have all of those push to a single remote repository. If you carefully setup the refspecs used by each local repository, it could even appear very much like you have separate remotes for each local repository.
But, it's possible that whatever provider that you're using would check for that type of use, especially if they're charging per repository.
You're much less likely to run into issues if you instead find a way to have a separate remote repository for each project. The git wiki has a list of hosting sites, a number of which will allow hosting of private repositories for free.

A: This is bad architecture. You're killing yourself by managing your repo's this way.
I have found that there is never a valid reason to have more than one repo per project.
I can only imagine what it must be like to have to constantly merge all of those repo's to keep them updated.
It seems to me like you should just create a separate branch for each "project", which will more easily allow you to maintain history, workflow, and do less merging. However, even this would be flawed because no matter what you do, you have to be leaving a large opportunity for merge conflicts in your project. If I were you, I would do anything I possibly could to cut down to your "allinone" repo, and just manage that by checking out feature branches when you're doing work that pertains to a certain "project".
Best of luck!


text:
Q: Customize or apply conditions on  in struts2 This tag works for when associated list is empty or null.  Can we make it to work only for empty list and not for null?  I have placed this tag in .properties file.
These are known as display tags:
<display: setProperty> tag is a struts tag used under
<display:table name="someList">
<display:table>


text:
Q: How to use unix commands and python together
Possible Duplicate:
How do you read from stdin in python

I am new Python convert. I have seen examples of people using this command.
cat file1 file2 | python <script name>

I was wondering how to do that? As in how should my python script handle taking this input.? Sorry I do not know the terms to use to search for this. My guess is it can be used for any unix command?
Thanks.

A: The pipe you see in the shell command is used to route the input of previous command to the next command. So when you cat the files file1 and file2. The output is fed to the python script as input.
So the contents of the two files are available at stdin of your python program, which can be accessed using sys.stdin. Hope that helps.


text:
Q: Visual Studio Code error can not explicitly assign protected access modifier to a class which is not defined in a namespace I code C # in VSCode version 1.63.2 and the problem is;

class ClassTwo
Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal, or private protected [test]csharp(CS1527)

I don't have any namespace declared in my .cs file now. At first, I had declared a namespace, then I remove it but the error still persists. What I've tried is to rename the class (it works, with different class name I don't face this problem), then I tried to remove the class file and recreate it with the same name (this did not work). I have a project named "test" with two classes and two .cs files with the same names, one is named ClassOne, the other one is ClassTwo.
ClassOne.cs
namespace test
{
    protected class ClassOne
    {

    }
}

ClassTwo.cs
protected class ClassTwo
{

}

test.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

Screenshot of the problem;
problem

A: You can't declare a private or a protected class in a namespace. Classes are either public or internal (except for nested classes). This issue isn't related to VS Code, it's simply the compiler telling you did a mistake.
Quote from the documentation:

Classes that you declare directly within a namespace, not nested within other classes, can be either public or internal. Classes are internal by default.

EDIT 2
Now that you posted your code we can finally understand what's exactly your issue and provide you an answer.
You're using .NET 5 which is using C# 9 by default. Therefore the answer I wrote down bellow in the first EDIT section isn't relevant.
In C# when you don't declare any namespace in a file, your class is by default added to the global namespace

The global namespace is the namespace that contains namespaces and types that are not declared inside a named namespace.

See this page for more information.
Assuming you're correcting the error and changing your class to public or internal, you can then use it like this
var myTwoObject = new global::ClassTwo();

EDIT
I'm keeping this section just because it's useful information but since you then posted your code we can now tell that you're not in C# 10 therefore this isn't the correct answer
From your comment I now understand that you must have created a .NET 6 console application.
By default, console application in .NET 6 are generated with a new template which is valid starting from C# 10
Have a look at the documentation New C# templates generate top-level statements
You can access your class by doing
Quote from this doc:

The term top-level statements means the compiler generates the namespace, class, and method elements for your main program. You can look at the code for the new application and imagine that it contains the statements inside the Main method generated by earlier templates.

It means even if you don't declare a namespace, it is still generated at compile time. Consider the namespace implicit just like Implicit using directives.


text:
Q: How do pass arguments to subroutines in Perl/Tk? I have designed one sign-up form,in this form after getting all necessary values I will click submit button.
And while clicking that submit button I want to call one function and I want to pass the arguments to that function.
I have written code for this purpose,but the function is called first before getting the details.(i.e)after getting the details in sign-up form I need to pass these values to one function and I need to validate those values.
But what happened was,before getting the details the function get called.

A: Carlos's suggestion is one way. Another is to put a command callback on the button that reads the values out of the form and calls your function, perhaps like this.
$button->configure(-command => sub { yourFunc($var1, $var2); });

I'm assuming you've bound the fields of the form to the variables $var1 and $var2 here; modify to fit your own situation of course.

A: You have a number of options when specifying a code ref and arguments to a bind to a widget:
$w->configure( -command => [ \&subname,   @args ... ]             );
$w->configure( -command => [ sub { ... }, @args ... ]             );
$w->configure( -command => [ 'methodname', $invocant, @args ... ] );
$w->configure( -command => [ $invocant, 'methodname', @args ... ] );

See the Tk::callbacks POD for more info.

A: Sounds like a vwait problem. Check in the Perl/Tk documentation for:
$widget->waitVariable(varRef)

In this way you are sure your code is only executed when the wait variable is modified (that's when you click the "submit" button)
Hope it helps.


text:
Q: "Named query not known" for named Hibernate query? What might be the problem?
@Entity
@NamedQueries( {
    @NamedQuery(name = User.ALL,
                query = "SELECT u FROM User u")
})

public class User {
    public static final String ALL = "User.all";
}

public class Service {
    find... with ... User.ALL
}

Stacktrace:
Caused by: org.hibernate.MappingException: Named query not known: User.all
    at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:93)
    at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1407)
    at $Session_a5ad46cfa25.getNamedQuery(Unknown Source)
    at $Session_a5ad46cf913.getNamedQuery(Unknown Source)
    at de.medicshare.dal.HibernateCrudServiceDAO.findUniqueWithNamedQuery(HibernateCrudServiceDAO.java:83)
    at $CrudServiceDAO_a5ad46cfa19.findUniqueWithNamedQuery(Unknown Source)
    at $CrudServiceDAO_a5ad46cfa1b.findUniqueWithNamedQuery(Unknown Source)
    at $CrudServiceDAO_a5ad46cf931.findUniqueWithNamedQuery(Unknown Source)
    at de.medicshare.pages.Signup.proceedSignup(Signup.java:82)
    at de.medicshare.pages.Signup.dispatchComponentEvent(Signup.java)
    at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:923)
    at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1106)
    ... 90 more

A: Not sure if this will be your issue but check out this post here.
The issue was the use of:
org.hibernate.annotations.Entity

Instead of:
javax.persistence.Entity


text:
Q: Upstart node.js mysql connection I am new to node.js so in an attempt to learn it I tried to run this example
http://markshust.com/2013/11/07/creating-nodejs-server-client-socket-io-mysql
It has no problems and everything is working fine. But then I wanted to run this server through forever and upstart, and a strange problem occured. When I first reboot the system, upstart runs the server fine, but the server script doesn't list mysql entries. But when I kill the server and forever starts it up again, everything works fine. Could you help me with this? Here is my upstart conf.
#!upstart

description "Forever and Node.js"

start on (starting mysql)
stop on shutdown

expect fork

env NODE_BIN_DIR="***"
env NODE_PATH="***"
env APPLICATION_DIRECTORY="***"
env APPLICATION_START="***"
env LOG="***"

script
        PATH=$NODE_BIN_DIR:$PATH

        exec forever --sourceDir $APPLICATION_DIRECTORY -a -l $LOG --minUptime 5000 --    spinSleepTime 2000 start $APPLICATION_START
end script

pre-stop script
        PATH=$NODE_BIN_DIR:$PATH
        exec forever stop $APPLICATION_START >> $LOG
end script

A: Replacing
start on (starting mysql)

with
start on (started mysql)

fixed the problem. Thank you all for this priceless community.


text:
Q: How to use CSS position correctly? I have a 3 DIVs like this

......

......

Using this structure, I want to have an output similar to this:

Green DIV have set to its width 100% and red DIV have a fixed width and set to center of the page. So my problem is I want to get my yellow DIV to red DIV having align to right of the red DIV.
.red {
   position: relative;
}

.yellow {
   position: absolute;
   top: 0;
   right: 20px;
}

But it's not my desired output.

A: here is a  fiddle, http://jsfiddle.net/P77RB/ you can play with the width and height to accommodate your needs.

.green{
width:500px;
height:300px;
background:green;
display:table;
 }
 .red{
width:80%;
height:270px;
margin:30px auto 0px auto;
background:red;
position:relative;
}
.yellow{
position:absolute;
background:yellow;
width:200px;
height:100px;
right:0;
top:50%;
margin-top:-40px;
}

A: Have you tried this?
.yellow {
  float: right;
  position: relative;
}

A: You have to use right: 0;
.yellow {
   position: absolute;
   top: 0;
   right: 0;
}

A: I have tested this DEMO
Adjust the height and width as per your page.

    .red {
   position: relative;
   width: 60%;
   margin-right: auto;
   margin-left: auto;
   height: 100%;
   background: red;

}

.yellow {
   position: absolute;
   right: 0;
   background: yellow;
   top: 20;
   height: 80%;
   width: 60%;
}

.green {
  width: 100%;
  background: green;
  padding-top: 20px;
  height: 200px;

}

A: Just put the yellow div into the red div in HTML and then set it to float: right;


text:
Q: Compile issues with curlpp: undefined reference to symbol 'curl_easy_setopt@@CURL_OPENSSL_3' Brief account of the issue:
After installing curlpp, I attempted to compile c++ code which uses the curlpp library and got the following error:
g++ testCurl.cpp -lcurlpp
/usr/bin/ld: /tmp/ccx5aH5P.o: undefined reference to symbol 'curl_easy_setopt@@CURL_OPENSSL_3'
//usr/lib/x86_64-linux-gnu/libcurl.so.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Any ideas how to fix this?
More detail:
I first attempted to install curlpp from source, but after running ./config, I was informed that I need boost (it's a new computer so I did not already have it installed). I installed boost. Then I was informed I needed "a working version of curl" or something like that. After a quick internet search, I found that I needed to install some version of libcurl-dev. In particular I installed the package: libcurl4-openssl-dev 7.35.0-1ubuntu2.2  After this, curlpp compiled and installed without issue.
Finally, I took some generic test code and attempted a compile using the command g++ test.cpp -lcurlpp. This led to the above error. I tried uninstalling curl and everything related and re-installing it. I also tried installing some of the alternate libcurl-dev implementations. Same error.
I have poked around the net for solutions and tried several other things. Nothing has worked so far.
Thanks in advance for any help!!

A: I found the dumb fix. I'll leave this up in case someone else has the same issue. You must compile with:
    g++ file.cpp -lcurlpp -lcurl


text:
Q: Reading .bmp(24 bit) into a 2D array I'm a complete beginner to this.I'll try to explain myself as much as i can.
int i, j;
string filename;
cout << "Please enter the file name: " << endl;
cin >> filename;
fstream stream;

stream.open(filename.c_str(),
    ios::in|ios::out|ios::binary);

int file_size = get_int(stream, 2);
int start = get_int(stream, 10);
int width = get_int(stream, 18);
int height = get_int(stream, 22);

This part should get the file and it's values.
for ( i = 0; i < height; i++ )
    {
        for ( j = 0; j < width; j++)
        {
            for (int k = 0; k < split*split; k++){

                int pos = stream.tellg();
                int blue = stream.get();
                int green = stream.get();
                int red = stream.get();

And this reaches inside each pixel and gets RBG values.
What i want is to first store RBG values into a 2D array and then do some manipulations on that array.Then i'd like to create a new file with manipulated image.
I've no clue so some instructions along with some code would be really helpfull.

A: This library is very easy to use http://easybmp.sourceforge.net/. U can easily check RGB values after loading the file.

A: Bmp file format is documented in many places. For example, on wikipedia.
The easiest way would be to implement structure that describes bmp header, and read entire structure in one go, then read individual pixels.
Your reading function is broken and doesn't function because you did not read file signature - "BM" field of the header.
On some operating system all there are already strcutures and functions for reading BMPs. On windows, there's BITMAPFILEHEADER. Using those structures means you aren't using "pure C++".
If you still want to read BMP yourself, read msdn articles aboud bmp or google for "read bmp file" tutorials.


text:
Q: Accepting Sql query in the form of argument in java code I am working on oracle coherence,have loaded data into the cache with the help of java code.I need help on how to accept random sql query in the form of argument in java to display output in the form of table.
This is the Sample sql query.
select dt,BCR,DCR,RCR,(BCR+DCR+RCR) as sum from (Select to_char(event_date,'DD-Mon-YY') as dt,
  case when sum(BCR_DNOM_D) in (0,NULL) then 0 else round((sum(BCR_NOM_D)*100/sum(BCR_DNOM_D)),2) end as BCR,
  case when sum(TCASSALL) in (0,NULL) or (sum(TNDROP-cellgen_cell23spare))<0 then 0 else round((sum(TNDROP-cellgen_cell23spare)*100/sum(TCASSALL)),2) end as DCR,
  case when sum(RCR_DNOM_D) in (0,NULL) then 0 else (case when round((sum(RCR_NOM_D)*100/sum(RCR_DNOM_D)),2)>100 then 0
  else round((sum(RCR_NOM_D)*100/sum(RCR_DNOM_D)),2)end) end as RCR
  from EDW_BASE_table A where 1=1
  group by event_date
  order by event_date)

A: Coherence is NOT a RDBMS. Coherence is a giant partitioned hashmap spread across multiple servers, hence it stores data in form of < Key, Value > where both key and value can be complex java objects and be queried against.
It will be very easy for you to write an Invocable class Coherence Node based processing documentation apply the business logic to get the expected result.


text:
Q: send long message with photo on telegram with php bot I need send to telegram long text with photo but telegram image caption has 200 character limit. How can send long text with photo using php and bot?
sendPhoto method has 200 character limit.
I see a telegram bot it's send long text and photo see my sample photo.

A: You can send standard message with parse_mode Markdown  or HTML.
In text content you need send link to your image.
https://core.telegram.org/bots/api#markdown-style
Some words [/start](https://www.google.ru/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png)
ok.
You will see google's logo in the bottom of message. The blue line on the left of the image indicates that it is the parsing contents of the link

A: You can send text message with Markdown Style or HTML Style and use inline URLs.
sample of inline URLs format:
[inline URL](http://www.example.com/)

You can use (ALT + NUMPAD characters) for hide link text.
For Example [ALT + 255] create non-breakable space which you can use this.
[ ](http://www.example.com/)

If you have many link in the text, Put your image link at the beginning of the text.

A: You can use empty character!
Just set parse_mode Field to HTML in sendMessage method ,
then in text Field insert the URL of the image into href
The hyperlink will not be seen when you use empty character :
<a href="https://www.nafasbekesh.ir/wp-content/uploads/2016/10/img1.jpg">
</a>

Copy the empty character for your own use.

A:
You can use (ALT + NUMPAD characters) for hide link text.
For Example [ALT + 255] create non-breakable space which you can use
  this.

but in this case i receved the following error
PHP Warning:  : failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request


text:
Q: How to cache objects store them for multiple requests? I am using Ruby on Rails and I need to store a search result set obtained by connecting to another server. The problem is I don't want to store the result set in the session and I want something where I can store the result set object over multiple requests.
The querying takes time so I don't want to repeat it. Is there a way I could store objects or cache objects so that I don't have to query it again and again?
Can use some kind of object store?
Any help would be great.
If memoizing is an option how do I memoize objects? The connection would still take time so how to store the result set.

A: If you don't want to store it in the session, obviously you have options here.
You can store in your DB temporarily (I assume querying the DB is faster than re-fetching from another server :)).
Also there's an option to use something like memcached. Although you have to be aware that restarting it will throw all your data away.
Depends on what you need to achieve and how you need to handle your data.

A: The memoization works only in single request. Can't be use in several request.
All request have all storage resource like Memcache or BDD.. If you use the ActiveSupport::Cache::MemCacheStore. you can push and fetch all object in all of your request.

A: If you need to store data between requests, memoization likely isn't what you are looking for. Memoization is typically used in Ruby/Rails when you are calling the same method repeatedly within a single request, and that method is expensive (either CPU intensive, multiple DB requests, etc).
You can memoize a method, which stores the result in an instance variable, and the next time it is called, the instance variable value is returned, rather than reevaluating the method. There are tons of resources out there on this if you want to look into it further.
For data that needs to persist across sessions, and may need to be shared between different users, I highly recommend memcached. Rails has some built in support for it, so it shouldn't be too hard to dig up some good resources.


text:
Q: Warnings when installing npm modules in project directories, but not when installing globally I have observed this issue when installing both newsapi and RequireJS. The path to my project directory is as follow: Users\username\project
In my project directory, when I run npm install newsapi --save (installation instructions per the newsapi site or npm install requirejs (installation instructions per the RequireJS site, I get the following identical warnings:
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.

It may be worth noting the project\node_modules\newsapi and project\node_modules\requirejs are still created and they seems to be populated as they should.
I noticed that when I install the modules globally (by running npm install -g newsapi --save or npm install -g requirejs) the installation succeeds without displaying any warnings. Why is this the case? What is happening in my project folder that might be causing this issue?

A: npm install fhqhwhgads will try to update the local project package.json but npm install -g fhqwhgads will install globally and so there's no package.json to update. So that's why you're note getting an warning with global installation.
If you want to create a package.json so that your dependencies can be tracked and replicated by others (or if you want to publish your code as a package), you can use npm init.


text:
Q: How to replace some values inside a specific tag in a index.html file using a cypress automation test Currently, I'm working with Cypress test automation. I have an index.html file inside cypress/downloads/sample/index.html. The index.html file has the below structure.
<html>
<head>
  <style type="text/css">
  </style>
</head>
<body>
<script src="https://test"></script>
<script src="https://test2"></script>

<!-- sample Config -->

  <script>
        const authConfig = {
            clientID: "sample value",
            signInRedirectURL: "sample value",
            serverOrigin: "sample value"
        };
    </script>
</body>
</html>

I will get copy the content inside the script tag which will be displayed in an application UI using a button click for the copy operation so the copied content will be as below
<script>
    const authConfig = {
        clientID: "abcd1234",
        signInRedirectURL: "https://localhost:8000",
        serverOrigin: "https://localhost:8000"
    };
</script>

Method written for copy and paste operation is as below:
static CopyConfigs() {

        cy.get(COPY_ICON).click();
        cy.wait(7000);
    }

static pasteoperation(Location){
            cy.task("getClipboard").then((value) => {
                cy.writeFile(Location + "/sample/index.html", value);
            });
    }

writeFile will replace the whole index.html file content
Need help on
I want to replace(paste) the content copied to the index.html file by replacing only the script tag(related to authConfig) content inside the index.html file without replacing the whole index.html file content. So that the values for clientID, signInRedirectURL, and serverOrigin inside the script tag of index.html file will have the new values. Is it possible to read the index.html file and capture the script tag and replace the <script> tag content using Cypress automation? Appreciate your support on how to achieve this.


text:
Q: Multiple definitions of main how do I correctly implement Lua in a C++ program? I downloaded the Lua source, put the .c files in my src folder and the .h files in my include folder, included lua.h in my program's source code (with extern "C"{} of course) and hit "Build".
That's how all the tutorials tell me to use Lua with a C++ project.
But now I get the error "multiple definition of main" and some Symbols in the Lua code that could not be resolved. I understand what the first error means (conflict because Lua has a main and my program also has one), but how can I solve it?
Or did I understand something completely wrong about implementing Lua in a C++ program?

A: Check to make sure you didn't include luac.c, lua.c, and the source for any other programs that are included with Lua in with your source code.  Lua's source includes a few extra utilities (i.e., luac), and chances are you've just included them in the project and forgotten to remove them, thus resulting in having more than one main.
In short, those are separate programs that you don't add to your project.  If you can, just build Lua normally, link to the library, and include the header files as normal.
So, on the point of you misunderstanding how to use Lua, you probably did to some degree.  It is entirely possible to just copy Lua's source into your code, though probably not advisable.  What you really want to do is pull up the extracted Lua source in a terminal and build it.  Then (according to Lua's INSTALL document), you'll want to type make platform, where you'll replace platform with whichever platform you're currently using (i.e., I'd use macosx, you might use linux, refer to the INSTALL for which platforms are supported).  After that, it's up to you if you want to install it or not, but you'll just do make install (or sudo make install) to get that done.
After that, either add the appropriate linker flags when compiling to link to Lua (e.g., -llua) or alter your project's settings in your editor of choice to do roughly the same thing.  That said, you'll want to refer to the INSTALL document provided with Lua for complete instructions on this.

A: I'm embedding Lua in my projects other way around, preferred way, IMO: compiled Lua as a static library.

A: Just comment the two main() blocks in Lua.c an Luac.c, then hit build and run again.
I made this on Lua 5.3.


text:
Q: Exzessive stack usage for simple function in debug build I have simple class using a kind of ATL database access.
All functions are defined in a header file.
The problematic functions all do the same. There are some macros in use. The generated code looks like this
void InitBindings()
{
     if (sName)   // Static global char*
         m_sTableName = sName;  // Save into member
     { AddCol("Name", some_constant_data... _GetOleDBType(...), ...); };
     { AddCol("Name1", some_other_constant_data_GetOleDBType(...), ...); };
     ...
}

AddCol returns a reference to a structure, but as you see it is ignored.
When I look into the assembler code where I have a function that uses 6 AddCol calls I can see that the function requires 2176 bytes of stack space. I have functions that requires 20kb and more. And in the debugger I can see that the stack isn't use at all. (All initialized to 0xCC and never touched)
See assembler code at the end.
The problem can be seen with VS-2015, and VS-2017.Only in Debug mode.
In Release mode the function reserves no extra stack space at all.
The only rule I see is; more AddCol calls, will cause more stack to be reserved. I can see that approximativ 500bytes per AddCol call is reserved.
Again: The function returns no object, it returns a reference to the binding information.
I already used the following pragmas in front of the function (but inside the class definition in the header):
__pragma(runtime_checks("", off)) __pragma(optimize("ts", on)) __pragma(strict_gs_check(push, off))

But no avail. This pragmas should turn optimization on, switches off runtime checks and stack checks. How can I reduce this unneeded stack space that is allocated. In some cases I can see stack overflows in the debug version, when this functions are used. No problems in the release version.
; 325  : BIND_BEGIN(CMasterData, _T("tblMasterData"))

    push    ebp
    mov ebp, esp
    sub esp, 2176               ; 00000880H
    push    ebx
    push    esi
    push    edi
    mov DWORD PTR _this$[ebp], ecx
    mov eax, OFFSET ??_C@_1BM@GOLNKAI@?$AAt?$AAb?$AAl?$AAM?$AAa?$AAs?$AAt?$AAe?$AAr?$AAD?$AAa?$AAt?$AAa?$AA?$AA@
    test    eax, eax
    je  SHORT $LN2@InitBindin
    push    OFFSET ??_C@_1BM@GOLNKAI@?$AAt?$AAb?$AAl?$AAM?$AAa?$AAs?$AAt?$AAe?$AAr?$AAD?$AAa?$AAt?$AAa?$AA?$AA@
    mov ecx, DWORD PTR _this$[ebp]
    add ecx, 136                ; 00000088H
    call    DWORD PTR __imp_??4?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@QAEAAV01@PB_W@Z
$LN2@InitBindin:

; 326  : // Columns:
; 327  :    B$C_IDENT   (_T("Id"),          m_lId);

    push    0
    push    0
    push    1
    push    4
    push    0
    call    ?_GetOleDBType@ATL@@YAGAAJ@Z        ; ATL::_GetOleDBType
    add esp, 4
    movzx   eax, ax
    push    eax
    push    0
    push    OFFSET ??_C@_15NCCOGFKM@?$AAI?$AAd?$AA?$AA@
    mov ecx, DWORD PTR _this$[ebp]
    call    ?AddCol@CDBAccess@DB@@QAEAAUS_BIND@2@PB_WKGKW4TYPE@32@0_N@Z ; DB::CDBAccess::AddCol

; 328  :    B$C         (_T("Name"),        m_szName);

    push    0
    push    0
    push    0
    push    122                 ; 0000007aH
    mov eax, 4
    push    eax
    call    ?_GetOleDBType@ATL@@YAGQA_W@Z       ; ATL::_GetOleDBType
    add esp, 4
    movzx   ecx, ax
    push    ecx
    push    4
    push    OFFSET ??_C@_19DINFBLAK@?$AAN?$AAa?$AAm?$AAe?$AA?$AA@
    mov ecx, DWORD PTR _this$[ebp]
    call    ?AddCol@CDBAccess@DB@@QAEAAUS_BIND@2@PB_WKGKW4TYPE@32@0_N@Z ; DB::CDBAccess::AddCol

; 329  :    B$C         (_T("Data"),        m_data);

    push    0
    push    0
    push    0
    push    4
    push    128                 ; 00000080H
    call    ?_GetOleDBType@ATL@@YAGAAVCComBSTR@1@@Z ; ATL::_GetOleDBType
    add esp, 4
    movzx   eax, ax
    push    eax
    push    128                 ; 00000080H
    push    OFFSET ??_C@_19IEEMEPMH@?$AAD?$AAa?$AAt?$AAa?$AA?$AA@
    mov ecx, DWORD PTR _this$[ebp]
    call    ?AddCol@CDBAccess@DB@@QAEAAUS_BIND@2@PB_WKGKW4TYPE@32@0_N@Z ; DB::CDBAccess::AddCol

A: It is a compiler bug. Already known in connect.
EDIT The problem seams to be fixed in VS-2017 15.5.1
The problem has to do with a bug in the built in offsetof.
It is not possible for me to #undef _CRT_USE_BUILTIN_OFFSETOF as written in this case.
For me it only works to #undef offsetof and to use one of this:
#define myoffsetof1(s,m)    ((size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
#define myoffsetof2(s, m)   ((size_t)&(((s*)0)->m))

#undef offsetof
#define offsetof myoffsetof1

All ATL DB consumers are affected.
Here is a minimum repro, that shows the bug. Set a breakpint on the Init function. Look into the assembler code and wonder how much stack is used!
// StackUsage.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <list>
#include <iostream>

using namespace std;

struct CRec
{
    char    t1[20];
    char    t2[20];
    char    t3[20];
    char    t4[20];
    char    t5[20];
    int     i1, i2, i3, i4, i5;
    GUID    g1, g2, g3, g4, g5;
    DBTIMESTAMP d1, d2, d3, d4, d5;
};

#define sizeofmember(s,m)   sizeof(reinterpret_cast<const s *>(0)->m)
#define typeofmember(c,m)   _GetOleDBType(((c*)0)->m)

#define myoffsetof1(s,m)    ((size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
#define myoffsetof2(s, m)   ((size_t)&(((s*)0)->m))

// Undef this lines to fix the bug
// #undef offsetof
// #define offsetof myoffsetof1

#define COL(n,v)    { AddCol(n,offsetof(CRec,v),typeofmember(CRec,v),sizeofmember(CRec,v));     }

class CFoo
{
public:
    CFoo()
    {
        Init();
    }

    void Init()
    {
        COL("t1", t1);
        COL("t2", t2);
        COL("t3", t3);
        COL("t4", t4);
        COL("t5", t5);
        COL("i1", i1);
        COL("i2", i2);
        COL("i3", i3);
        COL("i4", i4);
        COL("i5", i5);
        COL("g1", g1);
        COL("g2", g2);
        COL("g2", g3);
        COL("g2", g4);
        COL("g2", g5);
        COL("d1", d1);
        COL("d2", d2);
        COL("d2", d3);
        COL("d2", d4);
        COL("d2", d5);
    }
    void AddCol(PCSTR szName, ULONG nOffset, DBTYPE wType, ULONG nSize)
    {
        cout << szName << '\t' << nOffset << '\t' << wType << '\t' << nSize << endl;
    }
};

int main()
{
    CFoo foo;
    return 0;
}


text:
Q: Content-type header in response is getting appended by charset=ISO-8859-1 I have a web service that produces MediaType.APPLICATION_XML_VALUE
In rest client, I see content-type header as application/xml;charset=ISO-8859-1
Caller has set Accept header as application/xml
Not sure what is adding charset=ISO-8859-1 in the header.
To remove charset from content-type header,

*

*Tried with mentioning application/xml instead of MediaType.APPLICATION_XML_VALUE

*Tried adding spring filter CharacterEncodingFilter

*Tried adding spring.http.encoding.force=false in application.properties file

None of the above made any difference.
Caller

    curl -v -X POST \
      https://<URL> \
      -H 'Content-Type: application/x-www-form-urlencoded' \
      -H 'accept: application/xml'

Java Resource

    @RequestMapping(value = "<URL>",
                    method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
                    produces = MediaType.APPLICATION_XML_VALUE)
    @ResponseBody
    public String processRequest(HttpServletRequest request) {
        try {
            Object response = service(request);
            if (response != null) {
                return response.toString();
            }
        } catch (Exception e) {
            logger.error(e);
        }
        return createErrorResponse(ERR_CODE).toString();
    }

// response header
200 OK
Time:1247 ms
Size:1.62 KB
Save
Download
Date →Wed, 17 Jul 2019 07:30:28 GMT
Server →Apache
Strict-Transport-Security →max-age=31536000; includeSubDomains
Content-Type →application/xml;charset=ISO-8859-1
Content-Length →1374
Via →1.1 <URL>
Keep-Alive →timeout=5, max=10000
Connection →Keep-Alive

This was working fine. Started seeing above behavior post upgrading following libraries

    jackson 2.6.0 to 2.6.3
    httpclient 4.5 to 4.5.3
    httpcomponents 4.4.1 to 4.4.6
    springframework 4.2.9 to 4.3.17

Need to know a way how to omit charset from header and what is adding it in the first place.

A: Found the issues.
@ResponseBody annotation was converting String output to HTTP supported format.
Internally, it would append charset=ISO-8859-1 to the content-type header if not specified.
As I wanted to remove this, changed method return from String to ResponseEntity<String>
ResponseEntity will take care of converting output to HTTP supported format and not the annotation. So control on converting to HTTP is now in code rather than letting spring do it. Here we can explicitly set headers that we want.
New code looks something like this :
@RequestMapping(value = "<URL>",method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<String> processRequest(HttpServletRequest request) {
    try {
        Object response = service(request);
        if (response != null) {
            prepareResponseEntity(response.toString());
        }
    } catch (Exception e) {
        logger.error(e);
    }
    return prepareResponseEntity(createErrorResponse(ERR_CODE).toString());
}

private static ResponseEntity<String> prepareResponseEntity (String responseBody){
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add(HeartBeatServerConstants.HEADER_CONTENT_TYPE,MediaType.APPLICATION_XML_VALUE);
    return new ResponseEntity<String>(responseBody,responseHeaders,HttpStatus.OK);
}

Update : AbstractHttpMessageConverter of spring-web has changed between spring 4.2.9 and 4.3.17 to add charset if not present.Spring Doc


text:
Q: Is the variance the sum of the sum of conditional variances and variance of conditional expected value? Here is the following question:
"I buy a drill and wonder about its lifespan (which is a real positive number).
With a probability of 0.25 the drill has a hidden manufacturing defect and its service life
is evenly distributed between 1 and 7 years. If it is not defective (probability 0.75),
its lifespan is a random variable uniformly distributed between 9 and 15 years."
My problem is that I would like to calculate the variance of the lifespan. My problem is I am unsure of the formula to use (I didn't really understand it on wikipedia)
I use a variable T for the lifespan and D=0 being a defective tool and D =1 being a nondefective tool. For the conditional variances I obtain the following: $Var(T|D = 0)$ and $Var(T|D = 1) = 3$ and for the variance of the conditional expected value $\mathbb{E}[T|D]$ I obtain 12.
In the solution of the exercise, it is given 15 as the total variance. From what I've understood the total variance should be 18 and not 15.

A: Considering the two uniform random variables representing the two random lifespans:
1)
$$A\sim U[1;7]$$
2)
$$B\sim U[9;15]$$
The total lifespan's density is a mixture (a linear combination) of the two uniform densities:
$$f_T(t)=0.25\cdot f_A(t)+0.75\cdot f_B(t)$$
Thus
$$\mathbb{E}[T]=0.25\cdot 4+0.75\cdot12=10$$
$$\mathbb{E}[T^2]=0.25\cdot (3+4^2)+0.75\cdot(3+12^2)=115$$
Concluding:
$$\mathbb{V}[T]=115-10^2=15$$
...your textbook is right!


text:
Q: How to make the datagrid with no data? I have a page with two buttons: one is Load Data and the other Clear Data.
I am using DataSet and have used ds.Tables.Clear() in that click code.
If the user clicks Clear Data will the data in the datagrid disappear or not?

A: For showing grid with no rows, check GridView.EmptyDataTemplate Property
or
You can create an empty row and add to your datagrid like this -
if(datatable.Rows.Count == 0)
{
    datatable.Rows.Add(datatable.NewRow);
}
datagrid.DataSource = datatable;
datagrid.DataBind();

A: According to your comment, the answer is No.


text:
Q: How to count the each element of same index key in array? How to count the each element of same index number?
my @a = qw"A B C D E F";
my @b = qw"A B C C";
my $count = 0;
for($i = 0; $i<=scalar @a; $i++){
    for($j = 0; $j <= scalar @b; $j++){
        if($a[$i] eq $b[$j]){
            $count++;
        }
    }
}
print "Total: $count";

I expect the output is:
Total:3

The output is done by count only the same element of the index key? How can i do it?

A: There are two potential interpretations to your problem:
1. How does one count the intersection of two arrays?
A hash is an ideal data structure to test for existance:
use strict;
use warnings;

my @a = qw"A B C D E F";
my @b = qw"A B C C";

my %b = map {$_ => 1} @b;

my $count = scalar grep {$b{$_}} @a;

print "Total: $count";

Outputs:
Total: 3

Additional perldoc reference: How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
2. How does one test element equality between two arrays, index to index?
If this is your question, then you do not need two loops, just a single iterator.
use strict;
use warnings;

use List::Util qw(min);

my @a = qw"A B C D E F";
my @b = qw"A B C C";

my $count = scalar grep {$a[$_] eq $b[$_]} (0..min($#a, $#b));

print "Total: $count";

Outputs:
Total: 3


text:
Q: How do I make a readonly mirror of my github repo? We need to have a read only github repo that mirrors our main branch.
I've noticed castle have managed to do it with their entire collection of repositories.
How would I go about achieving this?

A: I believe this is what you are looking for right here:
http://justcramer.com/2011/05/09/creating-a-one-way-git-server-mirror/

A: Castleproject is an organization (also mentioned here) in order to restrict write access.
That is why you see read-only addresses on their projects.
That also means it (ie the organization "castleproject") can add users with read-only rights.
As a simple user owning a GitHub repo, you wouldn't have access to that feature.
You need to define an "organization".


text:
Q: kendo-multiselect with k-rebind model and options Can we rebind model and options using k-rebind in kendo-multiselect angular directive.

<select id="{{ vm.id }}"
 class="k-textbox InputBox inputBoxText"
 kendo-multiselect
 ng-disabled="vm.ngDisabled"
 k-ng-model="vm.ngModel"
 k-options="vm.options"
 k-rebind="vm.options">
</select>

A: Got the answer..

var kendoMultiSelect = $("#"+vm.id).find('select').data("kendoMultiSelect");
    kendoMultiSelect.dataSource.options = vm.options;
    kendoMultiSelect.dataSource.options.value = vm.ngModel;


text:
Q: Spree search filter for properties and variants I'm running Spree 1.3.1 and I'm trying to customize the Taxon show page.
I would like it to return the products contained inside the current Taxon, eventually filtered by a property or by an option value.
For example let's say that I'm seeing the Taxon of an underwear collection.
I'd like to filter the products shown, by providing a certain size (option_type).
In this case I should list only products that have variants with the requested size.
I would like also to be able to filter the products by the "fit" property.
Filtering by the slip fit, I should be able to list only products inside the current Taxon that have the required property.
This is the Taxon controller show action:
Spree::TaxonsController.class_eval do

    def show
      @taxon = Spree::Taxon.find_by_permalink!(params[:id])
      return unless @taxon

      @searcher = Spree::Config.searcher_class.new(params)
      @searcher.current_user = try_spree_current_user
      @searcher.current_currency = current_currency
      @products = @searcher.retrieve_products

      respond_with(@taxon)
    end

end

How should I modify it to fit my needs?

A: I partially solved the question.
I found out that I need to leave the controller as it is, the magic is done in the lib/spree/product_filters.rb file where I added this new product filter:
  if Spree::Property.table_exists?
    Spree::Product.add_search_scope :fit_any do |*opts|
      conds = opts.map {|o| ProductFilters.fit_filter[:conds][o]}.reject {|c| c.nil?}
      scope = conds.shift
      conds.each do |new_scope|
        scope = scope.or(new_scope)
      end
      Spree::Product.with_property("fit").where(scope)
    end

    def ProductFilters.fit_filter
      fit_property = Spree::Property.find_by_name("fit")
      fits = Spree::ProductProperty.where(:property_id => fit_property).pluck(:value).uniq
      pp = Spree::ProductProperty.arel_table
      conds = Hash[*fits.map { |b| [b, pp[:value].eq(b)] }.flatten]
      { :name   => "Fits",
        :scope  => :fit_any,
        :conds  => conds,
        :labels => (fits.sort).map { |k| [k, k] }
      }
    end
  end

Then I added the new filter to the Taxon model decorator with this:
Spree::Taxon.class_eval do

  def applicable_filters
    fs = []
    fs << Spree::Core::ProductFilters.fit_filter if Spree::Core::ProductFilters.respond_to?(:fit_filter)
    fs
  end

end

Still I haven't found out how to create a filter for variants that have a specific option value.

A: You talk about filtering on numerical value, I've written a filter for option ranges:
def ProductFilters.ov_range_test(range1, range2)
  ov = Arel::Table.new("spree_option_values")
  cast = Arel::Nodes::NamedFunction.new "CAST", [ ov[:presentation].as("integer")]
  comparaisons = cast.in(range1..range2)
  comparaisons
end

Spree::Product.add_search_scope :screenSize_range_any do |*opts|
  conds = opts.map {|o| Spree::ProductFilters.screenSize_filter[:conds][o]}.reject {|c| c.nil?}
  scope = conds.shift
  conds.each do |new_scope|
    scope = scope.or(new_scope)
  end
  option_values=Spree::OptionValue.where(scope).joins(:option_type).where(OptionType.table_name => {:name => "tailleEcran"}).pluck("#{OptionValue.table_name}.id")
  Spree::Product.where("#{Product.table_name}.id in (select product_id from #{Variant.table_name} v left join spree_option_values_variants ov on ov.variant_id = v.id where ov.option_value_id in (?))", option_values)
end

def ProductFilters.screenSize_filter
  conds = [ [ "20p ou moins",ov_range_test(0,20)],
  [ "20p - 30p",ov_range_test(20,30)],
  [ "30p - 40p" ,ov_range_test(30,40)],
  [ "40p ou plus",ov_range_test(40,190)]]
  { :name   => "taille",
    :scope  => :screenSize_range_any,
    :options => :tailleEcran,
    :conds  => Hash[*conds.flatten],
    :labels => conds.map {|k,v| [k,k]}
  }
end

You can see this one too, for discrete specific values:
https://gist.github.com/Ranger-X/2511088


text:
Q: Returning a Tuple List from an action and rendering it in the View model ASP.NET I have been going crazy over this one, I create a function that returns a tuple List, next is to store that List in another List which I want to render in the View.
The tuple List is of different type Lists.
Controller:
 public List<Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>> completeStats(int EnrollNumber, DateTime StartDate, DateTime EndDate)
        {

//some code

  List<Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>> generalList = new List<Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>>();

//some more code

   List<string> Name = new List<string>();
            List<TimeSpan> ArrivalTime = new List<TimeSpan>();
            List<int> FineList = new List<int>();
            List<TimeSpan> ArrList = new List<TimeSpan>();
            List<int> MinList = new List<int>();
            List<TimeSpan> DepartList = new List<TimeSpan>();
            List<TimeSpan> TimeSpentList = new List<TimeSpan>();

            for (int i = 0; i < fineList.Count(); i++)
            {
                if (fineList[i] > 0)
                {
                    Name.Add(empObj2.FirstName);
                    ArrivalTime.Add(AT);
                    FineList.Add(fineList[i]);
                    ArrList.Add(ArrivalList[i]);
                    MinList.Add(minutesList[i]);
                    DepartList.Add(departList[i]);
                    TimeSpentList.Add(timeSpentList[i]);
                }
            }

 generalList.Add(new Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>(
               Name, ArrList , ArrivalTime, MinList, FineList, DepartList, TimeSpentList

                ));
            return generalList;
}

now in th Index Action:
 public ActionResult Index(int? EnrollNumber, DateTime? StartDate, DateTime? EndDate)
        {

//some code

  var generalList2 = new List<Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>>();

//the line below does not work, why?
  //generalList2.Add(completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate));

//the line below works but this does not add all the list but only the last one
  //generalList2 = completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate);

//this works but obviously is not a good approach and slows down ALOT

 generalList2.Add(new Tuple<List<string>, List<TimeSpan>, List<TimeSpan>, List<int>, List<int>, List<TimeSpan>, List<TimeSpan>>(
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item1,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item2,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item3,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item4,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item5,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item6,
                            completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate).FirstOrDefault().Item7
                         ));

//next is to render the lists in the View, I tried with ViewBag instead.
 ViewBag.generalList = generalList2;
                return View(generalList2);

View:

               Name

               Scheduled Arrival Time

                Arrival Time

                Late Mins

                Fine Imposed

               Scheduled Departure Time

               Departure Time

               TimeSpent

               DateTime

                Action

        @foreach (var item in @ViewBag.generalList)
        {
            foreach (var item2 in item.Item1)
            {

                        @item2

                    @foreach (var item3 in item.Item2)
                    {

                        @item3

                    }

                    @foreach (var item4 in item.Item3)
                    {

                            @item4

                    }

                    @foreach (var item5 in item.Item4)
                    {

                            @item5

                    }

                    @foreach (var item6 in item.Item5)
                    {

                            @item6

                    }

                    @foreach (var item7 in item.Item6)
                    {

                            @item7

                    }

                    @foreach (var item8 in item.Item7)
                    {

                            @item8

                    }

                     @*

                            @*<button type="button" class="btn blue" onclick="location.href='@Url.Action("Edit", "FineReport", new { id = item.CronID })'" style="">Edit  </button>*@
                    @*<button type="button" class="btn green" onclick="location.href='@Url.Action("Details", "FineReport", new { id = item.CronID })'" style="">View  </button>*@
                    @*<button type="button" class="btn red" onclick="location.href='@Url.Action("Delete", "FineReport", new { id = item.CronID })'" style="">Delete  </button>

                        	*@

            }

        }

Now the snippet in the view above is very messed up as it does not renders the lists as expected. I tried with different
 approaches getting all messy records (mostly redundant entries). The list generalList2 has 7 different Lists with each list having different number of elements (Items in this case).
UPDATED: Continuing from Peter's suggestion I adopted the Viewmodel approach like below;
public class Agenda
{

    public IList<string> Names { get; set; }
    public IList<TimeSpan> ArrivalTimes { get; set; }
    public IList<int> Fines { get; set; }
    public IList<TimeSpan> ArrList { get; set; }
    public IList<int> MinList { get; set; }
    public IList<TimeSpan> Departures { get; set; }
    public IList<TimeSpan> TimesSpent { get; set; }
}

Controller:
public ActionResult Index(int? EnrollNumber, DateTime? StartDate, DateTime? EndDate)
        {
 var empId = db.Employees.Where(x => x.EnrollNumber == EnrollNumber.ToString()).Select(x => x.EmployeeId);

                var getLoggedID = SessionManager.CurrentUser.EmployeeId;
                var dept = db.Departments.Where(x => x.LeadBy == SessionManager.CurrentUser.EmployeeId).FirstOrDefault();

                var teams = db.Teams.Where(x => x.DeptID == dept.DepartmentId);

                List<Employee> refinedEmpList = new List<Employee>();
                var empList = db.Employees.ToList();
                foreach (var v in teams)
                {
                    foreach (var c in empList)
                    {
                        if (v.TeamID == c.TeamId)
                        {
                            refinedEmpList.Add(c);
                        }
                    }
                }
                if (EnrollNumber != null && StartDate != null && EndDate != null)
                {
                    foreach (var emp in refinedEmpList)
                    {
 agenda.Add(completeStats(Convert.ToInt32(emp.EnrollNumber), StartDate.Value, EndDate.Value));

                    }
                }
                else
                {
                    foreach (var emp in refinedEmpList)
                    {
                        DateTime now = DateTime.Now;
                        var startDate = new DateTime(now.Year, now.Month, 1);
                        var endDate = now.Date;
   agenda.Add(completeStats(Convert.ToInt32(emp.EnrollNumber), startDate, endDate));

                    }
                }
 return View(agenda);

View:

Late Fine Report

@{
    int sum = 0;
 }

                Name

                Total Fine

                Action

        @foreach (var agenda in Model)
        {
            if (agenda.Fines.Contains(0))
            {
                continue;
            }

            sum += agenda.Fines.Sum();

                        @Html.DisplayFor(modelItem => agenda.Names)

                        @Html.DisplayFor(modelItem => agenda.Fines)

            }

                Total

                 @sum

ISSUE:
Apart from being working fine, the problem is that it displays the same data every time, even when I give it the select startDate and endDate from the daerangepicker, funny thing is that when  inspected the Console on the browser it actually shows the data according to the selected date range but not the view, why? Attached pictures below:
Scenario 1: (by default when the index is loaded, no dates are given and so the month report is displayed)
enter image description here
Scenario 2: Now when I give a date range of 12 March - 14 March it displays the same result but if you see it in the console it is returning the expected result
     enter image description here

A: Peter has already given a better path, moving to the edited quesion; there are two ways to solve the issue.
The Problem is;

you are not clearing the model table before applying the latest data
  which is why it sticks to the old one

on your OnSubmit();

1) return a json object instead of the model view inside the controller that will give you latest table data.
2) Inside the View above, wrap the table with a
 like;
div id="tableContainer">

//

and then in the script make the changes;
 $('#myTable').html('');

            $.ajax({
                url: baseUrl + 'FineReport/Index?EnrollNumber=' + id + '&StartDate=' + moment(s).format("YYYY-MM-DD") + '&EndDate=' + moment(e).format("YYYY-MM-DD"),
                contenttype: 'application/json',
                data: '',
                type: 'post'
            }).done(function (data) {
 var result = $(data).find('#tableContainer');
 $('#tableContainer').html(result);

            });

This will find the selected element and append it to the table, notice that I cleared the table right before ajax  with;
$('#myTable').html('');

A: First, using Tuple's like this is basically avoiding the creation of a custom class. May I suggest you create a new model in your project : /Models/Agenda.cs
Which would look like this:
public class Agenda {
    public IList<string> Names {get;set;}
    public IList<TimeSpan> ArrivalTimes {get;set;}
    public IList<int> Fines {get;set;}
    public IList<TimeSpan> ArrList {get;set;}
    public IList<int> MinList {get;set;}
    public IList<TimeSpan> Departures {get;set;}
    public IList<TimeSpan> TimesSpent {get;set;}
}

Now in your view you could specify that the model of the view is a list of this class:
@model IList<Agenda>

And then you can call your view from the controller as such:
return View(myListOfAgendas)

without having to use the ViewBag.
Now you can access the model inside the view with the property ´Model´.
As a small example:

@foreach(var agenda in Model){

        ....

}

But as I mentioned in the comments. I know this is not an answer to your question, but I think if you refactor the code as such, you'll make it much simpler to understand.


text:
Q: IE width 100% doesn't work. How to fix it? This code won't work in any IE browser:

main {
  position: relative;
}

div {
  position: absolute;
  height: 300px;
  background-color: red;
  width: 100%;
}

I tried using width 100vw but horizontal scroll appears if page doesn't fit the viewport. A tried something like width calc(100vw - vertical_scroll_width) but it is not okay if there is no vertical scroll on the page.

A: "Partial support refers to only the  element (added later to the spec) being "unknown", though it can still be used and styled."
As shown here : https://caniuse.com/#search=main
Main is not fully supported. You can still style it through.
As explained before, simply do :
main {
  display: block;
}

A: You just need to make your main element block (in IE it's not block by default):
main {
  display: block;
}


text:
Q: Fetch All Value I have this code:
$query_search_select = $db->prepare("SELECT * , COUNT(*) AS coun FROM users WHERE user LIKE :keyword ;");
$query_search_select->bindParam(":keyword" , $key_search , PDO::PARAM_STR ) ;
$query_search_select->execute();

The query works, but when i take the information as this:
while($res = $query_search_select->fetch(PDO::FETCH_ASSOC)){
// code
}

But the loop during only 1 time, in COUNT(*) result 2 (it is right) but this loop during only 1 time... why? I search on stackoverflow and internet, i've tried fetchAll but with it i've the same problem...

A: try this
$result = $query_search_select->fetchAll(PDO::FETCH_ASSOC);

print_r($result);

Note: you dont have to use a while with fetchAll
In your case you should see if all info is in the result
while($res = $query_search_select->fetch(PDO::FETCH_ASSOC)){
    $collection[] = $res;
}
print_r($collection);

But as shown above, this could be handled in 1 row :)
Note 2: Your count in your select statement is kind of useless. Actually you have affected rows and you can get these with $query_search_select->rowCount();
Note 3:
I guess this is your main problem.
Check your LIKE statement. You have no % in there. If you have foo and foobar in your db and use your statment like you build it searching for foo, you will only
get 1 result returned!!! The LIKEstatement looks like this:
SELECT * FROM X WHERE name LIKE '%foo%'

Returns entrys with name foo and the entry can have values before and after foo
SELECT * FROM X WHERE name LIKE '%foo'

Returns entrys with name foo and the entry can have values before foo
SELECT * FROM X WHERE name LIKE 'foo%'

Returns entrys with name foo and the entry can have values after foo
SELECT * FROM X WHERE name LIKE 'foo'

Returns entrys with name foo and the entry CAN'T have values after or before foo

A: the problem here is, that COUNT() is a GROUP BY or aggregate function (see http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html)
so if you are using COUNT() in your MySQL statement, your resultset is automatically grouped to one row.

but you still can do it like this:
"SELECT * , (SELECT COUNT(*) FROM users WHERE user LIKE :keyword) AS coun FROM users WHERE user LIKE :keyword2"

NOTE:
you'll have to add another parameter binding since parameters can only be used once in the MySQL statement:
$query_search_select->bindParam(":keyword2" , $key_search , PDO::PARAM_STR ) ;

A: Second time I've responded to this question today. Don't use fetchAll() in a loop. It returns an array. If you need to look up PHP arrays in order to understand what this means, I suggest that course of action.
Then loop over the returned array, instead of trying to loop over the results of iterated fetch().


text:
Q: c - string manipulation to struct member Based on my previous post, I came up with the following code. I'm sure there is a better way of doing it. I'm wondering, what would that be?
It does split the string if greater than max chars OR if @ is found. Any ideas would be appreciated!
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct my_struct {
  char *str;
};

int main () {
  struct my_struct *struc;

  int max = 5;
  char *tmp = "Hello World@Foo Bar In here@Bar Foo dot com@here@there";

  struc = malloc (20 * sizeof (struct my_struct));

  int strIdx = 0, offSet = 0;
  char *p = tmp;
  char *tmpChar = malloc (strlen (tmp) + 1), *save;
  save = tmpChar;

  while (*p != '\0') {
    if (offSet < max) {
      offSet++;
      if (*p == '@') {
        if (offSet != 1) {
          *tmpChar = '\0';
          struc[strIdx++].str = strndup (save, max);
          save = tmpChar;
        }
        offSet = 0;
      } else
        *tmpChar++ = *p;
    } else {                    // max
      offSet = 0;
      *tmpChar = '\0';
      struc[strIdx++].str = strndup (save, max);
      save = tmpChar;
      continue;
    }
    p++;
  }
  struc[strIdx++].str = strndup (save, max);    // last 'save'

  for (strIdx = 0; strIdx < 11; strIdx++)
    printf ("%s\n", struc[strIdx].str);

  for (strIdx = 0; strIdx < 11; strIdx++)
    free (struc[strIdx].str);
  free (struc);
  return 0;
}

Output at 5 chars max:
Hello
 Worl
d
Foo B
ar In
 here
Bar F
oo do
t com
here
there

A: Alright, I'll take a crack at it. First, let me say that my formatting changes were for me. If you don't like lonely {s, that's fine.
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 5

struct string_bin
{
    char *str;
};

int main ()
{
    struct string_bin *strings;

    char *tmp = "Hello World@Foo Bar In here@Bar Foo dot com@here@there";

    char *p = tmp;
    strings = malloc (20 * sizeof (struct string_bin));
    memset(strings, 0, 20 * sizeof (struct string_bin));

    int strIdx = 0, offset = 0;
    char *cursor, *save;

    strings[strIdx].str = malloc(MAX+1);
    save = strings[strIdx].str;
    while (*p != '\0')
    {
        if (offset < MAX && *p != '@')
        {
            *(save++) = *(p++);
            offset++;
            continue;
        }
        else if (*p == '@')
            *p++;
        offset = 0;
        *save = '\0';
        strings[++strIdx].str = malloc(MAX+1);
        save = strings[strIdx].str;
    }
    *save = '\0';

    for (strIdx = 0; strings[strIdx].str != NULL; strIdx++)
    {
        printf ("%s\n", strings[strIdx].str);
        free (strings[strIdx].str);
    }

    free (strings);

    return 0;
}

The big change is that I got rid of your strdup calls. Instead, I stuffed the string directly into its destination buffer. I also made more calls to malloc for individual string buffers. That lets you not know the length of the input string ahead of time at the cost of a few extra allocations.


text:
Q: Is it possible to encrypt data using T-SQL for Always Encrypted columns? It's possible to use either the Encrypt Columns wizard in SSMS or Powershell to encrypt the data in Always Encrypted columns but can you use T-SQL for this?
To be clear, I don't want to create keys or columns that support encrypted columns, I want to complete the actual data encryption commensurate to the Set-SqlColumnEncryption cmdlet in Powershell but with T-SQL.


text:
Q: Memory issue inserting a large dataset in GDB with ArcObjects I am using the ArcObjects API for Java to load a very large dataset in a File Geodatabase in one feature class.
The whole dataset I have to load is composed of 200 datasets of 30k polygons, and I load the datasets one after the other. I read data from XML files (I am sure there is no memory leak in this step).
The loading process is in a BaseGeoprocessingTool.
Here is my code to write the data of one dataset in the feature class:
    IFeatureClass featureClass = ...
    IFeatureCursor insertCursor = featureClass.IFeatureClass_insert(false); // true uses too much memory
    IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer();
    IGeometry geometry = null;
    List<Integer> fieldIdsToClear = new ArrayList<Integer>();

    for(FeatureBean featureBean : features) {
        if(log.canContinue()) {
            geometry = featureBean.geometry.getGeometry();
            geometry.setSpatialReferenceByRef(fromSpatialReference);
            if(toBeProjected) geometry.project(toSpatialReference);
            featureBuffer.setShapeByRef(geometry);

            // reset the fields in the featureBuffer
            for(Integer fieldId : fieldIdsToClear) {
                featureBuffer.setValue(fieldId, Variant.VT_NULL);
            }
            fieldIdsToClear.clear();

            featureBuffer.setValue(idFieldId, (int)featureBean.id);

            for(Entry<String, String> tag : featureBean.tagMap.entrySet()) {
                int fieldId = fieldIdMap.get(tag.getKey());
                featureBuffer.setValue(fieldId, tag.getValue());
                fieldIdsToClear.add(fieldId);
            }

            insertCursor.insertFeature(featureBuffer);
        }
    }

    insertCursor.flush();

    Cleaner.release(geometry);
    Cleaner.release(featureBuffer);
    Cleaner.release(insertCursor);
    Cleaner.release(featureClass);

After reading these advices, I use an insert cursor instead of IFeature.store() so that process is ~5x faster. So, I do not recreate the FeatureBuffer each time I insert a new feature. Instead of, I reuse it and clear the necessary fields.
This process works well and is very fast. Nevertheless, there is a memory leak. Watching ArcMap.exe process memory, we can see that it uses about 100 Mb to load each dataset, then the memory is not released, even if objects are released in my code. When memory is about 1300 Mb (only after loaded the 5th dataset), the process crashes on the exception AutomationException: One or more arguments are invalid
I have tried different Java max heap sizes with JavaConfigTool.exe between 512 and 1900 Mb, but it doesn't change anything.
What solution could I try to be sure that ArcGIS really release useless objects? As I have a lot of datasets to load, I really need to release to get back the 100 Mb each time a dataset has been loaded.
Any help is welcome to optimize my process.
EDIT: I use ArcGIS 10.2 with Background Geoprocessing (64bits) and have 8 Go of RAM.