Posts

Showing posts from May, 2011

elasticsearch - Can I use the phrase_prefix query type with the fuzziness option? -

i'm using fuzziness option , want add "prefix functionality" find documents 1 of fields contains term starts x. i have multi_match query , understanding can't use type phrase_prefix fuzziness . there way can it? here's query: "query": { "multi_match": { "query": this.queryterm, "operator": "and", "fields": ["title", "content", "author.name", "tags"], "fuzziness": "auto" } }

json - Merge audio by timestamps -

here example of json, src - path audio file, time - milliseconds, start audio should played. so question, how can merge whese files in 1 wav or mp3, files played on it's timestamps? every file can play on same time another. so, scheme, created mp3/wav should contain this: -----|firstfile-0:02--|ended ----------|secondfile-0:03|ended ------------------------------------------|thirdfile-0:23---------|ended -------------------------------|silence-|------------- { 0: { src: "/audio/drumnbass/hits/dnb_voicefx001_160_c_sl2.wav", time: 803 } 1: { src:"/audio/drumnbass/hits/dnb_voicefx001_160_c_sl2.wav" time:812 } 2: { src:"/audio/drumnbass/drums/rnb_beats006_160_x_sl2.wav" time:1317 } 3: { src:"/audio/drumnbass/drums/rnb_beats006_160_x_sl2.wav" time:1318 } 4: { src:"/audio/drumnbass/sinth/dnb_synth105_160_c_sl2.wav" time:2054 } 5: { src:"/audio/drumnbass/sinth/dnb_synth105_160_c_sl2.wav" time:2054 } 6: { ...

python 2.7 - How to continue execution of fabricate based software when error is encountered -

there tool uses fabricate makefile , saxon xslt processor run , build xslt based project. program executed using main python script executes several files. have issue python script stopping when error encountered (for example if there syntax error in xsl template file, error comes on screen , execution stopped). want file execute when there error , log error file. know how log error file dont know how continue execution of program when error encountered. please answer question example because difficult understand theory.

c# - Unity Non player objects movements are not syncronized on server -

