Posts

What is the Infinity property used for in Javascript? -

why infinity property used command (rather result) for example, code below works, result isn't expected. alert(isodd(infinity)); function isodd(num) { return num%2==1; } infinity property of global object holds numeric value representing mathematical concept of infinity . don't know normal definition called "command." with regard edit, should return false (i ran confirm suspicion, , did on browser). correct, infinity not considered odd number.

could not find text file, java file I/O error -

not sure why won't read txt file saved in same directory. compiled fine when enter java blindfoldsaside cmd ln, says cannot find or load main class blindfoldsaside. case correct far can see , in right file path, i'm not sure went wrong! package blindfoldsaside; import java.io.bufferedreader; import java.io.fileinputstream; import java.io.filereader; import java.io.ioexception; import java.util.scanner; public class blindfoldsaside { public static void main (string[] args) { scanner scannerin = null; fileinputstream in = null; bufferedreader inputstream = null; int filechar; //character's int equivalent string fileline; try { // fileinputstream calls txt file in = new fileinputstream("blindfoldsaside.txt"); system.out.println("these lyrics tell story of woman, named kezia, is" + " \nbeing put death after being forced prostitution. song prison...

winforms - Toggle the picture of picture box with picture box on_click c# -

i have 1 image in picture box using resource want change image when click icon.png should changed icon1.png within picturebox when click again picture box should changed icon.png private void picturebox10_click(object sender, eventargs e) { if (picturebox10.imagelocation != @"icon1.png") { var image = image.fromfile(@"icon1.png"); picturebox10.image = image; } if (picturebox10.imagelocation == @"icon1.png") { var image = image.fromfile(@"icon.png"); picturebox10.image = image; } } but not working please me out of this. you're getting null image location it's not set when you're assigning picture image property. there few ways fix this: change assignment assign using imagelocation picturebox10.imagelocation = @"icon1.png"; change check see if image property equal new image picturebox10.image == im...

Dictionary vs. hashtable -

can explain difference between dictionaries , hashtables? in java, i've read dictionaries superset of hashtables, thought other way around. other languages seem treat 2 same. when should 1 used on other, , what's difference? the oxford dictionary of computing defines dictionary as... any data structure representing set of elements can support insertion , deletion of elements test membership. as such, dictionaries abstract idea can reasonably efficiently implemented e.g. binary trees or hash tables, tries, or direct array indexing if keys numeric , not sparse. said, python uses closed-hashing hash table dict implementation, , c# seems use kind of hash table (hence need separate sorteddictionary type). a hash table more specific , concrete data structures: there several implementations options ( closed vs. open hashing being perhaps fundamental), they're characterised o(1) amortised insertion, lookup , deletion, , there's no excuse begin-...

how to write elasticsearch script_score in java api -

i find function in elasticsearch like get /_search { "function_score": { "functions": [ { ...location clause... }, { ...price clause... }, { "script_score": { "params": { "threshold": 80, "discount": 0.1, "target": 10 }, "script": "price = doc['price'].value; margin = doc['margin'].value; if (price < threshold) { return price * margin / target }; return price * (1 - discount) * margin / target;" } } ] } } i use scorefunctionbuilder achive "location caluse" , "price caluse" ,but not know how write "script_score" , "script" java api the es version in project 2.2.0 , use java api achieve function but can not find api scriptscorefunctionbuilder. scriptfunction(string script, map<string...

eclipse - selenium find element in a while loop in java -

so, have selenium webdriver command condition while loop shown here: while (driver.findelement(by.cssselector("a[action='cancel']")).isdisplayed() == true){ driver.navigate().refresh(); timeunit.seconds.sleep(5); driver.findelement(by.id("479510558845313")).sendkeys(instagramaievx.spamusernameinput); driver.findelement(by.id("263795143794707")).sendkeys(instagramaievx.spamcommentinput); driver.findelement(by.id("u_0_4")).sendkeys(x); driver.findelement(by.id("u_0_5")).click(); } timeunit.seconds.sleep(2); driver.findelement(by.xpath("//a[contains(text(),'okay')]")).click(); killfirefox(); so, problem when condition false, not skip while loop , go what's below it. tries : driver.findelement(by.cssselector("a[action='cancel']")) makes program fail. how make skip wh...

ANDROID - Using CursorLoader to get audios causes duplication of audios -

i building activity want populate audios using loader. public class mainactivity extends baseactivity implements loadermanager.loadercallbacks<cursor> { private static final int internal_cursor_id = 0; private static final int external_cursor_id = 1; private arraylist<audio> audios = new arraylist<>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); initloader(); } private void initloader() { try { getsupportloadermanager().initloader(internal_cursor_id, null, this); getsupportloadermanager().initloader(external_cursor_id, null, this); } catch (securityexception e) { } catch (illegalargumentexception e) { } } private static final string[] internal_columns = new string[]{ mediastore.audio.media._id, mediastore.audio.media.album...