Posts

android - Load CSS file from assets to a WebView with custom HTML and predefined Base URL -

i need load html construct @ runtime webview , apply css file placed in assets directory . , already have base url need provide webview's loaddatawithbaseurl function. code snippet (not applying css file): stringbuffer buff = new stringbuffer(); buff.append("<head>"); buff.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_asset/my_css_file.css\"/>"); buff.append("</head>"); buff.append("<div class=\"announcement-header\">"); buff.append("header"); buff.append("</div>"); buff.append("<div class=\"announcement-separator\"></div>"); buff.append("<div class=\"announcement\">"); buff.append("content"); buff.append("</div>") webview.loaddatawithbaseurl(my_base_url, buff.tostring(), "text/html", http.utf_8, null); i've looked @ ...

Compile R script into standalone .exe file? -

is there easy way compile r script standalone .exe file matlab does? as matter of fact there way achieve solution meet requirements. have @ article on deploying desktop apps r on r-bloggers. detailed in article, end using few more things single exe file. also draw attention rgtk2 use of rgtk2 attempt develop own interface in r. if push comes shove, trust pack r code portable version of r , dependencies 1 installer , make , app that, create illusion of single exe file. in question asked whether it's easy develop standalone executable file interpreting r code. wouldn't it's easy. if have strong desire run r code application, in simpler manner using rcaller java or r.net .

javascript - Why the Ternary Operator isn't working right? -

well, i'm working in chat room website... , have problem... reason ternary operator doesn't give me right output... that's code piece of code job... html = html.replace(/(@[a-za-z0-9]{1,})/, "<span class='" + (myusername == "$1".replace('@', '') ? "highlighted-username" : "") + "'>$1</span>"); let's name "jimisdam" , writes in chat "@jimisdam"... so... i'm getting $1 , removing '@' compare myusername(which "jimisdam") what's wrong ?? js doesn't know want substitute $1 place before doing replacement. sees method call html.replace takes 2 arguments: the regex match the string replace with to calculate second parameter, evaluates expression: "<span class='" + (myusername == "$1".replace('@', '') ? "highlighted-username" : "") + "'>$1...

IOS Swift - How can I use 2 table views in a collectionview with different data -

i developing app have collectionview 2 different tableviews. need know how can recognize tableview filled data @ moment. each uiview object has tag property, used identify uiview @ runtime . you set this: mytableview1.tag = int.min mytableview2.tag = int.max and in delegate , datasource methods: func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { let rowcount: int if tableview.tag == int.min { rowcount = self.datafortableview1.count } else { rowcount = self.datafortableview2.count } return rowcount } use tag value identify right tableview , that's it.

java - Creating an RDD after retrieving data from cassandra DB -

i'm using cassandra , spark project, wrote retrieve data db: results = session.execute("select * foo.test"); arraylist<string> supportlist = new arraylist<string>(); (row row : results) { supportlist.add(row.getstring("firstcolumn") + "," + row.getstring("secondcolumn"))); } javardd<string> input = sparkcontext.parallelize(supportlist); javapairrdd<string, double> tuple = input.maptopair(new pairfunction<string, string, double>() { public tuple2<string, double> call(string x) { string[] parts = x.split(","); return new tuple2(parts[0],string.valueof(new random().nextint(30) + 1)); } it works, want know if there pretty way write above code, want achieve is: in scala can retrieve , fill rdd in way : val datardd = sc.cassandratable[tablecolumnnames]("keyspace", "table") h...

python - uploading a plot from memory to s3 using matplotlib and boto -

this working script generates plot, saves locally disk, uploads s3 , deletes file: plt.figure(figsize=(6,6)) plt.plot(x, y, 'bo') plt.savefig('file_location') conn = boto.s3.connect_to_region( region_name=aws_region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, calling_format=boto.s3.connection.ordinarycallingformat() ) bucket = conn.get_bucket('bucket_name') k = key(bucket) k.key = 'file_name' k.set_contents_from_filename('file_location') os.remove(file_location) what want skip disk writing , upload plot directly memory. any suggestions how achieve that? putting together: img_data = io.bytesio() plt.savefig(img_data, format='png') img_data.seek(0) s3 = boto3.resource('s3') bucket = s3.bucket(bucket_name) bucket.put_object(body=img_data, contenttype='image/png', key=key) thanks @padraic-cunningham , @guyb7 tips!

c++ - Queue implementation is losing track of head node -

i have queue add function implemented void queue::add(myobj info) { node* node = new node; node->info = &info; //<---suspect node->next = null; if(head == null){ head = node; } else{ tail->next = node; } tail = node; count++; } every time gets visited head node's data points whatever i'm passing in. realize there template trying build one, because need practice. i trying keep pointers pointed original objects. wanted pass in object , point refrence. the node struct myobj * info , node * next info parameter of function, passed value. in case, &info address of parameter, , not of original data. this undefined behaviour , can give weird results. one possible solution be: void queue::add(myobj& info) // pass reference { ... // unchanged code } in case, &info refer address of original object.