Posts

java - How to read full line while using line split? -

bufferedreader tableread = new bufferedreader(new filereader(tablefile)); while ((tableline = tableread.readline()) != null){ cnamedata = tableline.split(","); (int =0; i< cnamedata.length; i++){ system.out.println(cnamedata[i]); } } this code in mind takes line example, john, 23, male, , splits , puts array cnamedata, when prints out gives 23 , male only, how insert john array? in advance.

vb.net - Type Mismatch Error, declaring Range Variable in Excel VBA -

Image
this should simple fix, i've searched , searched , can't figure out wrong. i'm getting "run-time error 13: type mismatch": dim rng range dim endrw integer, endcol integer endrw = 30 endcol = 10 set rng = sheets("sheet1").range(sheets("sheet1").cells(2,3),sheets("sheet1").cells(endrw,endcol)) ^^^ last line causing error ^^^^ try set rng = sheets("sheet1").range(cells(2, 3), cells(endrw, endcol)) evidence.

php - My script does not recognize my IP -

i use geoiploc library . created simple script variables: $ip = $_server["remote_addr"]; $my_country_code = getcountryfromip($ip, "code"); and uploaded script server. result: variable $ip returns ip, , variable $my_country_code returns code of country, good! that same script uploaded server ( http://subdomain.my-domain.com , belongs job). result: variable $ip does not return ip, ip: 192.168.211.xxx. therefore, variable $my_country_code not return country code. in both cases use home pc. what's going on?

sqlite - distinct values as new columns & count -

i'm trying generate summary table using sqlite below. i need aggregate 1) number of times each model driven, 2) total distance driven & 3) distinct values driver col & count number of times each driver has driven particular model - group model with count(model) & sum(distance) 1 & 2 - `i need last part #3 , right approach find number of occurrences each distinct values of column , add them new columns each model ? my table is: id model datetime driver distance ---|-----|------------|--------|--------- 1 | s | 04/03/2009 | john | 399 2 | x | 04/03/2009 | juliet | 244 3 | 3 | 04/03/2009 | borat | 555 4 | 3 | 03/03/2009 | john | 300 5 | x | 03/03/2009 | juliet | 200 6 | x | 03/03/2009 | borat | 500 7 | s | 24/12/2008 | borat | 600 8 | x | 01/01/2009 | borat | 700 result be id model| drives distance john juliet borat ---|-----|--------|---------|------|------ |------ 1 | s | 2 | 999 | 1 | ...

generics - Can a Java argument be type-bound by a Class contained in another object? -

note: question theoretical; i've since given on using immediately , i've thought overcomplicates code , smells little antipattern. however, find interesting in theory , love community's it. i'm refurbing code written around turn of century image manipulation; beginning chopping apart single class lot of redundancies number of bifunction filters. each accept bufferedimage , intensity (double), , return new bufferedimage. of course, lot of these image filters have additional concerns, radius-of-effect or intensity, , if i'm going chain them efficiently, able set these "uniforms" (or quasi-constants) before use. my current method extend imagefilter class further, , set uniforms bean-style properties. thought of doing constraining them generic class held in interface, , having along lines of: public void addproperty(uniform<t> property, t type) in there, t specified entirely uniform. the original class kept of these uniforms in hashmap stri...

android - Sqlite database update after async post not working -

i using httppost method send message android device via web server. when response comes back, device supposed update on-board database format i've used million times, if(postmessage(themessage).trim().equals("ok")){ databasehelper helper = new databasehelper(sharedialog.this); database = helper.getwritabledatabase(); strsharedwith = strsharedwith + thenameencoded+ "|~|";//my delimiter; string strfilter = "listtitle= '" + listtitle + "'"; contentvalues values = new contentvalues(); values.put("sharedwith", strsharedwith); int numrows = database.update("listdata", values, strfilter, null); database.close(); toast.maketext(getbasecontext(), numrows + "", toast.length_short).show();//toasts "1" everything appears work: message sent other device, response comes web server, , toast message indicates 1 row has been updated...but value remains null. see i'm missing? thanks...

go - How to measure both before and after byte size and time to compress -

i want gzip string (it json response) var b bytes.buffer gz := gzip.newwriter(&b) if _, err := gz.write([]byte("yourdatahere")); err != nil { panic(err) } how can output size of bytes before , after compression , more importantly how can time takes compress , decompress string? you can calculate size per nipun talukdar's comment. len([]byte("yourdatahere")) b.len() and use time.now() , time.since() time taken. var b bytes.buffer input := []byte("yourdatahere") fmt.println("input size : ", len(input)) gz := gzip.newwriter(&b) start := time.now() gz.write(input) if _, err := gz.flush(); err != nil { panic(err) } totaltime := time.since(start) fmt.println("compressed size : ", b.len(), "\ntime taken : ", totaltime) gz.close() same method can applied unzipping. can create support function can timing. func timer(starttime time.time) { totaltime := time.since(starttime...