Posts

javascript - Google Line Chart Adding Array of Objects -

Image
i have array of objects i've created parsing json string: var measurementdata = @html.raw(jsonconvert.serializeobject(this.model.item1)); var stringifieddata = json.stringify(measurementdata); var parseddata = json.parse(stringifieddata); this gives me number of objects, depending on model, looking this: now question is, how add these google line chart without having hardcode datatable? this i've got now, works somewhat: var data = new google.visualization.datatable(); data.addcolumn('string', 'timestamp'); data.addcolumn('number', selectedmeasurements); data.addrows([ [parseddata[index[0]].timestamp, parseddata[index[0]][selectedmeasurements]], [parseddata[index[1]].timestamp, parseddata[index[1]][selectedmeasurements]] ]); chart.draw(data, options, { isstacked: true, vaxis: { viewwindowmode: 'explicit', ...

What is the best way to copy memory for X indexes to many locations within a single array in C? -

what best way copy memory x indexes many locations within single array in c? the problem trying solved emulated memory cpu emulator. original hardware has type of memory mirroring, , attempting replicate via code. say have array: int memory[100] = {0}; and have 10 indexes mirrored @ different locations. example if memory[0] changed, index 0, 10, 20, 30... should change value or if memory[3] changed, index 3, 13, 23, 33 should mirrored. likewise if mirrored location changed other mirror locations should reflect this, such if index 23 changed, 3, 13, 23, 33... etc should reflect this. another requirement way specify start , ends of mirrored locations are. example index 10-19 mirrored @ index 30-39, again @ 70-79 leaving unmodified space in between segments of mirrored indexes. would using memcpy fastest/most efficient way of achieving if this, or sort of iterating loop , pointer math better efficiency? how pointer math done calculate start address copy destination? ar...

c++ - GetPixel is WAY too slow -

i have bunch of squares , each has specific identity/symbol need identify. far have like: #include <iostream> #include <windows.h> using namespace std; int main() { hdc dc = getdc(0); colorref color; int sum, x, y; while (true) { sum = 0; sleep(100); (x = 512; x < 521; x++) { (y = 550; y < 565; y++) { color = getpixel(dc, x, y); sum = getrvalue(color) + getbvalue(color) + getgvalue(color); } } cout << "sum: " << sum << endl; } return 0; } obviously scans 1 block far. problem somehow though it's on 100 pixels, takes insanely long time. can't imagine going on. takes on second, maybe 2 seconds, each repetition. can do? there has faster way this. if can't query individual pixels, there way region of screen? zone not inside program's window.

php - How to test file upload with laravel and phpunit? -

i'm trying run functional test on laravel controller. test image processing, want fake image uploading. how do this? found few examples online none seem work me. here's have: public function testresizemethod() { $this->preparecleandb(); $this->_createaccessablecompany(); $local_file = __dir__ . '/test-files/large-avatar.jpg'; $uploadedfile = new symfony\component\httpfoundation\file\uploadedfile( $local_file, 'large-avatar.jpg', 'image/jpeg', null, null, true ); $values = array( 'company_id' => $this->company->id ); $response = $this->action( 'post', 'filestoragecontroller@store', $values, ['file' => $uploadedfile] ); $readable_response = $this->getreadableresponseobject($response); } but controller doesn't passed check: elseif (!input::hasfile('fi...

Can't get javafx and webview to handle google javascript -

i having issues getting javafx listen on google results. i'm sure it's due javascript live results can't find way around it. document doc = engine.getdocument(); nodelist elements = doc.getelementsbytagname("a"); for(int i=0; < elements.getlength();i++){ ((eventtarget) elements.item(i)).addeventlistener("click", listener, false); } in chrome browser i'm able right click result , inspect. dom shows fine. how have javafx replicate chrome browser can do? i able so: class1 javafx webview application class2 bridge between javascript , java in class1 created method so. can used upon clicking button. private void setjslisteners(){ class2 bridge = new class2(); jsobject hrefwindow = (jsobject) engine.executescript("window"); hrefwindow.setmember("java", bridge); engine.executescript("var links = document.getelementsbytagname(\"a\");" + "for (var = 0; < l...

haskell - Partial application of functions and currying, how to make a better code instead of a lot of maps? -

i beginner @ haskell , trying grasp it. i having following problem: i have function gets 5 parameters, lets f x y w z = x - y - w - z - and apply while changing variable x 1 10 whereas y , w , z , a same. implementation achieved following think there must better way. let's use: x 1 10 y = 1 w = 2 z = 3 = 4 accordingly managed apply function following: map ($ 4) $ map ($ 3) $ map ($ 2) $ map ($ 1) (map f [1..10]) i think there must better way apply lot of missing parameters partially applied functions without having use many maps. all suggestions far good. here's another, might seem bit weird @ first, turns out quite handy in lots of other situations. some type-forming operators, [] , operator maps type of elements, e.g. int type of lists of elements, [int] , have property of being applicative . lists, means there way, denoted operator, <*> , pronounced "apply", turn lists of functions , lists of arguments lists of res...

java - Is this code snippet about semaphore necessary? -

here's code java concurrency in practice , showing how make execute block when work queue full using semaphore bound task injection rate. semaphore equal pool size plus number of queued tasks want allow. public class boundedexecutor { private final executor exec; private final semaphore semaphore; public boundedexecutor(executor exec, int bound) { this.exec = exec; this.semaphore = new semaphore(bound); } public void submittask(final runnable command) throws interruptedexception { semaphore.acquire(); try { exec.execute(new runnable() { public void run() { try { command.run(); } { semaphore.release(); } } }); } catch (rejectedexecutionexception e) { semaphore.release(); } } } my question about catch (rejectedexecutio...