Posts

Showing posts from September, 2014

jquery - Create bootstrap select picker dynamically -

i'm using bootstrap select plugin . populating dynamically created select so: var select = $('<select/>', { 'class':"selectpicker" }).selectpicker(); (var idx in data) { if (data.hasownproperty(idx)) { select.append('<option value=' + data[idx].id+ '>' + data[idx].text+ '</option>'); } } select.selectpicker('refresh'); the data fine , select created, not recognizing bootstrap selectpicker trying create. have select on same page not create dynamically , works fine. <select class="selectpicker"> <option>mustard</option> <option>ketchup</option> <option>relish</option> </select> $('.selectpicker').selectpicker(); how dynamically create bootstrap select? thanks. you need append <select /> create dom before calling selectpicker() on it, this: var $select = $('<select/>&#

java - How to properly handle empty resultset with Hibernate and Spring Boot -

i have spring app using hibernate , spring data jpa's crudrepository . seems work if data queried exists in database. however, if there query returns no result, crudrepository returns null , nullpointerexception . example http://localhost:8080/api/id=3 if there row id 3 in database works fine. if there isn't row id of 3 fails a: there unexpected error (type=internal server error, status=500) on client side , nullpointerexception on server side. what proper way of dealing simple case of "no results" query? inspect return value, if it's not null , return representation of 200 ok response. otherwise, return 404 not found . in end, have controller like: @requestmapping(...) public responseentity<?> getone(...) { something = repository.findone(...); if (something == null) return responseentity.notfound().build(); return responseentity.ok(something); } can refactor preceding code incorporate java 8's opti

Neo4j Community Edition 3.0.1 failed to start -

i populated neo4j database using gremlin console 3.1.2. checked data persistent exiting above console , go pointing local database location: >graph=neo4jgraph.open('/myneo4jdb/graphdb') >g = graph.traversal() >g.v() ==>v[0] ==>v[1] ==>v[2] ==>v[3] working on windows 7 professional. checked directory c:\myneo4jdb\graph.db has been created , populated files. see visual representation of data using "neo4j community edition 3.0.1" got error "starting neo4j failed: component 'org.neo4j.server.database.lifecyclemanagingdatabase@3c5e750c initialized, failed start". know neo4j community edition 3.0.1" working fine display database. reason neo4j community edition failed open database? appreciated. you have upgrade database. set in neo4j.conf (you can reach via "options" pane in starter) dbms.allow_format_migration=true

marklogic - xdmp:node-delete funny behavior -

when used xdmp:node-delete on not existing node, works on query console in cpf throws xdmp-argtype: (err:xpty0004) xdmp:node-delete(()) -- arg1 not of type node() following in query console let $_ := xdmp:node-delete(fn:doc($uri)/enevelope:document-enevelope/enevelope:extractedtext) the document not have node, on query console not complain, give error when used in cpf? often times when works in query console doesn't work when i'm running in module permissions problem. as justin said it, error shows have empty sequence. happening because of xpath said or being happening because user running query cant see document. i'd check make sure document coming back. debugging cpf pain, check i'd xdmp:log it. you eval user in query console.

MySQL date between last monday and the next sunday -

i'm looking find records have booking date between previous monday , next sunday in mysql. so far have: select firstname , lastname , sessions , (select count(memberid) bookings m.memberid = b.memberid , b.date between lastmonday , nextsunday) sessionsused members i'm looking substitute lastmonday , nextsunday any appreciated! mysql's yearweek() function selects unique value each week can use comparison. takes a second parameter specifies whether weeks start on sunday (0) or monday (1). select count(memberid) bookings m.memberid = b.memberid , yearweek(b.date, 1) = yearweek(now(), 1); this select rows b.date in current week. specific week in past, change now() whatever date expression require. for more generic case week not start on sunday or monday, need more complicated logic. here substitute @weekday day on weeks begin, 2 = tues, 3 = wed, 4 = thu, 5 = fri, 6 = sat. select count(membe

Android: My GridView's photos is mixed -