hi i'am struggling problem long time. i have scene object (a cube) can moved client. problem movements not seen on server. the cube has network identity , network transform component. sync movements i'am using [command] (based on example found here http://docs.unity3d.com/scriptreference/networking.commandattribute.html ). i've found out problem that, statement: if (networkserver.active) is never true. could me please? thank much

scala - Akka Actor internal state during shard migration in a cluster -

we using akka sharding distribute our running actors across several nodes. actors persistent , keep internal state in database. now need add actorref "metrics actor", running on each node. each actor in shard supposed send telemetric data metrics actor - must choose right metrics actor running locally on same node. reason is, metric actor gathers data peer node. now, thinking create metric actor in main method (which runs on each node): val mvmetrics : actorref = system.actorof(metricsactor("mv"), "mvmetrics") and pass reference clustersharding inicialisation part of actors props object: clustersharding(system).start( typename = shardname, entityprops = myshardactor.props(mvmetrics), settings = clustershardingsettings(system), extractentityid = idextractor, extractshardid = shardresolver) my question is, happen if such created actors migrate between nodes, e.g. node -> b? can imagine migrated p...

Better naming convention for Jupyter notebook -

when naming jupyter notebook, if spaces used, i.e. notebook.ipynb then renders nicely when opened web browser. however, spaces evil on command line environment. if instead: this_is_my_notebook.ipynb or this-is-my-notebook.ipynb then title rendered not good. suggestions alternative convention still nice? i found myself searching answer well... i scoured through popular github repositories involving .ipynb files, under pretense of work being reputably standardized. found there no standard between utilizing dashes , underscores; however, didn't see notebooks using spaces - don't that. sources: https://github.com/irkernel/irkernel/tree/master/example-notebooks https://github.com/rlabbe/kalman-and-bayesian-filters-in-python/tree/master/supporting_notebooks

asp.net mvc - Jquery validation triggers but doesn't prevent the form submitting -

i have mvc project knockout. i'm trying validate register view using jquery validation. this register view: <form data-bind="submit: register" id="formregister"> <label>email</label> <input id="registeremail" name="registeremail" class="required email form-control" type="text" data-bind="value: registeremail" /> <label>password</label> <input id="registerpassword" name="registerpassword" class="required form-control" type="password" data-bind="value: registerpassword" /> <label>confirm password</label> <input id="registerpassword2" name="registerpassword2" class="required form-control" type="password" data-bind="value: registerpassword2" /> <button type="submit" class...

javascript - Gulp Plumber or PrettyError does not work in a loop -

i have problem gulp watch breaking after error. found reference use plumber, , extension of it, gulp-prettyerror . then create gulpfile.js const gulp = require('gulp'), babel = require('gulp-babel') changed = require('gulp-changed'), prettyerror = require('gulp-prettyerror'); ////////////////////////// start squarebook //////////////////////////////// const reactsquarebooksource = './common/modules/squarebook/web/jsx/*.{js,jsx}'; const reactsquarebookdest = './common/modules/squarebook/web/js'; // run babel on squarebook gulp.task('babel:squarebook', function () { return gulp.src(reactsquarebooksource) .pipe(prettyerror()) .pipe(changed(reactsquarebookdest)) // make sure changed source .pipe(babel()) // babel .pipe(gulp.dest(reactsquarebookdest)); }); gulp.task('watch:squarebook', function () { gulp.watch(reactsquarebooksource, ['babel:sq...

c# - Windows service keeps on failing -

i have windows service designed continuously retrieve messages azure service bus queue , pass other queues.i have deployed service 1 of server computer unfortunately service keeps failing @ random time interval. my application handles exceptions , writes them file.the main purpose of application hook queue , listen messages continuously , never move application stop stage.i'm using timer in application , don't think causing problem.i'd know best approach handle errors , make application stable, below code. in advance. public partial class scheduler : servicebase { private timer scheduletimer = null; private string servicenamespace; private string issuesecretkey; private string sourcequeue; private string destinationqueue; public scheduler() { initializecomponent(); } protected override void onstart(string[] args) { scheduletimer = new timer(); this.scheduletimer.interval = 1000;//1 sec this.s...

python - Drop pandas dataframe rows based on groupby() condition -

there pandas dataframe on input: store_id item_id items_sold date 1 1 0 2015-12-28 1 2 1 2015-12-28 1 1 0 2015-12-28 2 2 0 2015-12-28 2 1 1 2015-12-29 2 2 1 2015-12-29 2 1 0 2015-12-29 3 1 0 2015-12-30 3 1 0 2015-12-30 i need drop rows items have never been sold in particular store: pairs (1,1), (3,1) of (store_id, item_id) in dataframe the output expect following: store_id item_id items_sold date 1 2 1 2015-12-28 2 2 0 2015-12-28 2 1 1 2015-12-29 2 2 1 2015-12-29 2 1 0 2015-12-29 i've figured out how find required pairs of (store_id, item_id) using pd.groupby()[].sum() , stuck dropping them initial datafram...

android - Like button and like counter resets to old value after scrolling up and down in listview -

after liking news item heart button shows red , counter sets 1 after scrolling , down counter goes 0 , heart button changes red ash loaded server. tried using notifydatasetchanged() didn't work in adapter ....below code implemented. public class listviewadaptersup extends baseadapter { // declare variables context context; layoutinflater inflater; arraylist<hashmap<string, string>> data; imageloader imageloader; hashmap<string, string> resultp = new hashmap<string, string>(); public listviewadaptersup(context context, arraylist<hashmap<string, string>> arraylist) { this.context = context; data = arraylist; imageloader = new imageloader(context); } @override public int getcount() { return data.size(); } @override public object getitem(int position) { return null; } @override public long getitemid(int position) { return 0; } static class viewholder { // declare variables textview supmessagetv...

c++ - std::bind compiler error gcc -

in 1 of recent projects, did development work on ubuntu (cmake+gcc 4.8.4). code builds fine. however, when attempt build same code in cygwin (cmake + gcc 5.3), compiler error std::bind. goes away on doing #include <functional> . however, worries me little bit. expect code work fine on identical or similar compilers. i have shipped out piece of code used on centos. assumed because code builds fine ubuntu, other linux distributions similar compiler should not problem. however, no longer sure if code build fine on centos. my question this. can assume if code builds fine particular version of gcc on ubuntu machine, build fine on other linux distributions same or higher version of gcc? or being overly optimistic , should rely more testing? or has std::bind itself? there no guarantee gcc compiler versions behave same. in particular w.r.t. c++ 11 features there incompatible changes between compiler versions. gcc 4.8 had still experimental c++ 11 support. standard says s...

javascript - How can I insert vertical scrollbar in Titanium -

i'm building application titanium now want set scrollview in 1 window because content of windows big of device. want insert scrollview , show vertical scrollbar. so i'm building code: <alloy> <window id="indexwindow" orientation="titanium.ui.upside_portrait" fullscreen="false"> <scrollview id="scrollview" showverticalscrollindicator="true" showpagingcontrol= "true" showhorizontalscrollindicator="true" height="80%" width="80%"> <view class="container" layout="vertical"> <!-- title --> <label id="titledatianagrafici" class="labeltitle" ></label> <!-- personal data --> <tableview id="form_table" height="titanium.ui.size"> <tableviewrow id="name_row" class=...

javascript - Unable to change value of an element in array -

here's code: html: <div id="id1"> <a href="www.google.com">click</a> </div> <a href="www.yahoo.com">click</a> js: var element = document.queryselector("a[href^='www.google.com']"); console.log(element); // returns <a> object element = element.parentnode; console.log(element); // returns <div> object worked perfect. but, here's second part: var elements = document.queryselectorall("a[href^='www.google.com']"); console.log(elements[0]); //this returns <a> object elements[0] = elements[0].parentnode; console.log(elements[0]); //this returns <a> instead of <div> so, couldn't change value @ elements[0] . why happening? how can change without using temp variable temp = elements[0]; temp = temp.parentnode; console.log(temp); ? queryselectorall returns nodelist not array . if need mutate further convert array var ele...

Instagram api comment pagination -

i using instagram api , fetching comments of media. want add pagination 10 comments come @ time. have found nothing in instagram api documentation add limit comments. there way achieve functionality? there no pagination comments, api can 120 latest comments. https://api.instagram.com/v1/media/{media-id}/comments?access_token=access-token

Android GridLayout- cover whole screen programmatically -

Image
i want grid layout cover whole screen , want programmatically. when in static xml adding app:layout_columnweight attribute, looks want have follows: but when tried create same layout programmatically, looks this: i want same first image. here code: public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); android.support.v7.widget.gridlayout gridlayout = new android.support.v7.widget.gridlayout(this); gridlayout.setlayoutparams(new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.wrap_content)); gridlayout.setcolumncount(3); (int = 0; < 9; i++) { button button = new button(mainactivity.this); gridlayout.layoutparams lp = (gridlayout.layoutparams) button.getlayoutparams(); if (lp == null) { lp = new gridlayout.layoutparams(); } lp.columnspec = gridlayout.spec(g...

android - How can I POST "string request" and get data? -

i have tried application on android 23 , stuck somewhere. i have request not url format! !!! string format. post on server , return data. for example url is= http://api.someurl/app_dev.php/tr/content and need post string parameter { "command":"read", "ctrl":"summaryofday", "data":{"date":"08.04.2016"}, "order":null, "limit":null } and should return json data. because this request search parameter ! my code is httpurlconnection connection=null; bufferedreader reader=null; try { url url=new url(params[0]); connection=(httpurlconnection)url.openconnection(); inputstream stream=connection.getinputstream(); reader=new bufferedreader(new inputstreamreader(stream)); stringbuffer buffer=new stringbuffer(); string line = ""; while ((line = reader.readline())!= null){ buffer.append(line); } string sjson = buffer.tostrin...

types - Groovy coercing List to Map doesn't throw ClassCastException or what is ArrayList1_groovyProxy? -

i writing code tried cast object map. map = object map i alternatively use map = (map) object and whole question irrelevant throws classcastexception if object of type list, using former encountered interesting thing. if object list, i.e. object = [] , groovy type coercion behave different expected. my expectation classcastexception , instead got resulting object. object seems odd. instance of list , instance of map , using .tostring() on resulted in output of list, not map ( [a,b] ). not possible set value on map a['c'] = 'c' . results in java.lang.illegalargumentexception: argument type mismatch . map = ['a', 'b'] map println(a) println(a instanceof list) println(a instanceof map) println(a.getclass()) results in following output: [a, b] true true class arraylist1_groovyproxy i tried google find out arraylist1_groovyproxy is, couldn't find anything. it still doesn't make sense me, coercion returns object not should ,...

How to Get MSTest OwnerAttribute into Jenkins Report? -

i'd owner attribute of our mstest based unittests test reports @ jenkins (by mstest publisher). it's easy see @ jenkins test results report, responsible (failing) unittest. my test cases like: [testmethod, owner("aaa")] public void isitrealtest() { var result = isitreal(); assert.istrue(result); } i checked source of jenkins ms test plugin , transforms mstest trx format jenkins readable junit format, don't want change plugin. another way write test-owner stdout like: [testmethod, owner("aaa")] public void isitrealtest() { console.writeline("owner: "+ getownerattributeofcurrentmethod()); var result = isitreal(); assert.istrue(result); } but that's not feasible, since have thousands of test cases. tried using testcontext property, automatically set mstest. have base class tests, can following: public testcontext testcontext { { return testcontextinstance; } ...

javascript - Lazyload images and anchors -

i have webpage waits images loaded until visible in viewport of browser (lazyload). dimensions of images unknown. on top of webpage have link jumps anchor on bottom of page. when user presses link browsers scrolls wrong position of webpage. assume because images loaded in browser , changes height of page. in other words position of anchor changes after link link clicked. there anyway solve paradox. what do, append link , div after images loaded. for example: if images loaded, could: $("#somediv").append("<a href='#someotherdiv'></a>"); $("#somedivatthebottomofthepage").append("<div id='#jumptothis'></div>");

ios - iPhone app under test crashes after a few days -

i new making iphone apps , first attempt. i have made simple app has 2 buttons in it. 1 button opens url , other opens pop-up window. i yet enroll apple developer , testing application on physical device connecting xcode. when install application, runs few days in spite of disconnecting xcode. however, after few days, application not open , flashes black blank screen , goes home screen. when reconnect xcode , run same code again on same iphone, works again few days , crashes again. i unable understand why app behaving in such manner after few days , not immediately. is there expiry period application when 1 has not signed in developer? (the provisioning profile shows expiring soon) if not, can please guide me how go troubleshooting issue? kindly give me esteemed suggestions/comments badly stuck , need find solution possible. thanks lot! if application installed xcode , don't have paid program developer account, life expectancy of app 48h approximate ...

java - Setup for MacOS applications -

i developed app (for mac) create user-friendly instalation package. file structure of application follows: ───myapp.app └───contents │ info.plist │ pkginfo │ ├───java │ myapp.jar │ ├───macos │ javaapplauncher │ ├───plugins └───resources │ genericapp.icns │ └───en.lproj localizable.strings currently users have install myapp executing terminal command (if copy application in applications folder , not work): sudo mv myapp.app /applications/myapp.app is there program (not necessary free) creates installation process package (next, next, ... finish). on 1 of steps process should check version of java on user computer. can point me in right direction? i packages app lookin for.

Run entirely a python code in IOS app? -

i have code written in python. know if it's possible make ios app can execute python code ? for example, let's have python code can classify picture different categories printing correct category. create ios app take in input images, these images given python code, python code executed , result printed thank print function in objective c. thank in advance yes can use framework https://github.com/pybee/python-apple-support check python version first add header , framework search paths.

java - Binary Marshaller in Apache Ignite -

we create/update table schema @ run time per user. how can update queryentity cache @ run time , add columns queries sqlfieldsquery. so example of "it enables add , remove fields objects of same type. given server nodes not have model classes definitions, ability allows dynamic change objects structure, , allows multiple clients different versions of class definitions co-exist." per apache ignite? this not possible in current version of ignite. added in next few months in scope of ticket: https://issues.apache.org/jira/browse/ignite-735

c# - How do I read an Image's Height and Width from my View Model? -

i want line-drawing operations viewmodel (i.e. add collection of lines bound itemscontrol on view). for need know height , width of image in view. how them ? there workarounds mentioned in other posts they wpf , none of them work on metro. public static class sizeobserver { public static readonly dependencyproperty observeproperty = dependencyproperty.registerattached( "observe", typeof(bool), typeof(sizeobserver), new propertymetadata(null, onobservechanged)); //new frameworkpropertymetadata(onobservechanged)); public static readonly dependencyproperty observedwidthproperty = dependencyproperty.registerattached( "observedwidth", typeof(double), typeof(sizeobserver), null); public static readonly dependencyproperty observedheightproperty = dependencyproperty.registerattached( "observedheight", typeof(double), typeof(sizeobserver), null); pu...

c# - How do I populate the listbox plugin item Name as it is set in the Plugin interface? -

Image
when plugin buttons loaded, button gets populated name of iplugin interface asks in method string name { get; } i’m trying listbox item populate name same way doing button. private void assemblecomponents private void assemblecomponents(object sender) { icollection<iplugin> plugins = genericpluginloader<iplugin>.loadplugins("plugins"); string selection = ""; if (sender listbox) { if (((listbox)sender).selectedvalue != null) selection = ((listbox)sender).selectedvalue.tostring(); } string path = system.io.path.combine(appdomain.currentdomain.basedirectory, "plugins"); directorycatalog cat = new directorycatalog(path); //icollection<iplugin> plugins = pluginloader.loadplugins("plugins"); foreach (var item in plugins) { //add i...

javascript - Content slider with lightSlider using Ajax -

Image
i trying create dynamic content slider using lightslider plugin.i have built script loads content database table (returning json html ).i want 4 div 's of content displayed instead of 6 , below (6 transactions stored in database table in total) what need 4 div 's per slide displayed.does know how can that?please help.i have posted couldn't find out solution. ajax request: $.ajax({ url: 'ajax_json.php', type: 'post', data: {get_param: 'value'}, contenttype: "application/json; charset=utf-8", datatype: 'json', success: function(data) { $.each(data, function(index, item) { $('#content-slider').append('<li class="caption"><div class="col-md-3"><div class="item_img"><img src="' +item.image+ '" /></div><div class="item_title">"' +item.title+ '...

css - display image and text using division tag rowspan in html -

Image
i want achieve below format using td tags. but if have make use of div tags(rowspan) how possible. below format. not sure if you're looking for? .row { display: block; border-top: 1px solid #efefef; } .row > img.img { width: 100px; display: inline; float: left; margin: 10px 10px 5px 0; } .row > a.title { margin-top: 10px; font-family: tahoma; font-size: 18px; color: #338899; text-decoration: none; display: inline-block; } .row > span.description { color: #555555; display: inline-block; } <div class="row"> <img src="http://assets.rollingstone.com/assets/images/story/taylor-swift-cancels-thailand-concert-due-to-political-turbulence-20140527/20140527-taylorswift-x624-1401220626.jpg" class="img" /> <a href="#something" class="title">taylor swift</a> <br/> <span class="description">this singer</...

python - IOError while reading files -

from python pick file reading.is there specific folder,or pick anywhere on system given filename , extension.is there need mention absolute path. getting error while reading txt , csv files no such file or directory. f=open('info.csv') print f handle above file.but don't handle .txt,both in same folder.why give error? by default, python checks requested file in same directory program file in. if want python check file in other location, have specify absolute path. about error, nothing can said unless share code.

plot - Visualizing values in different columns for each row and connect them by line in R -

Image
i have following data frame: user_id 2016-23 2016-23 2016-25 1 10 20 30 2 5 15 45 3 20 11 21 4 40 30 20 5 40 21 17 i need visualize data frame have '2016-23' , '2016-23' , '2016-25' in x axis , connected dots each 'user_id ' based on value in column see if trend increasing or decreasing on time. if understand correctly, looking for.. library(ggplot2) library(reshape2) df <- data.frame(user_id=c(1,2,3,4,5),a=c(10,5,20,40,40), b=c(20,15,11,30,21),c=c(30,45,21,20,17)) colnames(df)=c("user_id","2016-23","2016-23","2016-25") df<- reshape2::melt(df,"user_id",2:4) df_res <- mutate(df,user_id = as.factor(user_id),variable=as.character(variable)) this results in: user_id variable value 1 1 2016-23 10 2 2 2016-23 5 3 3 2016-23 20 4 4 2...

c++ - components of a symbol name in objdump output -

i'm trying use objdump compare 2 different versions of binary file , wondering if knew how interpret symbol name following line of objdump output: 102b33bc l o .rodata 00000058 thisismystruct::thisismystruct()::c.24 this output generated using following command: objdump -t -c -r -w --special-syms my.bin > my.bin.txt my problem 2 different versions of my.bin have same line, 1 has c.24 @ end , other has c.12 @ end. what c.# represent? thanks! it represents whatever compiler wants represent. symbol name mangling entirely compiler specific, , vary version of compiler. other day surprised when gcc compiler options resulted in different symbol mangling. fun. a search of http://gcc.gnu.org not seem find documentation gcc's name mangling. general google search not enlightening.

javascript - How to find dynamically created element using jQuery selectors? -

i have form has elements in it. want elements inside form regardless of depth . this test code $(document).ready(function(){ //script.init(markchaining); $('#checkbutton').click(function(){ $('#saveform :input').each(function(key){ if($(this).is('select')) { var id = $(this).attr('id'); console.log('id '+id); $(this).trigger('change'); console.log('if-> element name '+$(this).attr('name')); } else { console.log('else-> element name '+$(this).attr('name')); } }); }); }); function addrow(ele,name) { var id = ele.id; $('#'+id+'').closest('tr').after('<tr><td class="label-cell">new row</td><td><input type="text" name="'+name+'...

javascript - Promises for promises that are yet to be created without using the deferred [anti]pattern -

problem 1: 1 api request allowed @ given time, real network requests queued while there's 1 has not been completed yet. app can call api level anytime , expecting promise in return. when api call queued, promise network request created @ point in future - return app? that's how can solved deferred "proxy" promise: var queue = []; function callapi (params) { if (api_available) { api_available = false; return dorealnetrequest(params).then(function(data){ api_available = true; continuerequests(); return data; }); } else { var deferred = promise.defer(); function makerequest() { api_available = false; dorealnetrequest(params).then(function(data) { deferred.resolve(data); api_available = true; continuerequests(); }, deferred.reject); } queue.push(makerequest); return deferred.promise; } } function continuerequests() { if (queue.length) { var makerequest = queue.sh...

parsing - How do you parse and process HTML/XML in PHP? -

how can 1 parse html/xml , extract information it? native xml extensions i prefer using 1 of native xml extensions since come bundled php, faster 3rd party libs , give me control need on markup. dom the dom extension allows operate on xml documents through dom api php 5. implementation of w3c's document object model core level 3, platform- , language-neutral interface allows programs , scripts dynamically access , update content, structure , style of documents. dom capable of parsing , modifying real world (broken) html , can xpath queries . based on libxml . it takes time productive dom, time worth imo. since dom language-agnostic interface, you'll find implementations in many languages, if need change programming language, chances know how use language's dom api then. a basic usage example can found in grabbing href attribute of element , general conceptual overview can found @ domdocument in php how use dom extension has been covered exte...

javascript - How to access the correct `this` inside a callback? -

i have constructor function registers event handler: function myconstructor(data, transport) { this.data = data; transport.on('data', function () { alert(this.data); }); } // mock transport object var transport = { on: function(event, callback) { settimeout(callback, 1000); } }; // called var obj = new myconstructor('foo', transport); however, i'm not able access data property of created object inside callback. looks this not refer object created other one. i tried use object method instead of anonymous function: function myconstructor(data, transport) { this.data = data; transport.on('data', this.alert); } myconstructor.prototype.alert = function() { alert(this.name); }; but exhibits same problems. how can access correct object? what should know this this (aka "the context") special keyword inside each function , value depends on how function...