Posts

Showing posts from April, 2010

php - False 302 redirect instead of 200 on Nginx -

on website have 3000 pages 302 answer instead of 200, google dumping pages, products, articles, everything. it's seo nightmare. few page answer 200, no apparent reason. can reason? example pages : https://www.musclenutrition.com/about-us page visualized correctly, seems redirected home page. cookies weird. any appreciated. >>> https://www.musclenutrition.com/about-us > -------------------------------------------- > 302 found > -------------------------------------------- status: 302 found code: 302 server: nginx date: sat, 12 nov 2016 22:52:55 gmt content-type: text/html; charset=utf-8 connection: close x-powered-by: php/7.0.10 set-cookie: frontend_cid=deleted; expires=thu, 01-jan-1970 00:00:01 gmt; max-age=0; path=/; domain=.www.musclenutrition.com expires: thu, 19 nov 1981 08:52:00 gmt cache-control: public pragma: no-cache location: https://www.musclenutrition.com/ access-control-allow-origin: * x-frame-options: sameorigin ...

algorithm - BFS and correctness on the term "VISITED" -

mark x visited list l = x tree t = x while l nonempty choose vertex v front of list process v each unmarked neighbor w mark w visited add end of list add edge vw t most of code choose mark adjacent node visited before visiting them. won't technically correct add neighbor first , visit them later? list l = x tree t = x while l nonempty choose vertex v front of list if (v not yet visitd) mark v visited here each unmarked neighbor w add end of list add edge vw t why every bfs seems mark node visited when did not visit them yet? trying find theoretically correct code bfs. 1 correct? both algorithms work, second version might add same node list l twice. doesn't affect correctness because of additional check whether node visited, increases memory consumption , requires check. that's why you'll typically see first algorithm in text books.

python - Load local resources with NLTK -

i'm using nltk python 3. i'd load custom pickle file knowing file name. i have pickle in directory like: /path/to/project/nltk/tokenizers/punkt/english.pickle i load , use so: import nltk sent_tokenizer = nltk.data.load('file:/path/to/project/nltk/tokenizers/punkt/english.pickle') tokens = sent_tokenizer('a big hunk of text.') however, seems nltk infers don't have python 3 version of resource , adds in py3 desired path: lookuperror: ********************************************************************** resource '/path/to/project/nltk/tokenizers/punkt/py3/english.pickle ' not found. please use nltk downloader obtain resource: >>> nltk.download() searched in: - '' ********************************************************************** i able use real path file, instead of leaving out py3 folder , expecting nltk insert it. there way directly import resource without nltk modifying path? thanks! j ...

reactjs - React function passed to child through props is undefined -

