Posts

Showing posts from January, 2011

java - Can spring boot be told to start an application only if a resource is available? -

i part of team developing spring boot backend application, provides mobile applications data. along new feature need of loading resource @ backend, need provided mobile application arose. due fact resource important , making access resource effective loading once during startup, wondered if can tell spring boot not start without resource existing in file system. know annotation @postconstruct, loading resource there seems late. thanks in advance suggtestions @postconstruct can used make sure application has stuff need when starts db pooling etc. example, can throw illegalstateexception() if file not there , can stop application loading. ran quick test , works. can use them below. @postconstruct public void setup() { // check stuff need. if (condition) { throw new illegalstateexception(); } }

xml - Java-Handling empty nodes in DOM -

i using java dom parse xml file, format elements , output csv further processing later. want skip on nodes empty or id attribute null , i'm not sure how go this. below exerpt source code, if want full listing let me know! ... setup ... list<employee> emplist = new arraylist<>(); nodelist = document.getdocumentelement().getchildnodes(); (int = 0; < nodelist.getlength(); i++) { node = nodelist.item(i); if (node instanceof element) { employee emp = new employee(); emp.id = node.getattributes().getnameditem("id").getnodevalue(); nodelist childnodes = node.getchildnodes(); (int j = 0; j < childnodes.getlength(); j++) { ... identify child tags , add list. thanks, shaw

html - Css selector .a.b how do i exclude it from selecting a.b.c? -

i have inherited markup similar html below. <div class="a b">how_can_i_select_ab_only</div> <div class="a b disabled">how_can_i_select_ab_and_disabled_only</div> i want select both elements individually. css selector .a.b selects both divs <div class="a b">how_can_i_select_ab_only</div> <div class="a b disabled">how_can_i_select_ab_and_disabled_only</div> what selector select class a.b.disabled , class a.b ? three ways how it: the first one, set styles .a.b , them remove them (override) .a.b.disabled . .a.b {color: red;} .a.b.disabled {color: grey} https://jsfiddle.net/p84s61gp/ the second way, use attr selector. [class='a b'] {color: red} https://jsfiddle.net/p84s61gp/1/ next, can use :not selector, support since ie9. .a.b:not(.disabled) {color: red} https://jsfiddle.net/p84s61gp/2/

adobe analytics - Google Tag manager code added with the help of DTM is not working -

i had request add google tag manager our website , added using dynamic tag manage (dtm). created page load rule , added script. client saying not working dtm adds code page iframe. there way can fix issue? alternative directly add in page. don't want go in route have update our page templates these tags. avoid adding tag manager code in other tag containers. built standalone tag management solution , google won't provide support if it's embedded in 3rd party solution. your best option select 1 tag management solution , stick that. having multiple tag managers kind of defeats purpose, no?

local videos on android not playing when device resolution is lower -

i'm working on android app needs display videos. client gave me mp4 videos (that have 1 of accepted android formats) , play on nexus 5. but when tried devices have lower resolutions, don't have image anymore (they're black) , sound playing. pop says "cannot play video". videos work if lower resolution (it seems cannot above device resolution) what best strategy make sure videos play @ least devices have resolution ~480x800 ? make different versions of them , place them in dpi folders ? or convince client stream them online ? i'm using videoview display them , place them in raw folder of resources. code looks this: setcontentview(r.layout.videoactivity); videoview videoview = (videoview) findviewbyid(r.id.videoview); mediacontroller mc = new mediacontroller(this); videoview.setmediacontroller(mc); videoview.setvideopath("android.resource://" + getpackagename() + "/" + r.raw.asset1); videoview.requestfocus(); videoview.start(); ...

java - Keep the order of the map as in the arrayList before -

this question has answer here: java class implements map , keeps insertion order? 6 answers i trying merge line toghether create data programm. curently merging part of string s in arraylist 's buffer works when output content of map getting of string in arraylist 's buffer . is there way keep order of string s in arraylist buffer ? output: nathan marcus adler [04:43, 05:43, 12:11, 12:41, 19:11, 19:41] dukes of bedford [04:56, 05:56, 12:24, 12:54, 19:24, 19:54] prince albert [04:48, 05:48, 12:16, 12:46, 19:16, 19:46] joseph addison [04:41, 05:41, 12:08, 12:38, 19:08, 19:38] william baker [04:52, 05:52, 12:20, 12:50, 19:20, 19:50] the ouput should looks this: joseph addison [04:41, 05:41, 12:08, 12:38, 19:08, 19:38] nathan marcus adler [04:43, 05:43, 12:11, 12:41, 19:11, 19:41] prince albert [04:48, 05:48, 12:16, 12:46, 19:16, 19:46] will...

pause audio clip in java -

i have code 2 classes mplayer , audio. mplayer has gui (jbuttons, jpanel , jframe etc), , audio has code play audio. problem when call pause method in class mplayer, not pause audio. can me it? mplayer.java: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class mplayer extends jframe implements actionlistener { imageicon icon1, icon2, icon3, icon4; jpanel pan1; jframe frame; jmenubar bar; jmenu menu; jmenuitem menuitem; jbutton btn1, btn2; public void initgui() { bar = new jmenubar(); menu = new jmenu("open"); bar.add(menu); menuitem = new jmenuitem("open"); menu.add(menuitem); borderlayout bl = new borderlayout(); flowlayout fl = new flowlayout(); pan1 = new jpanel(); frame = new jframe("music player"); frame.setlayout(bl); pan1.setlayout(fl); frame.setjmenubar(bar); icon1 = new i...

objective c - Table reloadData can cause crashes -

very (once week'ish) crashlytics reporting crashes such fatal exception: nsrangeexception -[__nsarraym objectatindex:]: index 7 beyond bounds [0 .. 1] [musiclist tableview:heightforrowatindexpath:] i'm wondering if these occurring due data being reloaded before table finishes rendering, when requests piece of data has been removed , not yet been re-inserted? if case, best remove reloaddata call viewwillappear , place in viewdidappear ? displaying potentially old data, refreshing newer content might jarring end user. this code far controller: @implementation musiclist - (void)viewdidload { [super viewdidload]; [self settitles:[[nsmutablearray alloc] init]]; [self setdata: [[nsmutablearray alloc] init]]; } - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; dispatch_queue_t loadmusic = dispatch_queue_create("loadmusic", null); dispatch_async(loadmusic, ^{ nsmutabledictionary * data = [music getmu...

ios - How to lock/unlock cross thread -

for code snippets, want execute 1 one, like: self.coredatalock = [[nsrecursivelock alloc] init]; // snippet 1 [self.coredatalock lock]; [childcontext performblock:^{ // [self.coredatalock unlock]; }]; // snippet 2 [self.coredatalock lock]; dispatch_group_notify(group, dispatch_get_main_queue(), ^{ // [self.coredatalock unlock]; }); but can't lock/unlock nsrecursivelock cross thread, how figure out?

linux - chrome stopped listen to xdotool bindings after system update -

after ran pacman -syyu , running: xdotool search --onlyvisible --name 'chrome' windowfocus key "ctrl+f" command got broken. the thing finds chrome window correctly - gets focused, , if gets focused on text input field - after running upper command types f it. looks chrome somehow strips control out of xdotool key command. same thing other chrome commands. if type control+f manually while focused on chrome window, works should, not problem chrome shortcuts changed. happened after yesterdays system update, knows cause such behavior? thx.

javascript - Dojo fallbacks for IE9 -

i need dojo. website i'm working on build using dojo. need make fallback css3 transitions/animations in ie9. required use dojo not jquery. so, how can implement fallback using dojo? this css3 property have fallback for: div#mainnav.opensubnav, .opensubnav div#mainnav { -webkit-transform: translate(300px, 0); -moz-transform: translate(300px, 0); -ms-transform: translate(300px, 0); -o-transform: translate(300px, 0); transform: translate(300px, 0); } you should @ http://dojotoolkit.org/reference-guide/1.10/dojo/fx.html it animations...

How do you click a menuItem in NavigationView on Android when testing with Espresso? -

how click on menuitem in navigationview design library using espresso? works fine on larger devices whole menu visible in landscape or smaller devices bottom of menu off screen , can not figure out way scroll/swipe these menuitems can click on them. calling: onview(withtext(r.string.contact_us)).perform(scrollto()).check(matches(isdisplayed())).perform(click()); generates following: caused by: java.lang.runtimeexception: action not performed because target view not match 1 or more of following constraints: (view has effective visibility=visible , descendant of a: (is assignable class: class android.widget.scrollview or assignable class: class android.widget.horizontalscrollview)) target view: "navigationmenuitemview{id=-1, visibility=visible, width=888, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root...

javascript - Hide a table using jQuery -

i keep table hidden @ time of loading. later slidedown table show when link clicked.i write code hide table. $('.table_div').hide(); i placed table in div. hide div. my problem @ time of loading first table display moment table hide. prevent display. thanks to prevent add css property .table_div .table_div { display: none; }

java - Jboss 7.1.1 correct hibernate dependencies -

i'm reviewing pom.xml of old project i'm trying run on jboss 7.1.1. pom contains lot of dependencies artifacts like: hibernate-core hibernate-validator hibernate-jpa-2.0-api hibernate-entitymanager ... as jboss 7.1.1 has module org.hibernate i've managed remove these dependencies except of hibernate-core creating \meta-inf\jboss-deployment-structure.xml following content: <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="org.hibernate"/> </dependencies> </deployment> </jboss-deployment-structure> so in order able compile war file need have dependency <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-core</artifactid> <version>${hibernate.version}</version> </dependency> but can't understand why can...

javascript - how to restructure a array of arrays into a array of objects -

i need structuring new json array of objects. starting array of arrays. need end array of objects. javascript or linq.js work perfectly. thanks this starting with var needtochangethisarray = [ [1558, 219561], [2520, 438218], [3482, 656874], [4444, 875531], [5406, 1094187] ]; this how array needs structured var needstolooklikethisarray = [ { "name": "arbor vista - arbor custom homes", "subid": "10394", "bldid": "8598" }, { "name": "arbor vista - dr horton - (or)", "subid": "10394", "bldid": "8597" }, { "name": "copper canyon estates - brentwood homes", "subid": "9048", "bldid": "16737" }`enter code here` ]; so need end this var needtoendupwiththisarray = [ { "sqft": "1558", "price": "219561" }, { "sqft": ...

c# - How to set group of a new user? -

Image
this might seem easy question, can't figure out answer. i have user table , groups table in database looks this: as can see both connected each other. groups table contains following entries: administrator support purchasing selling now want add new user following code using entity framework: private void adduser() { using (var context = new azubitestentities()) { var user = new benutzer(); user.name = username; user.passwort = generatehashpassword(); user.gruppen = ??? user.anlegedatum = datetime.now; user.loeschdatum = null; user.erstellerid = 1; context.benutzer.add(user); context.savechanges(); } } how can set group of user? since miss direct one-on-many foreign key gruppenid in benutzer table, assume you're using many-to-many middle table. in case (where don't see middle foreign key) have group database , assign user.gruppen property. private voi...

python - How can I use a CAST in an ExcludeConstraint in SQLAlchemy? -

in postgresql can create table exclusion constraint involving cast (the cast necessary because uuid type doesn't have default operator class gist ): create extension btree_gist; create table example ( id uuid, some_range int4range, exclude using gist (cast("id" text) =, some_range &&) ); i can't figure out how accomplish same thing in sqlalchemy. tried this: from sqlalchemy import * sqlalchemy.dialects.postgresql import ( uuid, int4range, excludeconstraint, text ) class example(base): __tablename__ = 'example' id = column(uuid) some_range = column(int4range) __table_args__ = ( excludeconstraint( (cast('id', text), '='), ('some_range', '&&') ), ) but error sqlalchemy.exc.argumenterror: can't add unnamed column column collection . how can sqlalchemy use cast in excludeconstraint ? alternatively, how can use raw sql define exclu...

Basic JSON formatting using Mule Expression Language -

when sending post requests address on slack, json needs formatted such: {"channel": "#testing", "username": "test", "text": "subject"} or of sort, normal. problem i'm having basic, basically, need send details obtained email via json, this: {"channel": "#testing", "username": "#[message.inboundproperties['from']]", "text": "subject"} and when log payload after this, get: {"channel": "#testing", "username": ""doe, john" <email@address.com>", "text": "subject"} and throws 500 error code, presumably because no longer valid json (my guess because of weird quotations, if else , this: {"channel": "#testing", "username": "username", "text": "#[message.payload]"} gives me this: {"channel": "#te...

c# - ASP.NET Webforms project is reading from a web.config in a completely different solution on my PC when debugging -

my web app reading web.config different project same name in solution. how can check/change web..config project referencing. want ensure web.config in current project. if it's got same name (copy of project?), maybe debugging settings same, e.g. use same iis express port number? once start project iis express remember code is. if stop project, open , run using same port number confused , view code first project.

javascript - How to call a function repeatedly after it finishes? -

i want call function main() contains lot of asynchronous db-connection calls. want call function repeatedly after iteration of main() gets finished. how should in nodejs? think there way use promises on here this. not able think in correct direction. use promise.all wait promises finish. https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/promise/all afterwards can call .then(main) function main() { var promises = []; promises.push(...); promises.push(...); ... promise.all(promises).then(main); }

c++ - Why can't I call protected virtual base class function in the derived class overridden function? -

class base { protected: virtual void show() { // stuff. } }; class derived : public base { protected: virtual void show() { // stuff. } }; class derived_2 : public derived { protected: virtual void show() { this->show(); // error: base::show() in accessible show(); // error: base::show() in accessible derived::show(); // error: base::show() in accessible } }; in above case calling virtual base class function (overridden in derived classes) gives error. the error can find, call show itsel leading infinite recursion , ending in stack overflow error. but code compiles , run without warning : class derived_2 : public derived { public: virtual void show() { //this->show(); // infinite recursion => stack overflow base::show(); // ok calls show() base derived::show(); // ok calls show() derived std::cout << "derived2...

Appium iOS automation using Java : get element using accessibility Id? -

i new ios automation using appium. can access elements , automation using xpath this driver.findelement(by.xpath("//uiaapplication[1]/uiawindow[2]/uiasecuretextfield[3]")).click(); i access elements using accessibility label name given. when using appium inspector can see accessibility name displayed under parameter value . how access value using java code? thanks. you should able use findelementbyaccessibilityid(string using) method in java. more info on here: http://appium.github.io/java-client/io/appium/java_client/findsbyaccessibilityid.html

api - Idempotent PUT in a concurrent environment -

context i have rest api multiple clients (applications) can update state of resource put. example, resource lamp can turn on or off . this resource automatically updated system when detects electricity failure has occurs, leading have lamp in broken state. want made distinction between broken , off , lamp in broken can not turn on ! problem i use put method this, put http://address:port/my_lamp { "state": "on"} but not sure if respect idempotent property of put method. in fact, have 3 cases: the lamp on . above code leads on state. the lamp on . above code leads on state.... cool! @ moment, idempotency still guaranteed :-) ! the lamp broken . above code leads error, 503 service unavailable question i not sure correctly understand notion of idempotency. trust me, read lot of thing still little bit confused. in understanding, multiple put leads same state of resource: not guaranteed in case due broken but understand in other wa...

How to handle empty parameters in a main method java call -

i have dynamic way of passing in parameters java main method call done via command line(cmd) runnable jar file. @ moment main() method takes 6 parameters , sets each 1 variable before calling method variables passed in. what id way give user ability pass 5 or less paramters command line , have safely handle missed parameter setting null or empty string("") value. for example, if ran command below, should know set missing parameters have not specified(clientname , outputfolder), empty string. java -xmx1024m -jar mainapp.jar "summary" **<missing>** "2015-06-07" "https://12345.bp.com/bp/" "c:\\parameters.txt" **<missing>** here code have main method: public static void main(string[] args) { try { string dtype = args[0]; string clientname = args[1]; string cyclestring = args[2]; string mspsurl = args[3]; string inputfile = args[4]; ...

go - Golang : gocraft/health package 100% CPU -

im using gocraft/health check health of service , have metrics of each endpoint. have problem: cpu reach 100% after 5 hours of starting service dont know why. without using " gocraft/health " takes 0,7% of cpu worked pack before var stream = health.newstream() func main() { // log stdout! (can use writersink write log file, syslog, etc) stream.addsink(&health.writersink{os.stdout}) http.handlefunc("/api/getvastplayer", vastplayer) http.handlefunc("/static/", func(w http.responsewriter, r *http.request) { http.servefile(w, r, r.url.path[1:]) }) log.println("listening...") panic(http.listenandserve(":2001", nil)) } ; func vastplayer(w http.responsewriter, r *http.request) { job_1 := stream.newjob("/api/getvastplayer") //job_2 := stream.newjob("/api/html/") sink := health.newjsonpollingsink(time.minute*5, time.minute*5) stream.addsink(sink) ...

c# - Implementing nested If-cycles in a winform -

for example have nested if-cycle in console like if (answer == "one") { console.writeline("one or two?"); string answer = console.readline(); if (answer == "one") { console.writeline("pressed1"); } else console.writeline("pressed2") //....and on } everything works fine. if try same in winform, turns out pressing button1 i nested results marked "btn1".so getting "pressed 1 pressed 1" . how can make program stop same way stops in console console.readline()? if (btn.name == "btn1") { richtextbox1.appendtext("pressed1"); if (btn.name == "btn1") { richtextbox1.appendtext("pressed1"); } else (btn.name == "btn2") { richtextbox1.appendtext("pressed2"); } the posted code fragment isn't full, it's easy speculate confusion is. basically, console applic...

c# - Auto Increment ID in Composite key Entity Framework -

i have 2 class these public partial class master { [key, column(order = 0)] public int idmaster { get; set; } /*more fields*/ } public partial class detail { [key, column(order = 0)] public int idmaster { get; set; } [key, column(order = 1)] [databasegenerated(databasegeneratedoption.identity)] public int id { get; set; } } i want auto-increment id in way: |----------|-----------| |masterid | id | ------------------------ | 1| 1| | 1| 2| | 1| 3| | 1| 4| | 2| 1| | 2| 2| | 2| 3| | 2| 4| ------------------------ how can in entity framework a lot of help edit: have want increment id mentioned: |----------|-----------| |masterid | id | ------------------------ | 1| 1| | 1| 2| | 1| 3| | 1| 4|...

php - What is the best way to refresh some script function every XX minutes? -

i working on football odds website first time. i getting xml data online xml feeder , parsing xml data using php , send data mysql database , php file data , print on html document . xml feeder has time limits each function, example: time limit league 3600s, time limit live fixture 25s etc.. i send data using 1 file called sendxmldata.php, there functions like: sendleaguestodb (), sendfixturestodb () etc.. and want run these functions every xx-xxxx seconds, each function has different time limit. how can run functions every xx seconds, need run , when users not on website? what best way this? using cron job or how? if answer yes , use cron , there way run function file 25s, , same file 3600s? or need every function or time_limit create new php file run? there functions. thanks. you can create 2 cronjobspointing same file @jquery.php.magento.com pointed out. can pass argument choose witch function call: 1 * * * * /path_to_php/cronjob.php variable1=t...

string - Perl and Regex - single line mode matching -

why doesn't perl -ne "print if /(<conn)([\s|\s]+?)(>)/sg;" /path/to/file match <connector port="port" protocol="http/1.1" sslenabled="true" maxthreads="150" scheme="https" secure="true" clientauth="false" sslprotocol="tls" />` when match <connector port="port" protocol="ajp/1.3" redirectport="port" /> and need match both same regex? the -n option reads file line-by-line, can alter line whole file undefining input line terminator. that's done using local $/; , or using command line option -0777 follows: perl -0777ne 'print "$1\n" while /(<conn.+?>)/sg;' /path/to/file it reads in whole file @ once. if that's problem, try setting $/ > (since pattern ends in > ) or -o076 on command-line: perl -076ne 'print "$1\n" if /(<conn.+?>)/sg;...

javascript - jQuery deferred array not triggering .done() as expected -

i'm having trouble jquery deferreds. here's code: function makeajaxcalls(purge){ var deferreds = []; // delete documents _.each(purge, function(element, index, list){ console.log('purging '+element.model+' id='+element.id); deferreds.push( $.ajax({ type: 'delete', url: '/api/admin/purge/'+element.model+'/'+element.id }) ); }); console.log('returning array '+deferreds.length+' deferreds'); return deferreds; }; function purgedeleteddocs(){ console.log('purging...'); var purge = []; _.each(arrayofids, function(element, index, list){ purge.push({'model': arrayofmodels.get(element).get('modelname'), 'id': element}); }); // [{model: 'modelname', id: 'id'}...] // when *all* ajax calls resolved run code $.when.apply(this, deferreds).done(function(){ console.log('done'); }); var deferreds = mak...

jQuery Ajax calling XML with Xinclude -

so got 3 levels of xml: app.xml includes 4 categories (xml-files). each category includes number of entries. the including part right done xinclude. my script runs ajax function getting first xml, app.xml right now, won't see through xinclude. clarify, alerts 'yes' , 'app' not 'cat'. in console.dir xml see xi:include, not what's in files. do need parse somehow? xinclude not work, or can include in better way? script.js $.ajax({ type: "get", url: "xml/app.xml", datatype: "xml", success: function(xml) { alert('yes'); $(xml).find('app').each(function(){ alert('app'); var test = $(this); console.dirxml(xml); $(this).find('category').each(function(){ alert('cat'); }); }); }, error: function() { alert("the xml file not processed correctly...

javascript - What is the best practice for sending password from frontend to API server? -

i implementing web application composed javascript front end (single page application if prefer), , rails backend. the front end app make request through api server, want know best practice sending password on login or password reset. should send clear password, or should send hash? i think both of 2 solutions have drawbacks: if hash password js, user have code in browser , can understand how secure password. if keep clear, beh, clear , can intercepted. as long you're using https password cannot intercepted. well.... won't intercepted. tactics have use in order capture password out of control. user have sure connected site. i suggest reading this answer well . he goes on take in order intercept https communication. responsibility make sure site serves on https , have valid certificate.

mysql - SQL query to obtain last proximate occurrence of a row (by timestamp) with a particular property -

this question regarding mysql table. suppose have change log table, reach row represents change of given type made on object user. e.g., table named changes : object_id type value timestamp 1 update_name test1 1/1/15 1 update_site site1 1/1/15 1 add_budget $10 1/1/15 1 add_expense $5 1/1/15 1 update_time 10 1/20/15 1 update_time 8 1/31/15 2 update_name site2 1/2/15 2 remove_budget $2 2/1/15 2 update_name newsite2 2/15/15 1 update_time 12 2/7/15 1 update_name newtest1 2/7/15 1 add_expense $4 2/7/15 suppose wanted find changes object_id 1 on 2/7/15: select * changes object_id=1 , timestamp='2015-02-07'; i back: 1 update_time 12 2/7/15 1 update_name newtest1 2/7/15 1 add_expense $4 2/7/15 suppose wanted understand in single query matching results, last proximate change matching type same object_id. so, example, while seeking 3 rows in above query 2/7/2015, i'd following rows (in single query):...

Android accelerometer detect device lying still -

i developing application android supposed check whether device lying still. has work when lay device on flat surface. this has work when device lying still on either side of device. while holding device still in hand check should fail. because small movement hand/arm should enough detect movement. i've tried on , on still seem fail in doing so. happens data receive sensoreventlistener fluctuating heavily. data below represents data device while lying still on flat surface. 0.07366191 0.056904275 0.034122672 0.047471035 0.080519415 0.07816742 1.2434766 0.34602648 0.25965866 0.52344894 0.14806636 i've tried following: 10 second calibrate while lying flat on table, storing calibrated value , use threshold. fixed thresholding based on math.sqrt(ax * ax + ay * ay + az * az) results. using either type_linear_acceleration or normal type. using gravity (9.8) threshold. at point don't know anymore. hope can me out. in advance. i'm not sure kind of...

javascript - Using Devbridge Autocomplete, is there a way to detect no results? -

i'm using devbridge autocomplete ( https://www.devbridge.com/sourcery/components/jquery-autocomplete ) on input field type text , reading results array. is there way to: 1) allow select list of results , not type else in field 2) if no results found, trigger function code: var people = ['ross chapman', 'curtis gomez', 'dolores gonzales']; $('.people').autocomplete({ lookup: people }); you can use onsearchcomplete method mentioned in docs here . onsearchcomplete: function (query, suggestions) {} second parameter suggestions array of suggestions letters being typed in input. checking suggestions.length can catch condition when suggestions array empty, meaning no results found. var people = ['ross chapman', 'curtis gomez', 'dolores gonzales']; $('.people').autocomplete({ lookup: people, onsearchcomplete: function (query, suggestions) { if(!suggestions.length){ ...

javascript - Click a button to change the text of text input -

i have part of code in codeigniter controller named 'ajaxcalls' : public function show_contact_persons($client_id) { $data['contact_persons'] = $this->common_model->select_records('ci_contact_persons', 'client_id', $client_id); //dump($data); function echoarray ($array) { foreach ($array $key => $value) { if ( true == is_array($value) ) { echoarray($value); } else { if ($key == 'contact_person_name') { echo '<input type="button" value="'.$value.'" onclick="changecontact(987)" /><br />'; } } } } echoarray($data); } and js part @ page calling php file : function changecontact(contact_name) { document.getelementbyid('contact_person').value = contact_name; ...

html - Image appears then disappears -

fiddle i need have image inside 2 divs, why appear , disappear? i need it's on screen. <div class="ad-container"> <div class="ad-item"> <img src="http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg"/> </div> </div> panthro, check , make sure there no javascript , other code manipulating classes: ad-container , ad-item. the snippet of code provided in fiddle looks fine me. there must other code manipulating classes.

function - How to create both onClick and mouseover to a link jQuery -

i have script change main image on click link .feature_thumb class. want make it's both click , hover. $(".feature_thumb").click(function(){ var main_href = $(this).attr('href'); change_image(main_href ); }); can me this? i tried didn't work... $(".feature_thumb").on('click hover') function(){ var main_href = $(this).attr('href'); change_image(main_href ); }); thank you hover() jquery method shorthand $( selector ).mouseenter( handlerin ).mouseleave( handlerout ); in fact want mouseover : $(".feature_thumb").on('click mouseover', function(){...}); or depending exact expected behaviour , html markup, use mouseenter .

jquery - DataTables: Adding a row dynamically -

Image
i binding 5 records in repeater <asp:repeater id="repeater1" runat="server"> <headertemplate> <table id="example" class="table table-hover" cellspacing="0" width="100%"> <thead> <tr> <th> <h3 style="font-size:24px;margin-top: 20px;margin-bottom: 20px; margin-left: 40px;"><b>teacher posts</b></h3></th> </tr> </thead> <tbody id="examplecontent"> </headertemplate> <itemtemplate> <tr> <td> <div class='col-md-12'> <div class='col-xs-10'> <div class='media...

c++ - making a vector of shared pointers from Spirit Qi -

this followup question a previous question . i can parse vectors of strings grammar, cannot seem parse vector of shared pointers strings ; i.e. std::vector<std::shared_ptr<std::string> > , , need bit of help. my compiling header: #define boost_spirit_use_phoenix_v3 1 #include <boost/spirit/include/qi_core.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <iostream> #include <string> #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/phoenix/bind/bind_member_function.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> // solution lazy make shared comes forum, user sehe. // https://stackoverflow.com/questions/21516201/how-to-create-boost-phoenix-make-shared // post found using google search terms `phoenix construct shared_ptr` // changed boost::shared_ptr std::shared_ptr namespace ...

mysql - Alerting framework for incoming traffic -

currently put hourly traffic (total number of input requests) of website in mysql table. keep data last 90 days. i want check every hour, lets 6th hour, has traffic increased/decreased beyond threshold last 7 days or last 30 days 6th hour traffic. basically, see pattern of traffic. different hours have different values. -> there alerting framework can use purpose? -> if yes, can suggest open source? -> if no, thinking of keeping running average of last 7 days / last 30 days in mysql table every hour. and according, write script generate alerts based on numbers. not sure whether should mean, median or standard deviation. can enlighten me there?

Salt IIS configuration fails -

i trying configure iis on windows 2012r2 x64 via salt . downloaded , linked salt-contrib . when run: salt-call --local iis.apppool_list i getting following error [error 2] system cannot find file specified but when running salt-call --local cmd.run "c:\windows\system32\inetsrv\appcmd.exe list apppool" it displays configured apppools. do have ides why first command fails? i haven't had time set environment test, i'm guessing it's bug in code.

php - Laravel-5 search certain fields if user input is not empty -

i'm trying build search query using laravel-5 seem generating wrong sql. here's code using: bookingdates::where('status', 'booked')->where('email', input::get('email'))->where('name', 'like', '%' . input::get('name') . '%')->where('date', $date)->get(); however user may not provide email. when happens, part of query ( where('email', input::get('email')) ) should omitted. example, query run if didn't provide email: bookingdates::where('status', 'booked')->where('name', 'like', '%' . input::get('name') . '%')->where('date', $date)->get(); is there easy/pretty way using laravel-5? thanks. you can build query in separate steps: $query = bookingdates::where('status', 'booked') ->where('name', 'like', '%' . inp...

How does a JavaScript engine choose what to execute next? -

while syntactically proficient @ javascript, clueless goes on under hood. running when , how javascript engine schedules it, if indeed it's scheduled in sense of word. clueless don't know terminology should use research it. i have assumed, hearing others parrot it, javascript engines can run 1 thread @ time. assuming true , function running when callback occurs, happens behind scenes? running function paused , callback executed or full stack of running function unwound, code in callback run. i clueless , shameful... how fit in ui thread in browser, how different in node.js sorry if question bit open ended, in end asking boils down -- should research(i.e google) learn more of this. the function being executed finishes execution before callback run. can implemented in different ways different engines. node not different , engine responsible executing javascript code shared browsers. since can't run 2 or more functions @ same time, , 1 function needs f...

C crypt function, malloc and valgrind -

my man page crypt function states that: "the return value points static data content overwritten each call." however, when using sha512 version (ie, salt starts $6$...), valgrind not seem agree. unless free pointer crypt returns, gets upset: 120 bytes in 1 blocks still reachable in loss record 1 of 1 @ 0x4c2bba0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 0x4c2df4f: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 0x521f4d4: __sha512_crypt (sha512-crypt.c:437) conversely, valgrind fine if use des version (so salt not start $6$ or similar). what's going on here , behaviour explained anywhere? thanks in advance. edit: platform ubuntu 15.04 64-bit. here's program: #define _xopen_source 700 #include <unistd.h> int main(int argc, char** argv) { char *hash = crypt("password", "$6$salty"); return 0; } for crypt variations, preallocated buffer not big enough, allocates (via ma...

c# - ExecuteScalar retuns NULL value -

stored procedure: dbo.getldate select dateentered table1 id = 4, gid=5 result: executed new query verify: declare @ldate datetime exec @ldate = getldate 4,5 results: dateentered 2014-02-13 06:21:43.600 thus, working fine final stored procedure created: exec @ldate = getldate 4,5 select 1 in c# int? id = _database.executescalar() int?; here, every time null value only. selecting 1 still null value. reason this. you selecting string '1' , can't converted int? cast . hence getting null. use: select 1 --without single quotes or can use convert.toint32 like: int? id = convert.toint32(_database.executescalar()); consider following example: object obj = "1"; int? id = obj int?; you null cast "1" (string) int/int? fail.

Pointer array and structure in C -

i lose guessing how come given output . can please explanation? also, short , quick resources try similar questions? void main() { struct { char ch[10]; char *str; }; struct s1={"hyderabad","bangalore"}; printf("\n%c%c",s1.ch[0],*s1.str); printf("\n%s%s",s1.ch,s1.str); getch(); } ans: hb, hyderabadbangalore struct s1={"hyderabad","bangalore"}; assigns "hyderabad" ch , "bangalore" str . printf("\n%c%c",s1.ch[0],*s1.str); prints first character of strings. since ch array, ch[0] represents first character. since str character pointer, points first character of string here. so, *s1.str have value 'b' printf("\n%s%s",s1.ch,s1.str); prints characters of both strings. fundamentally, ch equal &ch[0] , address of first character in array. and, str pointer variable holds address of first character of string lite...

python - Django Default language not working -

i have django app supports 2 languages english , arabic need change default language arabic language_code = 'ar' languages = ( (u'ar', _('arabic')), (u'en', _('english')), ) use_i18n = true use_l10n = true use_tz = false but when open 127.0.0.1:8000 redirects english 127.0.0.1:8000/en not arabic url.py include urlpatterns = patterns( '', url(r'^i18n/', include('django.conf.urls.i18n')), ) any suggestions ? try checking middleware_classes django.middleware.locale.localemiddleware. more on implementing available url: https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference i hope useful. source: https://docs.djangoproject.com/en/1.8/topics/i18n/translation/