Posts

Showing posts from June, 2013

javascript - Restangular getList() method not returning JSON -

Image
i have problem geting data restangular promise. promise instead of pure data in json. this response api localhost:3000/api/meal { "status": "success", "data": [ { "meal_id": 4, "meal_type_id": 2, "description": "blahblah", "price": "3.50", "info": "120/120/20g", "restaurant_id": 2 }, ... ... } ], "message": "retrieved meals" } this config method extracting data response restangularprovider.addresponseinterceptor(function(data, operation, what, url, response, deferred) { var extracteddata; // .. getlist operations if (operation === 'getlist') { // .. , handle data , meta data return data.data; } else { extracteddata = data.data; } return extracteddata; }); this how trying data api restangular.all('meal').getlist().then(function(meals) {

What is the maximum version of PHP that cakephp version 1.3.7 will work with? -

i have moodle course uses cake 1.3.7 has started generating errors. these 3 come up: redefining defined constructor class object in /home/eslwow87/public_html/cake/libs/object.php on line 54 non-static method configure::getinstance() should not called statically in /home/eslwow87/public_html/cake/bootstrap.php on line 38 non-static method cakelog::handleerror() should not called statically in /home/eslwow87/public_html/cake/libs/cake_log.php on line 290 i guessing these caused mis-match between cake , version of php running on server (5.3.29). guess correct? you can open file config/core.php , change error_reporting this: configure::write('error', array( 'handler' => 'errorhandler::handleerror', 'level' => e_all & ~e_deprecated & ~e_strict, 'trace' => true )); or alternatively upgrade newer 1.3.x version fix these errors instead of suppress them, i'm not sure download git

c# - Is it possible to add an implicit operator in assembly A between types from assemblies G and M? -

let's there's graphics api g doesn't want depend on external math library , therefore defines vector parameters bare structs ( like sharpdx raw types ). let there math library m . a developer wants provide implicit operators in assembly a cast between full type math library m raw type graphics api g ( another sample sharpdx, in case operators defined in m instead of a ). note both of types have exact same memory representation. afaik, there no means in c# language provide such operators. closest comes mind extension methods, user still needs call additional method conversion. is possible or there samples of such operators being added through il rewrite? limited knowledge, i'd think possible appreciate additional feedback on matter. thanks! you rewriting il of 1 of 2 libraries, specifically, add implicit operator type (and in process add dependency on other library). but think doing bad idea: means need use own version of library (i.e. ca

html - How do I accomplish this with url rewriting? -

i have menu, when open goes /#0 indicate menu has been opened , menu slides in , shows. want know how rewrite url instead of site.com/#0 site.com. believe can done .htaccess though i'm not quite sure how. in advance. please try if i'm getting point. # rewrite --- www.site.com/#0 => www.site.com rewriterule ^$ /?&%{query_string}

C program won't compile without warnings when GCC is called by makefile - Works otherwise -

so have program here, works when called $ gcc test.c -o test -std=c99 but when called in makefile: all: test test: test.c gcc test.c -o test -std=c99 it produces warnings instead , gives segmentation fault. terminal output: gcc -g test.c -o tester -std=c99 test.c: in function ‘test_split’: test.c:43:2: warning: implicit declaration of function‘strdup[-wimplicit-function-declaration] char *str_cpy = strdup(str); // allow mutation of original string test.c:43:18: warning: initialization makes pointer integer without cast [enabled default] char *str_cpy = strdup(str); // allow mutation of original string above error not appear otherwise , not produse segmentation fault. the code segment fails here. string.h included in header. file large file test other functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #define cnrm "\x1b[0m" #define cred "\x1b[31m" #define cgrn "\x1b[3

Using VBA in excel to provide a warning on start up if a value in a column falls below an integer -

i have excel document multiple worksheets. 1 of worksheets titled "inventory". tracks how of each product have , when these products expire. in 1 of columns, lists "days until expiration" each material have. want write vba script every time open excel file, script runs , checks values in "days until expiration column". if there value in column within 14 days of expiration, want script pop-up upon excel file starting , "____ material has # days left before expiration". please advise. assuming expiration dates on column d, please consider following code added workbook_open event: private sub workbook_open() dim wb workbook dim ws worksheet dim rngused range, rngexpirationcolumn range, rngcell range dim strexpirationmessage string set wb = thisworkbook set ws = wb.sheets("inventory") set rngused = ws.usedrange set rngexpirationcolumn = intersect(ws.columns(4), rngused) each rngcell in r

javascript - Changing the html of a td tag dynamically -

when edit function triggered td id "promo1" changes html show options save delete rule , cancel. cancel in tag onclick function called "cancel()". when clicked should revert td tag "promo1" image set. doesnt work when onclick coming cancel tag in td tag "promo1" works when cancel() function triggered cancel button, clues why occurring , fixes? function edit(stringid){ console.log (stringid); var id = '#promo' + stringid; $("#promo1").html("<div style='width:200px'><a onclick='save()' style='margin-right:10px'><b>save</b></a> <a onclick='save()' style='margin-right:10px'><b>delete rule</b></a> <a onclick='cancel()'><b>cancel</b></a><div>"); } function cancel() { $("#promo1").html("<img src='dist/img/editbutton.png'>"); } <scr

javascript - td background colouring applied to complete column rather to a single cell -

i've below html. <table border="1" class="mytable"> <tr> <th class="cname">component</th> <th class="pname">properties</th> <th class="sname">lqwasb02</th> </tr> <tr> <td class="cname">emwbisconfig</td> <td class="pname">reevaluationtimer</td> <td class="pvalue">every 1 hour without catch up</td> </tr> <tr> <td class="cname">calculatecategorymediainfoservice</td> <td class="pname">scheduled</td> <td class="pvalue">yes</td>

understanding javascript promise object -

i trying wrap head around promise object in javascript.so here have little piece of code.i have promise object , 2 console.log() on either side of promise object.i thought print hi there zami but printed hi zami there why that.i have 0 understanding on how promise works,but understand how asynchronous callback works in javascript.can 1 shed light on topic? console.log('hi'); var mypromise = new promise(function (resolve, reject) { if (true) { resolve('there!'); } else { reject('aww, didn\'t work.'); } }); mypromise.then(function (result) { // resolve callback. console.log(result); }, function (result) { // reject callback. console.error(result); }); console.log('zami'); promise execution asynchronous, means it's executed, program won't wait until it's finished continue rest of code. basically, code doing following: log 'hi' create promise

Ruby On Rails: jQuery datepicker only works when refresh page -

the problem having when navigate through form page , click on date_sent on text field, jquery supposed pop-up datepicker. however, nothing @ first, when refresh page works. i sure problem turbolinks, because assume javascript not loaded because of turbolinks. however, not want remove turbolinks because page renders slow without it. how can make work? application.js //= require jquery //= require jquery-ui/datepicker //= require jquery_ujs //= require bootstrap-sprockets //= require cocoon //= require turbolinks //= require_tree . application.scss *= require_self *= require jquery-ui/datepicker *= require_tree . */ @import 'bootstrap-sprockets'; @import 'bootstrap'; @import 'sites'; form.coffee jquery -> $('#send_date').datepicker() form.html.erb <div class="form-group" > <%= f.label :date_sent, class: 'control-label' %><br> <%= f.text_field :date_sent, id: 'send_date

c# - How to Grant Angular Authorization to my REST API Calls for Mobile App -

i have c# azure web api backend data retrieved front-end ionic mobile app (which angular app) the authorization of users done via ionic's cloud service, handle heavy lifting of registering users via fb, twitter, basic (username/password). my question is, when go call services backend api, how can make sure doesn't read hardcoded username/password inside of internal javascript code access backend data? i know it's pretty far fetched, there anyway api know request coming app (android , ios) , not trying insert data , comments web browser unauthorized? since you're calling api javascript available end users, can assume javascript , logic/credentials contained within accessible all. there secure ways around this, , fb/twitter , ilk have implemented (using oauth ). essentially, on passing credentials api, token generated, used subsequent calls api instead of credentials. you can avoid people randomly firing off 'unauthorized' requests using non

Does LruCache in android give you a significant performance difference against sqlite? -

i have application uses sqlite database present data movies user. each movie record in database contains strings , integers. every time activity re-created, database queried necessary "movies". my question following: if create lrucache when app launched avoid querying database each time, there performance improvement? "significant"? although lrucache can cache anything, thought helpful bitmap caching, bitmaps quite memory intensive. there other situations in can provide significant performance improvement? sorry ignorance, know tool for. thanks! lrucaches useful when need cache number of things- example bitmaps create cache of fixed size cache 100mb of images, , else fails. allows avoid oom issues (please note lrucache isn't magical, still have code app use correctly advantage). cost of you'll preallocate most/all of cache before needed. if have total memory used isn't 10s-100s of mb, you're better off using map instead.

mailmerge - How Can I Limit an .OpenDataSource in Word Mail Merge to Only 1 Record Using VBA? -

word 2013, sql server 2014 have word mail merge template created licensing application uses .ini file , excel file generate 1 certificate dataset of many. i want make word template work on it's own. able wire .udl file make connection database gives me tables, pick one, gives me document each row in table when need one. how can limit/filter document comes template use specific table , specific row (license_id) request? sub autonew() 'this returns rows after pick table thisdocument.mailmerge .opendatasource name:="c:\users\or0146575\desktop\xxx.udl" .execute end end sub i wire below code return 1 row if knew how. dim sql string sql = "select full_name, biglicensetype, licnosdisplay, expiration_date opcerts person_id= 30012" i decided take totally different route , hope doesn't detract points. using datasource file .udl or .odc bringing records , required selecting table @ runtime , couldn't sql work. i decided mak

machine learning - Writing Custom Python Layer With Learnable Parameters in Caffe -

i know this example supposed illustrate how add trainable parameters in python layer using add_blob() method. however, still unable understand how can used set dimensions of blob based on user defined parameters. there better example here on how write python layer here . here, layer not contain trainable parameters. please explain how write custom python layer trainable parameters. when add parameters blob using add_blob() , can reshape added blob, either in setup() method (right when add it), or in layer's reshape() method.

WSO2 Amazonsns connector issues publishing json message -

i trying publish json message using amazonsns connector in wso2 esb 4.9. able publish simple string message when set messagestructure json in order send different messages different platforms , attempting send json value of message not work. using simple transaction looks documentation sample. transaction: content-type: application/json;charset=utf-8 { "region":"us-west-2", "accesskeyid":"myaccesskey", "secretaccesskey":"mysecretaccesskey", "version":"", "messagestructure":"json", "subject":"test", "message": {"default":"mess","email":"message"}, "targetarn":"arn:aws:sns:us-west-2:977102061874:endpoint/apns_sandbox/mobile_ios_sandbox/34ed4324e6-1119-67sd-b7dd-f413c88e4e25", "topicarn":"" } my result unexpected error sending message out. caused by

excel - Match corresponding records on different sheets -

for example: have 2 sheets, both matching columns, column , b same on both sheet. column on both sheets match, contain same value, column b may different, in example bellow. of data matches besides row 3. in sheet 1 has "c" in column b, in sheet 2 has "f" in column b. what trying have column shows if match or not, in example, row 1, 2 , 4 have "match", row 3 "mismatch" , trying have on separate sheet (sheet 3). i think vlookup best bet, have no idea start. appreciated. sheet 1: columna | columnb 1 | 2 | b 3 | c 4 | d sheet 2: columna |columnb 1 | a 2 | b 3 | f 4 | d sheet 3: columna |columnb 1 | match 2 | match 3 | mismatch 4 | match if 2 lookup equal each other match, otherwise no match, in b1 of sheet3: =if(vlookup(a1,sheet1!a:b,2,false)=vlookup(a1,sheet2!a:b,2,false),"match","mismatch") and copy down.

Phalcon PhP - set view dynamically -

this question has answer here: phalcon php - how change view dynamically 1 answer i'm working on website phalcon php , set view (.volt file) dynamically, based on url. currently, can url , url matches name of .volt file. problem can content of .volt file layout seems blank because page renders without style. stylesheets include in layout. here code of action: public function indexaction($url){ $this->view->setlayout( 'website' ); $this->view->pick('program/'.$url); } the url comes right, render .volt content layout seems blank. currently similar in session , layout works: $html = $this->view->getrender('page', $url, array('page_title' => $page_title, 'page_css_class' => $page_css_class) ); die($html); but feature, want different because have set bunch o

shell - finding maximum from partial string -

i have list first 6 digit date in format yyyymmdd. next 4 digits part of timestamp. want select numbers maximum timestamp day. 20160905092900 20160905212900 20160906092900 20160906213000 20160907093000 20160907213000 20160908093000 20160908213000 20160910093000 20160910213100 20160911093100 20160911213100 20160912093100 means above list output should give below list. 20160905212900 20160906213000 20160907213000 20160908213000 20160910213100 20160911213100 20160912093100 you can use awk: awk '{ dt = substr($0, 1, 8) ts = substr($0, 9, 12) } ts > max[dt] { max[dt] = ts rec[dt] = $0 } end { (i in rec) print rec[i] }' file 20160905212900 20160906213000 20160907213000 20160908213000 20160910213100 20160911213100 20160912093100 we using associative array max uses first 8 characters key , next 4 characters value. array being used store max timestamp value given date. array rec used store full line date when encounter timestamp valu

python - Counting keys in an S3 bucket -

using boto3 library , python code below, can iterate through s3 buckets , prefixes, printing out prefix name , key name follows: import boto3 client = boto3.client('s3') pfx_paginator = client.get_paginator('list_objects_v2') pfx_iterator = pfx_paginator.paginate(bucket='app_folders', delimiter='/') prefix in pfx_iterator.search('commonprefixes'): print(prefix['prefix']) key_paginator = client.get_paginator('list_objects_v2') key_iterator = key_paginator.paginate(bucket='app_folders', prefix=prefix['prefix']) key in key_iterator.search('contents'): print(key['key']) inside key loop, can put in counter count number of keys (files), expensive operation. there way make 1 call given bucket name , prefix , return count of keys contained in prefix (even if more 1000)? update: found post here shows way aws cli follows: aws s3api list-objects --bucket bucketname --pr

excel - Adding a number to the end of a 4 digit number in a cell, while ignoring every other number -

Image
i trying add number end of 4 digit number in cell, while ignoring every other number. the code adds zeros , wanted leave out 5 digit numbers. sub leadingzeros() dim cel range, rg range dim zc double application.screenupdating = false set rg = range("g2") 'first cell converted set rg = range(rg, rg.worksheet.cells(rows.count, rg.column).end(xlup)) 'all data in column rg.numberformat = "@" on error resume next each cel in rg.cells if isnumeric(cel.value) d = val(cel.value) cel.value = format(d, "00000") cel.value = "0" & d end if next on error goto 0 end sub this should if issue leaving out length of 5. sub leadingzeros() dim cel range, rg range dim zc double application.screenupdating = false set rg = range("g2") 'first cell converted set rg = range(rg, rg.worksheet.cells(rows.count, rg.column).end(xlup)) 'all data in column rg.numberformat = "@"

android cardview onclick to display more details -

i'm working on android rest client application, , i, can retreive data local server i'm willing display more data when cardview recycler view clicked. if has idea on how it, or tutorial please share it. hmmm think when click card view holder.lnrlayout.setonclicklistener(new view.onclicklistener(){ public void onclick(view v) { intent.putextra("movie_year",getdataadapter1.getmovie_year()) ; v.getcontext().startactivity(intent); } }); }

Is there an official host uri for Gitlab API? -

is possible use gitlab api official gitlab server? mean www.gitlab.com . can't find host uri. here api: https://docs.gitlab.com/ce/api/ while the documention mention https://gitlab.example.com/api/v3/... , still able apply api gitlab.com itself. you use urls https://gitlab.com/api/v3/... described in this issue https://gitlab.com/api/v3/projects?private_token=... or here (for creating new project): curl --header "private-token: token" -d "name=test" "https://gitlab.com/api/v3/projects"

How to convert a hex string to bytes array in Crystal? -

how can convert hex string bytes array in crystal? example: 87 a3 69 6e 74 01 a5 66 6c 6f 61 74 cb 3f e0 00 00 00 00 00 00 a7 62 6f 6f 6c 65 61 6e c3 a4 6e 75 6c 6c c0 a6 73 74 72 69 6e 67 a7 66 6f 6f 20 62 61 72 a5 61 72 72 61 79 92 a3 66 6f 6f a3 62 61 72 a6 6f 62 6a 65 63 74 82 a3 66 6f 6f 01 a3 62 61 7a cb 3f e0 00 00 00 00 00 00 like this: hexstring = "87 a3 69 6e 74 01 a5 66 6c 6f 61 74 cb 3f e0 00 00 00 00 00 00 a7 62 6f 6f 6c 65 61 6e c3 a4 6e 75 6c 6c c0 a6 73 74 72 69 6e 67 a7 66 6f 6f 20 62 61 72 a5 61 72 72 61 79 92 a3 66 6f 6f a3 62 61 72 a6 6f 62 6a 65 63 74 82 a3 66 6f 6f 01 a3 62 61 7a cb 3f e0 00 00 00 00 00 00" bytes_array = hexstring.split.map(&.to_u8(16)) pp bytes_array, bytes_array.class https://play.crystal-lang.org/#/r/19dh

javascript - Need help understanding performance of native promises versus Blubird -

background : i writing meteor app populates db data retrieved via soap requests made api end point on server somewhere. the initial request search via search term select. list of id's records match search. then make api request, time, each of records store own db (only selected values, not data) if have list of search terms above performed each of these. to avoid 'callback hell' , because though opportunity learn new opted use promises ordered sequentially: goes this: foreach searchterm -> gettheresults.then.foreachresult->fetchrecord for short sequences of 100 or worked fine when got 1000 hang. after speaking uncle google, came across threads native promises not being optimized in way , third party libraries faster. decided try bluebird, before doing test assertion might make things faster. code code below creates sequence of 'sleep promises'. idea swap out bluebird promise implementation , observe time test takes run on sequence 5000 promises

c++ - std::map::insert change in C++17 -

i see insert method of std::map , std::unordered_map going change from template<class p> std::pair<iterator,bool> insert(p&& value); (c++11) to std::pair<iterator,bool> insert(value_type&& value); (c++17) however, these containers, value_type std::pair<a const, int> . 2 questions here: why change? upside? how going work move key on insertion? c++11 version accepts (the constraint on p default_constructible<value_type, p&&> ), std::pair<a, int> - of time type of argument 1 returned std::make_pair - , can call move constructor of a . in c++17 version, argument casted value_type , a const, non-movable. has copied, if not overlooking something. or c++17 change on side too? thanks! an additional non-template overload insert added in c++17. such overload has advantage permits .insert( { {key}, {value, args} } ) syntax -- {} based construction. template arguments cannot passed {} based con

sql server - How would I pivot this type of data in T-SQL? -

i have query generates results such this id | column2 | sentence ----|---------|--------- 1 | sameval |this sentence 1 | sameval |this unique sentence 1 | sameval |a third unique sentence 2 | sameval |this sentence 2 | sameval |this unique sentence 2 | sameval |a third unique sentence 3 | sameval |this sentence 3 | sameval |this unique sentence 3 | sameval |a third unique sentence is possible pivot data somehow results so id | column2 | sentence ----|---------|--------- 1 | sameval |this sentence 2 | sameval |this unique sentence 3 | sameval |a third unique sentence query below: select distinct t1.id, t2.department, t1.reportmonth, t2.supplier, t1.repid, t1.customerid, t4.sentence table1 t1 join table2 t2 on t2.id = t1.id join table3 rt on rt.lookupcd = t1.programcd join table4 t4 on t4.customerid = t1.customerid left join table5 t5 on t1.customerid = t5.customerid t1.code = 'ax' , t2.program = &#

javascript - JS: Do different things depending on if value is null -

<!doctype html> <html> <head> <meta charset="utf-8"> <title>document</title> <script> function mygender() { if (document.queryselector('input[name="gender"]:checked').value==null) { document.getelementbyid('demo').innerhtml = "please select gender"; } else { document.getelementbyid('demo').innerhtml = document.queryselector('input[name="gender"]:checked').value; } } </script> </head> <body> <label for="gender"> gender: </label> <br> <input type="radio" name="gender" value="man"> man<br> <input type="radio" name="gender" value="woman" >woman<br> <input type="radio" name="gender" value="other" >other<br> <button onclick="mygender()">wh

javascript - Merging issue between array and string -

i have array containing letters , colors. const = [ {char: 'h', color: 'red'}, {char: 'e', color: 'red'}, {char: 'y', color: 'red'}, {char: ' ', color: 'green'}, {char: 't', color: 'red'}, {char: 'h', color: 'red'}, {char: 'e', color: 'red'}, {char: 'r', color: 'red'}, {char: 'e', color: 'red'} ]; i want write function merges string: const s = 'hey, howdy there'; while preserving original mapping of chars colors. instance, chars compose hey , there should still red , green, painted in array a, while new chars default arbitrary, yellow , old chars deleted. so, output of function give me like: res = [ {char: 'h', color: 'red'}, {char: 'e', color: 'red'}, {char: 'y', color: 'red'}, {char: ',', color: 'ye

ruby on rails - how to include module for MiniTest -

i have class company include growthrate . models/company.rb class company < activerecord::base include growthrate end in growth_rate.rb , add methods array . models/company/growth_rate.rb module company::growthrate extend activesupport::concern end module company::growthrate::array def growth_rate # calculate growth rate end end class array include company::growthrate::array end and want test method of array minitest. test/models/company/growth_rate_test.rb require 'test_helper' class companytest < activesupport::testcase include company::growthrate test 'test adjusted_growth_rate' array = [1, 0.9] array.stub :growth_rate, 1 # assert_equal end end end but test ends name error. nameerror: undefined method `growth_rate' `company::growthrate::array' how can include method minitest? test/test_helper.rb env['rails_env'] ||= 'test' require file.expand_path('../../config/e

windows - Change registry value permission command line or NSIS -

i'm trying grant ordinary users write access registry value created. they cannot have write access parent key. through regedit , it's simple: 1. select value 2. edit permissions (change accordingly) 3. ok however i'm struggling same via command line or nsis. the command regini has nice method changing key permissions. if worked changing value permissions, script installer. the nsis plugin accesscontrol has nice method changing key permissions no evidence of changing value permissions. in case, key hklm\software\microsoft\windows\currentversion\run not modify permissions of. how can change only permissions of value i've created? how can regedit allows, silently through command line or nsis? the value like: [hklm\software\microsoft\windows\currentversion\run] "my value"="c:\please\let\me\change\permissions\sadface.exe" note, scripted software installer build script run on mac, linux , windows (nsis allows this).

apache - Can't find .htaccess loop error "Too many redirects" -

i can't figure out why when trying load webpage modified .htaccess file, browser returns me error "too many redirects". can me find inside file mistake is? options +followsymlinks rewriteengine on rewritecond %{http_host} ^([www\.]*domain\.com)$ [nc] rewritecond %{request_uri} ^/.+$ [nc] rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] rewritecond %{http_host} ^([www\.]*domain\.com)$ [nc] rewritecond %{request_uri} ^/$ [nc] rewriterule ^(.*)$ https://www.domain.com/web [l,r=301] your error first rule: rewritecond %{http_host} ^([www\.]*domain\.com)$ [nc] rewritecond %{request_uri} ^/.+$ [nc] rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] this saying: if host "www.domain.com" or "domain.com" and request isn't "/" then redirect same host , request using "https" scheme so no matter request go to, end in loop because of rule. let's say, go http://domain.com/ : t

get one field from elasticsearch by spring data -

i have es document this class user { string name; string describe; list<string> items; } i'm using spring data talk es repository interface interface userrepository extends repository<user, string> { } now need build rest interface responses json-format data this {"name": string, "firstitem": string} because describe , items in user big, it's expensive retrieve field es. i know es have feature named "response filtering" can fit requirement, don't find way using in spring data. how in spring data? what need mix of source filtering (for not retrieving heavy fields) , response filtering (for not returning heavy fields). however, latter not supported in spring data es (yet) for former, can leverage nativesearchquerybuilder , specify fetchsourcefilter retrieve fields need. latter not supported yet in spring data es. can create field named firstitem in you'd store first element of i

mysql - How to use SQL to get records that are distributed evenly from each category? -

i have table this: category_id uid popularity ts ======================================= 03 05 07 07 07 10 10 for each row, uid unique , each row belongs category, presented category_id . let's have 10 categories in total , there thousands of records. i try make sql query 50 records within timeframe sorted popularity. can done. however, if hope these 50 records distributed evenly each category? example, if there 10 categories, each has 5 records, there 50 records in total. there way via 1 sql query? or have in 10 separate sql queries? select * mytable categoryid = 1 order popularity desc limit 10 union select * mytable categoryid = 2 order popularity desc limit 10 union select * mytable categoryid = 3 order popularity desc limit 10 repeat many categories have some mysql wizard can tell how group by too. see: unions

android - How to give the runtime permission for read the OTP number for marshmallow? -

this class read otp number works fine in devices in marshmallow doesn't read otp number. know resolving issue wants runtime permission don't know how can give runtime permission read otp number sent server. public class incominmsg extends broadcastreceiver { final smsmanager smsmanager = smsmanager.getdefault(); public static string general_otp_template = "(.*) otp reset password app. treat confidential"; public static final string key_prefernce = "prefernce"; public static final string key_otp = "otp"; string otp; sharedpreferences sharedpreferences; sharedpreferences.editor editor; private final int request_code_ask_for_permissions = 1234; @override public void onreceive(context context, intent intent) { final bundle bundle = intent.getextras(); int permissioncheck = contextcompat.checkselfpermission(context, android.manifest.permission.read_sms); sharedpreferences = con

javascript - React.js - Creating simple table -

sorry appears newbie question (been working late , got started react) trying figure out how render simple table n x n dimension. for instance, in component, render output this: <table id="simple-board"> <tbody> <tr id="row0"> <td id="cell0-0"></td> <td id="cell0-1"></td> <td id="cell0-2"></td> </tr> <tr id="row1"> <td id="cell1-0"></td> <td id="cell1-1"></td> <td id="cell1-2"></td> </tr> <tr id="row2"> <td id="cell2-0"></td> <td id="cell2-1"></td> <td id="cell2-2"></td> </tr> </tbody> </table>

java - How to add 30 days (month) to given date? -

this question has answer here: how add 1 month current date in java? 12 answers i use calenderutil this.i tried few times code.but didn't work.starting date given date chooser , after addition of 30 days need set ending date other date chooser.but doesn't work , please mention event need prefer. ex: mouseclicked event import com.google.gwt.user.datepicker.client.calendarutil; import java.text.dateformat; import java.util.date; date d; d = startingdatebox.getdate(); calendarutil.addmonthstodate(d, 1); endingdatebox.setdate(d); well try this. calendar cal = calendar.getinstance(); cal.add(calendar.month, 1);

node.js - I have a issue with the url in nodejs -

i creating small application , have problem, in homepage have url localhost:8000/ home so, when put name of other page localhost:8000/test direct page , not good, have create method avoid kind of thing,what want when put name after localhost:8000/ redirect , show message "you can't access page".

parallax - jquery sticky background scroll -

i want achieve this; http://wind-dance.com/sticky/ i want html fixed position until image scroll till bottom. script coded scroll along html scroll. is there jquery script achieve similar effect want? update 1 maybe question above not clear. changed way of question then. want scroll div element without scrolling body content till div element reached bottom. hope make clear everyone. , inline script current code achieve partial of it. update 2 looking @ @bhavesh solution, tried modify this $(document).ready(function() { var row = $('.row'); var scroll_banner = $('.scroll_banner'); var scroll_banner_height = scroll_banner.height(); var row_height = row.height(); $(window).on('scroll', function() { scroll_banner_height = scroll_banner.height(); var windowpos = $(this).scrolltop(); var scrollableamount = windowpos / row_height * scroll_banner_height; row.scrolltop(scrollableamount); }) });

java - Elasticsearch increasing heap size -

we running elasticsearch inside docker container on amazons ecs. noticed heap increase on time. first time noticed when raised above 70% , started throw away requests (indices.breaker.total.limit). the thing never seen decreasing heap, feels fishy! so far have increased instance size, running instance 30g memory. heap set aprox half memory, es_heap_size=14g (xmx=xms=14g). someone else have similar experience? bug in elasticsearch? or incorrect configurated? elasticsearch ver: 1.5.1 > curl localhost:9200/_cat/fielddata?v id host ip node total position deal_status heading.sortorder org_relationlastmodified deal_value deal_probability 1_zipcodevisit_0 tag employer_tag 1_cityvisit_0 dateofregistration temperature uniqueid _type quick_ratio org_relation employer_relationlastmodified turnover turnover_per_employee deal_source employer_relation deal_statusdate 1_custom_1466 average_salary_per_employee deal_orderdate 0_numberof

javascript - How to add `0` this kind of condition in code? -

i have code below working fine trying if input 5:30 code auto add 0 output 05:30 . i try edit code jsfiddle 2 failed it. is possible want output be?. html : <div> <input id="departure" type="text" style="width: 50px; text-align: center" placeholder="00:00" maxlength = "5" /> </div> javascript : <script type="text/javascript"> document.getelementbyid('departure').addeventlistener('keyup', function(event) { if(event.target.value.length === 2) { if((event.key && !isnan(event.key)) || (event.keycode >= 48 && event.keycode <= 57)) { if(!isnan(event.target.value) && parseint(event.target.value) > 12) { event.target.value = event.target.value.slice(0,1) + ':' + event.target.value.substring(1); } else { event.target.value += ':';

python - how to copy numpy array value into higher dimensions -

i have (w,h) np array in 2d. want make 3d dimension has value greater 1 , copy value on along 3rd dimensions. hoping broadcast can't. how i'm doing it arr = np.expand_dims(arr, axis=2) arr = np.concatenate((arr,arr,arr), axis=2) is there a faster way so? you can push dims forward, introducing singleton dim/new axis last dim create 3d array , repeat 3 times along 1 np.repeat , - arr3d = np.repeat(arr[...,none],3,axis=2) here's approach using np.tile - arr3d = np.tile(arr[...,none],3)

javascript - onClick event is being caught by the parent element along with the clicked element -

i have div , inside there elements. my parent div has test() function using onclick . in inside parent div there quickview() function using onclick . now, when click on quickview() function, test() function fired . <div onclick="test();" class="product-inner"> <h5 class="product-title height-40-px"> title </p> </h5> <hr class="mt8 mb8"> <div class="product-meta"> <ul class="product-price-list"> <li><span class="product-save dir-to-right"><strong>7500</strong></span> </li> <li><span class="product-old-price dir-to-right">120,000</span> </li> <li><span class="product-price">%95</span> </li> </ul> <hr class="mt0 mb0 mr6 hr-blue"> <div class="col-md-12 mt10"> <span clas

android - ActionBarDrawerToggle won't appear in fragment -

i implemented this default fragment when navigation drawer fires , works, actionbardrawertoggle won't appear. main activity: public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener{ private actionbardrawertoggle toggle; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // initializing toolbar , setting actionbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); servicefragment servicefragment = new servicefragment(); fragmentmanager manager = getsupportfragmentmanager(); manager.begintransaction() .replace(r.id.content_fragment, servicefragment) .commit(); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer_open, r.string.navigat

php - How can I get illuminate\Http\Request for laravel 5.3? -

i getting below error in project. non-static method illuminate\http\request::all() should not called statically . assuming $this incompatible context you haven't provided code sample, sounds of error, looks you're trying call all() method of illuminate\http\request using $this->all() syntax, method static. you might have class extending request class, if that's case need call self::all() or parent::all()

javascript - HTML how to validate any of checkbox which are in Array before submit -

below html/php code, in need validate of checkbox out of 5 before submit form. function checkaddress(checkbox) { if (checkbox.checked) { document.frmuser.action = "edit_user.php"; document.frmuser.submit(); } else {alert("checkbox");} } <!doctype html> <head> <meta charset="utf-8"> <title>details form</title> <script language="javascript" type="text/javascript"> function checkaddress(checkbox) { if (checkbox.checked) { document.frmuser.action = "edit_user.php"; document.frmuser.submit(); } else {alert("checkbox");} } </script> </head> <body> <div class="form-style-1"> <form name="frmuser" method="post" action=""> <?php i=0; while(i=5){ ?> <input type="checkbox" name="users[]" value="<?php echo i

android - How can I make this ContactsContract.Contact query faster with CommonDataKinds.Phone inner query? -

i'm iterating through contacts table , each iteration iteration on phone table takes appx. 4 seconds contact list 243 contacts (without iterating phone numbers loads instantly). i'm sure there way make faster. already made projections fetch needed columns, haven't improved much. maybe should improve sqlite query or iterate in other manner: contact realmcontact = new contact(); uri uri = contacts.content_uri; string[] projection = { contacts.lookup_key, contacts.display_name_primary, contacts.last_time_contacted, contacts.has_phone_number }; string selection = "((" + commondatakinds.phone.display_name_primary + " notnull) , (" + contacts.has_phone_number + "=1) , (" + commondatakinds.phone.display_name_primary + " != '' ))"; cursor phones = getactivity() .getconten