Posts

Showing posts from May, 2015

xcode - Navigation Controller back button image manipulation -

Image
i am, no matter try, unable change button colour , default image. here looks rite now: the leftmost arrow default , right custom arrow. this how set in storyboard: how remove pesky default image , replace own? the button adding overriten default button provided navbar. way adding within code , creating uibutton inside uibarbutton image and/or text, should set action popviewcontroller.

sql server - How to simplyfy this sql query? -

update room set selected = 1 room_id = (select room_id room_rev rev_id = (select rev_id room_rev room_id = 'rom0001' , (start_date<='2015-03-20' , end_date>'2015-03-20'))) can me simplify query? i want select many room_id room_rev same rev_id room_id = 'rom0001', room_id use update selected room , room_rev 1 many relationship you can use join like: update r set r.selected = 1 room r inner join room_rev rr on r.room_id = rr.room_id rr.room_id = 'rom0001' , (rr.start_date<='2015-03-20' , rr.end_date>'2015-03-20')

sql - How to insert generated id into a results table -

i have following query select q.pol_id quot q ,fgn_clm_hist fch q.quot_id = fch.quot_id union select q.pol_id tdb2wccu.quot q q.nr_prr_ls_yr_cov not null for every row in result set, want create new row in table (call table1) , update pol_id in quot table (from above result set) generated primary key inserted row in table1. table1 has 2 columns. id , timestamp. i'm using db2 10.1. i've tried numerous things , have been unsuccessful quite while. thanks! simple solution: create new table result set of query, has identity column in it. then, after running query, update pol_id field newly generated id in result table. alteratively, can more manually using row_number() olap function, found convenient creating ids. convenient use stored procedure following: get maximum old id table1 , write variable old_max_id . after generating result set, write row-numbers table1 , maybe like insert table1 select row_number() on (partition <primary-key

web services - Converting a Future[T] to an always-successful Future[Option[T]] -

the motivating use-case have in mind follows: in play framework controller, calling play's ws . produces potentially-failing future i want handle separate cases of ws request succeeding vs failing. in both cases, want produce play response (likely future[response] ) what think trying is: asynchronously, after future completes, unconditionally handle completion produce future[response] corresponding desired response i don't believe can use future.map because need customize handling of failure case , not pass on future 's failure. if have alternative suggestions how solve cleanly, please let me know. you're looking future.recover . val wsresponse: future[wsresponse] = ??? wsresponse map { response => // success case ok(response.json) } recover { // failure case, turn throwable response case t: throwable => internalservererror(t.getmessage) } recover takes partial function throwable => t . in case, t option[resp

Writing complex/nested JSON Writes in Scala PlayFramework -

going assume have 2 case classes: child , parent like: case class child() case class parent(child: child) assume i've implemented writes[child] . i'd implement writes[parent] . i'm able using combinators: implicit val parentwrites: writes[parent] = ( (__ \ "child").write[child] )(unlift(parent.unapply)) but following approach, compiler complains it's seeing type child while expecting jsvaluewrapper : implicit val parentwrites = new writes[parent] { def writes(parent: parent) = json.obj( "child" -> parent.child ) } hoping can me understand how implement writes[parent] without using combinators. this work me without compile issues. import play.api.libs.json._ case class child(t: string) case class parent(child: child) implicit val parentwrites = new writes[parent] { def writes(parent: parent) = json.obj("child" -> parent.child) } if still having trouble, useful if can share complete s

Twilio Post Issue on Heroku + Rails 4 -

my app used hosted on hosting platform i've had move heroku recently. since dns hosted godaddy, i've had cname www.medapulse.org https://salty-coast-5328.herokuapp.com/ , forward medapulse.org www.medapulse.org.sending texts app works fine twilio setup corre sadly, has broken route app receive text messages (to convert emails , save db). this current route working medapulse.org: get "text_messages/receive" match '/receivetext' => 'text_messages#receive', :via => :post i've tried change twilio post url no avail when text app: post urls i've tried on twilio: http://medapulse.org/receivetext (408 response) http://www.medapulse.org/receivetext (400 response) http://salty-coast-5328.herokuapp.com/receivetext (404 response) https://salty-coast-5328.herokuapp.com/receivetext (500 response) i'm sure related forwarding url/understand posting heroku. can provide. issue solved. i kept /receivetext rout

javascript - how to disable mouseout visibility="hidden" effect for medias smaller than 768px? -

i pretty new @ javascript. created effect text appears under image icon when user hovers on it. effect work when screen on 768px , text stay visible @ times when viewed on smaller devices. i've tried using different variants of if (screen.width < 768px) {} , @media , (min-width: 768px) {} else {} to control effect liking without luck. help??? here code: <section id="s1"> <h1><a href="web/services.html"> <img src="images/icon-transcription.png" class="hover"></a></h1> <p class="text">transcription</p> </section> <script> $('.hover').mouseover(function() { $('.text').css("visibility","visible"); }); $('.hover').mouseout(function() { $('.text').css("visibility","hidden");}); </script> if must via js(this can accomplished css media queries ), first should wid

nested ifelse calculations in R -

i relatively new r , finding nested ifelse functionality not behave expect. begin, info used input function: loss_cor_df<-data.frame(from_1=c(0,.4,0), to_1=c(0,.5,0), from_2=c(0,.55,0), to_2=c(0,.65,0), from_3=c(0,.75,0), to_3=c(0,.85,0) ) loss_cor_dol<-100*loss_cor_df loss_cor_rate_df<-data.frame(rate_1=c(0,0.5,0), rate_2=c(0,0.75,0), rate_3=c(0,1,0)) my function: apply_lc<- function(x, lc, rate) {ifelse(x>=lc$from_3, -rate$rate_1*(min(x,lc$to_1) - lc$from_1) - rate$rate_2*(min(x,lc$to_2)-lc$from_2) - rate$rate_3*(min(x,lc$to_3)-lc$from_3), ifelse(x>=lc$from_2, -rate$rate_1*(min(x,lc$to_1) - lc$from_1) - rate$rate_2*(min(x,lc$to_2)-lc$from_2), ifelse(x>=lc$from_1, -rate$rate_1*(min(x,lc$to_1) - lc$from_1), 0))) } if apply scalar, expected result. > apply_lc(85,loss_cor_dol[2,], loss_cor_rate_df[2,]) [1] -22.5 however, when attempt following, no longer correct answer.

unity3d - unity player chrome error making me crazy -

i want open unity game in chrome browser it’s showing me error says unity web player needs permission , it’s not playing. i've installed unity player in pc. have tried things still it’s not working. don't know how solve this... please! enter chrome://plugins/ url bar chrome. find unity player plugin , check box always allowed . i imagine haven't allowed plugin run. when try , run it, see icon @ right end of url bar? if do, icon indicates plugin blocked. when click on it, should able decide (allow or continue blocking). you can find more info here .

Using cuts in Prolog -

i trying find of distinct entries person's name john, peter or fred. however, if there were, example, 2 people called peter, want display 1 occurrence of name. my code far follows: searchpeople(x) :- people(_,[x|_]), x=john; x=peter; x=fred. i understand solution cuts (having read other posts), cannot find example cuts used when trying retrieve x or y or z (in case john, peter or fred). thanks in advance. the problem you're confusing operator precedence. more conventional programming languages writing this if ( , b or c or d ) ... is going in trouble, code has exact same problem. operator precedence , associativity causes searchpeople(x) :- people(_,[x|_]) , x=john ; x=peter ; x=fred . to parsed if written searchpeople(x) :- ( people(_,[x|_]) , x = john ) ; ( x = peter ; x = fred ) . which not intended. while could use parenthesis effect want: searchpeople(x) :- people(_,[x|_]) , ( x = john ; x = pete

c# - DNN Database Repository Reuse in Console Application -

i have project based on chris hammond, christoc, module template. have ton of code use access data external database. in repositories change database default whichever need particular object. code looks this: using (idatacontext ctx = datacontext.instance(mymodulesettingsbase.database_connection_string_key)) { var rep = ctx.getrepository<product>(); products = rep.get().tolist(); } the default database switched in call .instance(). repositories used custom dnn modules. repository part of solution contains multiple custom modules. when compile , install using extensions part of dnn, works well. in code above, mymodulesettingsbase.database_connection_string_key found in file mymodulesettingsbase.cs file of module solution. set simple string "productdatabase". in solution base dnn install (not module solution), within web.config file, there value in <connectionstrings> name="productdatabase" contains actual connection string. l

webforms - Google reCAPTCHA 2 ("noCAPTCHA") does not get reapplied when using ASP.NET Web-Form UpdatePanel -

google recaptcha 2 ("nocaptcha") not reapplied when using updatepanel i not using old asp.net recaptcha control. here code running. <asp:scriptmanager id="scriptmanager1" runat="server" /> <asp:updatepanel id="googlecaptchaupdatepanel" runat="server" updatemode="always" > <contenttemplate> <div class="googlecaptchawrapper"> <div class="g-recaptcha" data-sitekey="<%= getcaptchapublickey() %>"></div> <asp:label id="captchaerror" cssclass="captchaerror" runat="server" forecolor="red" visible="false" /> </div> <div class="smallcontentrow" style="margin-top: 10px; margin-left: auto; margin-right: auto; width: 100%; text-align: center;"> <asp:linkbutton id="btnsubmit" runat="

python - A program to read a file and print out the sum of the numbers in the file. The file contains a single floating point numbers separated by commas -

for example, if file contained: -2.5, 2.0 8.0 100.0, 3.0, 5.1, 3.6 6.5 then sample run of program like: please enter file name: nums.txt sum of numbers 125.7. i have run program giving me error, saying "sum_number = sum_number + float(i) valueerror: not convert string float: '.'" any appreciated! filename = input("please enter file name: ") sum_number = 0 openthefile = open(filename, "r") in openthefile: split = i.split(',') join = "".join(split) print(join) in join: sum_number = sum_number + float(i) print("the sum of numbers is",sum_number) you can follows: filename = input("please enter file name: ") sum_number = 0 openthefile = open(filename, "r") line in openthefile: num in line.split(','): sum_number = sum_number + float(num.strip()) print("the sum of numbers %.1f" %(sum_number)) we cycle through each line of file,

javascript - Why is ng-disabled not working on button? -

Image
my plunkr: http://plnkr.co/edit/4mkenjpczfbxy5aoilll?p=preview <body ng-controller="mainctrl main"> <h1>hello plunker!</h1> <p>button should not disabled:</p> <div ng-init="main.btndisabled = false"> <button ng-model="main.my_button" ng-class="{ 'btn-success' : !tc.switching, 'btn-disabled' : tc.switching }" disabled="main.btndisabled" type="button" class="btn btn-info btn-sm switch-btn">my button</button> </div> angular angular.module('app').controller('mainctrl', function($scope) { vm = this; vm.btndisabled = false; }); i found this answer here , didn't work in example. the button disabled because there disabled attribute. enough browser know element must inactive. value disabled attribute doesn't matter, can anything. this reason why angular pro

Renaming *.nfo files to match their *.mkv's -

trying organize shows *.nfo files have same name mkv(edit:avi woops doesn't change code) match. test folder: 76107.2.1.nfo 76107.2.2.nfo 76107.2.3.nfo doctor - s02e01 (009) - planet of giants (1) - planet of giants.avi doctor - s02e01 (009) - planet of giants (2) - dangerous journey.avi doctor - s02e01 (009) - planet of giants (3) - crisis.avi now episode numbers in 76107.2.*.nfo's wrong in later folders similarity in test folder because first of season. can't compare names match them in right order i'm trying use counters rename first *.nfo same first *.avi , second *.nfo same second *.avi , on! i made script thought should work it's doing nothing. appreciated! edit works aacini except odd bug noted under code. @echo on setlocal enabledelayedexpansion set cnta=0 set cntb=0 %%b in (*.avi) ( set /a cnta=cnta+1 set line_!cnta!=%%~nb ) %%c in (*.nfo) ( set /a cntb=cntb+1 %%i in (!cntb!) ren "%%~fc" "!line_%%i!.nfo" ) bug: first

Google maps hide/display issue -

i using ionic framework (though not sure that's relevant) , have view user can toggle between map , list mode. issue if initial mode list, , user toggles, map cropped/messed up. if initial mode map itself, well. have codepen - http://codepen.io/anon/pen/oprvrg - illustrate issue experiencing. it's set map mode right now, can change line $scope.viewmode = 'map'; to $scope.viewmode = 'list'; to see problem. ideas why happening or how fix/get around it? changed changeviewmethod function changeviewmode (){ if (viewmode == 'map'){ document.getelementbyid('map-canvas').style.display = 'none'; document.getelementbyid('list-canvas').style.display = 'block'; viewmode = 'list'; } else { document.getelementbyid('map-canvas').style.display = 'block'; document.getelementbyid('list-canvas').style.display = 'none'; viewmode = 'map';

Android not parsing JSON Array -

i trying parse json array in code problem never enters try block. here code: protected void doinbackground(void... arg0) { jsonparser jsonparser = new jsonparser(); string json = jsonparser.getjsonfromurl("http://hills.ccsf.edu/~jpark41/vib/sample.json"); if(json != null) { log.i("json: ", "not null"); // log executes!! try { log.i("we: ", " out here"); // not!! jsonobject jobj = new jsonobject(json); jsonarray jsar = new jsonarray(json); iterator<string> iter = jobj.keys(); while (iter.hasnext()) { string key = iter.next(); try { jsonobject value = (jsonobject)jobj.get(key); id = value.getstring("id"); thumb = value.getstring("thumb");

arrays - How to fix this "out of memory error " in MATLAB? -

two of lines in code, commented below, throw "out of memory error". can corrected? [x1,x2]=textread(tline,'%u,%u'); x1 , x2 contains integer value % disp(x1); % disp(x2); previousmovie = nextmovie; nextmovie = x1; allmovies = [allmovies x1]; ///////// error in line if(iline ==1) if((nextmovie ~= previousmovie) & (previousmovie==0)) currentgenres = x2; end end if(nextmovie == previousmovie) currentgenres = [currentgenres x2];///////// in line error end

css - Images on top of each other while centered vert. and hor -

i have looked tips how center div in middle of page. used method: width: 750px; height: 400px; position: absolute; left: 50%; top: 50%; margin-top: -200px; margin-left: -375px; so, div in middle of page, need images inside of line directly on top of 1 another. if this, can fade them out using jquery, revealing new image. now, tried many different techniques line them up, none work when centered this. html: <div class="choose" align="center"> <h2 id="question">rock, paper, or scissors?</h2> <img src="images/rock.png" id="rock"> <img src="images/result/red rock.png" id="selected" style="opacity:1"> <img src="images/paper.png" id="paper"> <img src="images/result/red paper.png" id="selected" style="opacity:1"> <img src="images/scissors.png" id="scissors">

migration - On-premise email contentious sync to Office 365 -

i know cut on migration can keep sync mailbox office 365 until change mx record. sync mailboxs of on-premise exchange. want sync part of users 100 out of 1000 office 365.( 400gb ). want sync them office 365 , cut over. possible ? stage migration not option because move user 1 one. user cannot update email on on-premise server. take days or weeks so. want cut on over same date, can make backup of cut off day could clarify? syncing users, in stages of 100 per batch job? or 100 out of total 1000? you can't sync subset, cut over, , sync subset. you can sync subset making migration job, deleting users don't want sync after automatically provisioned, batch job fail users, succeed others.

python - How can a Qt/Qml app authenticate to GAE flask app? -

i wrote simple google app engine app using flask web framework. used flask-login , flask-restful libraries handle authentication , provide simple restful api app. next step have qt/qml app login gae app , have use rest api created. app written in qt 5.4 , runs on multiple desktop , mobile platforms. tried using qml webview qt 5.4 see if authentication happen , use cookie produced during authentication make restful calls separate network connection using qnetworkaccessmanager. never worked unable cookies webview. @ bit of loss of how else this? thanks!

playframework - Play Morphia MappingException In WebSocket Iteratee After Reload -

i'm using play 2.3 , akka set simple publish subscribe protocol on web socket. part of protocol, after client subscribes, server sends initial state database. my current code works but, during development, morphia query inside socket iteratee stops working after development reload. regular requests, requests make exact same query, continue work fine. i'm using distributed pub sub mediator akka plugin. here's relevant code actor representing web socket listener: object subscriber { def props(channel: concurrent.channel[jsvalue]): props = props(new subscriber(channel)) } class subscriber(channel: concurrent.channel[jsvalue]) extends actor { def receive = { case statusupdate(...) => channel.push(...) } } and main view controller: object socketcontroller extends controller { val mediator = distributedpubsubextension.get(akka.system).mediator def index = websocket.using[jsvalue] { implicit request => val (out, channel) = concurrent.b

java - A simple algorithm to find value from sequence for a Random number? -

this question has answer here: convert numbers letters beyond 26 character alphabet 2 answers i create general algorithm sequence (i not storing sequence anywhere).. if 1=a 2=b 3=c . . . 26=z 27=aa 28=ab 29=ac 30=ad what should code value of random number ? e.g 333 a brilliant example here here .. function getcharcode(displaynumber){ var orda = 'a'.charcodeat(0); var ordz = 'z'.charcodeat(0); var len = ordz - orda + 1; var returnsequence = ""; while(displaynumber >= 0) { returnsequence = string.fromcharcode(displaynumber % len + orda) + returnsequence; // (displaynumber % 26 + 65) +"" displaynumber = math.floor(displaynumber / len) - 1; //(displaynumber / 26) - 1 } return returnsequence; } or modified .. function getcharcode(displaynumber){

php - How to save all query results into an array -

i'm trying store query results array. i've table 50 rows , 6 columns, how save 50 values array? problem save array like: value1 - red - metal - 100 - in stock - price so each cell of array must have organization. you can use 2 dimensional array in manner $sql = "select * table"; $result = mysql_query($query); $myarray = array(); while(*emphasized text*$arrayresult = mysql_fetch_array($result)) { $myarray[] = array( 'id'=>$arrayresult['id'], 'title'=>$arrayresult['title'] ); }

boot2docker - Docker in debugging mode -

i have flume, hdfs container running in boot2docker. have java code under /c/users/ directory automatically mounted boot2docker[according docs ]. i copied required jars running container instead mounting volume using -v flag. want debug code inside running container. how achieve this? need mount , run container debug mode? how this? if steps or example, helpful any suggestions? use docker exec -ti container /bin/bash open terminal in container, check dock https://docs.docker.com/reference/commandline/cli/#exec

mysql - Need to select sum of the same field in SQL with diffrent Conditions -

i have 2 tables used select sum of same field different conditions tried query follows result showing same in 2 fields select sum( s.message_count) total,(case when s.dlr_status = 'delivrd' sum( s.message_count) end ) delivered `sent` s join `track` t on t.track_id = s.track_id group t.sent_type any appreciable thank you move sum outside of case..when projection, , completeness, return 0 in 'else'. you'll need sent_type column in select in order group it. select t.sent_type, sum(s.message_count) total, sum(case when s.dlr_status = 'delivrd' s.message_count else 0 end) delivered `sent` s join `track` t on t.track_id = s.track_id group t.sent_type;

python - Azure ML & Pandas: How to convert String to DateTime -

i've got dataset @ hand column of datetime in string format, eg. a = 'tue sep 22 1998 00:00:00 gmt+0000 (coordinated universal time)' and value column. if use metadata editor in azure machine learning studio, won't work , complain can't conversion (from string datetime). guess it's format. i'm trying following: a = str(a)[:10]+','+str(a)[10:15] #'tue sep 22, 1998' now .net surely can conversion, mean method convert.todatetime(). however, when visualized output of python script, found string has been changed 'tue sep 22, 1998 none,', quite weird. knows what's wrong it? i'm attaching excerpt of python code down below: def azureml_main(dataframe1 = none, dataframe2 = none): dataframe1['timestamp'] = dataframe1['timestamp'].apply(lambda a: str(a)[:10]+','+str(a)[10:15]) return dataframe1, i use python date format normalization. have change string before returning dataframe bec

java - Selecting no of images using multiselectgrid in Android -

i have designed app have used mulitiselectgridview image selection.my requirement want restrict user select max 8 images, means whenever user try chek on 9th element should display warning message popup i.e max 8 images can selected , 9th images should autometically unchecked. public class multiimagepicactivity extends activity { gridview mgrid; private string[] arrpath,modifiedarraypath; private int ids[]; private int count; int selectcount; activity act=this; list<string> imagepaths; int maximageselection; //int sel=0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //now intent extras imagepaths=new arraylist<string>(); imagepaths.clear(); loadapps(); setcontentview(r.layout.grid_1); mgrid = (gridview) findviewbyid(r.id.mygrid); mgrid.setadapter(new imageadapterxtends()); mgrid.setchoicemode(gridview.choice_mode_multiple_modal); mgrid.setmultichoicemodelistener(new

bytearray - RTSP Programming with Java. How to read single part frames? -

i trying implement rtsp server java fun. since not have pre-knowledge rtsp. starting analysis made source code. i found code in internet. link : http://nsl.cs.sfu.ca/teaching/09/820/streaming/client.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/server.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/videostream.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/rtppacket.html for posting, got question videostream.java. it has method below : public int getnextframe(byte[] frame) throws exception { int length = 0; string length_string; byte[] frame_length = new byte[5]; //read current frame length fis.read(frame_length,0,5); //transform frame_length integer length_string = new string(frame_length); length = integer.parseint(length_string); return(fis.read(frame,0,length)); } as can see, casts byte[] string integer. however, in experience, string turns out hexa string. changed like... below. integer.parseint(l

python - Custom exception handler not working as documented in django-rest-framework -

i'm trying write custom exception handler in django-rest-framework, , code same given in example: from rest_framework.views import exception_handler def custom_exception_handler(exc, context): # call rest framework's default exception handler first, # standard error response. response = exception_handler(exc, context) # add http status code response. if response not none: response.data['status_code'] = response.status_code return response but on raising exception view, not work, instead throws message: custom_exception_handler() missing 1 required positional argument: 'context' i've tried setting first argument none , so: def custom_exception_handler(exc, context=none): but happens: exception_handler() takes 1 positional argument 2 given so seems rest_framework.views.exception_handler takes 1 argument. indeed case: def exception_handler(exc): """ returns response should us

wordpress - Displaying specific thumbnail size in single.php -

currently i'm building wordpress theme , i'm trying display specific image size, cropped in single.php , , on individual post pages , not having luck. here's functions.php : add_theme_support( 'post-thumbnails' ); add_image_size('new-thumbnail-size',600,340, true); here's single.php : <?php if( get_the_post_thumbnail() ) : ?> <div class = 'postimgcon'> <div class="feat-img"> <?php the_post_thumbnail('new-thumbnail-size'); ?> </div> </div> <?php endif; ?> any ideas? you're using correct functions declare support post thumbnails , add image size need inside after_setup_theme hook. inside functions.php change: add_theme_support( 'post-thumbnails' ); add_image_size('new-thumbnail-size',600,340, true); to: function wpse_setup_theme() { add_theme_support( 'post-thumbnails' ); add_image_

sql - Conditional summing (Alasql) -

i've discovered alasql, saving me tons of work data manipulation. now i'm trying aggregate yearly revenues each customer. i've tried partition no success, , i've tried conditional approach, returns either 2013 or 2014 data, not both @ same time: var custtable = alasql('select customer customer, sum(revenue::number) revenuetotal, sum(case when year = "2013" revenue::number end) revenue2013, sum(case when year = "2014" revenue::number end) revenue2014 ? group customer', [revenuetestdata]); basically i'm trying this: {"year":"2013","month":"1","customer":"some customer","revenue":"7533.36"}, {"year":"2014","month":"1","customer":"some customer","revenue":"10000"} to this: {"customer":"some customer","revenuet

ios - Sections in WKInterfaceTable -

i trying create table sections having varying number of rows. saw solution given here how create sections in wkinterfacetable , tried follows: tableview.setrowtypes(rowtypes); q in 0...rowtypes.count-1 { if (rowtypes[q] == "teamsection") { let row = tableview.rowcontrolleratindex(q) as? teamsection; } else { let row = tableview.rowcontrolleratindex(q) as? teamrow; } } i have rowtypes follows: let rowtypes = ["teamsection", "teamrow", "teamsection", "teamrow", "teamrow", "teamrow", "teamrow", "teamrow", "teamrow", "teamrow", "teamrow"]; i expecting 11 rows getting 9 of teamrow type , none of teamsection . can spot doing wrong? it looks teamsection isn't valid row type. sure you've set table in storyboard 2 rows , set identifier correctly 1 of them "teamsection"?

Fill textbox when click a button according to dropdown selection in php jQuery -

my process this: have dropdown menu , text box. when select id (unique id) dropdown , click submit button want display corresponding name text box. my database fields : id (auto increment) agencyname_id (unique id) name dispay.html <select name="agencyid_dwn" class="idlookup_dwn" id="agencyid_dwn" > <option selected>...select...</option> <?php while($row = mysqli_fetch_array($result)){ ?> <option value="<?php echo $row['agencyname_id'];?>"> <?php echo $row['agencyname_id'];?></option> <?php } ?> </select> // input text <input type="text" id="testid"> // submit button <input type="submit" name="lookupsubmit"> dataget.php <?php if (isset($_post["lookupsubmit"])) { $user_id=$_post['agencyid_d

node.js - Create hashid based on mongodb '_id` attribute -

i have mongo db schema follows: var mytable = mongoose.model('items', { name: string, keyid: string }); i store keyid hashid of '_id' item being created. eg. say, add item db "hello world", , mongodb create '_id' item while inserting. i make use of _id use , generate hashid same item being inserted. this: var hashids = require("hashids"), hashids = new hashids("this salt"); var id = hashids.encrypt("507f191e810c19729de860ea"); is there way, know id before hand. or let mongodb generate value id field based on criteria specify. just note on this. hashids module has encrypthex (or encodehex in v1.x), intended use mongodb ids.

swift - Scene created in Sprite kit level editor is not working -

i'm trying while. have main scene game named playscene . have pause button there. when player tapping button want load scene, named pausescene. visualy creating scene use sprite kit level editor. have 2 files pausescene.swift and pausescene.sks . .sks content ( background now) isn't unarchiving. don't know make mistake. transition via pause button, located in playscene for touch: anyobject in touches { let location = touch.locationinnode(self) if self.nodeatpoint(location) == self.pause { var scene = pausescene(size: self.size) scene.paused = true let skview = self.view skview! skview.ignoressiblingorder = true scene.scalemode = .aspectfill scene.size = skview.bounds.size skview.presentscene(scene) } } and have in pausescene.swift : class pausescene: skscene { override func didmovetoview(view: skview) { self.initpausescene() } func initpausescene() {

javascript - Event doesnt work for elements putted via Ajax -

i have got elements event "onclick", need update elements ajax, unfortunately onclick event bound. my question is, how refresh event trigger? there way it? since event can bound elements exist @ time, use little trick called "event delegation". that means going listen clicks on parent element exists, , if click on child meets requirement, something. example, newly added elements appended container: <ul id="output"></ul> since did not mention using jquery, made version without it, , 1 it. example: native js document.getelementbyid('output').addeventlistener('click', makemered); then, in makemered example function, need check if element clicked on ( event.target ) meets requirements (i want <li> in case): function makemered(event){ if(event.target && event.target.nodename == 'li'){ event.target.style.background = 'red'; } } js fiddle demo using jq

angularjs - Need to resolve a $http request before the execution of the resolve property inside $stateProvider -

i’m building angular application going run on several domains. since there different configurations on each domain i'll need fetch variables doing call server. call return json object contains different rest urls. problem need call before 'resolve' step inside $stateprovider, since have task dependent on configuration object server. what should work here great feature $urlrouterprovider.deferintercept(); documented here: $urlrouterprovider the deferintercept(defer) disables (or enables) deferring location change interception. if wish customize behavior of syncing url (for example, if wish defer transition maintain current url) , call method @ configuration time. then, @ run time, call $urlrouter.listen() after have configured own $locationchangesuccess event handler. the code snippet api documentation: var app = angular.module('app', ['ui.router.router']); app.config(function($urlrouterprovider) { // prevent $urlr

combination, shortest path algorithms and Python -

i don't know in codding understand basic python. wanted challenge myself writing program solve next - considering store giving 3 options - x$ per day, y$ per month or z$ per year, combination best me assuming want t amount of time? now, far can understand, have here basic combinatoric question creating tree of combinations, , need of shortest-path algorithms (djikstra, bellman-ford..?) finding best option ("shortests","less expensive") please me find need approach problem. this instance of multiple item knapsack problem , time weight, , "value" cost. knapsack size amount of time want. in here want minimize value, equivalent maximizing negatives (assume day "costs -x, month -y, year -z). this can solved following recursive formula (assuming costs integers or can brought integers), , can implemented rather efficiently using dynamic programming . d(0,0) = 0 d(x,0) = infinity x>0 d(x,i) = infinity x < 0 d(x,i) = min{ d(x,

bash - How to find unique words from file linux -

i have big file, teh lines text numbers etc. [man-(some numers)] lot of man-somenumbers repeat in few lines, want count unique mans -words. cant use unique file , because text before man words different in each line. how can count unique man-somenumbers words in file ? if understand want correctly, then grep -oe 'man-[0-9]+' filename | sort | uniq -c should trick. works follows: first grep -oe 'man-[0-9]+' filename isolates words file match man-[0-9]+ regular expression. list piped through sort sorted list uniq requires, , sorted list piped through uniq -c count how each unique man- word appears.

build.gradle - Android Unable to identify the apk for variant arm-debug and device -

i have .so files , jar, when run error: unable identify apk variant arm-debug , device. i'm noob here must doing wrong, cant seem figure out. ideas? using android studio 1.1.0 , genymotion emulation. this build file looks like: apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "22.0.0" defaultconfig { applicationid "com.ctech.music.androidstreamer" minsdkversion 14 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } productflavors { x86 { ndk { abifilter "x86" } } arm { ndk { abifilters "armeabi-v7a", "armeabi" }

node.js - What is the use to serve favicon from server -

i have doubt regarding favicon , can add favicon directly in html file following code. <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> i have tried above code, it's working fine. have seen there modules in npm server favicon images. if add through html , why have use modules serve. for case of serve-favicon module: why use module? user agents request favicon.ico , indiscriminately, may wish exclude these requests logs using middleware before logger middleware. this module caches icon in memory improve performance skipping disk access. this module provides etag based on contents of icon, rather file system properties. this module serve compatible content-type.

java - How to remove text from textflow in javafx? -

i'm new javafx , trying display large amount of text in textflow. displays fine, cannot figure out how delete text. so i'm trying delete text nodes textflow so textflow.getchildren().removeall(); but when , add textflow, shows after text displayed there. text there removed , show added text beginning of textflow. i guess have somehow rerender view of textflow, don't know how. how delete , add text anew? removeall(...) remove values pass parameters: in case there none, doesn't remove anything. use textflow.getchildren().clear();

c - Server to Validate Credentials (Socket Programming) -

first of all, i'm beginner in c. program simulates server client connects via telnet on port 8000 , give username , password , server validates them. username client, have problem validating it. need compare username list of credentials, doesn't seem work. here's code i've written far... #include <stdio.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> int main() { char * credentialslist[7][2] = {{"alice","abcdef"}, {"bob","1234567"}, {"cindy","qwerty"}, {"david","abababab"}, {"eve", "cdefgh"}, {"frank","7654321"}, {"george", "12341234"}}; int serversocket=socket(af_inet, sock_stream, 0); int new_socket, i; char *message, client_message[10]; struct sockaddr_in server, client; server.sin_family = af_inet; server.sin_addr.s_addr

go - How to build mixed array -

in ruby can created array filled types: [1, 'hello', :world] # [fixnum, string, symbol] => [1, "hello", :here] how implement similar array filled mixed types in go? how declare array? you can via empty interface - interface{} : arr := make([]interface{}, 0) arr = append(arr, "asdfs") arr = append(arr, 5) or in literal form: arr := []interface{}{"asdfs", 5} whenever want use value of array need use type assertion.

javascript - How to create jQuery plugin to cache jQuery object as shown below -

problem is, in case of e of type htmlelement this causes performance issue $(e) !== $(e) instead of reusing jquery object, jquery creates new object each time when call $(e) $(e).attr(.... $(e).css(... $(e).find(.... for each statement, new jquery object created , performance increases when do var $e = $(e); $e.attr(.... $e.css(... $e.find(.... so decided cache rewriting $ below. instead of changing huge code. var $old = window.$; var $ = function(o){ if(typeof htmlelement === "object" ? o instanceof htmlelement : o && typeof o === "object" && o !== null && o.nodetype === 1 && typeof o.nodename==="string"){ o.__$ = o.__$ || $old(o); return o.__$; } return $old(o); }; $.prototype = $old.prototype; after $(e) === $(e) returns true, , in context of page, if called multiple times, runs pretty fast. however, $.trim, $.isarray function gone,

function - Generating random number with different digits -

so need write program generates random numbers 100 999, , tricky part digits in number can't same. for example: 222 , 212 , on not allowed. so far, have this: import random = int (random.randint(1,9)) <-- first digit b = int (random.randint(0,9)) <-- second digit c = int (random.randint(0,9)) <-- third digit if (a != b , != b , b != c): print a,b,c as can see, generate 3 digits separately. think it's easier check if there same digits in number. so, want loop generate numbers until requirements met (now either prints blank page or number). note generates once , have open program again. in c++ did ' while loop '. , here don't know how it. and 1 more question. how can code number(quantity) of random numbers want generate? more specific: want generate 4 random numbers. how should code it? p.s. thank answers , suggestions, keen on learning new techniques , codes. to loop until it's ok can use while in python: from ra

Pattern matching on records in Clojure -

is supported right now? information find example wiki ( https://github.com/clojure/core.match/wiki/deftype-and-defrecord-matching ) produces error: compilerexception java.lang.assertionerror: invalid list syntax (red. (red. x b) y c) in (black. (red. (red. x b) y c) z d). valid syntax: [[:default :guard] [:or :default] [:default :only] [:default :seq] [:default :when] [:default :as] [:default :<<] [:default :clojure.core.match/vector]] this has not been implemented yet, since records behave maps can do: (defrecord ab [a b]) user.ab user> (let [x (->ab 1 1)] (match [x] [{:a _ :b 2}] :a0 [{:a 1 :b 1}] :a1 [{:c 3 :d _ :e 4}] :a2 :else nil)) :a1 you can match on type of record, bit inelegant. user> (let [x (->ab 1 1) aba user.ab] (match [(type x) x] [aba {:a _ :b 2}] :a0 [aba {:a 1 :b 1}] :a1 [aba {:c 3 :d _ :e 4}] :a2 :else nil)) :a1 https://github.com/clojure/core.match/wiki/basic-usage

javascript - Change CSS from hovering to clicking in visualization -

i'm new js, css , html feel excited explore more. my visualization , whole code here: https://gist.github.com/dariaalekseeva/a71475378a5d12ea40bc at moment when move mouse across object, many paths appear , not easy see details. i'd change setting in visualization hovering clicking. first hover , active paths change. pick 1 path, click on , path stays active. , still should able see appearing comments when hover along path. need "unclick" path (or click outside object) , keep hovering until find path click on. thank help. you need modify mousemove mousedown . changed display tip click event, not 'hover'. i created plunkr that, display tip clicking. http://plnkr.co/edit/rn76z5z8cxzpqkkm7pen (i modified mousemove mousedown @ 218 line.) you can use 'mouseout', 'mousedown', 'mousemove' implement these kinds of interaction.

How to make a funcion in C++ which read from a file to an array of hex? -

first of must i'm total noob in c++ programing. have make funcion: void license(bool& exists, unsigned int longlicense, unsigned int license[]) it has read txt file contains 6 hex numbers separated "-", example: 462e3784-11f24312-13b57611-27a3197f-3b30158a-ab7ef8e0 and save numbers (in decimal) in "license" array. has return true or false in "exists". i've tried doing doesn't work. reads correctly first number. rest of them aren't same have in txt file. #include <iostream> #include <fstream> #include <string> #define n_int_license 6 using namespace std; bool existe; unsigned int licencia[n_int_license]; ifstream stream; stream.open("license.txt"); if (stream) { (int = 0; < n_int_license; i++) { stream >> hex >> licencia[i]; } i didn't find other topic me if there 1 i'm sorry posting that. please me. thank you. you should skip dash: f

git - .gitignore file is not working in my project -

i have project named "shortcut", here issue & steps cd shortcut vim .gitignore git init git add * git status i still see .exe files , .pdb files in staging. what's wrong git operation steps ??? here .gitignore file [dd]ebug/ [dd]ebugpublic/ [rr]elease/ [rr]eleases/ *.exe *.pdb *.dll i think you're confused, although it's hard tell where. consider following: $ mkdir shortcut $ cd shortcut $ touch foo $ echo foo > .gitignore $ git init initialized empty git repository in ~/shortcut/.git/ $ git add * following paths ignored 1 of .gitignore files: foo use -f if want add them. fatal: no files added

c++ - gcc 4.9.2 bug in -Wmissing-field-initializers? -

i have issue in code - can copied 1:1 cpp file in order test behaving: #include <atomic> typedef struct { char sdatetime [20]; char slogfiledirectory [300]; char slogfilenametemplate [300]; char slogoutput [10][100]; std::atomic<bool> breadytoflush; } logentries; typedef struct { logentries lelogentries [1] {}; } logthreads; compiling gcc 4.9.2 sles 11 sp2 g++ -std=c++11 gcc-warning-bug.cpp -wall -wextra -c receive these strange warnings: gcc-warning-bug.cpp:18:34: warning: missing initializer member ‘logentries::sdatetime’ [-wmissing-field-initializers] logentries lelogentries [1] {}; ^ gcc-warning-bug.cpp:18:34: warning: missing initializer member ‘logentries::slogfiledirectory’ [-wmissing-field-initializers] gcc-warning-bug.cpp:18:34: warning: missing initializer member ‘logentries::slogfilenametemplate’ [-wmissing-field-i