Posts

Showing posts from May, 2012

python - Combine two lists which have the same item in dict -

i have 2 lists named a_list , b_list : a_list = [{'category_id': 1, 'category_name': u'aaa'}, \ { 'category_id': 2, 'category_name': u'bbb'}] b_list = [{'project_count': u'20', 'category_name': u'aaa'}, \ {'project_count': u'31', 'category_name': u'bbb'}] i want make new list, c_list , combines a_list , b_list category_name . resulting list should like: c_list = [{'category_id': 1,'project_count': u'20', 'category_name': u'aaa'},\ {'category_id': 2,'project_count': u'31', 'category_name': u'bbb'}] the goal able access both page_max , 'category_id' same 'category_name'. for entry in c_list: page_num =1 category_name = entry['category_name'] category_id = entry['category_id'] url = 'https://www.test.com?catego...

ruby - chef attributes value not getting parsed in another attribute -

i setting attributes in default.rb as default[:my_app] = { :vol => "data02", :commitlog => "/foo/bar/node[:vol]/commitlog", } but :vol value not getting parsed in commitlog attribute , getting following error. merror executing action `create` on resource 'directory[/foo/bar/node[:vol]/comitlog]'[0m you're missing string interpolation syntax, e.g. y = "the value of x #{x}." want: default[:my_app] = { :vol => "data02", :commitlog => "/foo/bar/#{node[:vol]}/commitlog", } also, keep in mind if make 1 attribute depend on value of another, might override node[:my_app][:vol] later , expect value of node[:my_app][:commitlog] change it, , may not. attributes parsed together, potentially before override affects first one.

go - Convert back byte array into file using golang -

is there way write byte array file? have file name , file extension(like temp.xml). sounds want ioutil.writefile function standard library? https://golang.org/pkg/io/ioutil/#writefile it this: permissions := 0644 # or whatever need bytearray := []byte("to written file\n") err := ioutil.writefile("file.txt", bytearray, permissions) if err != nil { ... }

php - Selecting multiple options using Laracasts\Integrated -

i using laracasts\integrated library test web application. have form this: <select multiple name="resource[]"> <option value="coal">coal</option> <option value="another">aluminum</option> . . </select> my test case is: $this->select('resource[]' , ['coal' , 'another']); i error: symfony\component\cssselector\exception\syntaxerrorexception: expected identifier│ or "*", <delimiter "]" @ 11> found. please me . solution got gal: my test case: /**@test*/ public function add_new() { $this->storeinput('resource', ['6pgm+au' ,'coal'], true) ->andpress('submit') } public function storeinput($element, $text, $force = false) { if ($force) { $this->inputs[$element] = $text; return $this; } else { return parent::storeinput($element, $te...

html - Create the same height in a panel-box with a different length of text by bootstrap -

i've created bootstrap theme 4 panel boxes , text in it. 3 of boxes have have 3 snetence in 1 of box 1 sentence. problem is, 3 boxes have different height 1 box little text. is there css option create panel - boxes same height, not matters how text in boxes? edit: here code <div class="container"> <div class="row"> <div class="col-md-3"> <div class="row"> <div class="col-sm-12 text-center"> <div class="panel panel-default"> <div class="panel-heading"> <h3>heading</h3></div> <div class="panel-body "> <p>much text, here :)</p> </div> </div> ...

java - Why would import.sql fail in Spring Boot? -

Image
i've followed this tutorial on spring boot. the guy goes seems same our code. when point view h2 console noticed i'm missing speaker table. i've seen lots of questions on here, blogs everywhere, , seems all have have file in main/resources , works. well, doesn't! some of answers talk persistence.xml and/or configuration file h2. well, don't have , neither tutorial , yet works. i'm finding of seemingly simple things terribly frustrating spring , i'm sick of looking around , finding same answer doesn't work. can shed light on why fail? i can't imagine else need aside pom.xml since tutorial adds import.sql , else claims - works. add more if needed. pom.xml <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache....

android - How to auto scroll up the chat messages (using recyclerview instead of listview) above the softkeypad whenever keypad pop ups? -

like in chat applications whenever want send messages soft keypad pop ups auto scroll last seen messages top of soft keypad provided nothing hidden behind soft keypad. in case keypad hides conversations. how fix issue , have used recycler view displaying messages. used android.support.v7.widget.recyclerview with recyclerview can achieve follows: linearlayoutmanager linearlayoutmanager = new linearlayoutmanager(this); linearlayoutmanager.setreverselayout(true); recyclerview.setlayoutmanager(linearlayoutmanager); this block of code tell recyclerview scroll relative bottom of list shows messages in reverse order in code if getting messages database, read them last message this: cursor c = ...; c.movetolast(); do{ //your code gets messages cursor... }while(c.movetoprevoius()); and when want add new message list add them this: //arraylist messages messages.add(0, message);

objective c - IOS Application Terminating at main file itself NSException -

2015-09-21 10:57:48.696 kip up[4707:140538] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsarraym insertobject:atindex:]: object cannot nil' *** first throw call stack: ( 0 corefoundation 0x00ce6746 __exceptionpreprocess + 182 1 libobjc.a.dylib 0x005b9a97 objc_exception_throw + 44 2 corefoundation 0x00b9bce1 -[__nsarraym insertobject:atindex:] + 881 3 corefoundation 0x00b9b941 -[__nsarraym addobject:] + 65 4 uikit 0x0134bc3b -[uiview(uiviewgestures) addgesturerecognizer:] + 210 5 kip 0x000c0c1e -[viewcontroller viewdidload] + 414 6 uikit 0x0141dd54 -[uiviewcontroller loadviewifrequired] + 771 7 uikit 0x0141e045 -[uiviewcontroller view] + 35 8 uikit ...

What's up with the python tax program I wrote -

what's tax rate program i'm writing precise i'm trying figure out why 2.5% isn't showing on program when run it shows different percentage here's i've got far ` script name: tax program # author : # purpose: purpose of program ask user enter amount of item purchase. # program should compute state , county sales tax. assume # state sales tax 5 percent , county sales tax 2.5 percent. program # should display amount of purchase, state sales tax, county # sales tax, total sales tax , total of sale (which sum of # amount of purchase plus total sales tax) # use value 0.05 , 0.025 # display "enter item_price amount" # input item_price # display "state tax 5%" # set state_tax= 0.05 # display "county_tax 2.5%" # set county_sales tax = 0.025 county_tax = 0.025 state_tax = 0.05 tax_rate= county_tax + state_tax #ask user enter item price , store in item price varible item_price = float(input("please e...

php - Monolog get requested url and simple log on in Laravel 5 -

i have checked official repo of monolog , put below code, working great , getting response in slack. response verbose, how can simple response, without stack trace. and suggested on doc have added $monolog->pushprocessor(new webprocessor($_server)); not giving information requested url , server. class appserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { if ($this->app->environment('production')) { // logger $monolog = log::getmonolog(); // ********************************************************************************************** // have tried official webprocessor url, not giving me // ********************************************************************************************** $monolog->pushprocessor(new webprocessor($_server)); $monolog->pushprocessor(function ($record) ...

php - unable to trace XML API error -

i trying integrate shipping api not working , not returning erro either. trying achieve is, sending customer shipping data in xml format api url , create shipment , return me shipping tracking number. not working , unable trace error, if there any. can please review code , tell me if there issue. info: piece of code, working integrate magento shipment methods. here code.. $xmlns = [ 'soap' => 'http://www.w3.org/2003/05/soap-envelope', 't' => 'http://tempuri.org/' ]; $xml = new simplexmlelement( '<?xml version = "1.0" encoding="utf-8"?><soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" />' ); $body = $xml->addchild("soap:body", null, $xmlns['soap']); $shipinfo = $body->addchild('insertdata', null, $xmlns['t...

php - Loading laravel view with ajax -

i new web development.i using laravel app used blade templates creating pages.i have main blade in header , footer exist , using wrapper.i want of other pages open in without reloading base template , when open page extends main wrapper new view correctly when update page's content ajax content of page doubles footer may because @includes() creates new page within existing 1 want fix double content , footer.please help!here code of pages used load within main wrapper @extends('wrappertemplate') @section('content') <div class="body-content">` , content here </div> @stop i advise unless it's simple use case/playground exercise, don't way, , instead define proper api using laravel, use front end framework react, angular, ember etc etc. interact api , handle dom manipulation/creation. seems v bizarre re-render entire page using html loaded of ajax. there plenty of tutorials on using laravel , various front end frameworks ...

Powershell Split with : but only once -

this question has answer here: only split on first occurence of character 2 answers so, here's text file contains content this: dbsnapshotidentifier : rds:xyz-new-2015-08-17-03-43 dbsnapshotidentifier : xyz-new-2015-08-17-04-43 dbsnapshotidentifier : rds:abc-2015-08-17-03-43 my code: foreach($line in $lines) { $del = $line -split ':' | select-object -last 1 } i trying read entire string (left of :), it's reading entire string in 2nd content. fails 1 , 3. 1 , 3, read value xyz-new-2015-08-17-03-43 , abc-2015-08-17-03-43 respectively (note rds:) omitted. so, want entire string after first :, if multiple :'s found in string. tried -unique that, no luck. tried -last 2, coming 2 single words. need exact string rds:blah_blah_blah can please me on this.? why not? "dbsnapshotidentifier : rds:xyz-new-2015-08-17-03-43" -spli...

logcat - What's the meaning of "faults" in Android ANR log? -

as in following example, besides cpu usage value in each process, there's pair of "faults" values in "minor" , "major". what's exact meaning? anr in com.rescuetime.android pid: 11517 reason: broadcast of intent { act=android.intent.action.screen_on flg=0x50000010 } load: 3.35 / 5.22 / 9.91 cpu usage 0ms 7475ms later 99% awake: 97% 947/system_server: 80% user + 16% kernel / faults: 7489 minor 81 major 0.1% 269/debuggerd: 0% user + 0% kernel / faults: 4711 minor 16 major 7% 1493/com.android.phone: 3.3% user + 3.7% kernel / faults: 3615 minor 10 major 6.5% 1201/com.android.systemui: 3.3% user + 3.2% kernel / faults: 3074 minor 5 major

android - New Lollipop BLE API does not detect all advertising packets -

i have seen few posts same question have no been able solution problem. i see callback function (onscanresult) new ble api detects advertising packets peripheral first time. not see subsequent packets @ all. strange thing happens on few devices. not happen on s4 running lollipop have been seeing issue on 1 plus one. have been able connect peripheral though, using bluetooth gatt methods. i start , stop scan delay of 2 seconds in between. seem work fine if use old api on lollipop devices scanning seems lot slower. if (isscanning) { if (build.version.sdk_int >= build.version_codes.lollipop) { if(first_time) { first_time = false; scanner = bluetoothadapter.getdefaultadapter().getbluetoothlescanner(); settings = new scansettings.builder() ...

PHP Languages and database -

is long question hope can me well have added system switch language on site want make language file dynamyc... i try explain so: i have file create slide on home page: <?php $sql = "select img_url, caption cc_homeslide order position asc"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "<div><figure><div class='dark-effect'><img class='lazyowl' data-src='images/slide_home/fake_img.png' alt='awesone food' style='background-image: url(images/slide_home/". $row["img_url"]. ")' /></div><figcaption>". $row["caption"] ."</figcaption></figure></div>"; } } else { echo "0 results"; } ?> perfect working. want switch $row["caption"] $lang["slide_caption"] why? b...

javascript - ng-enter with out calling any function -

the below code part of todo-list code. the first line input box value accessible through newtodo .the input box used type new task in todo-list. <input class="todofield" id="newtodofield" type="text" ng-model="newtodo" placeholder="add new todo" ng-enter> <button id="todosubmit" class="btn btn-default" ng-click="addtodo()">add</button> there 2 way submit newly typed task name js. 1 .after typing task name clicking add button(the button in second line) of code.which calling addtodo() js function job of adding typed text in todo-list. 2 .after typing task name pressing enter button in input box. the doubt second type method.because ng-enter does't call function. written in end of tag.( if code ng-enter="addtodo()" means have understood) and more on if ng-enter does't call function second method works nicely.how ng-enter model sup...

facebook - FBSDKShare not work in ios 9 -

i use fbsdkshare share image facebook.the code work in ios 8, not ios 9.recently use xcode version 7.0 (7a220) recompile code.i know there has difference between ios version.i have read facebook document , did in document. used last facebook sdk v4.6 , use pod manager fbsdkshare. thanks pods, can debug fbsdksharekit code. found in fbsdksharekit->fbsdksharedialog.m line 546,the slcomposeviewcontroller cannot create in ios 9.the code like: slcomposeviewcontroller *composeviewcontroller = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypefacebook]; not same code same result.the composeviewcontroller nil, have no issue why happen.

php - Access sub folder of module in HMVC Codeigniter -

i have sub folder uploads in module. using hmvc extension codeigniter. structure of application following: modules --mymodule ----/controllers ----/models ----/views ----/uploads -------/images how can access images folder using url? place uploads folder outside of application folder(root directory). so can access <img src="<?php echo base_url(); ?>uploads/images/logo.png" alt=""> i don't think works. tip if folder inside application folder can use apppath <img src="<?php echo apppath ?>uploads/images/logo.png" alt="">

python - Django: How to delete duplicate rows based on 2 columns? -

i found out in this answer can delete duplicate rows (duplication based on n columns) in table raw sql. is there equivalence using django orm ? stuff found in django concerned duplicated based on 1 column only. note : know there way prevent future duplicates (based on several fields) in django, using unique_together field (but didn't know before). thanks. a direct translation sql in other answer django orm: from django.db.models import min # first select min ids min_id_objects = mymodel.objects.values('a', 'b').annotate(minid=min('id')) min_ids = [obj['minid'] obj in min_id_objects] # delete mymodel.objects.exclude(id__in=min_ids).delete() this results in 2 separate sql queries instead of 1 nested sql provided in other answer. think enough.

javascript - jQuery slider doesn't rotate -

i have slider rotator on site doesn't rotate items automatically in boxes - navigation works , rotate want rotate automatically, right after enter site. js: $(document).ready(function() { var nbr = 0; $('.slider').each(function() { var slider = $(this); //get width , height of wrapper , give ul var wrapperwidth = $(slider).width() * $(slider).find('ul > li').size(); $(slider).find('ul').css('width', wrapperwidth); var wrapperheight = $(slider).height(); $(slider).find('ul').css('height', wrapperheight); //set li width var width = $(slider).width(); $(slider).find('ul li').css('width', width); //set counter vars var counter = $(slider).find('ul > li').size(); var decount = 1; var autocount = 1; if (counter > 1) { //create number navigation var createnum = 1; $(slider).after('<ul class="numbers...

special characters - How to properly encode ATG commerce JSON taglib droplet response -

i had problem doing jquery $get list of schools. using rqlforeach droplet retrieve list , specified output json, take returned json , use jquery template render out result. problem seeing following in output king&#39;s which should've been king's school. i used {{html schoolname}} supposed take care of decoding correctly. did not.... the solution problem. problem: encoding , decoding happening twice. first json:object gets output droplet escaping xml. therefore encode & of apostrophe. i.e. reaching client side &amp#39; instead of &#39; . therefore {{hmtl}} not decode correctly answer: set <json:object escapexml="false"> meant time reaches client side in correct format &#39; decoded jquery {{html }} tag.

ruby - Association Issue -

i have 3 models user, club , mcq. in club model. assign club (class) - 9-physics 9-chemistry 10-physics 10-chemistry... here association class user < activerecord::base has_and_belongs_to_many :clubs end class club < activerecord::base has_many :mcqs has_and_belongs_to_many :users end class mcq < activerecord::base belongs_to :club end in student view (student show index) show club (as subject) , after click on subject want show mcq topic of related subject. for club controller - class clubscontroller < applicationcontroller #its show subject list def student_show_index @club = current_user.clubs end #its show topic according subject. def student_show_topic @club = current_user.clubs @mcq = @club.first.mcqs.order('created_at desc') end end so question is, when click on subject physics show mcq of 9th. , same chemistry. i want filtered mcq according subject. you have send params club_id in link ...

Got java.lang.NoClassDefFoundError while learning Spring framework -

i've been searching reason why failed long time, couldn't figure out. the structure of files src |__com.learn.spring.beans.annotation | |__main.java | |__testobject.java | |__beans.annotation.xml main.java package com.learn.spring.beans.annotation; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; public class main { public static void main(string[] args) { applicationcontext ctx = new classpathxmlapplicationcontext("beans-annotation.xml"); testobject = (testobject)ctx.getbean("testobject"); system.out.println(to); } } testobject.java package com.learn.spring.beans.annotation; import org.springframework.stereotype.component; @component public class testobject { } beans-annotation.xml <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans...

sql server - How SQL queries may be optimized -

Image
i have sql server table top_research_areas contains data i.e. aid res_category_id research_area paper_count --------------------------------------------------------------- 2937 33 markov chain 3 2937 33 markov decision process 1 2937 1 linear system 1 11120 29 aspect oriented prog 4 11120 1 graph cut 2 11120 1 optimization problem 2 12403 2 differential equation 7 12403 1 data structure 2 12403 1 problem solving 1 35786 1 complete graphs 11 35786 1 graph cut 10 35786 null null ...

Create Tabs Dynamically Based on Values Selected in Listbox in ASP.Net -

does know how can create tabs dynamically based on selected listbox? this have: listbox: <asp:listbox id="selectionlistbox" runat="server" appenddatabounditems="true" selectionmode="multiple" height="130px" width="350px"> <asp:listitem text="apple" value ="1" /> <asp:listitem text="watermelon" value ="2" /> <asp:listitem text="kiwi" value ="3" /> <asp:listitem text="plum" value ="4" /> <asp:listitem text="pineapple" value ="5" /> </asp:listbox> retrievebutton: <asp:button id="retrievebutton" runat="server" text="button" /> based on user has selected listbox, when user pressed on retrieve button, number of tabs created based on number of values user has selected listbox. for example: let's user has s...

asp.net - Owin AuthenticationMode Active and Passive for different path -

i'm using owin wsfederation authentication. unauthorized users want 1 path redirected sts , return 401 response. possible set different authenticationmode different path? you can "fork" owin pipeline in order configure middleware differently different paths. public void configuration(iappbuilder app) { app.useerrorpage(new errorpageoptions()); app.map("active", active => { active.useopenidconnectauthentication( new openidconnectauthenticationoptions { authenticationmode = authenticationmode.active //todo: add other options. }); }); app.map("passive", passive => { passive.useopenidconnectauthentication( new openidconnectauthenticationoptions { authenticationmode = authenticationmode.passive, //todo: add other options. }); }); } this sample configures ...

LAZY Loading : jQuery -

can lazy load content manually using jquery code. not want code inputs on can possible implementation. as of thinking right now, following 1 example. there table of catalogue get's populated on click when user enter search criterion. ajax call triggered search criterion ajax return 2000 objects , catalogue shows 10 items per page. is possible show 10 items receive ajax (is intervention possible ?) , paint ui on screen while receiving rest of data ajax call. just heads great....

Facebook API Metric - how to get: total photo views, comments, share and link click -

i trying data via facebook api. can get: organic impression (metric: page_impressions_organic) organic paid impression (metric: page_impressions_paid) total likes (metric: page_fans) total video views (metric: page_video_views) what need is: total photo views total shares total link clicks total comments but not know how it. is possible data via metric or different way through facebook api? tell me methods achieve please? thanks

android - want to include Fragments under tabFragment -

i have activity has navigation drawer , tabview viewpager. want open fragments inside tabview according selection in navigation drawer. how navigate fragments according selection mnavigationview.setnavigationitemselectedlistener(new navigationview.onnavigationitemselectedlistener() { @override public boolean onnavigationitemselected(menuitem menuitem) { mdrawerlayout.closedrawers(); if (menuitem.getitemid() == r.id.ap) { fragmenttransaction fragmenttransaction = mfragmentmanager.begintransaction(); fragmenttransaction.replace(r.id.containerview, new fpfragment()).commit(); } if (menuitem.getitemid() == r.id.vfp) { fragmenttransaction xfragmenttransaction = mfragmentmanager.begintransaction(); xfragmenttransaction.replace(r.id.containerview, new veryfinfrag()).commit(); } is possible??

mysql - How to find duplicated rows happening in a short period within a predefined time frame in sql -

i have table following number timestamp 123456 17-09-2015 11:06 455677 17-09-2015 11:09 123456 17-09-2015 11:10 453377 17-09-2015 11:20 123456 17-09-2015 11:35 123456 17-09-2015 11:42 the result should follows: 123456 17-09-2015 11:06 123456 17-09-2015 11:10 every hour, 11:00 12:00, search numbers appear duplicate within 5 minutes. know basic sql commands. have tried duplicate rows within hour. select t.number, group_concat(time) my_table t t.time>=now()-interval 1 hour , t.time <=now() group t.number having count(*)>1; finding duplicate records within 5 minutes in each 5 hours seems complicated me. sql statements can this? in advance. following query give list of repetitive number every 5 min interval: select number,group_concat(date_time) t1 group floor(unix_timestamp(date_time)/(5 * 60)),number having count(*)>1; verify result @ http://sqlfiddle.com/#!9/75ea0/...

c - quicksort program provides partially sorted output -

below simple quick sort code last element pivot,almost works except last element fails sorted. thoughts program went wrong? here's output: $a.out 4 3 5 2 1 3 2 3 //input 1 2 2 3 3 3 5 4 //output simple swap looks fine void swap ( int* a, int* b ) { int t = *a; *a = *b; *b = t; } hmm..fine ..may issue end ? int partition(int a[],int start,int end){ int pivot = a[end]; int pindex=start;int i; ( i=start; <= end-1; i++){ if (a[i] <= pivot){ swap(&a[i],&a[pindex]);pindex++; } } swap(&a[pindex],&a[pivot]); return (pindex + 1); } surely looks good. void quicksort(int a[],int start,int end){ int pindex; if (start < end){ pindex = partition(a,start,end-1); quicksort(a,start,pindex-1); quicksort(a,pindex+1,end); } } simple main call int main(){ int a[8] = {4, 3, 5, 2, 1, 3, 2, 3}; int i=0; for(i=0;i<8;i++) printf(" %d",...

java - Multiarray inputs -

i unable create loop add hours multi-array. when use method hours there error. suspect for-loop not capturing input. import javax.swing.joptionpane; public class gain { // defining array names. string[] name = {"a", “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “l”}; int[][] hours = new int[10][3]; public final int hours() { boolean canceled = false; (int index = 0; index < name.length; index++) { joptionpane.shoemessagedialog(“please enter " + name[index] + “’s hours”); (int x = 0; x <= hours.length; x++) (int y = 0; y <= hours[x].length; y++) integer value = promptforint(artist[index] + “’s first hour: ”); if (value != null) { while (value < 0) { joptionpane.showmessagedialog(null, "please positive figures." + "\nplease try again."); value = promptforint(name[index] + “’s first hour: ”); } pay[...

excel - MAX function with VLOOKUP -

Image
i need able see last date each reference , gender (if any) associated reference , last date. need perform in function rather vba. data: a0001 11/06/2002 f a0001 21/02/2012 f a0001 11/06/2002 m a0001 21/02/2012 m a0001 21/02/2012 a0002 20/05/2002 f a0002 20/05/2002 m a0002 20/05/2002 f a0002 20/05/2002 m a0002 11/04/2007 f a0002 11/04/2007 m i've been banging head against lookup, address, index, match, max functions morning , have headache, please put me out of misery. first off if can use pivot table, drag item number rows, gender rows, , date values. click on arrow next date in values section. choose value field settings, choose max, go number format, , choose date. ask. now, if must use formulas (this amusing item number in column a, date in column b, , gender in column c) =max(if($a$2:$a$11=$e2,if($c$2:$c$11=f$1,$b$2:$b$11))) which require control shift enter.

javascript - Codeigniter: The default value of a text input field if data is not returned from the controller -

i have text input populated values database passed controller. how have done it: <input type="text" class="form-control" id="groupname" name="groupname" disabled value="<?php foreach ($result $r) { echo $r->group_name; };?>"/> <br>` this code should executed once search button clicked , working well. problem is, every time load view,this input field loaded meaning code executed , since have not searched anything, giving me error. how can set default value of input box null/empty default or if no value returned controller. am newbie. appreciated. you can check whether search performed or not checking array <input type="text" class="form-control" id="groupname" name="groupname" disabled value="<?php if(isset($result) && !empty($result)){ foreach ($result $r) { echo $r->group_name; } };?>"/> <br>` explanation ...

reactjs - Responding to high frequency state changes in React.js / Flux -

i have application receives messages server every 1 second , via socket.io these messages broadcast react component. my react component using flux style architecture, calls action when message received adds (or updates) record in collection in store. my component monitors changes on store , updates ui when changes. in case, draws marker on map. the problem due frequency of updates component redraws markers every second, don't want. i'm looking approach allow map component respond changes in collection in store, not have state update every second. i thought have collection raw data, , update networkgps collection selectively in store, component seems change based on property in store seem part of state. in summary i'm looking to: collect data every 1 second in raw form , add data store. bind component collection in store update when changes require ui redraw. what think need do: either: avoid putting raw data state of store (at moment i'm unsu...

c++ - Threaded timer, interrupting a sleep (stopping it) -

i'm wanting reasonably reliable threaded timer, i've written timer object fires std::function on thread. give timer ability stop before gets next tick; can't ::sleep (at least don't think can). so i've done put condition variable on mutex. if condition times out, fire event. if condition signalled thread exited. stop method needs able thread stop and/or interrupt wait, think it's doing right now. there problems however. thread isn't joinable() , condition signalled after timeout before it's put wait state. how can improve , make robust? the following full repo. wait 10 seconds here program should terminate foo created , destroyed. not. #include <atomic> #include <thread> #include <future> #include <sstream> #include <chrono> #include <iostream> class timer { public: timer() {} ~timer() { stop(); } void start(std::chrono::milliseconds const & interva...

java - Math.round gives a decimal number in android -

i have fuction: enemigo.posz = 5.1529696e8 //this value @ runtime, it's float. double posicionz = math.round(enemigo.posz*100.0f)/100.0f; and output, why? should round integer! posicionz = 2.1474836e7 an integer lot of digits begins 21474... should clue! java has 2 versions of math.round() : public static int math.round(float a) // float -> 32-bit int public static long math.round(double a) // double -> 64-bit long let's @ code: double posicionz = math.round(enemigo.posz * 100.0f) / 100.0f; since enemigo.posz float, first version used. wants return enemigo.posz * 100.0 , or 51529696000.0, 32-bit int, can't because overflows. returns integer.max_value , or 2^³¹ - 1 = 2147483647. divison 100.0f returns 21474836.0, 2.1474836e7.

java - how to get userid and password from database and pass to Method in Spring MVC -

<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>user login.</title> </head> <body> <h4>user login.</h4> <form:form method="post" name="loginform" action="login-check"> <table> <tr> <td>user name:</td> <td><form:input path="name" value="${form.name}"/></td> </tr> <tr> <td>password:</td> <td><form:input path="password" value="${form.password}"/></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" value="submit"></td> </tr> </tabl...

javascript - jquery offset incrementing previous value on .hide() -

setting position jquery.offset() not behaving expect. example code attempts overlay div (.slide) (.active) div on hover. understand offset({top,left}} set position of element {top, left} incrementing position amount each time. as exercise - if set active block display:block , remove active.hide() statement positioning works expect. .hide() appears causing offset accumulation. im grateful guidance. http://jsfiddle.net/laurencefass/q815mqkm/ $(".slide").mouseenter(function (e) { $(this).css("background-color", "red"); offset = $(this).offset(); } more code follow link... see fiddle edited code overlay div on top of hovered div. assume wanted. see updated fiddle . in code setting top:1 , left:1 not true div's @ different positions , need use offsets instead of using 1 , 1 every time , setting offset defined setting coordinates(position) of element make work element should made visible @ first instance set coordinates activ...

ruby on rails - Updating nested_attribute on a model, doesn't update the has_many through relationship -

i have following model relationship: class role < activerecord::base has_many :permissions_roles, inverse_of: :role, dependent: :destroy has_many :permissions, through: :permissions_roles accepts_nested_attributes_for :permissions_roles, allow_destroy: true end class permissionsrole < activerecord::base belongs_to :permission belongs_to :role end permission class has id , name etc. i using rails 4.2.4 , facing error update method of role model. when update nested attribute permissions_roles , doesn't update has_many :through permissions attribute of model. did verify error in rails console: > role = role.create(name: 'role', permissions_roles_attributes: [{permission_id: 1}]) # checking permissions role > role.permissions [#<permission:0x007ff3c3963160 id: 1, name: "read">] # updating nested attributes > role.update(permissions_roles_attributes: [{permission_id: 10}]) # checking nested attributed - return expected ...

javascript - app.route not working in browser while working fine in mobile - Polymer1.0 -

i have polymer 1.0 app. in routing.html file have following configuration routes. page('/applications', function () { app.route = 'applications'; }); page('/claims', function () { app.route = 'claims'; }); i have applied data-routes attr in index.html file map corresponding section part. for ex: <a data-route="claims" href="/claims"> <iron-icon icon="report-problem"></iron-icon> <span>claims</span> </a> <section data-route="claims"> <div class="vertical layout center"> <div> <p>getting claims...</p> <paper-progress value="10" secondary-progress="30" class="" indeterminate elavation="4"></p...

spring batch - Skip step based on job parameter -

i've read through spring batch docs few times , searched way skip job step based on job parameters. for example have job <batch:job id="job" restartable="true" xmlns="http://www.springframework.org/schema/batch"> <batch:step id="step1-partitioned-export-master"> <batch:partition handler="partitionhandler" partitioner="partitioner" /> <batch:next on="completed" to="step2-join" /> </batch:step> <batch:step id="step2-join"> <batch:tasklet> <batch:chunk reader="xmlmultiresourcereader" writer="joinxmlitemwriter" commit-interval="1000"> </batch:chunk> </batch:tasklet> <batch:next on="completed" to="step3-zipfile" /> ...

iphone - After updating to iOS 9 my device is not supported by Xcode 6.4 -

the ios 9 (my device ios) update not supported xcode 6.4 testing purposes. there way connect device xcode testing? it showing me these messages: iphone may running version of ios not supported version of xcode. xcode 6.4 doesn't contain ios 9 sdk, that's why isn't working. need update xcode 7.0 (available on appstore)

C auto start program on windows can't use files -

i create program auto start windows, using registry: current_user\microsoft\windows\currentversion\run when windows starts, program starts too, problem on auto start can't manipulate files, when open program can everything. using getlasterror can see error code 5: access denied, strerror return "access denied" , using formatstring message like: "error description 5: access denied. can explain why hapening? the program starting system32, create files in exe dir, better use getmodulefilename .

angularjs - How to add an Icon in a angular select directive? -

i have simple angular select show many options , need include glyphicon each row. <select name="service" required class="form-control" ng-change="selectservicetype(selectedservicetype)" ng-model="selectedservicetype" ng-options="type.name | translate type in eqtypes"> </select> what best way add glyphicon angular select?

regex - Text replacement in all the files in a directory -

in windows 2008, have multiple files in directory. files having paths contents , texts should replaced other string.find example below: the files having paths like: file1: c:\apps\ etc\a1 \x.exe should replaced c:\apps\ exe \x.exe file2: c:\apps\ etc\b1 \y.exe should replaced c:\apps\ exe \y.exe i trying find single command replace bold lettered strings mentioned above. in case of normal strings use below command , works: perl -i.bak -pe "begin{@argv = map glob, @argv} s/string1/string2/g" ./*.txt but current requirement seems use regular expression not able find solution. just replace etc\ followed \ again exe: 's/etc\\[^\\]*\\/exe\\/g'