Posts

date - Java: Group arraylist records by derived attribute -

i have arraylist created input csv file, in calculations performed generate more columns afterwards printed csv file. in arraylist, 1 of attributes unix time stamp. record comprises of 7 different days. want group records day, if it's not in order, order groups time (the specifics, i.e. hours, minutes, seconds). so, input csv file, extracted unix timestamp using delimiter, e.g. 1442327884 , used code retrieve day java.util.date time = new java.util.date((long) timestamp * 1000); // gives result of tue sep 15 22:38:04 sgt 2015 string date = string.valueof(time.getdate());; // gives result of "15" a method used calculation grouping follows map<string, list<string>> groups = data.stream().collect(collectors.groupingby(e -> e.split(",")[1])); how set groupby string date mentioned above? you check out radix sort . kind of sorting you're looking for.

Android native webrtc app stream quality -

i have problem android application using webrtc. in general working correctly on devices quality of stream terrible. using io.pristine:libjingle:9127@aar lib establish webrtc connection - compiled version of official webrtc android lib. for example on nexus 5 video quality awesome 20-25% usage of cpu. on se sp quality terrible, cpu arround 50% (so still power available). both devices working on same wifi network. as far know webrtc should pick video quality own, there way manually ? i use following on ios limit framerate , resolution, giving library more room scale bitrate instead. // initialize video constraints nsmutablearray *m = [[nsmutablearray alloc] init]; nsmutablearray *o = [[nsmutablearray alloc] init]; [m addobject:[[rtcpair alloc] initwithkey:@"minwidth" value:@"640"]]; [m addobject:[[rtcpair alloc] initwithkey:@"minheight" value:@"480"]]; [m addobject:[[rtcpair alloc] initwithkey:@"maxframerate" value...

javascript - Change color of text in pop up message box -

i have message box pops display message if field left blank on form. want change color of writing red protected void displaymsg(string msg) { string script = "<script>$(document).ready(function () { $(\"<div>" + msg.replace("'","").replace("\"","")+ "</div>\").dialog({modal: true,title: \"note\",buttons: [ { text: \"ok\", click: function() { $( ).dialog( \"close\" ); } } ]}); });</script>"; clientscript.registerclientscriptblock(this.gettype(), "message", script); } how change color of text? just add style div element, this "<div style='color:red'>" + msg.replace("'","").replace("\"","")+ "</div>\"

Formatting a list of numbers using for loops in python -

so i've got homework assignment i'm having trouble with. we're supposed use nested loops display set of numbers in variety of different ways. need 3 out of 4 of following patterns, , know how make 1. pattern a 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 pattern b 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 pattern c 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 pattern d 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 (i don't know why c , d won't display right, should have idea) i've got following code make pattern a: for x in range(5): y in range(1, x + 2): print(y, end = '\r') print() any appreciated! what see changing part c , d? there's numbers change along initial space between first number, right? implies need keep track of # of spaces in loop. , b, if can piece algorithm 1, can other. hint: what's initial starting point...

Python Multithreading how to set 1 pool to run tasks as a queue -

i want make 1 pool run tasks should follow queue , order. import multiprocessing import time def func(msg): in xrange(3): print msg time.sleep(2) if __name__ == "__main__": pool = multiprocessing.pool(processes=1) in xrange(10): msg = "hello %d" %(i) pool.apply_async(func, (msg, )) pool.close() time.sleep(50); print "sub-process(es) done." it can print something. there not come 1 one. done immediately actually runs @ different time. show @ same time.

ios - STHTTPRequest "& char" how i can send this char to a php page? -

my ios app have send/retrive date throught php pages. example call usingi sthttprequest : __block sthttprequest *up = [sthttprequest requestwithurlstring:[nsstring stringwithformat:@"%@%@",pathserver,@"retrivedata.php"]]; up.encodepostdictionary=no; up.postdataencoding=nsutf8stringencoding; up.postdictionary = @{@"name":@"name", @"surname":@"surname"}; it's ok until decide insert lik : up.postdictionary = @{@"name":@"na&me", @"surname":@"surname"}; in way a print_r($_post); in retrivedata.php results in: array ( [name] => na [surname] => surname ) the name cutted @ "&" char index. have tried no success like: utf8_encode/utf8_decode($name) it seems name arrives retrivedata.php cutted, can't use chars conversion/encoding... in sthttprequest have tried set: up.encodepostdictionary=yes; with setting can send "&"...

linux - Merge two Json files with awk in bash -

i try merge 2 json files in 1 file, 1 condition, e.g : if file 1 has example : testa:result>fail , file b contains same line different result e.g : testa:result>pass, file 1 update results file 2, have line awk command merge files without condition : awk 'begin{print "{"} fnr > 1 && last_file == filename {print line} fnr == 1 {line = ""} fnr==1 && fnr != nr {printf ","} fnr > 1 {line = $0} {last_file = filename} end{print "}"}' json_files/* > json_files/all_merged.json please need this. i suggest use python task. consider example: import json pprint import pprint filename1 = "file1.json" # file1 contains { "testname": "color", "result": "fail" } filename2 = "file2.json" # file2 contains { "anothertestname": "color2", "result": "pass" } filenameto = "file3.json" def visualize(dat...