Posts

json - Data Structure for Range Matching Lookup -

assume have structure of ranges, , associated data, instance: data [ [ [0, 100], "new york"], [ [101, 200], "boston"], ... ] for function receives n arguments , returns entry n in range of left element. for instance, > 103 < "boston" what best structure transform above achieve fastest lookup time? if data set should dynamic, use interval tree .

Docker swarm mode scale service issue with one worker -

so, trying out docker swarm mode in 1.12. took me time figure out mounts during docker service create, got part work. when try scale, gives me below error: invalid bind mount source, so… is error happening because have 1 worker , mount set ? also, because binding ports, , if have 1 worker node swarm still work if scale app 3 or 5 apps ? how swarm handle port conflicts on 1 worker node ? need this. thanks, jason

Auto input credentials when prompted in ruby -

i newbie ruby. have our install process automated in ruby. facing issue on making ruby script adapt changes in shell script. execute "update_imports" cwd import_home command "./import.sh #{download_dir}/#{import_file} #{user} #{shellwords.escape(password)}" action :run end the import.sh modified such asks username , password (doesn't take username , password arguments earlier) earlier: ./import.sh /tmp/importtest.xml test1 password now: ./import.sh /tmp/importtest.xml username: test1 password: i want modify ruby file adapt change. can suggest best way so? tried searching , learning being pretty new ruby, clueless. you can use open3 in ruby standard library: download_dir = "./test/dir" shell_command = "./import.sh #{download_dir}" username = "username" password = "password" open3.popen3("shell_command") |input, output, error, thread| input.puts(username) # answers username prompt inpu...

node.js - mongoose find not returning results when mongodb it does -

based on this question , this issue find faster findone if query not executed, i'm trying in node.js. in mongodb (cli) i'm executing following command: > db.carts.find({_id: objectid("57bd3df5c878685d3ec581d6")}).limit(1).count() 1 then in node.js, using mongoose i'm using code returns 0: const cartid = '57bd3df5c878685d3ec581d6'; const query = cart.find({ _id: new mongoose.types.objectid(cartid) }).limit(1); console.log(query.count()); // 0 also noted if query executed returns cart: query.exec().then(console.log); // [ { _id: 57bd3df5c878685d3ec581d6, __v: 0, ... here cart model: const cartschema = new schema({ cartitems: [], cartitemscount: { type: number, default: 0 }, carttotal: { eur: { value: { type: number, default: 0 }, currencyprec: { type: number, default: 2 }, count: { type: number, default: 0 }, }, }, carttotalineur: { itemscost: { type: n...

javascript - Can I use save button directly in window function -

i have following code.in when click on 'print map' button popup window gets open on there 2 buttons 'save' , 'print'. when click on 'save' button opens window save file. what want when click on 'print map' button window after clicking save button should open. function printelem(elem) { popup($(elem).html()); } function popup(data) { var mywindow = window.open('', 'parent', 'height=400,width=600'); mywindow.document.write('<html><head><title>my div</title>'); /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />'); mywindow.document.write('</head><body >'); mywindow.document.write(data); mywindow.document.write('</body></html>'); mywindow.document.close(); // necessary ie >= 10 mywindow.f...

Reset/swap two fragments in ViewPager Android -

i have 2 fragments in viewpager along tabs. have settings option in app allows user choose default fragment in viewpager. here have tried: btnsavelayout.click += delegate { var selectedid = radiogrouplayout.checkedradiobuttonid; radiobuttonlayout = dialog.findviewbyid<radiobutton>(selectedid); layoutpreference = radiobuttonlayout.text; meditor.putstring("defaultlayout", layoutpreference); meditor.commit(); dialog.dismiss(); setupviewpager(layoutpreference); ; }; private void setupviewpager(string layoutpref) { adapter = new viewpageradapter(supportfragmentmanager); pager = findviewbyid<viewpager>(resource.id.tabanim_viewpager); if (string.isnullorempty(layoutpref) || layoutpref.equals("first view")) ...

c# - Why this range attribute in mvc does not give me right answer.? -

i'm trying apply range attribute on class field this. [range(typeof(int32), "1","999", errormessage = "must number between 1 , 999")] public long? fieldname{ get; set; } but doesn't validate range expecting. supposed validate range between 1 , 999. how resolve issue. try this.......... [range(typeof(int32), "1", "999", errormessage = "must positive natural number between 1 , 999")] [regularexpression("^[0-9]{1,3}$", errormessage = "must positive natural number between 1 , 999")] public long? fieldname { get; set; }