public class imageadapter extends baseadapter { layoutinflater inflater; imageview photo; checkbox check; bitmapfactory.options options; public imageadapter(context c) { inflater = (layoutinflater)c.getsystemservice(context.layout_inflater_service); } public int getcount() { return receivedphoto.size(); } public object getitem(int position) { return receivedphoto.get(position); } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { if(convertview == null) { convertview = inflater.inflate(r.layout.phototab_list, parent, false); photo = (imageview)convertview.findviewbyid(r.id.photos); check = (checkbox)convertview.findviewbyid(r.id.photoscheck); options = new bitmapfactory.options(); options.insamplesize = 16; } log.i("load", posit

How to get the constructor method of a class? -

i have class a takes class b template argument, , need b 's constructor in order (somewhat pseudocode): class a(b) { import std.typecons : tuple; import std.traits : parameters; tuple!(parameters!b) _args; this(parameters!b args) { _args = args; } } to store arguments constructor , later construct object of class b arguments stored in _args . this pretty command pattern. is there way constructor of b parameters ? or there better way achieve deferred object construction? yes, constructor's internal name __ctor : class c { this(int a, string b) { } } import std.traits; pragma(msg, parameters!(c.__ctor)); this outputs: (int, string)

html - CSS : How to add an absolute div to a scrollable background? -

i add div scrollable background, may find script have here . i have problem because when add box, it's being drawn window canvas, draw background #wrapper , , stay in exact spot div being added. for instance, if click in position (eg. images[0]), drawn around top right corner. however, when started scrolling background, added div stay in same position. div drawn @ images[0] is, , if start scrolling, still drawn @ position of images[0]. in css, tried assigning width 100% #wrapper below, still doesn't work... #wrapper{ width: 100%; } hence, know if problem in js or css... thank :))) when place absolute div(s), make sure placing within parent position set relative . can reliably control position of absolute child divs. there no issue javascript. simply set position:relative #wrapper div. should work expected. see fiddle : https://jsfiddle.net/davidsekar/38ebkd05/

ios - Cannot decode Base64 string swift -

i'm trying decode following base64 encoded string : /9j/4aaqskzjrgabaqaasabiaad/4qbyrxhpzgaatu0akgaaaagaagesaamaaaabaaeaaidpaaqaaaabaaaajgaaaaaaa6abaamaaaabaaeaakacaaqaaaabaaaazkadaaqaaaabaaaazaaaaad/7qa4ughvdg9zag9widmumaa4qklnbaqaaaaaaaa4qklnbcuaaaaaabduhyzzjwcybomaczjs%2bej%2b/8aaeqgazabkaweiaairaqmraf/eab8aaaefaqebaqebaaaaaaaaaaabagmebqyhcakkc//ealuqaaibawmcbamfbqqeaaabfqecawaeequsitfbbhnryqcicrqygzghccncscevuthwjdnicoijchyxgbkajsynkckqndu2nzg5okneruzhselku1rvvldywvpjzgvmz2hpann0dxz3ehl6g4sfhoeiiyqsk5svlpeymzqio6slpqeoqaqys7s1tre4ubrcw8tfxsfiycrs09tv1tfy2drh4upk5ebn6onq8flz9px29/j5%2bv/eab8baambaqebaqebaqeaaaaaaaabagmebqyhcakkc//ealuraaibagqeawqhbqqeaaecdwabagmrbauhmqysqvehyxetijkbcbrckagxwqkjm1lwfwjy0qowjdthjfexgbkajicokso1njc4otpdrevgr0hjslnuvvzxwflay2rlzmdoawpzdhv2d3h5eokdhiwgh4ijipktljwwl5izmqkjpkwmp6ipqrkztlw2t7i5usldxmxgx8jjytlt1nxw19jz2ulj5oxm5%2bjp6vlz9px29/j5%2bv/baemabgygbgygcgygcg4kcgooeg4odg4sfxisehisfxwxfxcxfxcchbwchbwchciiiiiiiicnjycnlcwslcwslcwslp/baembbwch

shared ptr - Using shared_ptr for refcounting -

i have class objects extensively used using shared_pointers. however, want track usage of these objects , when refcount goes particular value want delete object. how can ? thinking of overriding shared_ptr's destructor can decrement refcount when every shared_ptr reference goes away. however, looks not possible. alternatives ? you wouldn't want because if refcount greater 0 means there still pointers pointing object out there, intending access it. if wanted that, you'd have make own shared_ptr class, i'd add functionality checking if pointer still valid since might disappear on people.

gcc - How to know what code has been optimized out? -

is there way information during or after compilation parts of code have been optimized out, without looking @ assembly or executing code. it'd nice know if big code chunk gets optimized away. gcc -s will output assembly code have been passed assembler (and been linked executable). if squint right way (and patient), can work backwards confirm whether given bit of code has been included in executable, or optimized away. obviously not you'd unless have suspicion going on, given time , effort required...

git - How to reset commit from another dev but keeping mine's? -

Image
i have list of commits: the first 2 commits pretty , works properly. need remove 3 commits below without affecting work(first 2 commits). suggestions? since commits want newer, can't checkout commit because previous commits there. suggest doing following. checkout new branch. reset last commit want (which commit before 0e4e ) on new branch, run git cherry-pick 54d8c0a2 , fix conflicts, , run git cherry-pick d108639e . this leave branch <commit before 0e4e> - 54d8c0a2 - d108639e

javascript - Debug Counter Code -

i have website inherited web designer has counter on not work. site runs on wordpress 4.5.2 , counter consists of 3 parts. should appear on page https://electratherm.com/ above cumulative fleet runtime. the first part div tag on page: <div id="counter" style="text-align: center;"></div> the second section edited client, shows towards bottom of source code: <script> //update next 3 variables once per week using current fleet data var start_date = new date("june 5, 2016 23:59:00"); // date , time when run hours known var start_value = 548047; // run hours known @ date above var increment = 0.0041; // 4000 fleet hrs per week = .0050 per sec, how many fleet run hours added every second of day. # of week hours / 7/24/60/60 </script> the third part actual javascript file linked lower in source code: <script src="https://electratherm-electratherm.netdna-ssl.com/wp-content/themes/impreza-child/js/counter.js

Putting my JSON data into my XML templates for a TVOS TVML app -

i have completed few tutorials developing apple tv apps , able , parse json no problem , display in xml template made within js file. i have made app using menu bar navigate through multiple xml templates. need merge these 2 , have app uses menu bar navigate through xml templates have data in them via json . first time working both xml , json appreciated.

multi-class support vector machine classification -

i try run own svm-code using 1 against 1 have error in selected function best (c,sigma) , error in plot function ,i hope give me hand,and code clear clc close %load data load dataset load spacies [~,~,group] = unique(spacies); data=dataset(1:12,1:19); xdata=zscore(data); %group=spacies(1:end,1); p=0.5; [train,test]=crossvalind('holdout',group,p); trainingsample=xdata(train,:); traininglabel=group(train,1); testingsample=xdata(test,:); testinglabel=group(test,1); numclass=max(group); i=1:numclass j=i+1:numclass inij=(traininglabel==i)|(traininglabel==j); trainingsampleij=trainingsample(inij,:); traininglabelij=traininglabel(inij,:); %%k-fold using training data numfold=8; indices=crossvalind('kfold',traininglabelij,numfold); sigma=2.^(-10:1:10); c=2.^(-5:1:5); [bestsigma,bestc]=bestparametersrbf(trainingsampleij,... traininglabelij,sigma,c,indices,numfold);

jersey 2.0 - Running JerseyTest with PowerMock Exception for LoggingFeature.Verbosity -

edit 1 pom.xml <!-- test dependencies --> <dependency> <groupid>javax.servlet</groupid> <artifactid>servlet-api</artifactid> <scope>test</scope> </dependency> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <scope>test</scope> </dependency> <dependency> <groupid>org.easymock</groupid> <artifactid>easymock</artifactid> <scope>test</scope> </dependency> <dependency> <groupid>com.sun.jersey.jersey-test-framework</groupid> <artifactid>jersey-test-framework-core</artifactid> <version>1.18</version> <scope>test</scope> </dependency> <dependency> <groupid>org.glassfish.jersey.test-framework.providers</groupid> <artifactid>jersey-test-framework-provider-grizzly2</artifactid

How does python order values in a heap? -

for example, list of random numbers: >>> x = [1,24,5,1,5,1,23,6] >>> heapq.heapify(x) [1, 1, 1, 6, 5, 5, 23, 24] why arbitrarily 6,5,5 , not 5,5,6 or 5,6,5? python docs contain following description of heapq : heaps binary trees every parent node has value less or equal of children. implementation uses arrays heap[k] <= heap[2*k+1] , heap[k] <= heap[2*k+2] k , counting elements zero. sake of comparison, non-existing elements considered infinite. interesting property of heap smallest element root, heap[0] . you can verify example data: >>> in xrange(len(x)): ... print '{0} <= {1}'.format(x[i], x[i*2+1:i*2+3]) ... 1 <= [1, 1] 1 <= [6, 5] 1 <= [5, 23] 6 <= [24] 5 <= [] 5 <= [] 23 <= [] 24 <= [] for more information binary heaps can check wikipedia .

.net - Determine whether destination for file move is on same filesystem in C# -

i have windows forms application uses file.move move files in response user request. not asynchronous method, when destination on same drive happens instantly (i assume because can rewrite header , not move anything). however, blocks application if destination not on same drive. not desirable. so naturally thought switching async. looks way use file streams , use stream.copytoasync before removing original. that's fine, except if is on same drive, lot of wasteful copying. is there reliable way determine if proposed destination file on different drive drive stored on before deciding operation perform? @ drive letter, seems kind of hacky , think there cases junction points not work correctly. another possible choice use task.run(() => file.move(x)) , although have vaguely bad feeling that. i think best effort going comparing volume serial numbers. getfileinformationbyhandle() able volume serial number of file handle. ymmv raid / striped volumes, if ap

javascript - Loading effect on google chart refresh -

i have page multiple google charts. have drop-down @ page level. refresh/ reload charts when user changes values drop-down. everything working fine there few seconds delay between value selection , charts update. want show loading effect overlay , image on page before charts refreshed. the problem unable overlay effect on top of google charts. loading effect javascript trigger , background gets greyed, loading image hidden behind charts. jsfiddle problem: https://jsfiddle.net/0tj1pzsk/14/ how can overlay spinner image on top of google charts? placing spinner image inside chart div display first chart load , not subsequent refreshes code: css #loading-img { background: url(https://i1.wp.com/cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif) center center no-repeat; height: 100%; z-index: 20; } .loading { background: #a3a3a3; display: none; position: absolute; top: 0; right: 0; bottom: 0; left: 0; opacity: 0.5; } javascript $('

android - App is closing without crash -

i creating exam app in android , loading questions in viewpager. when moving 1 question app getting closed without crash and. fragmentpageradapter mfragmentpageradapter = new viewpageradapter(getactivity(), getchildfragmentmanager(), takeexamresponse.getpayloads().getquestions(), mfragmentnavigator, takeexamresponse.getpayloads().gettype(), "finished".equals(getactivity().getintent().getstringextra("is_finished")) ? true : false, mquestionsfragment); viewpager.setadapter(mfragmentpageradapter); adapter class. package com.comquest.adapter; import android.content.context; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import com.comquest.fragment.viewpagerfragment; import com.comquest.interfaces.fragmentnavigator; import com.comquest.response.question; import com.comquest.utilities.examguruapplication; import java.util.list; public class viewpageradapter extends f

google visualization - Publish motion chart: set initial state -

after creating motion chart in spreadsheet , selecting 'publish', following code, pasted html page on server produces working chart (i removed spreadsheet url): <script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js"> {"datasourceurl":"//docs.google.com/spreadsheet/tq?key=[mysheet]&transpose=0&headers=1&range=a1%3ac57&gid=0&pub=1","options":{"showchartbuttons":true,"vaxes":[{"title":"left vertical axis title","useformatfromdata":true,"minvalue":null,"viewwindow":{"min":null,"max":null},"maxvalue":null},{"useformatfromdata":true,"minvalue":null,"viewwindow":{"min":null,"max":null},"maxvalue":null}],"titletextstyle":{"fontsize":16},"title":"chart title","boo

php - Can not get email address by Facebook login (javascript) -

this question has answer here: facebook js sdk's fb.api('/me') method doesn't return fields expect in graph api v2.4+ 2 answers i use facebook javascript handle function login facebook. before, can use it, , facebook send server user's info: localhost v2.2 id: first_name: last_name: email: token: v2.5 - but, get: id: first_name: last_name: token: don't have email? what's problem @ here? , how can fix it. thank much! it called "declarative fields" , came v2.4 of graph api: https://developers.facebook.com/docs/apps/changelog#v2_4 you have specify fields want in api call, or basic ones.

Multiple request with NSURLConnection with NSURLConnectionDelegate protocol methods in swift -

in nsurlconnectiondelegate protocol function connectiondidfinishloading(connection: nsurlconnection!), getting son result. if try use nsurlconnection twice connecting api in server, getting error "the data couldn’t read because isn’t in correct format". if u run request separately, giving output. i use code found in stack overflow nsurlconnection using ios swift

javascript - signInWithEmailAndPassword and EmailAuthProvider -

i trying understand new authentication model. trying convert web code used older authwithpassword. considering had: firebase.authwithpassword({email: email, password: password }).then( authdata => console.log('auth: authwithpassword success '+authdata.uid), err => console.log('auth: authwithpassword fail: '+err)); how achieve same thing new version ? there seem 2 different interfaces: auth().signinwithemailandpassword and firepad.auth.emailauthprovider but don't understand difference or how use them. there clear example correct way email authentication ? there lot of such differences new api. best stick closely docs. the new docs site has guide on email/password authentication, specific question code: firebase.auth().signinwithemailandpassword(email, password).catch(function(error) { // handle errors here. var errorcode = error.code; var errormessage = error.message; // ... }); source: https://firebase.google

Long random numbers in C -

my problem simple (silly, maybe). need long random number using c language simple possible. researched through out internet , coudn't find me. thing find rand() function cannot handle numbers bigger 32,767. here part of code, , long number should between 0 , 1,000,000: #include <stdio.h> #include <time.h> #include <conio.h> #define max 999999 void main() { int i; printf("\n test random numbers."); printf("\n ------------------------------------\n\n"); srand(time(null)); for(i = 0; < 50; i++) { printf(" %li\n", rand() % max+1); } printf("\n ====================================\n"); getch(); } you can build bigger numbers or:ing several calls rand(). #include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #define limit (1000000) static uint16_t highest_bit(uint64_t v) { uint16_t out = 0; while (v &

iphone - wrong dismissal after presenting a UIViewController working as a detail view of a tableViewCell -

Image
this question has answer here: dismiss modalview presented tableviewcontroller? [closed] 3 answers in project app launches in viewcontroller, loads inside table (table class) adding subview (viewcontroller.h - [self.view addsubview: table.tableview];) camera class detailed view, when tap in table row loads camara.xib. until here works fine. the problem comes when try dismiss camera.xib , go viewcontroller.xib, when camera.xib dismisses okay instead of going viewcontroller.xib table.xib inside of it, app loads table.xib, rest of objects placed in view of viewcontroller.xib not displaying. what doing wrong? thanks in advance!! code: table.m - (void)viewdidload { roomsarray = [[nsmutablearray alloc] initwithobjects:nil]; [super viewdidload]; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { //

scala - Docker Akka-Http application endpoint not reachable -

i have basic akka-http app not more hello-world setup - have defined endpoint , bound "localhost" , port "8080": object main extends app routes { private implicit val system = actorsystem() protected implicit val executor: executioncontext = system.dispatcher protected implicit val materializer: actormaterializer = actormaterializer() protected val log: loggingadapter = logging( system, getclass ) log.info( "starting server" ) http().bindandhandle( logrequestresult("log",logging.infolevel)( allroutes ), "localhost", 8080 ) log.info( "server started, awaiting requests.." ) } (allroutes mixed in via routes, dummy endpoint serialises simple case class json response) if start using sbt endpoints works fine ( http://localhost:8080/colour/red example). i trying package docker container run - have read things http://yeghishe.github.io/2015/06/24/running-akka-applications.html , have added sbt-native-packa

Issue with nagios monitoring -

i need nagios monitoring. i installed on server , agents when go main screen see 2 services being monitored , says 2 services in "critical" i have attached screenshots same says below 2 services monitored on agents ?? thought should 8 ? current users cpu load the following services critical command not found error: sh monitoring -- nrpe: command 'check_ssh' not defined ftp monitoring-- nrpe: command 'check_ftp' not defined any appreciated. check ssh , check ftp external commands had delete check_nrpe| client side make work. secondly had install ftp server ftp monitoring work. now.

php - Reading Ad set fields with targeting in Facebook marketing API -

i have using marketing api version 2.6. in 2.5 version can use field targeting retrieve ads in ad set. in 2.6, field targeting not supported. wanna retrieve age_min, age_max, geo_locations, , page_types. how retrieve targeting fields in ad set? code have using fields if(is_null(access_token) || is_null(app_id) || is_null(app_secret)) { throw new \exception( 'you must set access token, app id , app secret before executing' ); } if (is_null(account_id)) { throw new \exception( 'you must set account id before executing'); } api::init(app_id, app_secret, access_token); $adset = new adset($adsetid); $fields = array('name', 'targeting', 'creative', 'conversion_specs', 'redownload', 'genders', 'tracking_specs'); $result = $adset->getads($fields, $limit); maybe $result = $adset->read($fields); should work? i think "ge

c# - id field resolution when using JObject.FromObject -

i have family of custom json converters. work this: public override void writejson(newtonsoft.json.jsonwriter writer, object value, newtonsoft.json.jsonserializer serializer) { jobject jo = jobject.fromobject(value); // own stuff jobject here -- adding property. value of property depends on specific converter being used. jo.writeto(writer, this); } the problem id field of jobject 1. not good. tried using inner serializer id field: private jsonserializer _innerserializer {get;set;} private jsonserializer innerserializer { { if (_innerserializer == null) { _innerserializer = new jsonserializer(); } return _innerserializer; } } public override void writejson(newtonsoft.json.jsonwriter writer, object value, newtonsoft.json.jsonserializer serializer) { jsonserializer inner = this.innerserializer; jo = jobject.fromobject(value, inner); //my stuff here jo.writeto(writer, this); } that gives different id each time, if hits same object twice. wan

java - Active mq multiple consumers working in parallel -

Image
the jms contract 1 session used 1 thread @ once resource: http://activemq.apache.org/multiple-consumers-on-a-queue.html as can see in image every consumer session id one. ok have, , how check if consumers consuming 1 @ time or working in parallel? is session id same each consumer right configuration? just let consumers print out message , see working in parallel. use instance number on each consumer instead.

intel xdk - Phaser Game Development XDK -

i using xdk phaser html 5 game development. using sample click counter website not working. can me? here code below: /* globals phaser:false */ // create basicgame class basicgame = { }; // create game function in basicgame basicgame.game = function (game) { }; var counter = 0; // set game function prototype basicgame.game.prototype = { init: function () { // set input max pointers this.input.maxpointers = 1; // set stage disable visibility change this.stage.disablevisibilitychange = true; // set scaling method used scalemanager // valid values scalemode are: // * exact_fit // * no_scale // * show_all // * resize // see http://docs.phaser.io/phaser.scalemanager.html full document this.scale.scalemode = phaser.scalemanager.show_all; // if wish align game in middle of page can // set value true. place re-calculated margin-left // pixel value onto canvas e