i trying pass selectnotebook notebooknav used in onclick() function. can see selectnotebook in prop in react dev tools, whenever click button, error uncaught typeerror: cannot read property 'selectnotebook' of undefined(…) . this parent component: var app = react.createclass({ getinitialstate: function() { return { notebooks: this.props.notebooks, nav: this.props.nav }; }, selectnotebook: function(id) { const nav = {...this.state.nav}; nav[notebook] = this.props.notebooks[id]; this.setstate({nav}) }, render: function() { return ( <div style={{"height": "100%"}}> <notebooknav notebooks={this.props.notebooks} selectnotebook={this.selectnotebook} > </notebooknav> <technique></technique> </div> ); } }); this child component: var notebooknav = react.createclass({ render: function() { no...

python - Efficiently check permutations of a small string against a dictionary -

i'm trying see words can made scrambled string, compared dictionary. got long string case already, think short string case dragging program 20 seconds range. testing 1000 scrambles , dictionary of 170,000 "words". for short scrambled word case thought more efficient create every permutation of string , compare against dictionary entries, so: from itertools import permutations wordstore = { 7:[], 8:['acowbtec', 'acowbtce', 'acowbetc', 'aocwbtec', 'acwobetc', 'acotbecw', 'caowbtec', 'caowbtce', 'caowbetc', 'zsdfvsvv', 'sdffbrfv', 'sdjfjsjf', 'sjnshsnj', 'adhnsrhn', 'sdfbhxdf', 'zsdfgzdf', 'cnzsdfgf', 'sdbdzvff', 'dbgtbzdf', 'zsvrvrdz', 'zdrvrvrn', 'nhcncnby', 'mmmnyndd', 'zswewedf', 'zeswffee', 'sefdedee', 'sefeefee', 'i...

ios - OAuth 1.0a not working on http -

i've been struggling ios app authenticate user on http wordpress site. it's understanding oauth 1.0a should working http website , oauth 2.0 works https. on wordpress site, 2 plugins installed: wordpress rest api (version 2) , wordpress rest api - oauth 1.0a server . client side of ios app, i'm using oauthswift library perform authentication process. my error @ first step of oauth authentication request following endpoint: http://example.us/oauth1/request the operation couldn’t completed. (oauthswifterror error -11.) printing description of error.requesterror.error: error domain=nsurlerrordomain code=400 "http status 400: bad request, response: no oauth parameters supplied" userinfo={nserrorfailingurlkey=http://example.us/oauth1/request, nslocalizeddescription=http status 400: bad request, response: no oauth parameters supplied, response-headers={ "access-control-allow-headers" = authorization; connection = "keep-alive"; ...

Installing R in Red Hat Enterprise Linux Server release 7.1 (Maipo) -

i trying install r on rhel 7 following error. error: package: r-core-devel-3.2.3-4.el7.x86_64 (epel) requires: blas-devel >= 3.0 error: package: r-core-devel-3.2.3-4.el7.x86_64 (epel) requires: lapack-devel error: package: r-core-devel-3.2.3-4.el7.x86_64 (epel) requires: texinfo-tex i installed epel-release-7-8.noarch. tried group install development tools below. yum group install "development tools" tried enable repos yum-config-manager --enable epel i tried several suggestions posted in internet. nothing seems work or solve issue. can me install r? should simple 3 steps process became nightmare me complete it. please find below system details. red hat enterprise linux server release 7.1 (maipo) many thanks! you should install couple of dependencies. $ sudo dnf -y install blas-devel lapack-devel texinfo-tex

python - Inserting data into regression network in keras -

i struggling understand how should train regression network using keras. not sure how should pass input data network. both input data , output data stored list of numpy arrays. each input numpy array matrix has (400 rows, x columns) each output numpy array matrix has (x number of rows, 13 columns) so input dimension 400 , output 13. how pass each of these sets within list training? # multilayer perceptron model = sequential() # feedforward model.add(dense(3, input_dim=400)) model.add(activation('tanh')) model.add(dense(1)) model.compile('sgd', 'mse') just parsing data gives me error message : traceback (most recent call last): file "tensorflow_datapreprocess_mfcc_extraction_rnn.py", line 167, in <module> model.fit(train_set_data,train_set_output,verbose=1) file "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 620, in fit sample_weight=sample_weight) file "/usr/local/lib/python2.7/dis...

php - How would I go about traversing this JSON object? -

how access [0] -> array() located below , retrieve [title] "spirited away" iterating on array? array ( [@attributes] => array ( [version] => 2.0 ) [channel] => array ( [title] => site title [link] => site/ [language] => en-us [category] => [image] => array ( [title] => site [url] => http://example.com [link] => example.com ) [item] => array ( [0] => array ( [title] => spirited away [pubdate] => date [category] => movies [link] => linkhere [enclosure] => array ( [@attributes] => array ( ...

java - Why is the largest testable integer parsed from user input as a string (10^8)-1? -

accepting user input 1 character @ time, largest acceptable integer before have limit input seems (10^8)-1. mildly surprised wasn't integer.max_value . why isn't it? code written out in keyboard class extends keyadapter : import java.awt.event.keyadapter; import java.awt.event.keyevent; public class keyboard extends keyadapter{ private final int max_testable = 99999999; private final int vk_number = 48; //ascii 0 starts here private final int vk_numberpad = 96; //ascii numberpad offset public void keypressed(keyevent e){ int key = e.getkeycode(); if(((char)key == '0' || (char)key == '1' || (char)key == '2' || (char)key == '3' || (char)key == '4' || (char)key == '5' || (char)key == '6' || (char)key == '7' || (char)key == '8' || (char)key == '9')){ ...

plsql - PLS-00103: Encountered the symbol "/" -

i aware has been asked many times, problem doesn't seem go away. i've put delimiter in correct places still keep on getting error 'error(9,1): encountered symbol "/" ' @ line 9. if i'm not mistaken, delimiter causes error shold there. create or replace package for_class_nov2 procedure print_sname(s_no s.sno%type); function find_max_qty return number; end; / create or replace package body for_class_nov2 procedure print_sname(s_no s.sno%type) s_sname s.sname%type; begin select sname s_sname s sno = s_no; dbms_out.put_line('supplier name is: ' || s_name); end print_sname; function find_max_qty() return number m_qty number; begin select ax(sty) m_qty sp; return m_qty; end find_max_qty; end; / i think should not use parenthesis in function when there's no parameters. try replacing this: function find_max_qty() return number with this: function find_max_qty return number also, have variable named s...

Deploy ASP.NET Application to AWS from Visual Studio Team Service -

i need advice continuous deployment within visual studio team service. honest, quite new in area, forgive silly question because can't find reference aws azure. my idea can deploy asp.net application aws ec2 built vsts source control. my current scenario is: i had source control contain asp.net application code inside vsts. i created build definition build source code , produce artifact. i created release definition, copy artifact remote aws ec2 instance. .... i don't have idea continue next step, give advice should next ? or better scenario ? thank you. currently don't see tasks can directly deploy aws, way seems possible if create own task or use powershell or bash along aws cli deploy artifact. process this download artifact in release. default if link artifact. make sure agent machine using has aws cli powershell or aws shell if using bash. you can write powershell or bash script utilize aws cli deploy artifact aws.

matlab - Auto selecting square blob area from image : Computer Vision -

Image
trying develop auto calibration plugin, need average pixel value value of centre blob in image. of converting image binary, , able identify different blobs in image. but, want central blob getting identified how. maybe can take of surrounding 6 small blobs. original image: https://drive.google.com/open?id=0b9kvfpiocm1ewnhjegtbz3a4etg matlab code: i = imread('blob.tif'); ibw = ~im2bw(i, 0.75); ifill = imfill(ibw,'holes'); iarea = bwareaopen(ifill, 500); stat = regionprops(ifinal,'boundingbox'); imshow(i); hold on; cnt = 1 : numel(stat) bb = stat(cnt).boundingbox; rectangle('position',bb,'edgecolor','r','linewidth',2); end your results close. after perform conversion binary, thresholding , performing area opening, image: there pixels along borders of pixels still around. can use imclearborder function remove pixels touching border. absolutely sure, use 8-connectedness searches pixels in 8 direct...

.net - how i can declare out in parameter in powershell like c# -

i have c# code , want find alternative of code in powershell . found [ref]$parameter it's doesn't work . code : private static bool testfunction(string param1, out string param 2) { param1 = ""; param2 += "hello"; return true; } please give me alternative code in powershell. i try : class tst { static test([ref]$param) { $param.value = "world " } } $test = "ddd" $test [tst]::test($test) $test this doesn't work. function testfunction { param ( [string] $param1, [ref] $param2 ) $param2.value= "world" return $true } ps c:\> $hello = "hello" ps c:\> testfunction "somestring" ([ref]$hello) true ps c:\> $hello world powershell supports ref parameters. sure call ref parameter in brackets (e.g. ([ref] $parameter ). aware declare [ref] as type in param block. further details: stackoverflow ss6...

c++ - Adding Too Many Nodes -

i created data bag structure, text files consist of short stories , poems. first time instance of string inserted, datavalue contains string , datacount set one. if instance of same string inserted, datacount incremented. reason keeps outputting same word on , on , of strings contain count of 1 reason. there suggestions on adjust? struct bagnode { string datavalue; string datacopy; int datacount; bagnode * next; }; class bag{ private: bagnode * head; public: bag() { head = null; } void insert(string v) { if(head == null){ //empty list head = new bagnode; removepunct(v); head->datavalue = v; transform(v.begin(), v.end(), v.begin(), ::tolower); head->datacopy = v; head->next = null; } else { bagnode * n = new bagnode; // new node removepunct(v); n->datavalue = v; transform(v.begin(), v.end(), v.begin(), ::tolower); n->datacopy = v; ...

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum ...

ORMLite - select specific columns of foreign object -

i have class contains foreign class b. want query class , of columns (fields) of class b. class selectcolumns, foreign object b? @databasetable() public class { @databasefield(generatedid = true) private int id; @databasefield(canbenull = false, foreign = true, foreignautorefresh = true) private b mb; } @databasetable() public class b { @databasefield(generatedid = true) private int id; @databasefield private string includethis; @databasefield private string excludethis; }

windows - batch file that searches for strings in a text file inside all files in folders/subfolders -

i have text file (sample.txt) has 500 strings , have folder (package) has many sub-folders many files of different file types(.xml, .cpp, .hpp, few more). sample.txt looks like gi_70_1 if_mne_70f_black backserver type_gradient area_round i need search these strings in files in "package" folder , print path found in result.txt here had managed till now @echo off set result_file="result.txt" /f %%i in (sample.txt) ( pushd %~p0 type nul > %result_file%.tmp /f "delims=" %%a in ('dir /b /s *.txt') ( /f "tokens=3 delims=:" %%c in ('find /i /c "%%i" "%%a"') ( /f "tokens=*" %%f in ('find /i "%%i" "%%a"') if %%c neq 0 echo %%f ) ) >> "%result_file%".tmp move %result_file%.tmp %result_file% >nul 2>&1 ) :: open file "%result_file%" popd but prints search string name found , last searched string, not all. could me...

php - Notice: Undefined offset: 4 -

this question has answer here: php: “notice: undefined variable”, “notice: undefined index”, , “notice: undefined offset” 23 answers i'm working on ticketing system project, there's error on code , i've search on web answer nothing works. error says notice: undefined offset: 4 in c:\wamp\www\online bus reservation\admin\bussch.php on line 69 here code $ddaa = mysql_query("select id, route, time bus_sch order id"); echo mysql_error(); while ($data = mysql_fetch_array($ddaa)) { $sold = mysql_fetch_array(mysql_query("select count(*) seat_details busid='".$data[0]."' , status='1'")); $available = $data[4]-$sold[0]; $rname = mysql_fetch_array(mysql_query("select routename bus_route id='".$data[1]."'")); the line 69 is: $available = $data[4]-$sold[0]; please help. thank :)...

c# - Reset value of a method in another controller? -

is there way can change value of isclicked reviewscontroller once logout page has redirected user home.cshtml page in views/home/ ? i have method in controller called reviews sets isclicked bool true after button clicked when user logged in. i have method index (views/reviews/index.cshtml) within reviewscontroller resets isclicked value false when unauthenticated user visits page: // get: reviews public async task<iactionresult> index() { var results = await _context.reviews.tolistasync(); //check authentication foreach (reviews reviews in results) { if (!user.identity.isauthenticated) { reviews.isclicked = false; _context.update(reviews); await _context.savechangesasync(); } } return view(await _context.reviews.tolistasync()); } if user logs out page redirected home.cshtml (views/home/). however, if user logs in home.cshtml page afterwards clicks on index.cshtml page(views/reviews...

xamarin.ios - Disposing a cloned object also disposes the reference object -

uicolor foo = (uicolor) bar.copy(); foo.dispose(); i observing above code causes bar disposed. based on documentation, foo should new instance of bar , therefore expect bar not affected changes made foo . can explain why happening? perhaps i'm misunderstanding something... if so, there way copy of uicolor without having copy on of property values myself?

javascript - looped nested $http js functions -

i have 2 javscript async $http funtions: using angular js in nested way create table dynamically. i want way execute these functions synchronously. right now, j loop executes on initial value of resultb. once table compiled fuctb gets executed values of i. $scope.funca = function() { $http({ method : 'get', url : url, }).then(function successcallback(response) { $scope.resulta = response.data; //process based on $scope.resulta (var = 0; < $scope.resulta .length; i++){ $scope.funcb($scope.resulta[i][0]); for(j=0; j<$scope.resultb .length; j++){ //process based on $scope.resultb } } $compile(/* document element*/); }, function errorcallback(response) { console.log(response.statustext); }); } $scope.funcb = function(k){ $http({ method : 'get', url : url+k data: k , }).then(function successcallback(response) { return $scope.resultb...

html - PHP when sending data (table name) via a Submit button always shows the last table created -

so, im little new php , need send table name php file code have: <form action="clases.php" method="get"> <?php $result= mysql_query('show tables', $conn) or die ('cannot show tables'); while($tablename = mysql_fetch_array($result)){ $a=0; $table = $tablename[$a]; echo '<table cellpadding="0" cellspacing="0" class="db-table">'; echo '<tr>'; echo '<td>',$table,'<input type="hidden" name="class" value="' . $table . '" />'; echo '</td>'; echo "<td><input type='submit' name='entrar' value='enter'></td>"; echo "<td><input type='submit' name='eliminar' value='delete'></td>"; echo '</tr>'; ...

sql - Possible to upsert in Postgres on conflict on exactly one of 2 columns? -

i have table has 2 columns unique, , upsert if first column (or both columns) has conflict, nothing if second column has conflict. possible? create table test ( username varchar(255) not null unique, email varchar(255) not null unique, status varchar(127) ); the following works check conflicts on email: insert test(username, email) values ('test', 'test@test.test') on conflict(email) update set status='upserted'; but i'd (invalid syntax below): (insert test(username, email) values ('test', 'test@test.test') on conflict(email) update set status='upserted') on conflict nothing; yes, can this, requires conditional trickery. first of all, can have 1 on conflict clause, clause can specify multiple columns constraints defined on them. in case on conflict (username, email) . when either or both of columns trigger conflict, conflict_action kicks in. secondly, conflict...

javascript - How prevent user to enter Zero as first digit in html input box using jquery Validation plug-in, -

i working on validation of html form using j query validate plugin, want restrict things user cannot enter 0 first digit. for example: have text box enter amount item user can not enter 0 amount. you can perform custom validation adding own validator using addmethod as want restrict user entering 0 first digit in text field, can achieved using regular expression ^[^0]\d* . here snippet. $.validator.addmethod("pattern", function(value, element, regexpr) { return regexpr.test(value); }, "please enter valid value."); $("form").validate({ rules: { cost: { required: true, //change regexp suit needs pattern: /^[^0]\d*$/g } } }); .form-group label.error { color: maroon; } <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script src="https://code.jque...

php - Null the price of a Specific Product category from Cart Total -

Image
i want remove / takeout price of specific category products cart total. please see screenshot: what hook use this? thanks. the right hook woocommerce_before_calculate_totals using has_term() wordpress conditional function filter product categories in cart items. way can null price cart items. this code: add_action( 'woocommerce_before_calculate_totals', 'custom_price_product_category', 10, 1 ); function custom_price_product_category( $cart_object ) { foreach ( $cart_object->cart_contents $key => $item ) { // when product has 'glass' category null price. if( has_term( 'posters', 'product_cat', $item["product_id"] ) ) $item['data']->price = '0'; } } this goes in function.php file of active child theme (or theme) or in plugin file. this code tested , works.

c - Can't build the STM32 microcontroller project in System Workbench -

Image
installed system workbench ide, started new project. downloading firmware board f103rb didn't work - downloads first ~200kb of zip file , stops, had find manually (it had same name should correct) , extract in c:\users[username]\appdata\roaming\ac6\sw4stm32\firmwares . after doing this, system workbench found firmware , didn't prompt download it; project created. downloaded toolchain , after installation checked checkbox add path. when building project these error remains , i'm stuck here: and console tab outputs this: 10:27:06 **** incremental build of configuration debug project sluchawki **** make process_begin: createprocess(null, echo "building file: ../startup/startup_stm32f10x_md.s", ...) failed. make (e=2): nie można odnaleźć określonego pliku. [can't find specified file.] make: *** [startup/startup_stm32f10x_md.o] error 2 10:27:07 build finished (took 1s.403ms)

nested for loop java poker game arraylist constructor -

this constructor far deck of 45 cards i'm writing basic constructor should make deck of 45 cards suit values (0-spades, 1-hearts, 2-clubs, 3-diamonds, 4-madeupname) , card values (1-9 1 ace) private arraylist cards; public deck() { cards = new arraylist <card>(); (int valuekind = 1; valuekind<9; valuekind++){ card newcard = new card(valuekind,0); cards.add(newcard); } (int valuekind = 1; valuekind<9; valuekind++){ card newcard = new card(valuekind,1); cards.add(newcard); } (int valuekind = 1 ; valuekind<9; valuekind++){ card newcard = new card(valuekind,2); cards.add(newcard); } (int valuekind = 1; valuekind<9; valuekind++){ card newcard = new card(valuekind,3); cards.add(newcard); } (int valuekind = 1; valuekind<9; valuekind++){ card newcard = new card(valuekind,4); cards.add(newcard); } what's wrong/missi...

java - How to schedule a task at specific time in Scala? -

i want execute scala function cleaner.run() @ particular time every day. reading akka , play framework. looks akka supports intervals, e.g. "execute task every 30 minutes", not support executing tasks @ exact time. appreciate if can me put things in order (using particular example), because bit missed information , forum threads read. so, scala object , want schedule cleaner.run() every day @ 23:55. object mytestmanager { def main(args: array[string]) { val cleaner = new cleaner() cleaner.run() } } i interested in doing this, cannot find way of passing scala 2.10. import play.jobs.*; /** fire @ 12pm (noon) every day **/ @on("0 0 12 * * ?") public class bootstrap extends job { public void dojob() { logger.info("maintenance job ..."); ... } } also, after packaging scala code, right way launch application keeps executing every day @ 23:55? simple java -jar target/scala-2.10/my-assembly-1.0.jar job,...

classification - Does MLE produce a generative or discriminative classifier? -

i understand general concept of generative versus discriminative classifiers: generative classifier can produce actual model of data. discriminative classifiers on other hand produce decision. the problem have concept generative classifier needs prior in order produce (generate) data. if parameter produced mle sufficient reproduce data, isn't a generative model, @ least criteria above. the problem having, think, if parameters of model not known, distribution of parameters required model meaningful. however, given data sufficient produce mle of paramters, @ point parameters taken given , becomes generative model.

javascript - Drop images from browser using dropzone.js -

i making web chat application has feature drag-drop file , upload server (i have make whatsapp web has feature). i'm using dropzone.js achieve , has been working great far except 1 thing. event 'sending' never called when dropping image browser. here's example new dropzone('.drag-overlay', { url: "www.example.com", paramname: "attachment", init: function() { this.on("drop", function(e){ console.log("drop event"); }); this.on("sending", function(file){ console.log("sending event"); }); } }); the drop event called fine sending never called. can give me direction how can send file browser using library? thanks sending event call . upload document . change call dropzone method . var mydropzone = new dropzone live demo here . see console in web see below example // dropzone class: var mydropzone = new dropzone(".drag-overlay",...

server - Laravel php artisan serve doesn't work -

i have laravel 5.3.16 installed. have built projects , until work properly. past few days can't connect local host. use following command on mac terminal, php artisan serve and in terminal it's fine, on browser error of server being busy! can tell me problem? the issue might time ran 'php artisan' serve wasn't stopped. can check doing following steps: assuming on osx computer: open terminal run: ps -ef | grep php lookup if there laravel process in use. get id running instance , kill it. kill 012345 try run command: php artisan serve again.

c# - MessageBox closed event -

this question has answer here: how create message box “yes”, “no” choices , dialogresult? 9 answers i have messagebox ok button, although there's close button. in code can check dialogresult.ok . how should check button user had pressed? if (messagebox("error") != dialogresult.ok) or there's way? event, occures, when user closes messagebox? you can way, dialogresult result = messagebox.show("message", "tests", messageboxbuttons.okcancel); if (result == dialogresult.ok) { } else if (result == dialogresult.cancel) { }

Headphone button control Android 5.0 -

i writing program catches headphone button presses different things depending how long , how many times press it. going api level 21. android 5.0. can catch button press, when start mp3 player start catching button presses. how can prevent that? second question how resume paused mp3, , other program not program playing mp3. audiosession = new mediasession(getapplicationcontext(), "tag11"); mscallback= new mediasession.callback() { @override public boolean onmediabuttonevent(final intent mediabuttonintent) { string intentaction = mediabuttonintent.getaction(); log.i("onmediabuttonevent", intentaction ); if (intent.action_media_button.equals(intentaction)) { keyevent event = mediabuttonintent.getparcelableextra(intent.extra_key_event); if (event != null) { if(toast!=null){ toast.cancel(); } ...

Append geoJSON feature with Python? -

i have following structure in geojsonfile: {"crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:epsg::4326"} }, "type": "featurecollection", "features": [ {"geometry": {"type": "polygon", "coordinates": [[[10.914622377957983, 45.682007076150505], [10.927456267537572, 45.68179119797432], [10.927147329501077, 45.672795442796335], [10.914315493899755, 45.67301125363092], [10.914622377957983, 45.682007076150505]]]}, "type": "feature", "id": 0, "properties": {"cellid": 38} }, {"geometry": {"type": "polygon", "coordinates": ... etc. ... i want r...

python 2.7 - getting input from kivy textinput -

i want use later project, want print user's input textinput clicking button on mainscreen , when run , click on button text "print text" nothing happens no errors , no output. the .kv file: #: import fadetransition kivy.uix.screenmanager.fadetransition screenmanagement: transition: fadetransition() mainscreen: secondscreen: <mainscreen>: name: "main" button: on_release: root.get_text text: "print text" font_size: 50 size_hint:0.3,0.1 textinput: text:"hello world" size_hint: 0.35,0.25 pos_hint:{"right":1, "top":1} color:1,0,0,1 id: user_text button: color: 0,1,0,1 font_size: 25 size_hint: 0.3,0.25 text: "continue" on_release: app.root.current = "other" pos_hint:{"right":1, "top":0} <secondscr...

javascript - In jQuery, how to attach events to dynamic html elements? -

this question has answer here: event binding on dynamically created elements? 19 answers suppose have jquery code attaches event handler elements class "myclass". example: $(function(){ $(".myclass").click( function() { // }); }); and html might follows: <a class="myclass" href="#">test1</a> <a class="myclass" href="#">test2</a> <a class="myclass" href="#">test3</a> that works no problem. however, consider if "myclass" elements written page @ future time. for example: <a id="anchor1" href="#">create link dynamically</a> <script type="text/javascript"> $(function(){ $("#anchor1").click( function() { $("#anchor1").append('<a class=...

c++ - Some problems with struct -

#include <iostream> using namespace std; struct student{ char name[10]; int grade; }; int main() { struct student s[10]; student s[0].name = "jack"; cout<<s[0].name; } i want create struct type data student arraign. when did this, errors appeared , didn't know why.following errors: 1.error: redefinition of 's' different type: 'student [0]' vs 'struct student [10]' student s[0].name = "jack"; ^ 2.note: previous definition here struct student s[10]; ^ 3. error: expected ';' @ end of declaration student s[0].name = "jack"; ^ ; char name[10]; : 10 characters short name. char assumes names not outside ascii or utf-8, , doesn't you're using unicode library. fixed-sized arrays storing strings not keeping idiomatic c++. solution: use std::string or std::wstring - , use unicode library...

spring data rest - SDR 2.5.1 ManyToOne vs ManyToMany -

when create resource manytoone relation resource ok. resource created , other resource gets linked. when try create resource manytomany relation resource type other resources not loaded orm (hibernate 5) , resource cannot persited. when create resource without linked resources , patch resouces works. is intent or bug? does not work: post /foo {"name": "foo", "links": ["/1", "/2"]} works: post /foo {"name": "foo"} patch /foo/1 {"links": ["/1", "/2"]}

c - Why printf is not able to handle flags, field width and precisions properly? -

i'm trying discover capabilities of printf , have tried : printf("test:%+*0d", 10, 20); that prints test:%+100d i have use first flag + , width * , re-use flag 0 . why it's make output ? purposely used printf() in bad way wonder why shows me number 100? this because, you're supplying syntactical nonsense compiler, free whatever wants. related reading, undefined behavior . compile code warnings enabled , tell like warning: unknown conversion type character ‘0’ in format [-wformat=] printf("test:%+*0d", 10, 20); ^ to correct, statement should either of printf("test:%+*.0d", 10, 20); // note '.' where, 0 used precision related, quoting c11 , chapter §7.21.6.1, ( emphasis mine ) an optional precision gives minimum number of digits appear d , i , o , u , x , , x conversions, number of digits appear after decimal-point character a , a , e , e , f , , f conversions, ...

python - Tracking down text form kivy dropdown button -

hi guys have question kivy dropdown . have example: def dropdownbutton(self): dropdown = dropdown() classlist = ['barbarian', 'knight', 'sorcerer', 'typical seba', 'hunter'] index in classlist: btn = button(text='%s' % index, size_hint_y=none, height=44) btn.bind(on_release=lambda btn: dropdown.select(btn.text)) dropdown.add_widget(btn) mainbutton = button(text='class', size_hint=(none, none)) mainbutton.bind(on_release=dropdown.open) dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, 'text', x)) return mainbutton and want do, track current btn.txt choose, mby dumb, spend hour on this... can me? btn.text returns me hunter time you've hit classic problem defining lambda functions in loop. try: btn.bind(on_release=lambda btn=btn: dropdown.select(btn.text))

Supertest request expect multiple responses -

i use supertest test http request should return multiple responses. i've been using supertest until case, i've tried: agent.post("/route/with/multiple/responses") .type('json') .send({some: 'json'}) .expect((res) => { expect(res.status).toequal(200); }) .expect((res) => { expect(res.status).toequal(200); }) .expect((res) => { expect(res.status).toequal(500); cb(); }); this attempt sends post request never gets first "expect" (probably bad syntax on part), tried using supertest-as-promised : agent.post("/route/with/multiple/responses") .type('json') .send({some: 'json') .expect((res) => { expect(res.status).toequal(200); }) .topromise() .then((res) => { expect(res.status).toequal(200); }) .then((res) => { expect(res.status).toequal(500); cb(); }); this 1 runs...

ios - Is it possible to make an Android/iPhone app which will show info on a locked screen? -

i want make app (for both android , iphone) user puts info app , info (text) permanently shown on lock screen. possible make this? if yes, how please? you can't show info permanently on lock screen on ios. there no app extension that. but, close can done creating today widget in ios. widget can viewable when device locked. need swipe down. more info on creating it. please following tutorial: https://www.appcoda.com/app-extension-programming-today/

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

this question has answer here: how send form input values , invoke method in jsf bean 1 answer i error when trying send values jsf page bean. i want set values fields in bean, create airplane instance , add database. error telling me use illegal syntax setter part of bean. why error? didnt find on site helped me problem. here jsf part: <h4>add plane</h4> <c:if test="#{not empty listairplanebb.error}"> <div class="alert alert-danger"> <span class="glyphicon glyphicon-remove"></span> <h:outputtext value="#{listairplanebb.error}" /> </div> </c:if> <h:form> <table class="table"> <thead> ...