Posts

Showing posts from March, 2014

php - Is it possible to upload files directly to the Google Cloud Storage? -

i have written file upload larger files uploading files cloud storage. unfortunately takes while, because files uploaded web server first, , again web server google cloud storage. there way upload files directly cloud storage google php api client ( https://github.com/google/google-api-php-client )? couldn't find on topic in docs. you need create upload url name of bucket, , upload go directly bucket. https://cloud.google.com/appengine/docs/php/googlestorage/user_upload

php - Script works in browser only when I hit F5 -

my script works in browser when hit f5. previous result seem cached or something. this how looks like: http://mywebsite.com/unsubscribe.php this causes serious problem. have unsubscribe link in email want send out users when click it, nothing happens, because click considered same when hit enter in browser. though have parameter in link as http://mywebsite.com/unsubscribe.php?email=tom@gmail.com the value not captured. $email = $_get['email']; $newsletter = 'no'; try { $stmt = $conn->prepare("update users set newsletter = ? email = ?"); $stmt->execute(array($newsletter, $email)); $response["success"] = 1; } catch(pdoexception $e) { echo 'error: ' . $e->getmessage(); $response["success"] = 0; } echo 'email: '.$email.'<br>'; print(json_encode($response)); result: email: tom@gmail.com {"success":1} but becaus...

forms - Confused with php sessions for a user? -

in login.php store username , user id in sessions. after login user selects page , once lead page, can select lecturer name needs name, not other's lecturer. know lecturer name selected needs stored in session. afterwards, have match either user id or username control user can see. problem how match these sessions login.php , `lecturer.php. should create separate file sessions? login.php <?php require ('connect.php'); $username = $_post['username']; $password = $_post['password']; if (isset($_post['submit'])) { if ($username && $password) { $check = mysql_query("select * users username='".$username."' , password= '".$password."'"); $rows = mysql_num_rows($check); if(mysql_num_rows($check) != 0){ session_start(); $run_login =mysql_fetch_array($check); $uid = $run_login['id']; $_session['uid'] = $_post['uid...

php - Split code by semicolon -

i parse source code. read line line, 1 line can contain more 1 command. i wonder if possible split line semicolons, those, aren't in '...' or "..." blocks. answering question: split line semi-colon not inside double or single quoation marks, can use following regex: (?:'[^']*'|"[^"]*")(*skip)(*fail)|; it find ; outside "..." , '...' . see demo . however, please consider using appropriate tools task taking up.

minimize the runtime or the performance time of a code -

i wondering how can minimize runtime of following code int j = 0; while (j < n) { int = 0; while (i < m) { cout << i*j; i++; } j++; } there's not do, these mere loops. however, more efficient accumulate strings , print @ end printing tiny strings several times.

html - what's wrong with this include statement that i did in php? -

<?php include("articles/article_6.html"); ?> i wanted article posted on website gives error: parse error: syntax error, unexpected 'version' (t_string) in /opt/lampp/htdocs/white_coats/articles/article_6.html on line 1 article_6.html has no php tags. word file saved in .html displayed on website. it's article pictures. then don't include it. read it's contents , print em. include statements code includes , not plain html or text content. echo file_get_contents("articles/article_6.html");

angularjs - angular js checkbox and select dynamic binding to give total price -

i have working code gives sum of total item in json file after ticking 1 or of checkboxes here controller $scope.testfood = [{ name: item1, price: 400 }, { name: item2, price: 800 }, { name: item3, price: 1000 }]; $scope.selecteditems = []; $scope.value = function (isselected, item) { if (isselected == true) { $scope.selecteditems.push(item); } else { // console.log(item.name); angular.foreach($scope.selecteditems, function (itemrmv, $index) { if (itemrmv.itemid == item.itemid) { $scope.selecteditems.splice($index, 1); } }) } console.log($scope.selecteditems); } the filter: .filter('getprice', function () { return function (value, property) { var total = 0; angular.foreach(value, function (val, index) { total = total + number(val.price) }); return total.tofixed(2); } }); ...

ios - invalid Signature error while uploading Linphone App ipa file to itunes -

we facing issue 1 week, couldn't slove issue. can 1 me appreciate them alot. while uploading linphone-ios ipa file(64-bit source code) itunes through application loader. we using 1) mac version 10.10.3. 2) xcode version 6.1.1. below error getting while uploading through application loader. can suggest me how can able slove issue. in advance. error message: "invalid signature. code object not signed @ all. binary @ path [linphone.app/imageoptim.sh] contains invalid signature. make sure have signed application distribution certificate, not ad hoc certificate or development certificate. verify code signing settings in xcode correct @ target level (which override values @ project level). additionally, make sure bundle uploading built using release target in xcode, not simulator target. if code signing settings correct, choose "clean all" in xcode, delete "build" directory in finder, , rebuild release target. for more information, please consult...

javascript - Spliting two different @All of items and then combining them according to same indexes. Total number of indexes are same in both @All of items -

individualproduct = @all of transaction product name+''; productitem= individual_product.split(','); individual_quantity = @all of transaction quantity+'' quantityitem = individualquantity.split(',')+''; for(count=0;count<productitem.length;count++) { var combine += productitem[count]+'' + quantity_item[count]+''; } it not work. if : for(count=0;count<productitem.length;count++) { productitem[count]+'' + quantity_item[count]+''; } it not show error. through this, can value @ last index. expecting them all. i not sure trying achieve, need do? when assign @all of transactional product name individualproduct , can't append ' ' since it's array. same individual_quantity . is wanted? individualproduct = @all of product name; individualquantity = @all of quantity; var combine = ''; for(i = 0; < individualproduct.length; i++) { combine += individualproduct[i...

c++ - Conditional Variable doesn't wake up -

i have build pizzeria in c++ school project. in order have use thread , condvar. i'm doing condvar: class condvar { pthread_cond_t m_cond_var; mutex _mut; public: condvar() { _mut.init(); pthread_cond_init(&m_cond_var, null); } ~condvar() { pthread_cond_destroy(&m_cond_var); } void wait() { _mut.lock(); pthread_cond_wait(&m_cond_var, _mut.getmutex()); _mut.unlock(); } void signal() { pthread_cond_signal(&m_cond_var); } void broadcast() { pthread_cond_broadcast(&m_cond_var); } }; the constructor of kitchen: kitchen::kitchen(int nb_cooks, float mult, int time_ing):_nb_cooks(nb_cooks), _mult(mult), _time_ing(time_ing) { int = 0; _pipe = new pipeclass(); _fork = new fork(); if (_fork->isson()) { _pipe->setson(true); _run = true; _cond = new condvar(); _stock.push_back(new mushrooms(5)); cook_mutex.init(); ingr_mutex.init(); whil...

java - How can i write persian in android? -

Image
i amateur coder , want write persian in android studio. after typing persian, android studio shows strange characters. of course right 3 months, it's strange. :| grateful if me fix it. in android studio 1.2 should go configure> settings> colors , fonts> font> use scheme> uncheck show monospaced fonts> , use tahoma font , apply , ok. enjoy it! instruction

matlab - Concatenating cell arrays of different sizes -

it appreciated if me concatenate 2 cell arrays have different sizes. example, consider cell arrays: a={'p' 'e' 't' 'k'; 2 3 4 6; 3 5 9 8; 5 4 1 0; 8 9 6 5}; b={'a' 'v'; 1 2; 3 4; 0 5; 6 8}; array b have different size, depending on iteration result. want combine these cell arrays, end with c={'p' 'e' 't' 'k';2 3 4 6; 3 5 9 8; 5 4 1 0; ... 8 9 6 5;'a' 'v' nan nan;1 2 nan nan; 3 4 nan nan;0 5 nan nan; 6 8 nan nan}; how can this, when sizes of a , b different each time run code? you first need "pad" smaller cell array, can concatenate both cell arrays with standard methods . in comment question indicated want pad matrix nan . how it, assuming width of array b smaller or equal width of array a : a={'p' 'e' 't' 'k';2 3 4 6; 3 5 9 8; 5 4 1 0;8 9 6 5}; b={'a' 'v' ;1 2; 3 4;0 5; 6 8}; sa = size(a); sb = size(b...

scala - Play-Framework: 2.3.x: play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: -

i using play-framework 2.3.x reactivemongo-extension json type . following code fetch data db below: def getstoredaccesstoken(authinfo: authinfo[user]) = { println(">>>>>>>>>>>>>>>>>>>>>>: before"); //$doc("clientid" $eq authinfo.user.email, "userid" $eq authinfo.user._id.get) var future = accesstokenservice.findrandom(json.obj("clientid" -> authinfo.user.email, "userid" -> authinfo.user._id.get)); println(">>>>>>>>>>>>>>>>>>>>>>: after: "+future); future.map { option => { println("*************************** ") println("***************************: "+option.isempty) if (!option.isempty){ var accesstoken = option.get;println(">>>>>>>>>>>>>>>>>>>>>>: before value"); var value ...

php - WP Woocommerce - Create a select dropdown with attributes for a user uploadform. -

i have site users can uploa dproducts themself woocommerce. im using meta keys in uploader set size, gender , other choices products. however, filer plugins uses attributes , taxomonys filter product, , im looking way add woo attributes trough uploader via dropdowns , checkboxes. possible? two example im using - dropdown categories , 1 textfield input field metakey. categories: case 'post_categories': $options = userpro_publish_categories($args); $res .= "<select name='".$key.'-'.$i.'[]'."' multiple='multiple' class='chosen-select' data-custom-error='".__('please choose category @ least','userpro')."' data-required='".$args['require_category']."' data-placeholder='".$placeholder."'>"; foreach($options $k=>$v) { if (strstr($k, 'optgroup_b')) { ...

c++ - Can't access object variables passed in a std callback -

i have callback function (ouside class) i'm passing bassmusicplayer class object parameter. if breakpoint inside it, can see variables , methods in 'self'. if try read/print values, won't compile , give error c2027: use of undefined type ' bassmusicplayer '. added static class definition suggested others. use global variables workaround want avoid doing that. this have in class file: class bassmusicplayer; void __stdcall loopsyncproc(hsync handle, dword channel, dword data, void *user) { bassmusicplayer * self = reinterpret_cast<bassmusicplayer*>(user); //printf("%d\n", self->loop_start); //if (!bass_channelsetposition(channel, self->loop_start, bass_pos_byte)) if (!bass_channelsetposition(channel, 0, bass_pos_byte)) // try seeking loop start bass_channelsetposition(channel, 0, bass_pos_byte); // failed, go start of file instead } class bassmusicplayer { private: std::string m_filename; ...

c# - Create cron Expression from 8:30 to 12:30 -

i want create cron run 8:30 12:30 every 1 minute in mon,tue,wed,sat,sun. i create expression: 0 30/1 8-12 ? * mon,tue,wed,thu,sun * but not work me. you should use multiple cron expressions instead of one. try this: 0 30-59 8 ? * mon-wed,sat,sun * // 8:30 - 8:59 0 * 9-11 ? * mon-wed,sat,sun * // 9:00 - 11:59 0 0-30 12 ? * mon-wed,sat,sun * // 12:00 - 12:30 please note year field isn't mandatory, can omit last field, this: 0 30-59 8 ? * mon-wed,sat,sun // 8:30 - 8:59 0 * 9-11 ? * mon-wed,sat,sun // 9:00 - 11:59 0 0-30 12 ? * mon-wed,sat,sun // 12:00 - 12:30 good luck!

broadcastreceiver - Android Error receiving broadcast Intent { act=Take_Message flg=0x10 (has extras) } -

below there broadcastreceiver code i'm getting error: public class messagereceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { bundle = intent.getextras(); string username = extra.getstring(messageinfo.userid); string message = extra.getstring(messageinfo.messagetext); if (username != null && message != null) { if (friend.username.equals(username)) { myarray.add(username + ":" + "\n" + message); adapter.notifydatasetchanged(); localstoragehandler.insert(username, imservice.getusername(), message); } else { if (message.length() > 15) { message = message.substring(0, 15); } ...

Can I do multiple MySQL work in Laravel? -

i wrote code (i use mysql, pdo, innodb, laravel4, localhost & mac) : $all_queue = queue1::all()->toarray(); //count 10000 ob_end_clean(); foreach($all_queue $key=>$value) { $pricecreate=array(...); price::create($pricecreate); queue1::where('id',$value['id'])->delete(); } this worked me (65mg ram usage), when working, other parts of program(such other tables) didn't work. can't open database on mysql even. program , sql wait , when process completed ,they work. i don't know supposed do. think not laravel , php or mysql configuration. this php.ini , mysql config i assume $all_foreach($all_queue $key=>$value) { is foreach($all_queue $key=>$value) { and have no errors (you have set debug true in app config). try set no time limit script. in php.ini max_execution_time = 3600 ;this 1 hour, set 0 no limit or in code set_time_limit(0) and if it's memory problem try free memory , unset unus...

asp.net - How to display a message below the dropdownlist not an alert box when specific dropdownlist item is chosen? -

to provide consistency, cannot use alert box display message in code when chooses specific item in dropdownlist. needs display red message below dropdown field if has chosen specific item. so in case if chooses alabama state dropdownlist example, red message needs display below dropdownlist box after choice made. old version of form works accurately, new version of form many changes in not displaying message. in code behind file (the aspx.vb file) have these code snippets: protected sub statedropdownlist_selectedindexchanged(byval sender object, byval e system.eventargs) handles statedropdownlist.selectedindexchanged if statedropdownlist.text = "ak" alabamapanel.visible = true session("alabama") = "yes" else alabamapanel.visible = false session("alabama") = "no" end if statedropdownlist.focus() end sub i'm using previous code edits , part of problem don't unders...

python 2.7 - ImportError: No module named bitarray -

i trying implement fuzzy c means algorithm in python..i have used builtin function same in matlab.i know whether there such simple method in python also.i tried http://peach.googlecode.com/hg/doc/build/html/tutorial/fuzzy-c-means.html i have tried : from numpy import * import peach p x = array( [ [ 0., 0. ], [ 0., 1. ], [ 0., 2. ], [ 1., 0. ], [ 1., 1. ], [ 1., 2. ], [ 2., 0. ], [ 2., 1. ], [ 2., 2. ], [ 5., 5. ], [ 5., 6. ], [ 5., 7. ], [ 6., 5. ], [ 6., 6. ], [ 6., 7. ], [ 7., 5. ], [ 7., 6. ], [ 7., 7. ] ] ) mu = array( [ [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ] ] ) m = 2.0 fcm = p.fuzzycmeans(x, mu, m) print "after 20 iterations, algorithm converged centers:" print fcm(em...

encryption - Working with EVP and OpenSSL, coding in C -

i've seen many questions on openssl , evp, not many clear answers, figured i'd still post question here , hope better feedback. the materials given me signed file "symmetrickey.bin", rsa key set "privatekey_a.pem", "publickey_a.pem", , other user's public key "publickey_b.pem". what need is: unsign symmetrickey.bin , store text file. encrypt message.txt using symmetrickey.txt , algorithm aes example. sign encrypted message privatekey_a.pem , write file cipher.bin . after need unsign , verify signature on cipher.bin . then decrypt message our symmetric key write file. the issues i'm having understanding how implement openssl evp libraries. api page not clear values each function comes from. example, evp_openinit() getting ek or length of ek "ekl"? "prvi" private key? , how know type? these things i'm not given. i've looked @ many implementations , don't answer questions or ...

vb.net - Why am I getting a NullReferenceExeption with listbox.SelectedIndex -

i run little piece of code kind of activity log window. sub writetolog(i string) try 'outfile.write(datetime.now.tostring("mm/dd/yyyy - h:mm:ss:fffffff") & "--->" & & vbcrlf) console.writeline(datetime.now.tostring("hh:mm:ss:ff") & " - " & i) if string.isnullorwhitespace(i) = false loglb.items.add(datetime.now.tostring("[" & "mm/dd/yy - hh:mm:ss:ff") & "] -- " & i) 'else msgbox(i & " nothing!") if loglb.items.count >= 100 loglb.items.removeat(0) if loglb.items.count > 0 loglb.selectedindex = loglb.items.count - 1 catch ex exception console.write(ex) end try end sub so works of time, reason @ seemingly random times null exception , points end of line @ loglb.items.count - 1 i don't know why. ideas?

erlang - Customizing Ejabberd -

i creating xmpp chat service i'm using ejabberd. features want implement are add custom fields phone number , email @ time of registration.i need regarding lines should edit in mod_register accept more fields @ time of registration. eliminate default vcard module custom profile module can act same serve images url avatar.example.org/getavatar.php?username=myusername@example.com am new erlang little confused how start developing these modules or customizing built in modules of ejabberd can serve these features. thank you you're going have have fundamental skill in operating environment able solve problems in it. if gave broken automobile, think ask question on how make work without having idea of how internal combustion engines work in first place? if wasn't engine @ all? i not trying snarky, you're going have invest more time in understanding things, ask specific questions include you've tried, , might make progress answers people provide. ...

asp.net - how can i to access Control in UpdatePanel for Read value controls? -

i can't find dropdownlist ,because inside update panel other control outside update panel can find using following code: for each c control in form1.page.controls findcontrol(c) next private function findcontrol(c control) each k control in c.controls if typeof k dropdownlist if ctype(k, dropdownlist).id = "c1" ctype(k, dropdownlist).selecteditem.value = 2 end if findcontrol(k) end if next return "" end function //////////////////////////////////// <td class="combo_ghaza"> <asp:updatepanel id="upc1" runat="server"> <contenttemplate> <asp:dropdownlist runat="server" width="180px" id="c1" class="combo_gh...

memory management - What is the difference between demand paging and page replacement? -

from understand, demand paging paging swapping, can swap in page when needed. page replacement seems more or less same thing, bring in page needed , switching existing page in physical memory. so there distinct difference? in system uses demand paging, operating system copies disk page physical memory if attempt made access , page not in memory (i.e., if page fault occurs). follows process begins execution none of pages in physical memory, , many page faults occur until of process's working set of pages located in physical memory. example of lazy loading technique. demand paging follows pages should brought memory if executing process demands them . referred lazy evaluation only pages demanded process swapped secondary storage main memory . contrast pure swapping, memory process swapped secondary storage main memory during process startup . whereas, page replacement technique done when there occurs page-fault. page replacement technique utilised bot...

asp.net - Delete data records - keep joined data -

i not able find better title this. branches users attendance ----------- ----------- ----------- branchid^ userid^ courseid^ branchname username userid* branchid* here's table. due company re-structure need delete old branches , users belong in them. when boss wants see old attendances wants see old usernames if don't exist. what's best practice here? i'm thinking add disabled column in branches/users aren't visible on web page. a "soft delete" flag used address requirement retain both current , logically deleted data. alternatively, move rows archive tables historical reporting. having both current , logically deleted rows in same table more convenient if need combined reporting on both. downside presence of inactive rows can add more overhead queries of active data only. depends on percentage of inactive rows , number of rows.

python 3.x - How to create function that returns 'change in highest denominations' -

i trying make programme return correct change, in highest denominations possible i.e $73 return 1 x $50, 1 x $20, 1 x $2 , 1 $1 (i using whole values of $100, $50, $20, $10, $5, $2, $1) i have long code works...it is hundred = x // 100 hundred_remainder = x % 100 fifty = hundred_remainder // 50 fifty_remainder = hundred_remainder % 50 twenty = fifty_remainder // 20 etc....then if hundred > 0: print (str(hundred) + " x $100") if fifty> 0: print (str(fifty) + " x $50") etc....which works fine, know there must way of writing function has loop work out less typing. x = $345, gets 3 x $100, subtracts total , updates x remainder, repeats process going through each denomination, until complete. i'm bit unsure how figure out, guidance appreciated! i think cool model problem defining values consider "legal" up-front, , iterating on top bottom reach counts. consider following loop: #where x value you're maki...

Kotlin object expression not working as expected -

i going through kotlin exercises on github (see link below). i don't quite understand following code. specifically where mouse listener created? how mouselistener invoked? invoked 4 times. didn't see syntax before. great if point documentation. // code on github , working val result = task10 { mouselistener -> mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) } i thinking code should written following. if ran, no event gets triggered. // not working val result = task10 { mouselistener -> { mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) mouselistener.mouseclicked(mouseevent) } } the full declaration of method is: fun task10(handlemouse: (mouselistener) -> unit): int { var mouseclicks = 0 handlemouse(todot...

reactjs - Command `bundle` unrecognized.Did you mean to run this inside a react-native project? -

Image
run react-native bundle command in terminal root directory of app what root directory of app? trying run uiexplorer (on device) official repo giving me message when run react-native bundle command bundle unrecognized.did mean run inside react-native project? i think tried pretty every directory inside /react-native-master you don't need run react-native bundle . you should follow 'option 2' instruction in appdelegate.m, find screenshots below: the instruction in react-native website not clear, clearer instructions be: open ios/appdelegate.m comment out jscodelocation = [nsurl urlwithstring:@" http://localhost:8081/index.ios.bundle "]; uncomment jscodelocation = [[nsbundle mainbundle] urlforresource:@"main" withextension:@"jsbundle"]; run curl given in 'option 2' (e.g. http://localhost:8081/index.ios.bundle -o main.jsbundle ) if fails add --ipv4 flag end of it. in xcode, right click on project ...

javascript - Using a data attribute to pass information to a modal: is there a way to pass more than one piece of information? -

i'm using following code pass variable modal: <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#examplemodal" data-whatever="<?php echo urlencode($parkrow['name']) ?>">open modal <?php echo $parkrow['name']; ?></button> and javascript: $('#examplemodal').on('show.bs.modal', function (event) { var div = document.getelementbyid("dom-target"); var mydata = div.textcontent; var button = $(event.relatedtarget) var recipient = button.data('whatever') var modal = $(this) modal.find('.modal-header').text('new message ' + recipient) modal.find('.modal-body input').val(mydata) is there way send more 1 piece of information? i've tried doing through array , bunch of other ways, can't seem make work. something ? ...

geolocation - Matlabs ellipse hours calc -

i make sundial simulator , draw ellipse , have draw hours on ellipse. every our specified by: x = * sin(t); y = b * cos(t); where: a- length of longer semi-axis b- length of smaller semi-axis t- hour in degrees ( 1 hour == 15 degrees) i wrote function in matlab: function [hx,hy] = calchourcoords(ra,rb) %input: %ra, rb length of semi-axis in ellipse %output: %hx, hy coords of hour's plot hourangle = 15*180/pi; step = 0; i=1:1:24 hx(i)= ra * sin(step); hy(i)= rb * cos(step); step = step+hourangle; end end finally pic: my ellipse , hours points but should looks like: correct hour place's ellipse correct ( draw version other latitude ). maybe me ? sorry english :) edit i repair - convert degrees radians. edit2 i change source code fyi function [hx,hy] = calchourcoords(ra,rb) %input: %ra, rb length of semi-axis in ellipse %output: %hx, hy coords of hour's plot houra...

c - Switch statement code without a label -

this question has answer here: can put code outside of cases in switch? 5 answers how come ansi c allows extraneous code before case labels within switch statement? #include <stdio.h> int main(void) { const int foo = 1; switch (foo) { printf("wut\n"); /* no label, doesn't output */ case 1: printf("1\n"); break; default: printf("other\n"); break; } return 0; } compiled with $ gcc -pedantic -wall -werror -wextra -ansi test.c it compiles without warnings , executes fine - sans "wut" . it allowed put statements in switch without label. standard says that: c11: 6.8.4.2 switch statement (p7): in artificial program fragment switch (expr) { int = 4; f(i); case 0: = 17; /* falls through default code */ default: ...

python 3.x - dict1 is the subset of dict2 when dict2 contains same key and value that dict1 has -

example: if = dict(a=1,b=2) b = dict(a=1,b=2, c=3) dict1 subset of dict2 when dict2 contains same key , value dict1 has what simplest way it? this have far. there other method return bool determine whether dict1 subset of dict2? condition = true a, b in dict1.items(): if dict2[a] = b: condition = false return condition i think easiest way take advantage of simplicity of set set. must convert dicts sets of tuples. that, must firstly convert dicts lists of tuples, , create sets. after that, you'll able use method set.issubset: def issubset(dict1, dict2): # dict -> list list1 = list(dict1.items()) list2 = list(dict2.items()) # list -> set set1 = set(list1) set2 = set(list2) return set1.issubset(set2)

javascript - Referer in iframe -

note: iframe , parent url not controlled me ex: parent url website load yahoo.com in iframe. set iframe google.com google.com has received website referer. but when click google.com link inside yahoo.com, google.com receives yahoo.com referer. what have tried: after loading yahoo.com in iframe, have executed javascript parent. document.getelementbyid('iframeid').src="http://google.com/"; parent url mysite.com sent referer. but need yahoo.com referer . this question seems noob thing. once undertand concept said, tricky.

javascript - How to include angular JS expressions inside an SVG circle -

i have following html code create concentric circles. <div id="delightmeter"> {{delightscore}} <svg width='500px' height='300px' version='1.1' xmlns='http://www.w3.org/2000/svg'> <g class=''> <circle class='' cx='200' cy='60' r='20'></circle> <circle class="" cx='200' cy='60' r='17' ></circle> </g> </svg> </div> i have js file in operations using angular js , have value in $scope variable. there way access variable other file , show inside svg circle update: 'use strict'; angular.module('delightmeterapp', [ ]) .directive('delightmeter', function () { function link($scope, $element, $attrs) { document.getelementbyid("arc1").setattribute("d", describearc(200, 2...

php - PhpStorm remote debug with xdebug -

i want debug phpstorm ide , xdebug site in server. locally works perfectly, when want configure debug server can't. i installed xdebug in server, configuration: xdebug.remote_enable=1 xdebug.remote_connect_back=1 xdebug.remote_handler=dbgp xdebug.remote_host=my ip xdebug.remote_port=9000 xdebug.idekey=phpstorm then setup in phpstorm in "edit configurations" "php remote debug" , "server" in server put: name: xxxx port: 80 host: url of site debugger: xdebug checked "use path mapping" , in file/directory put local proyect path "/home/mysite" in "absolute path on server" put path in server proyect: "/var/www/html/mysite" in "php remote debug" put: name: xxxx servers: server created ide key: phpstorm with these settings did not work. use chrome extension xdebug ide key phpstorm enable. what lacking me work? i think had same problem @ work once when freshly hatched. when xde...

Java Swing Layouts and Menus -

ok having trouble using grid layout arrange window in format, want arrange each label , text field individual line , have centered button @ bottom. public class main extends jframe { //below how want format frame /*label textfield label textfield label textfield button*/ jpanel panel = new jpanel(); jlabel namelabel = new jlabel("name"); jtextfield nametext = new jtextfield(15); jlabel addresslabel = new jlabel("address"); jtextfield addresstext = new jtextfield(15); public main(){ settitle("jswing"); setlayout(new gridlayout(3,2)); setcomponentorientation(componentorientation.left_to_right); setvisible(true); setsize(450,250); //setresizable(false); setdefaultcloseoperation(exit_on_close); panel.add(namelabel); panel.add(nametext); ...

sockets - Android DatagramSocket error message: EADDRINUSE (Address already in use) -

i trying write simple android chat app. have created service class handles networking communication. datagramsocket binding in separate thread. once in while getting error , app crashes: java.net.bindexception: bind failed: eaddrinuse (address in use) @ libcore.io.iobridge.bind(iobridge.java:89) @ java.net.plaindatagramsocketimpl.bind(plaindatagramsocketimpl.java:68) @ java.net.datagramsocket.createsocket(datagramsocket.java:133) @ java.net.datagramsocket.<init>(datagramsocket.java:78) and code prodruces it. error occur on line new datagramsocket how can avoid error? thank you. private class comthread extends thread { private static final int bcast_port = 8779; datagramsocket msocket; inetaddress mybcastip, mylocalip; public comthread() { try { mybcastip = getbroadcastaddress(); if (d) log.d(tag, "my bcast ip : " + mybcastip); mylocalip = getloc...

android - using a button in recycler view to open up maps -

i trying set intents button appears on card in recycler view, error startactivity(intent) part saying "cannot resolve method 'startactivity(android.content.intent)'" new , not sure going wrong code works in other parts of app. here adapter showing code: public class eventcalenderadapter extends recyclerview.adapter<eventcalenderadapter.viewholder> { string[] title; string[] time_start; string[] time_finish; string[] date; string[] description; string[] loc_lat; string[] loc_long; static class viewholder extends recyclerview.viewholder { cardview cardview; textview titleview; textview auxview1; textview auxview2; textview auxview3; button time_date; button location; public viewholder(cardview card) { super(card); cardview = card; titleview = (textview) card.findviewbyid(r.id.text1); auxview1 = (textview) card.findviewbyid(r.id.text2); auxview2 = (textview) card.findviewbyid(r.id.t...

java - OKHTTP -- Posting user-input data, retrieving JSON response to determine success -

i've been thinking in how this. i've read trough okhttp documentation, have idea on how handle i'm not entirely sure. i'll have user submit 3 fields ( username, password, database ). i'll have php file uploaded host accepts post data. ( it's pure php, no html. accepts data posted page. ) once values have been submitted, i'll perform check. credentials found? return/echo json array ( success/ failure ). check if array key " success " equals either 1 || 0. if 1, show toast user has been logged in successfully. now, question. logic correct? if not, how it? have tips me? examples? to send "authorization" in http requests have set header 403. header('http/1.0 403 forbidden'); echo 'you forbidden!'; but when send json via php page, using 'generator' make easy, simple json php . include('includes/json.php'); $json = new json(); $json->add('status', '403'); $json->...

jquery - Javascript, advancing date range -

i using date-picker set start , end date. date range supposed move forward each day 2 week, sliding window of entry. my code below works refactor easier maintain. techniques or tools can use improve code? var challenge_start = new date(2015,04,04); var challenge_end = new date(2015,06,12); var range_start; var range_end; var today = new date(); var dd = today.getdate(); var mm = today.getmonth()+1; //january 0! var yyyy = today.getfullyear(); if(today<challenge_start) { range_start=challenge_start; range_end=challenge_start; } else if(today>challenge_start && today<challenge_end) { if(mm==5) { if(dd<18) { range_start=challenge_start; range_end=today; } else { range_start=today.setdate(today.getdate()-14); range_end=today; } } else if(mm=6) { if(dd<29) { range_start=today.setdate(today.getdate()-14); range_end=toda...

javascript - How to open a link in a new tab when clicking on an image in a chrome extension? -

i made simple chrome extension that, when clicked, has dropdown menu has row of icons. possible set when icon clicked, opens respective website in new tab? (note: have tried make refer link in popup.html file, if click on icon, doesn't anything.) any help, suggestions or advice appreciated, thanks! you need assign click handler icon executes following: chrome.tabs.create({url: websitetoopen}); if want open in background without closing popup, 1 more parameter required: chrome.tabs.create({url: websitetoopen, active: false}); do note "tabs" permission not needed this. this example chrome docs shows how assign click hanlder in way that's compatible chrome extensions ( onclick attribute not work)

android - Drawable's movement with buttons -

i've been learning android month, , want make simple game custom class extends view, , it's included on main_activity.xml. in main activity.class create instance of view, , control movement of sprite on gameview buttons, each button has method control sprite's movement this: public void move_up(view v){ gameview.sprite.move(dir.up);} the problem works when button released, , it's executed 1 time. want method executed while botton pressed can't figure out how this. i'm assuming name of method you're adding onclick property xml layout file in order handle event. while may seem convenient @ first not give need. instead, should implement ontouchlistener gives information touch event happening, in case you'd want handle action_down action: findviewbyid(r.id.btn_up).setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if(event.getaction() == motionevent.action_down...

javascript - textContent Vs. innerText Cross Browser solution -

i've been having hard time cross browser compatibility , scrapping dom. i've added data analytics tracking ecommerce transactions in order grab product , transaction amount each purchase. initially using document.queryselectorall('#someid')[0].textcontent product name , working fine every browser except internet explorer. it took time figure out .textcontent part causing ie problems. yesterday changed .textcontent .innertext . looking inside analytics seems issue has been resolved ie firefox failing. i hoping find solution without writing if statement check functionality of .textcontent or .innertext . is there cross browser solution .getthetext ? if not best way around this? there simple solution? (i ask given knowledge , experience scripting, limited) ** added following comments ** if code block: // build products object var prods = []; var brand = document.queryselectorall('.txtstayroomlocation'); var name = document.queryselectorall(...

javascript - Jquery function dont reconize the click on script -

i need script, works when click on empty space, when click script inside div, jquery function dont work, need make work when click on script on div div close cookie. code in jsfiddle http://jsfiddle.net/fcfw2/406/ your script tag creates iframe. clicks in iframe won't bubble iframe's parent. you'd have write code in iframe src link. see capture click on div surrounding iframe related question (your script tag inserts iframe @ location)

c# - ItemContainer style with nested ItemControls won't bind correctly -

a summary of i'm trying do: i have list of shapes all shapes have list of blocks i want draw blocks in canvas , bind position. but problem right if draw blocks don't bind position correctly , show @ (0,0). here how right nested itemscontrol: <itemscontrol itemssource="{binding path=shapes}"> <itemscontrol.itemspanel> <itemspaneltemplate> <canvas background="aqua" width="250" height="400"/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <itemscontrol itemssource="{binding blocks}"> <itemscontrol.itemcontainerstyle> <style targettype="contentpresenter"> <setter property="canvas.left" value="{binding x}"/> ...

php - Removing a core order status -

i’m trying remove 3 order statuses woocommerce: wc-pending, wc-refunded , wc-failed. i tried remove them /wc-order-functions.php , when did, not longer place order. instead error 400 returned, means cannot insert order database. does have solution this? how can order statuses removed or disabled? please check faq in woo extension here : http://docs.woothemes.com/document/woocommerce-order-status-manager/ q: why can’t delete core order statuses can custom statuses? a: core order statuses, may not typically use in workflow, used plugins. these plugins expect core order statuses present, cannot remove them don’t break plugins, payment gateways, depend on them. you can edit names these statuses if desired, cannot delete these statuses or change slugs.