Thursday 15 January 2015

cookies - Python SimpleCookie Access Using CherryPy -



cookies - Python SimpleCookie Access Using CherryPy -

i'm having issues retrieving cookies sent client on server using python module cherrypy.

in web browser can see cookies in chrome's web console going resources -> cookies -> localhost. , have 3 cookies next values.

and on server side have next info eclipse debugger:

my question why don't foo , release_id show in keys? there i'm doing wrong?

note:

cookies = cherrypy.request.cookie

javascript code setting cookies:

$(function() { // functions w3c schools: http://www.w3schools.com/js/js_cookies.asp function setcookie(cname, cvalue, exdays) { var d = new date(); d.settime(d.gettime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toutcstring() + ";"; var path = "path=/;" // accessible all. document.cookie = cname + "=" + cvalue + "; " + expires + path; } function getcookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charat(0)==' ') c = c.substring(1); if (c.indexof(name) != -1) homecoming c.substring(name.length, c.length); } homecoming ""; } setcookie("foo", "bar", 1 ); setcookie("release_id", "2", 1 ); });

are sure cookies.keys not cherrypy.response.cookie?

cherrypy.response.cookie != cherrypy.request.cookie

from debugger print-screen perspective, seems ok havecherrypy.response.cookie thesession_id key @ point.

python cookies cherrypy

c# make multiple different methods trigger a bool -



c# make multiple different methods trigger a bool -

i'm trying grab , handle content changes of listview (add, rename, delete items) on own there no predefined events job. read approach place , switch bool in functions changes ugly coding, i'd avoid. that's why i'm asking if knows way register multiple methods triggers bool in turn tells if considerable changes made, pseudo code:

bool changesdetected = false; void additem() {...} void renameitem() {...} void removeitem() {...} void watchoutforchanges() { if(additemhascompleted || renameitemhascompleted || removeitemhascompleted) { changesdetected = true; } } void formclosing() { if(changesdetected) { // save file selection } }

any ideas appreciated!

you can create own delegate, event, , event handler, , invoke method capture changes. however, think looking way handle events listview has (in windows forms):

bool changesdetected = false; public void setup() { listview view = new listview(); view.afterlabeledit += watchoutforchanges; view.controladded += watchoutforchanges; view.controlremoved += watchoutforchanges; } public void watchoutforchanges(object sender, eventargs e) { changesdetected = true; }

c# methods triggers boolean

javascript - Defered-loaded background image flickers -



javascript - Defered-loaded background image flickers -

i maintain javascript site in 1 huge file - my_scripts.js. on pages, defer loading of file (using in-lined javascript). lastly thing loads.

because html body utilize big background image, thought thought defer loading of image. body css class deleted part: background-image: url('my_background.jpg');

then, first line of my_scripts.js added this: document.body.style.backgroundimage = "url(my_background.jpg)";

now, css needed show background image added main style-sheet javascript. works, big background loads after else has loaded.

but: when navigate between pages, background image flickers. loaded each time. doing wrong? my_scripts.js should in browser's cache! why flicker?

edit: still flickers if preload image with

if (document.images) { img1 = new image(); img1.src = "my_background.jpg"; }

use background-image:url('my_background.jpg)"; instead of document.body.style.backgroundimage = "url(my_background.jpg)";, because, simply, css rule worked no flicker. simple.

javascript html css

Is there a way to ensure that a kernel module runs in a specific process context? -



Is there a way to ensure that a kernel module runs in a specific process context? -

basically, how can create sure in module, specific process current. i've looked @ kick_process, i'm not sure how have module execute in context of process 1 time kicking kernel mode.

i found related question, has no replies. believe reply question help asker well.

note: aware if want task_struct of process, can up. i'm interested in running in specific context since want phone call functions reference current.

best way have found in context of particular process in kernel, sleep in process context(wait_* family of functions) , wake thread , whatever needs done in context. ofcourse mean have have application phone call kernel via ioctl or , sleep on thread , wake whenever need something. seems used , popular mechanism.

process linux-kernel kernel-module

objective c - Open a view that only changes based on the pin that you click? -



objective c - Open a view that only changes based on the pin that you click? -

i have problem not know how solve, have mapview series of pin, if click gives me info of local , when click on "i" should open view info of it. problem this: if wanted open view changes depending on pin clicked?

the mkmapview delegate method mapview:annotationview:calloutaccessorycontroltapped: gives mkannotationview object has property annotation, has properties such title, subtitle, , coordinate. if not plenty identify annotation, subclass , give more properties.

objective-c xcode uiviewcontroller annotations mkmapview

objective c - Slow tableView reload with Yelp API iOS -



objective c - Slow tableView reload with Yelp API iOS -

i playing around yelp's api. have managed create little app allows user input 'term' , 'location', , tableview containing 5 businesses appear. however, takes 30 seconds min info appear on tableview after clicking search. if log out jsonresponse, info in nsarrray in second, still doesn't appear in tableview. sometimes, businesses won't appear @ all.

the code utilize search.

- (ibaction)searchbuttonpressed:(uibutton *)sender { ypapisample *ypapi = [[ypapisample alloc]init]; nsstring *term = self.termtextfield.text; nsstring *location = self.locationtextfield.text; dispatch_group_t requestgroup = dispatch_group_create(); dispatch_group_enter(requestgroup); [ypapi querybusinessesforterm:term location:location completionhandler:^(nsarray *jsonresponse, nserror *error) { if (!error) { self.businessinfoarray = jsonresponse; nslog(@"%lu",[businessinfoarray count]); [self.tableview reloaddata]; } else nslog(@"%@", error); dispatch_group_leave(requestgroup); }]; dispatch_group_wait(requestgroup, dispatch_time_forever); // avoids programme exiting before our asynchronous callbacks have been made. }

you have reload table info using performselector on main thread can got info on time remove dispatch grouping code e.g

-

(void)querytopbusinessinfoforterm:(nsstring *)term location:(nsstring *)location category:(nsstring *)category completionhandler:(void (^)(nsdictionary *topbusinessjson, nserror *error))completionhandler { nslog(@"querying search api term \'%@\' , location \'%@' , category '%@'", term, location,category); nsurlrequest *searchrequest = [self _searchrequestwithterm:term location:location category:category]; nsurlsession *session = [nsurlsession sharedsession]; [[session datataskwithrequest:searchrequest completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { nshttpurlresponse *httpresponse = (nshttpurlresponse *)response; if (!error && httpresponse.statuscode == 200) { nsdictionary *searchresponsejson = [nsjsonserialization jsonobjectwithdata:data options:0 error:&error]; nsarray *businessarray = searchresponsejson[@"businesses"]; if ([businessarray count] > 0) { nslog(@"total businesses==>%@",[searchresponsejson valueforkey:@"total"]); lblresults.text = [nsstring stringwithformat:@"%@",[searchresponsejson valueforkey:@"total"]]; hotellistarray = [businessarray mutablecopy]; allobjectarray = [businessarray mutablecopy]; self.tablehotels.hidden = no; [self performselectoronmainthread:@selector(reloadtabledata:) withobject:hotellistarray waituntildone:yes]; } else { completionhandler(nil, error); // no business found } } else { completionhandler(nil, error); // error happened or http response not 200 ok } }] resume];

ios objective-c uitableview

android - The method putStringExtra(String, String) is undefined for the type Intent -



android - The method putStringExtra(String, String) is undefined for the type Intent -

i trying prepare issue not understand. error "the method putstringextra(string, string) undefined type intent" in line 4 within onitemclick method. reason this?

public void onitemclick(adapterview<?> adapter, view arg1, int position, long arg3) { string item=adapter.getitematposition(position).tostring(); toast.maketext(activity.this, "you click on:"+item, toast.length_short).show(); intent intent = new intent(this, myotheractivity.class); intent.putstringextra(myotheractivity.text_to_display, item); startactivity(intent); }

just utilize intent.putextra(). there no method putstringextra() on intent. knows type of parameter , adds type.

android android-intent

php - format time input on form for 3 dropdown boxes -



php - format time input on form for 3 dropdown boxes -

in cakephp have got form input of type time. user selects time 3 drop downwards boxes (hrs,mins , am/pm). need user able select no time alternative called 'not available'

i have alternative select 'not available' user has alternative of not specifying time. works shown below.

i have drop downwards box of time , needed select not available alternative on hour. instead of selecting not available on min dropdown box , am.pm wanted min , am/pm drop boxes automatically set not available when select alternative on hour.

echo $this->form->input('mon_start', array('label'=> 'start','type' => 'time', 'style'=>'width: 80px', 'empty' => 'not available', 'selected'=>$monstart));

the question little unspecific, here's unspecific answer.

you have utilize javascript, check selected value in onchange event, , set selected options other select elements based on selected value.

here's jquery based example.

js

var selects = $('.selectlr').on('change', function() { if($(this).find(':selected').val() === 'none') { selects.find('[value="none"]').prop('selected', true); } });

html

<select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select class="selectlr"> <option value="none">none</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select>

fiddle

http://jsfiddle.net/7g97no5a/

php cakephp

How do I set where a string starts and ends in python? -



How do I set where a string starts and ends in python? -

i working on project work, , work need capture info on serial port, set string form, , 2 key words in string. 2 words i'm looking "pass" , "2x400mhz".

at work have automated ram tester , automate sorting process ram passes using arduino. in order need monitor info comes out of ram tester via serial port , speed of ram beingness tested, , results of test (pass or fail). 1 time create string necessary info have python write arduino on serial , arduino take care of sorting.

the reason stuck, , makes hard info comes on serial port varies in length according if ram passes or fails instantly, halfway, or near end of test. test around 52 seconds 2gb module , 32 seconds 1gb module. module testing info comes on serial line name of test beingness run , timer counts second, when test on (failed or passed) of info on module's spd chip dumped on serial line along word "pass" or "fail". timer counter making amount of info per test different depending on fails why want create string of spd info since contains info has significance me.

i have used serial monitoring programme capture sample show info working with.the spd info interested in near bottom, rest of info above timer. info near bottom same besides spd info (speed, configuration, serial number). hoping there way have python utilize 1 word show before , after spd info start , stop creating string, way string spd info , exclude counter data.

..waiting handler start ....Åþ....[ esc. ]Åþe.Åþe.Åþe.Åþ.*..l001: wk_addr [00:00]Åþ....[cancel]Åþa'Åþ.*..l001: wk_data [00:00]Åþ....[cancel]Åþa'Åþ.*..l001: mats [00:01]Åþ....[cancel]Åþa'Åþ...![00:02]Åþ...![00:02]Åþ...![00:03]Åþ...![00:03]Åþ...![00:03]Åþ...![00:04]Åþ...![00:05]Åþ...![00:05]Åþ...![00:06]Åþ...![00:06]Åþ...![00:07]Åþ...![00:07]Åþ...![00:08]Åþ...![00:09]Åþ...![00:09]Åþ...![00:10]Åþ.*..l001: mar_x [00:10]Åþ....[cancel]Åþa'Åþ...![00:11]Åþ...![00:11]Åþ...![00:12]Åþ...![00:12]Åþ...![00:12]Åþ...![00:13]Åþ...![00:14]Åþ...![00:14]Åþ...![00:15]Åþ...![00:15]Åþ...![00:16]Åþ...![00:16]Åþ...![00:17]Åþ...![00:18]Åþ...![00:18]Åþ...![00:19]Åþ...![00:19]Åþ...![00:20]Åþ...![00:20]Åþ...![00:21]Åþ.*..l001: mar_c [00:21]Åþ....[cancel]Åþa'Åþ...![00:22]Åþ...![00:22]Åþ...![00:23]Åþ...![00:23]Åþ...![00:24]Åþ...![00:24]Åþ...![00:25]Åþ...![00:25]Åþ...![00:26]Åþ...![00:26]Åþ...![00:27]Åþ...![00:28]Åþ...![00:28]Åþ...![00:29]Åþ...![00:29]Åþ...![00:30]Åþ...![00:31]Åþ...![00:31]Åþ...![00:32]Åþ...![00:32]Åþ...![00:32]Åþ...![00:33]Åþ...![00:34]Åþ...![00:34]Åþ...![00:35]Åþ...![00:35]Åþ...![00:36]Åþ...![00:37]Åþ...![00:37]Åþ...![00:37]Åþ...![00:38]Åþ...![00:39]Åþ.*..l001: mar_y [00:39]Åþ....[cancel]Åþa'Åþ...![00:39]Åþ...![00:40]Åþ...![00:40]Åþ...![00:41]Åþ...![00:41]Åþ...![00:42]Åþ...![00:42]Åþ...![00:43]Åþ...![00:43]Åþ...![00:44]Åþ...![00:44]Åþ...![00:45]Åþ...![00:45]Åþ...![00:46]Åþ...![00:46]Åþ...![00:47]Åþ...![00:47]Åþ...![00:48]Åþ...![00:48]Åþ...![00:49]Åþ...![00:49]Åþ...![00:50]Åþ...![00:50]Åþ...![00:51]Åþ...![00:51]Åþ...![00:52]Åþ...![00:52]Åþ...![00:53]Åþe.Åþ}...Åþe.Åþa¡Åþd.Åþ"0.module..: ****ddr2 256mx72 2gb 2r(8)@2x400mhz 1.8v.Åþ"...(tested @ 2x400mhz).Åþ".addr.(rowxcol.).: 14 x 10.Åþ".data (rankxbit).: 2 x 72.Åþ".internal banks.: 8.Åþ""burst.: mode=sequential, length=8.Åþ"*ac parameters.: cl=5, al=0, trcd=5, trp=5.Åþ".s/n spd.: a128f4f3.Åþ".test loop #.: 1.Åþ"..## pass: loop 1 ##.Åþ"..elapsed time.: 00:00:53.448.Åþa¢Åþc.............h..ÿÿÿÿ"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ...s-(u.?€.....".. Åþ@.Åþe.Åþ....**pass - l001 @2x400mhzÅþ...![00:53]Åþ....transmit results ...Åþa¡Åþd.Åþ"0.module..: ddr2 256mx72 2gb 2r(8)@2x400mhz 1.8v.Åþ"...(tested @ 2x400mhz).Åþ".addr.(rowxcol.).: 14 x 10.Åþ".data (rankxbit).: 2 x 72.Åþ".internal banks.: 8.Åþ""burst.: mode=sequential, length=8.Åþ"*ac parameters.: cl=5, al=0, trcd=5, trp=5.Åþ".s/n spd.: .Åþ".test loop #.: 1.Åþ"..## pass: loop 1 ##.Åþ"..elapsed time.: 00:00:53.448.Åþa¢Åþ@.Åþ.** ..**

seems you're looking .find() method of string. using , wonderful utility python's string slices, can accomplish you're after.

as example:

# our string text we're after. blob = "filler text filler text begin we're after. end filler text." # utilize .find() find first occurrence of 2 given substrings. start = blob.find("begin") end = blob.find("end") # our result be: 'begin we're after. ' result = blob[start:end]

if wanted take step further, add together len() value of start string piece in order prevent begin beingness added , remove leading , trailing spaces blob.strip()

hope helps.

python string serial-port slice

Verilog code does not print desired output -



Verilog code does not print desired output -

can tell me why simple verilog programme doesn't print 4 want?

primitive confrontatore(output z, input x, input y); table 0 0 : 1; 0 1 : 0; 1 0 : 0; 1 1 : 1; endtable endprimitive

comparatore :

module comparatore (r, x, y); output wire r; input wire [21:0]x; input wire [21:0]y; wire [21:0]z; genvar i; generate for(i=0; i<22; i=i+1) begin confrontatore t(z[i],x[i],y[i]); end endgenerate assign r = & z; endmodule

commutatore :

module commutatore (uscita_commutatore, alpha); output wire [2:0]uscita_commutatore; input wire alpha; reg [2:0]temp; initial begin case (alpha) 1'b0 : assign temp = 3; 1'b1 : assign temp = 4; endcase end assign uscita_commutatore = temp; endmodule

prova:

module prova(); reg [21:0]in1; reg [21:0]in2; wire [2:0]uscita; wire uscita_comparatore; comparatore c(uscita_comparatore, in1, in2); commutatore c(uscita, uscita_comparatore); initial begin in1 = 14; $dumpfile("prova.vcd"); $dumpvars; $monitor("\n in1 %d in2 %d -> uscita %d uscita_comparatore %d \n", in1, in2, uscita, uscita_comparatore); #25 in2 = 14; #100 $finish; end endmodule

the issue in commutatore. using initial, means procedural block executed @ time 0. @ time 0, input alpha 1'bx, meaning temp not assigned anything. instead of initial, utilize always @* execute procedural block every time alpha changes.

generally should not assign statements in procedural blocks. legal verilog source of design bugs , synthesis back upwards limited.

always @* begin case (alpha) 1'b0 : temp = 3; 1'b1 : temp = 4; default: temp = 3'bx; // <-- optional : grab known unknown transitions endcase end

verilog

c# - WPF Button content to Textbox -



c# - WPF Button content to Textbox -

i'm trying create calculator , first time coding using gui

i'm using visual studio 2012 wpf using c# application

how button content calculator textbox (screen) ?

xaml:

<button x:name="one" style="{staticresource {x:static toolbar.buttonstylekey}}" foreground="white" fontsize="20" fontweight="bold" width="50" height="41" content="1" margin="31,350,491,64" click="button_click" horizontalalignment="left" verticalalignment="bottom"/>

c#:

private void button_click(object sender, eventargs e) { button b = (button)sender; screen.text = screen.text + b.text; }

it underlines text next b.

error 1 'system.windows.controls.button' not contain definition 'text' , no extension method 'text' accepting first argument of type 'system.windows.controls.button' found (are missing using directive or assembly reference?)

time larn msdn! here page button class. notice there no text property, there content property. have cast string content of type object.

screen.text = screen.text + b.content.tostring();

note simplify code to:

screen.text += b.content.tostring();

c# wpf xaml button textbox

Convert string to custom date format - c# razor -



Convert string to custom date format - c# razor -

i have mysql database storing events , events have dates. i'm pulling in event dates , they're outputting in html strings.

<ul id="latest-events"> @{ ientity[] latestevents = viewbag.latestevents; foreach (ientity event in latestevents) { <li class="item"> <span class="event-date"> @event["displaydate"] </span> <a href="#">@event["title"]</a> <span class="teaser">@html.raw(event["teaser"])</span> </li> } } </ul>

currently, format "10/31/2014 12:00:00 am"

i prefer oct 31 believe mmm d format.

is possible?

var mydate = event["displaydate"]; var oldformat = "m/d/yyyy h:m:s"; var newformat = "mmm d"; var newdate = mydate.oldformat.convertto(newformat);

just clear, don't know c# why above convertto not possible. possible convert string using datetime?

you should able utilize razor phone call conversion:

@item.date.tostring("mmmm dd, yyyy")

another approach:

[displayformat(dataformatstring = "{mmmm 0:dd yyyy")] public datetime date { get; set; } @html.displayfor(d => d.date);

you do, datetime.parseexact.

var date = datetime.parseexact(odate, format, cultureinfo.invariantculture);

another option, hope helps.

c# razor

regex - redirect htaccess not working -



regex - redirect htaccess not working -

im trying redirects site inherited, didnt build original htaccess

currently when click in link in google takes me 404 landing page , whereas want take me about_us page...

rewritebase / rewriterule ^showroom$ index.php?route=showroom/showroom [l] rewriterule ^blog$ index.php?route=blog/home [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] rewriterule ^about$ https://www.example.ie/about_us/ [r,l]

you need maintain redirect rules before internal routing ones:

rewriteengine on rewritebase / rewriterule ^about$ https://www.example.ie/about_us/ [r,l] rewriterule ^showroom$ index.php?route=showroom/showroom [l] rewriterule ^blog$ index.php?route=blog/home [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^(.*)$ index.php?_route_=$1 [l,qsa]

regex apache .htaccess mod-rewrite redirect

Flex native extension for iOS packaging error -



Flex native extension for iOS packaging error -

i trying create native extension in air receipt printer in ios. when seek bundle application using flash builder 4.7 (on windows 8.1), error message:

error occurred while packaging application:

ld: file built archive not architecture beingness linked (armv7): c:\users\appdata\local\temp\cfb2713d-1d55-4db3-b645-f5e8b4a58f36/libcom.domain.printer.a architecture armv7

compilation failed while executing : ld64

please help !

ios flex package flash-builder ane

eclipse - Digital clock text stopped in Android -



eclipse - Digital clock text stopped in Android -

final textview tw = (textview) findviewbyid(r.id.textview1); string mydate = java.text.dateformat.getdatetimeinstance().format( calendar.getinstance().gettime()); tw.settext(mydate);

is android application code, text displayed hr hour stopped, why?

because, have refresh it, when want display time. code set once. can utilize textclock, or refresh code every x seconds in infinitive thread this:

private thread datetimethread; private textview tw; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); tw = (textview) findviewbyid(r.id.textview1); } @override public void onpause() { super.onpause(); if (datetimethread != null) { datetimethread.interrupt(); datetimethread = null; } } @override public void onresume() { super.onresume(); datetimerunner timerunnable = new datetimerunner(); datetimethread = new thread(timerunnable); datetimethread.start(); } private void ticktime() { runonuithread(new runnable() { public void run() { string mydate = java.text.dateformat.getdatetimeinstance().format(calendar.getinstance().gettime()); tw.settext(mydate); } }); } protected class datetimerunner implements runnable { // @override public void run() { while (!thread.currentthread().isinterrupted()) { seek { ticktime(); thread.sleep(1000); } grab (interruptedexception e) { thread.currentthread().interrupt(); } grab (exception e) { } } } }

android eclipse time

java - Understanding String type MAP -



java - Understanding String type MAP -

can 1 explain below code :

public map<string, list<subscriptionbean>> getsubscriptioninfo(drivermanagerdatasource ds, webmartconfiguration webmartconnection, int publisherid, int setno, inputdetails inputdetailsob, reportproperties repob, publishergeneralbean pubob);

as know map pair of key , values. , in scenario key string type , object list type of subscription bean. please right me if m wrong.

now unable understand getsubscriptioninfo ?

in probability, builds map. keys strings, values lists of subscriptionbeans. after builds map, returns it.

but of course, way know read method's documentation.

java string generics map hashmap

maven - Mock FacesContext to test my faces message displayer class -



maven - Mock FacesContext to test my faces message displayer class -

my backing bean:

@managedbean(name = "messagedisplayer") @viewscoped public class messagedisplayer implements serializable { private final logger logger = loggerfactory.getlogger(this.getclass()); public void showmessage (facesmessage.severity severity, string summary, string detail) { facescontext context = facescontext.getcurrentinstance(); logger.debug("showing message severity='{}', summary='{}', detail='{}'", severity, summary, detail); context.addmessage(null, new facesmessage(severity, summary, detail)); } }

any help on how can utilize moclito test class!?

you should utilize powermock mock static methods. here illustration of how utilize it: https://code.google.com/p/powermock/wiki/mockstatic

maven jsf junit mockito facescontext

c - Bitwise Operations Help/Suggestions -



c - Bitwise Operations Help/Suggestions -

alright, i'm not looking answers or that. on recent exams, when i've been asked perform relatively simple bitwise operations, can't seem job done. given 30 minutes hour, flush out, 10 minutes or less, stuck.

for example, asked write little function, if x > y,return 1, else 0. couldnt life of me provide answer. after exam, went home , wrote out answer, took me half hour.

im doing best faster @ because know i'm going these kind of questions 1 time again on final.

what rules, axioms, or can utilize help me going on these kind of problems. when see problem this, reasoning helps form answer.

you're going need next general knowledge

understanding of c operators 2's complement arithmetic boolean algebra

a trick may come in handy n-bit folding. example, let's i'm given 32-bit value argument function, , need homecoming 1 if of bits 1, or 0 otherwise. (further assume rules of question don't allow me in sensible fashion.) function this

int hasbitsset( uint32_t value ) { value |= value >> 16; value |= value >> 8; value |= value >> 4; value |= value >> 2; value |= value >> 1; return( value & 1 ); }

the first 5 lines of function "fold" 32-bit value, if bit 1, lsb of result 1. lastly line of function returns lsb. using brute forcefulness boolean algebra, equivalent function is

int hasbitsset( uint32_t value ) { uint32_t bit31 = (value >> 31) & 1; uint32_t bit30 = (value >> 30) & 1; ... uint32_t bit0 = value & 1; return( bit31 | bit30 | ... | bit0 ); }

the point folding useful in reducing amount of code have write, can folding can done brute-force boolean algebra. if you're not sure whether folding work, algebra.

the final thing i'll mention comparisons implemented subtraction. in other words, determine whether x > y, first compute x - y, , check whether result positive. in 2's complement arithmetic, number positive if msb 0 , @ to the lowest degree 1 of other bits 1. extract msb, fold other 31 bits, , utilize boolean algebra generate final result.

that lastly bit of knowledge (comparison equivalence subtraction) problem-specific , troublesome since every question have arcane tidbit of knowledge makes question easier. can pay attending in class , hope little gems stick in mind when they're mentioned.

c bit-manipulation bitwise-operators computer-architecture

java - Not able to download ARM EABI 7a system image for Android 4.4 -



java - Not able to download ARM EABI 7a system image for Android 4.4 -

i not able install arm eabi scheme 7a scheme image android 4.4 getting while trying install sdk:

downloading android sdk tools, revision 23.0.5 download interrupted: unexpected http status 403 downloading android tv arm eabi v7a scheme image, android api 21, revision 1 download interrupted: unexpected http status 403 downloading android tv intel x86 atom scheme image, android api 21, revision 1 download interrupted: unexpected http status 403 downloading arm eabi v7a scheme image, android api 21, revision 1 download interrupted: unexpected http status 403 downloading intel x86 atom_64 scheme image, android api 21, revision 1 download interrupted: unexpected http status 403 downloading intel x86 atom scheme image, android api 21, revision 1 download interrupted: unexpected http status 403 done. nil installed.

i tried installing offline.i downloaded zip file : http://dl-ssl.google.com/android/repository/sys-img/android-wear/sysimg_wear_arm-20_r02.zip copied .zip file in temp folder of sdk directory.but still tries install scheme image net , gives same error mentioned above. without arm scheme image file not able create avd , hence not able proceed. thought how can prepare this.

just re-create sdk folder other computer , paste in yours. don't forget, in eclipse, give path of copied folder.

java android sdk download android-avd

Strange behavior with Python flood-fill algorithm -



Strange behavior with Python flood-fill algorithm -

i'm implementing flood-fill algorithm python minesweeper.

before show algorithm, allow me define things important:

board, when pretty printed, looks this:

x 1 1 1 3 x 2 1 2 x 2 2 3 x 2 x x 3 1 2 1 1 2 2 1 2 x 3 x 3 2 x 2 2 x x 2 3 4 x 4 x 3 x 1 x 2 1 x 2 3 3 x 2 1 1 1 3 3 2 1 x 2 4 x 4 1 1 x 2 2 3 3 2 x 4 3 1 1 x 1 1 2 3 4 x 3 1 1 1 1 2 3 2 x x 2 2 x x 1 2 3 3 2 2 x x 3 4 x 2 1 x x 2 x 3 3 2 3 3 3 2 1 2 2 x x 4 x 3 2 3 x x 2 1 1 1 3 2 2 1 x 2 x 1 2 x 3 x 4 x x 4 3 1 2 x 3 1 1 2 x 2 2 2 2 1 1 3 x 4 2 3 3 3 x x 3 2 1 1 1 1 1 x 3 1 3 x 2 2 x 2 1 x 1 1 4 x x 1 1 x 2 x 3 1 3 x 2 1 2 2 2 2 2 2 3 x 3 1 2 3 x 2 3 x 2 1 1 1 1 1 1 x 2 2 x 4 x 3 1 1 x 2 x 2 1 1 1 1 2 x 1 1 2 3 x 2 2 x x 2 1 1 1 2 2 1 2 3 x 2 1 1 1 x 2 1 1 1 2 2 2 2 2 1 x 2 1 x x 3 2 1 1 3 3 2 1 1 1 1 1 2 x x 2 x 2 1 2 2 3 x 2 1 x x 2 2 x 1 2 x 3 3 x 2 1 1 1 1 2 1 1 2 x 2 2 3 4 x 2 2 2 4 x 3 1 1 1 1 x 1 1 x 1 2 2 3 2 x 3 2 1 1 x 3 x 2 2 2 2 1 1 1 1 x 2 x 3 x 1 1 1 2 1 1 1 x 1

obviously x's represent mines, , numbers represent number of mines surrounding place. empty spaces mean there no numbers there. board how i'm storing information.

current_board, when pretty printed, looks this:

[a][b][c][d][e][f][g][h][i][j][k][l][m][n][o][p][q][r][s][t][u][v][w][x][y] [1] o o o o o o o o o o o o o o o o o o o o o o o o o [2] o o o o o o o o o o o o o o o o o o o o o o o o o [3] o o o o o o o o o o o o o o o o o o o o o o o o o [4] o o o o o o o o o o o o o o o o o o o o o o o o o [5] o o o o o o o o o o o o o o o o o o o o o o o o o [6] o o o o o o o o o o o o o o o o o o o o o o o o o [7] o o o o o o o o o o o o o o o o o o o o o o o o o [8] o o o o o o o o o o o o o o o o o o o o o o o o o [9] o o o o o o o o o o o o o o o o o o o o o o o o o [10] o o o o o o o o o o o o o o o o o o o o o o o o o [11] o o o o o o o o o o o o o o o o o o o o o o o o o [12] o o o o o o o o o o o o o o o o o o o o o o o o o [13] o o o o o o o o o o o o o o o o o o o o o o o o o [14] o o o o o o o o o o o o o o o o o o o o o o o o o [15] o o o o o o o o o o o o o o o o o o o o o o o o o [16] o o o o o o o o o o o o o o o o o o o o o o o o o [17] o o o o o o o o o o o o o o o o o o o o o o o o o [18] o o o o o o o o o o o o o o o o o o o o o o o o o

the zeros covered cells. board , current_board have same number of rows , columns.

finally,

possible_mine_numbers = ['1','2','3','4','5','6','7','8']

so, when user enters row , column value, eg 1,a, coverted python indexing, (0,0) , passed floodfill algorithm (note print statements used rough debugging).

def floodfill(current_board, row, col): print row print col if board[row][col] in possible_mine_numbers: current_board[row][col] = board[row][col] + ' ' else: if current_board[row][col] != ' ': current_board[row][col] = ' ' if row > 0: print 'a' floodfill(current_board, row - 1, col) if row < len(board[row]) - 1: print 'b' floodfill(current_board, row + 1, col) if col > 0: print 'c' floodfill(current_board, row, col - 1) if col < len(board) - 1: print 'd' floodfill(current_board, row, col + 1)

now, algorithm works fine in position other bottom row of board (row 17). when seek run on bottom row, illustration 18, e (17, 4) next output (due debugging) (look @ lastly 3):

17 4 16 4 15 4 14 4 16 4 b 15 3 c 15 5 d 17 4 b 16 3 c 16 5 d 18 4

it says 'a', 18, , 4! reason floodfill algorithm jumping 16 18 on first if branch. makes absolutely no sense me , i'm not sure why i'm getting unusual behavior. if @ rest of output, can see jumping 2 row indices @ points.

can see wrong algorithm?

you're saying if row < len(board[row]) comparing row index length of row (i.e. number of columns) not number of rows. similarly, you're comparing col, column index, len(board), len(board) certainly number of rows, not number of columns.

python algorithm list flood-fill minesweeper

Receive an email in SQL Server to add data to a table -



Receive an email in SQL Server to add data to a table -

i have set email business relationship uses msdb database automatically generated. i've set emails sent sql server works fine, not receiving replies database, nor stand lone email sent database, appears email business relationship using send emails from...

is able help me or point me in right direction can send email sql server database update file, illustration want send time sheet via email in format:

monday 08:00 17:00 tuesday 08:00 17:30

if stored database know can read , convert represent want, ability send email the sql server having issues with.

i using sql server 2012 64 bit aswell

sql sql-server-2012

c++ - How to find the frequency of a range of random numbers? -



c++ - How to find the frequency of a range of random numbers? -

i'm beginner @ c++ , trying find frequency of numbers(1-6) random number generator of 100 numbers. commands can utilize rand, srand, cin, cout, loops, , if else. possible create programme shows frequency using these commands? give thanks you.

you can utilize std::map<int, int> first random number , second count.

therefore frequency count / total.

c++ random numbers generator frequency

javascript - Looping through the JSON returned for creating my chart -



javascript - Looping through the JSON returned for creating my chart -

i trying create info series needed canvasjs chart dynamically , far had no joy. somehow code not working. getting next error:

syntaxerror: missing : after property id for(var i=0; i<datapoints.length; i++){

this json data

[ { "t": "t3", "y": 6.8, "x": "2004-07-05" }, { "t": "t4", "y": 29, "x": "2004-07-05" }, { "t": "tsh", "y": 0.01, "x": "2004-07-05" }, { "t": "thyroglobulin level", "y": 0.5, "x": "2004-07-05" }, { "t": "t3", "y": 5.2, "x": "2005-06-15" }, { "t": "t4", "y": 30, "x": "2005-06-15" }, { "t": "tsh", "y": 0.02, "x": "2005-06-15" }, { "t": "thyroglobulin level", "y": 0.5, "x": "2005-06-15" } ]

here code retrieving json , creating info series

$(document).ready(function(){ $("#find").click(function(e){ e.preventdefault(); $.ajax({ // url request url: "bloodtest.php", // info send (will converted query string) data: {pnhsno: "1001001002"}, // whether post or request type: "get", // type of info expect datatype : "json", // code run if request succeeds; // response passed function success: function(json){ if(json.length !=0){ var datapoints = json.map(function (p) { p.x = new date(p.x); homecoming p; }); $("#chart").canvasjschart({ //pass chart options title:{text:"blood test results"}, axisx:{valueformatstring:"dd-mm-yyyy",labelangle:-45}, data: [{ type: "line", //change column, spline, line, pie, etc for(var i=0; i<datapoints.length; i++){ if(datapoints[i].t =="t3"){ datapoints:[ {x:datapoints.x, y:datapoints.y}] } } ] }); } } }); }); });

at point in code syntax error occurs, you're attempting create object literal for loop within of it. compiler crapping out because can't interpret program. it's expecting object property identifier, not for loop.

specifically, illegal part:

data: [{ type: "line", for(...) <----- javascript doesn't allow 'for' loop here...

javascript jquery json iteration

awk to print unique latest date & time lines based on column fields -



awk to print unique latest date & time lines based on column fields -

would print unique lines based on first field , latest date & time of 3rd field, maintain latest date , time occurrence of line , remove duplicate of other occurrences. having around 50 1000000 rows , file not sorted ...

input.csv

10,ab,15-sep-14.11:09:06,abc,xxx,yyy,zzz 20,ab,23-sep-14.08:09:35,abc,xxx,yyy,zzz 10,ab,25-sep-14.08:09:26,abc,xxx,yyy,zzz 62,ab,12-sep-14.03:09:23,abc,xxx,yyy,zzz 58,ab,22-jul-14.05:07:07,abc,xxx,yyy,zzz 20,ab,23-sep-14.07:09:35,abc,xxx,yyy,zzz

desired output:

10,ab,25-sep-14.08:09:26,abc,xxx,yyy,zzz 20,ab,23-sep-14.08:09:35,abc,xxx,yyy,zzz 62,ab,12-sep-14.03:09:23,abc,xxx,yyy,zzz 58,ab,22-jul-14.05:07:07,abc,xxx,yyy,zzz

have attempeted partial commands , in-complete due date , time format of file united nations sorting order ...

awk -f, '!seen[$1,$3]++' input.csv

looking suggestions ...

this awk command you:

awk -f, -v ofs=',' '{sub(/[.]/," ",$3);"date -d\""$3"\" +%s"|getline d} !($1 in b)||d>b[$1] {b[$1] =d; a[$1] = $0} end{for(x in a)print a[x]}' file first line transforms original $3 valid date format string , seconds 1970 via date cmd, later compare. using a , b 2 arrays hold final result , latest date (seconds) the end block print rows a test illustration data: kent$ cat f 10,ab,15-sep-14.11:09:06,abc,xxx,yyy,zzz 20,ab,23-sep-14.08:09:35,abc,xxx,yyy,zzz 10,ab,25-sep-14.08:09:26,abc,xxx,yyy,zzz 62,ab,12-sep-14.03:09:23,abc,xxx,yyy,zzz 58,ab,22-jul-14.05:07:07,abc,xxx,yyy,zzz 20,ab,23-sep-14.07:09:35,abc,xxx,yyy,zzz kent$ awk -f, '{sub(/[.]/," ",$3);"date -d\""$3"\" +%s"|getline d} !($1 in b)||d>b[$1] { b[$1] =d;a[$1] = $0 } end{for(x in a)print a[x]}' f 10 ab 25-sep-14 08:09:26 abc xxx yyy zzz 20 ab 23-sep-14 08:09:35 abc xxx yyy zzz 58 ab 22-jul-14 05:07:07 abc xxx yyy zzz 62 ab 12-sep-14 03:09:23 abc xxx yyy zzz

awk

c# - 'The parameter 'f' was not bound in the specified LINQ to Entities query expression' -



c# - 'The parameter 'f' was not bound in the specified LINQ to Entities query expression' -

using ef 6. can tell me doing wrong?

public list<searchresult> searchdocuments(list<searchcriteria> searchcriterias) { list<searchresult> results = new list<searchresult>(); var fieldsettings = loadcoordinatesystemfieldsettings(searchcriterias); using (var context = createcontext()) { var tractsquery = predicatebuilder.false<v_uploadbytract_activeuploads>(); foreach (var searchcriteria in searchcriterias) { var querybuilder = predicatebuilder.true<v_uploadbytract_activeuploads>(); // tractsquery if (searchcriteria.stateapi.hasvalue) querybuilder = querybuilder.and(a => a.stateapi == searchcriteria.stateapi.value); if (searchcriteria.countyapi.hasvalue) querybuilder = querybuilder.and(a => a.countyapi == searchcriteria.countyapi.value); // ... // ... many more similar if-ands // ... tractsquery = tractsquery.or(querybuilder); } var searchquery = context.v_uploadbytract_activeuploads.asexpandable().where(tractsquery).tolist(); //.select(a => searchresult.create(a)); //results.addrange(searchquery.tolist()); } homecoming results; } public static class predicatebuilder { public static expression<func<t, bool>> true<t>() { homecoming f => true; } public static expression<func<t, bool>> false<t>() { homecoming f => false; } public static expression<func<t, bool>> or<t>(this expression<func<t, bool>> expr1, expression<func<t, bool>> expr2) { var invokedexpr = expression.invoke(expr2, expr1.parameters.cast<expression>()); homecoming expression.lambda<func<t, bool>> (expression.orelse(expr1.body, invokedexpr), expr1.parameters); } public static expression<func<t, bool>> and<t>(this expression<func<t, bool>> expr1, expression<func<t, bool>> expr2) { var invokedexpr = expression.invoke(expr2, expr1.parameters.cast<expression>()); homecoming expression.lambda<func<t, bool>> (expression.andalso(expr1.body, invokedexpr), expr1.parameters); } }

quetzalcoatl answer. other post did it. else had come across asexpandable() , overlooked 1 thinking it's talking same. after reading post , re-reading discussion, worked. since post shows "comment", unable mark answer. suggestions on how consolidate nasty ifs.

c# predicatebuilder entities: parameter 'f' not bound in specified linq entities query expression

c# entity-framework-6.1

drop down menu - Liferay 6.2 Alloy UI Dropdown -



drop down menu - Liferay 6.2 Alloy UI Dropdown -

im trying create illustration work on liferay 6.2 installation: http://alloyui.com/tutorials/dropdown/

but reason not working me, have added code on view.jsp file within portlet, code:

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> `<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-collapse"> <ul class="nav navbar-nav"> <li id="mydropdown" class="dropdown"> <a id="mytrigger" href="#" class="dropdown-toggle">dropdown <b class="caret"></b></a> <ul class="dropdown-menu" style="padding: 8px"> close on escape </ul> </li> </ul> </div> </div> </nav>

and right after alloy ui code:

<aui:script> yui().use( 'aui-dropdown', function(y) { new y.dropdown( { boundingbox: '#mydropdown', trigger: '#mytrigger', hideonclickoutside: false, hideonesc: true, open: true } ).render(); } ); </aui:script>

what dropdown link can't find way create "i close on escape" dropdown when click trigger. (just in case helps guys thought of what's going on) when seek portlet on website im not able create dropdown work on liferay dockbar, guess it's wrong yui code.

it not possible utilize aui-dropdown in liferay 6.2.

according liferay integration wiki article, liferay 6.2 uses alloyui 2.0.x. aui-dropdown created in commit e9b3a1035a36148f9ea75c15796d0d4d342a3452, , first tag contain commit 3.0.0pr1~164,* means aui-dropdown not in alloyui 2.0.x.

note: it's not possible upgrade new major version of alloyui in liferay either.

*found using:

git describe --contains e9b3a1035a36148f9ea75c15796d0d4d342a3452

drop-down-menu liferay yui alloy-ui

c# - Oracle odbc driver not registered IIS -



c# - Oracle odbc driver not registered IIS -

i know been asked many times. i'm struggling on this. have 32bit app on iis7, have oracle client installed 32bit. have path set oracle home folder. can see 32bit dirvers installed in wow64 (odbc info sources.exe) folder. can see iis app running in 32bit mode. there.

i have test console app can connect oracle ii7 app keeps ticking, provider not registered.. both have same code same connection string.

i have enable app pool run 32bit apps. have run command aspreg_iis -enable -i

i have un-installed , reinstalled oracle client tools..

nothing wants work..

please help.

not versions of odp seem work equally. v 12b seems work best 32bit apps on 64bit pcs. i'd remove other versions, install , create sure files version in gac , in path variable.

c# oracle iis-7 provider

apache - Why http client responds to a [FIN, ACK] with a [ACK], (without responding a [FIN, ACK])? -



apache - Why http client responds to a [FIN, ACK] with a [ACK], (without responding a [FIN, ACK])? -

server sends [fin, ack] after connection timeout, client responds [fin, ack] , collection closed properly. client responds [ack] , seek send info server.

can please explain why sometime client responds [ack]?

apache http tcp httpconnection

sublimetext - How do I dynamically reload snippets in Sublime Text? -



sublimetext - How do I dynamically reload snippets in Sublime Text? -

when create plugin, , alter .py file, automatically reloads , changes take effect in sublime text 3 immediately. when create .sublime-snippet file seems updated after restarting sublime.

upd: interesting behavior on symbolic link. create in packages folder symbolic link git repo, exist .py , snipets. when alter .py plugin automatically reload, snepets doesn't. in true folder in packages work fine!

regarding symlink issue, mount --bind <src> <dest>. mounts (dropbox, whatever...) folder volume true path. when @ it, symlink file, explain update not occurring.

the alternative of creating hard link works files, not folders, way.

sublimetext sublimetext3

java - How to get current thread/object memory usage in jsp? -



java - How to get current thread/object memory usage in jsp? -

i seek memory usage linkedlist, homecoming 0.

<% runtime runtime = runtime.getruntime(); java.text.decimalformat df = new java.text.decimalformat("###,###.##"); long start = runtime.freememory(); java.util.linkedlist list = new java.util.linkedlist(); (int = 0; < 100; i++) list.add("asd"); system.out.println(df.format(start - runtime.freememory())); %>

is there anyway improve way memory usage thread or object?

java jsp memory

plsql - How can I generate (or get) a ddl script on an existing table in oracle? I have to re-create them in Hive -



plsql - How can I generate (or get) a ddl script on an existing table in oracle? I have to re-create them in Hive -

how can generate ddl script on existing table in oracle? working on project have re-create tables nowadays in oracle table hive.

if sql client doesn't back upwards this, can utilize dbms_metadata bundle source in database:

for table utilize this:

select dbms_metadata.get_ddl('table', 'your_table_name') dual;

you can tables @ once:

select dbms_metadata.get_ddl('table', table_name) user_tables;

and spool output sql script.

more details in manual: http://docs.oracle.com/cd/e11882_01/appdev.112/e40758/d_metada.htm

oracle plsql ddl

jquery - JavaScript reading cookie not working -



jquery - JavaScript reading cookie not working -

i have been searching reading cookies lastly several hours , posted questions in site still no luck.

all need set cookie on 1 page , read cookie on other page. have tried escape , unescape no result.

here code on first page setting cookie

document.cookie = 'province=' +window.escape($(elem).text()) +'; expires=fri, 3 dec 2014 20:47:11 utc; path=/';

and here reading it

function re() { var = get_cookie("province"); alert(a); window.location = "lp.aspx?"+a; } function get_cookie(cookie_name) { var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); if (results) homecoming (window.unescape(results[1])); else homecoming null; }

i have tried answers on stackoverflow still looking solution.

again need set cookie on 1 page , read on other page.

try using following

var testcookievalue = $.cookie("testcookie"); // read $.cookie("testcookie", 1); // write

hope helps.

javascript jquery cookies

javascript - can't find the error in json document -



javascript - can't find the error in json document -

i cannot find error in json document, have tried validate on jsonlint, cannot understand error.

{ "type": "mongodb", "mongodb": { "servers": [ { "port": 27017, "host": “abc.com” } ], "options": { "secondary_read_preference": true }, "db": “abc”, "collection": “abc” }, "index": { "name": “abc”, "type": “id” } }

here jsonlint result screenshot

please explain wrong it.

you using wrong double quotes, should utilize " instead of

javascript json

ios - Darken an opaque UIView without blending -



ios - Darken an opaque UIView without blending -

my app's background opaque uiimageview. under circumstances darken downwards in animated way total brightness 50%. lower alpha property of view , works well. because nil behind view, background image becomes dark.

however, i've been profiling using core animation instrument , when this, see the whole background shows beingness blended. i'd avoid if possible.

it seems me achievable during compositing. if view opaque, possible mix black without behind showing through. it's not necessary blend it, adjust pixel values.

i wondered if uikit's gpu compositing supports. while blending isn't great, it's lot improve updating image on cpu, think cpu approach not substitute.

another question asks this, , few ideas suggested including setting alpha. no 1 has brought mechanism avoiding blending though.

an of import question here whether want alter using darkened background animated.

not animated

prepare 2 different background images , swap between them. uiimage+imageeffects library help generating darkened image, or give leads.

animated.

take @ gpuimage - "an open source ios framework gpu-based image , video processing". based on render background in scene in darkened way.

ios uiimageview uikit opacity alphablending

R: Spline Across/Horizontally/Across a Matrix -



R: Spline Across/Horizontally/Across a Matrix -

i have matrix similar this:

1 2 3 4 5 1.4 na 2.3 0.2 na b na 3.2 1.2 na na c 3.5 na na na na d 2.1 1.9 na na na

i need interpolate na's in matrix. able when specify row in:

fmm = spline(x = 1:5, y = rationa[1,1:5], xout = 1:5, method = "fmm")

but not entire table @ once.

plus, instead of doing each row, each column. is, instead of interpolating in terms of (1.4, na, 2.3, 0.2, na), uses (1.4, na, 3.5, 2.1). need former.

how spline per row instead of columns without specifying row?

thank you.

you can utilize function apply execute specified function each row or column of matrix

sample data

*txt=" 1 2 3 4 5 1.4 na 2.3 0.2 na b na 3.2 1.2 na na c 3.5 na na na na d 2.1 1.9 na na na" df=read.table(text=txt,header=t)*

sample calculation

fmm = spline(x = 1:5, y = df[1,1:5], xout = 1:5, method = "fmm")

function calculate each row

myfun<-function(yrow){ fmm = spline(x = 1:5, y = yrow, xout = 1:5, method = "fmm") return(fmm$y) }

evaluate each row of matrix. note, transpose needed since output of "apply" column vector.

df_interp <- t(apply(df, 1, myfun))

resulting output

df_interp [,1] [,2] [,3] [,4] [,5] 1.4 2.7 2.3 0.2 -3.6 b 5.2 3.2 1.2 -0.8 -2.8 c 3.5 3.5 3.5 3.5 3.5 d 2.1 1.9 1.7 1.5 1.3

r matrix interpolation spline

algorithm - Rewrite matrix into rules -



algorithm - Rewrite matrix into rules -

i have lot of rectangular matrices each cell represents outcome. matrices hard maintain, goal rewrite of them rules.

example matrix 1:

this easy turn rules (pseudocode):

if (i <= 5 , j <=3) else if (i <= 5 , j >=4) b else c

how rewrite next matrix?

plain text:

ij 1 2 3 4 5 6 7 8 9 1 c c c c b 2 c c c c b b 3 c c c c b b b 4 c c c c b b b b 5 c c c c b b b b b 6 c c c b b b b b b 7 c c b b b b b b b 8 c b b b b b b b b 9 b b b b b b b b b

the sec matrix can represented as:

if (i+j <= 5) homecoming a; else if (i+j <= 9) homecoming c; else homecoming b;

in general, can check side of diagonal line point on testing i+j / line, or i-j \ line.

algorithm matrix

Transfering equations from Excel To C# -



Transfering equations from Excel To C# -

i'm trying convert excel spreadsheet little programme made c#.

the equation have on excel is:

if(s6>=3.55;1;if(s6>2.25;0.8;if(s6>1.61;0.65;0.5)))

where s6 cell value check written.

i tried following:

if (width>=3.55) { double radius = 1.0; else if (width>2.25 ) { double radius = 0.8; } else if (width>1.6 ) { double radius = 0.65; } else { double radius = 0.5; } }

but doesn't work, i'm missing, how should declare variable radius dependent of variable width? message on c# says cannot declare variable "radius" in current scope, should declare variable before loop? msdn help file utilize fixed value homecoming statement within if statement, means cannot have variable dependency within if{} loop?also, there other more effective way kind of conditional logic?

an if block not contain else/else if statements. need close original if statement first. also, declaring local variable in each scope , not using doesn't create sense. want declare radius outside scope of of if/else blocks

double radius; if (width>=3.55) { radius = 1.0; } else if (width>2.25 ) { radius = 0.8; } else if (width>1.6 ) { radius = 0.65; } else { radius = 0.5; }

c# excel

javascript - NodeJS request works local, not on VPS -



javascript - NodeJS request works local, not on VPS -

in nodejs project, send request html of webpage. works fine when run code on macbook, request times out when run same code on vps. don't know lot servers, have no thought look.

this request send:

request({ uri: 'http://torrentz.eu/search?f=' + encodeuricomponent(data.query) , headers: { 'user-agent': 'mozilla/5.0 (macintosh; intel mac os x 10_6_8) applewebkit/537.13+ (khtml, gecko) version/5.1.7 safari/534.57.2', } }, console.dir);

error:

{ [error: connect etimedout] code: 'etimedout', errno: 'etimedout', syscall: 'connect' }

edit:

other requests (like 1 below) work fine.

request({ uri: 'http://api.trakt.tv/account/test/' + config.trakt.apikey , method: 'post' , form: { username: data.username , password: data.password } }, function( err, resp, info ) { if( data.status === 'success' ) { user.set({ trakt_username: data.username , trakt_password: data.password }).then(defer.resolve).catch(defer.reject); } else { defer.reject( data.error ); } });

javascript node.js vps

java - finding the first instance of an integer in command line -



java - finding the first instance of an integer in command line -

how find first int of command prompt input user inputs

jdshusaduidsuiuhd3j

what utilize extract 3? thinking

int whatever = new scanner(system.in).usedelimiter("\\d+").nextint();

but doesn't seem work do?

try this:

scanner in = new scanner(system.in); string str = in.next(); int whatever = new scanner(str).usedelimiter("\\d+").nextint();

java

c++ - Qt websockets to connect to Pusher service -



c++ - Qt websockets to connect to Pusher service -

i have javascript snippet connects pusher service need convert c++

<script src="//js.pusher.com/2.2/pusher.min.js" type="text/javascript"></script> <script type="text/javascript"> var pusher = new pusher("cb65d0a7a72cd94adf1f"); var channel = pusher.subscribe("ticker.155"); channel.bind("message", function(data) { //console.log(data); var topbuy = data.trade.topbuy; var topsell = data.trade.topsell; console.log("buy price: ", topbuy.price, "buy quantity:", topbuy.quantity), console.log("sell price: ", topsell.price, "sell quantity:", topsell.quantity); }); </script>

i able bust open connection packet little thought of going on http://i.imgur.com/4iyidlz.png can't seem connection.

socketclass.cpp

#include "socketclass.h" socketclass::socketclass(qobject *parent) : qobject(parent) { } void socketclass::test() { socket = new qtcpsocket(this); connect(socket,signal(connected()), this, slot(connected())); connect(socket,signal(disconnected()), this, slot(disconnected())); connect(socket,signal(readyread()), this, slot(readyread())); connect(socket,signal(byteswritten(qint64)), this, slot(byteswritten(qint64))); qdebug() << "......connecting"; socket->connecttohost("ws.pusherapp.com/app/cb65d0a7a72cd94adf1f?protocol=7&client=js&version=2.2.3&flash=false",80); if(!socket->waitforconnected(1000)) { qdebug() << "error: " << socket->errorstring(); } } void socketclass::connected() { //meat , potatoes goes here qdebug() << "......connected"; //socket->write("head / http/1.0\r\n\r\n\r\n"); socket->event(); } void socketclass::disconnected() { qdebug() << "......disconnected"; } void socketclass::byteswritten (qint64 bytes) { qdebug() << "we wrote: " << bytes; } void socketclass::readyread() { qdebug() << "reading..,,"; qdebug() << socket->readall(); }

socketclass.h

#ifndef socketclass_h #define socketclass_h #include <qdebug> #include <qobject> #include <qtcpsocket> #include <qabstractsocket> class socketclass : public qobject { q_object public: explicit socketclass(qobject *parent = 0); void test(); signals: public slots: void connected(); void disconnected(); void byteswritten (qint64 bytes); void readyread(); private: qtcpsocket *socket; }; #endif // socketclass_h

main.cpp

#include <qcoreapplication> #include "socketclass.h" int main(int argc, char *argv[]) { qcoreapplication a(argc, argv); socketclass mtest; mtest.test(); homecoming a.exec(); }

what proper connection parameters should utilize c++ websockets emulate javascript? trying receive ticker info , assign object or variable.

my qt experience bit old, see won't signals since don't have event loop running. should not utilize waitforconnected call, should either run a.exec() , allow take care of pumping events. thing seems weird phone call waitforconnected, an error still phone call a.exec() don't signals after (or maybe stopping application after failure?).

c++ qt websocket pusher

orm - CakePHP 3.0 -> Between find condition -



orm - CakePHP 3.0 -> Between find condition -

is possible "between ? , ?" status in cakephp 2.5? in cakephp 2.5 write like

'conditions' => ['start_date between ? , ?' => ['2014-01-01', '2014-12-32']]

how can migrate that?

additionally write

'conditions' => [ '? between start_date , end_date'] => '2014-03-31']

update in mean time between look added core, supports first case:

$query = $table ->find('all') ->where([function($exp) { homecoming $exp->between('start_date', '2014-01-01', '2014-12-32', 'date'); }]);

also value binding works fine orm query builder too:

$query = $table ->find('all') ->where([ 'start_date between :start , :end' ]) ->bind(':start', new \datetime('2014-01-01'), 'date') ->bind(':end', new \datetime('2014-12-31'), 'date'); debug($query->all()->toarray());

currently there seems 2 options.

value binding (via database query builder)

for orm query builder (cake\orm\query), 1 beingness retrived when invoking illustration find() on table object, doesn't back upwards value binding

https://github.com/cakephp/cakephp/issues/4926

so, beingness able utilize bindings you'd have utilize underlying database query builder (cake\database\query), can illustration retrived via connection::newquery().

here's example:

$conn = connectionmanager::get('default'); $query = $conn->newquery(); $query ->select('*') ->from('table_name') ->where([ 'start_date between :start , :end' ]) ->bind(':start', new \datetime('2014-01-01'), 'date') ->bind(':end', new \datetime('2014-12-31'), 'date'); debug($query->execute()->fetchall());

this result in query similar this

select * table_name start_date between '2014-01-01' , '2014-12-31' a custom look class

another alternative custom expression class generates appropriate sql snippets. here's example.

column names should wrapped identifier look objects in order them auto quoted (in case auto quoting enabled), key > value array syntax binding values, array key actual value, , array value datatype.

please note it's not safe straight pass user input column names, not beingness escaped! utilize whitelist or similar create sure column name safe use!

field between values use app\database\expression\betweencomparison; utilize cake\database\expression\identifierexpression; $between = new betweencomparison( new identifierexpression('created'), ['2014-01-01' => 'date'], ['2014-12-31' => 'date'] ); $tablename = tableregistry::get('tablename'); $query = $tablename ->find('all') ->where($between); debug($query->execute()->fetchall());

this generate query similar 1 above.

value between fields use app\database\expression\betweencomparison; utilize cake\database\expression\identifierexpression; $between = new betweencomparison( ['2014-03-31' => 'date'], new identifierexpression('start_date'), new identifierexpression('end_date') ); $tablename = tableregistry::get('tablename'); $query = $tablename ->find('all') ->where($between); debug($query->execute()->fetchall());

this on other hand result in query similar this

select * table_name '2014-03-31' between start_date , end_date the look class namespace app\database\expression; utilize cake\database\expressioninterface; utilize cake\database\valuebinder; class betweencomparison implements expressioninterface { protected $_field; protected $_valuea; protected $_valueb; public function __construct($field, $valuea, $valueb) { $this->_field = $field; $this->_valuea = $valuea; $this->_valueb = $valueb; } public function sql(valuebinder $generator) { $field = $this->_compilepart($this->_field, $generator); $valuea = $this->_compilepart($this->_valuea, $generator); $valueb = $this->_compilepart($this->_valueb, $generator); homecoming sprintf('%s between %s , %s', $field, $valuea, $valueb); } public function traverse(callable $callable) { $this->_traversepart($this->_field, $callable); $this->_traversepart($this->_valuea, $callable); $this->_traversepart($this->_valueb, $callable); } protected function _bindvalue($value, $generator, $type) { $placeholder = $generator->placeholder('c'); $generator->bind($placeholder, $value, $type); homecoming $placeholder; } protected function _compilepart($value, $generator) { if ($value instanceof expressioninterface) { homecoming $value->sql($generator); } else if(is_array($value)) { homecoming $this->_bindvalue(key($value), $generator, current($value)); } homecoming $value; } protected function _traversepart($value, callable $callable) { if ($value instanceof expressioninterface) { $callable($value); $value->traverse($callable); } } }

cakephp orm cakephp-3.0

Using Phabricator for a full code audit -



Using Phabricator for a full code audit -

i got phabricator installed , hoping utilize our future code reviews. 1 time issue i'm having have couple of projects have never been reviewed/audited, , we're hoping sit down downwards , audit them.

however, i'm not sure how can go doing using phabricator. when comes auditing, phabricator seems geared towards auditing individual commits, rather total codebase. liked ability browse through code in phabricator, highlight sections , comment them (especially since we've got multiple people reviewing same code, 1 of in different timezone), can't regular code viewer.

is there way total code audit of existing project on phabricator, while still benefitting review features have such adding comments?

this feature doesn't exist in phabricator. see following:

https://secure.phabricator.com/t5744 https://secure.phabricator.com/t4348

audit phabricator

android - AppCompat v7 r21 returning error in values.xml? -



android - AppCompat v7 r21 returning error in values.xml? -

i'm using android studio , when add together compile "com.android.support:appcompat-v7:21.0.0" gradle file, i'm getting ton of errors:

c:\users\windowssucks\androidstudioprojects\mmmeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v11\values.xml error:(36, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(36, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(36, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(36, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. c:\users\windowssucks\androidstudioprojects\mmmeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v14\values.xml error:(9, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(9, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(9, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. error:(9, 21) no resource found matches given name: attr 'android:actionmodesharedrawable'. c:\users\windowssucks\androidstudioprojects\mmmeds\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v21\values.xml error:error retrieving parent item: no resource found matches given name 'android:textappearance.material'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.body1'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.body2'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.button'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.caption'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.display1'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.display2'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.display3'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.display4'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.headline'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.large'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.large.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.popupmenu.large'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.popupmenu.small'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.medium'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.medium.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.menu'. error:error retrieving parent item: no resource found matches given name '@android:textappearance.material.searchresult.subtitle'. error:error retrieving parent item: no resource found matches given name '@android:textappearance.material.searchresult.title'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.small'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.small.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.subhead'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.title'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.menu'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.subtitle'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.subtitle.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.title'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.title.inverse'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionmode.subtitle'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionmode.title'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.popupmenu.large'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.popupmenu.small'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.button'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.subtitle'. error:error retrieving parent item: no resource found matches given name 'android:textappearance.material.widget.actionbar.title'. error:error retrieving parent item: no resource found matches given name 'android:themeoverlay.material'. error:error retrieving parent item: no resource found matches given name 'android:themeoverlay.material.actionbar'. error:error retrieving parent item: no resource found matches given name 'android:themeoverlay.material.dark'. error:error retrieving parent item: no resource found matches given name 'android:themeoverlay.material.dark.actionbar'. error:error retrieving parent item: no resource found matches given name 'android:themeoverlay.material.light'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.actionbar.tabtext'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.actionbar.tabview'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.actionbutton'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.actionbutton.closemode'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.actionbutton.overflow'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.autocompletetextview'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.dropdownitem.spinner'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.light.actionbar.tabtext'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.light.actionbar.tabtext'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.light.actionbar.tabview'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.autocompletetextview'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.light.popupmenu'. error:(298, 21) no resource found matches given name: attr 'android:overlapanchor'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.listpopupwindow'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.listview.dropdown'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.listview'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.popupmenu'. error:(298, 21) no resource found matches given name: attr 'android:overlapanchor'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.progressbar'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.progressbar.horizontal'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.spinner'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.spinner'. error:error retrieving parent item: no resource found matches given name 'android:widget.material.toolbar.button.navigation'. error:error retrieving parent item: no resource found matches given name 'android:theme.material'. error:error retrieving parent item: no resource found matches given name 'android:theme.material.dialog'. error:error retrieving parent item: no resource found matches given name 'android:theme.material.light'. error:error retrieving parent item: no resource found matches given name 'android:theme.material.light.dialog'. error:(144, 21) no resource found matches given name: attr 'android:coloraccent'. error:(146, 21) no resource found matches given name: attr 'android:colorcontrolactivated'. error:(147, 21) no resource found matches given name: attr 'android:colorcontrolhighlight'. error:(145, 21) no resource found matches given name: attr 'android:colorcontrolnormal'. error:(142, 21) no resource found matches given name: attr 'android:colorprimary'. error:(143, 21) no resource found matches given name: attr 'android:colorprimarydark'. error:(144, 21) no resource found matches given name: attr 'android:coloraccent'. error:(146, 21) no resource found matches given name: attr 'android:colorcontrolactivated'. error:(147, 21) no resource found matches given name: attr 'android:colorcontrolhighlight'. error:(145, 21) no resource found matches given name: attr 'android:colorcontrolnormal'. error:(142, 21) no resource found matches given name: attr 'android:colorprimary'. error:(143, 21) no resource found matches given name: attr 'android:colorprimarydark'. error:(144, 21) no resource found matches given name: attr 'android:coloraccent'. error:(146, 21) no resource found matches given name: attr 'android:colorcontrolactivated'. error:(147, 21) no resource found matches given name: attr 'android:colorcontrolhighlight'. error:(145, 21) no resource found matches given name: attr 'android:colorcontrolnormal'. error:(142, 21) no resource found matches given name: attr 'android:colorprimary'. error:(143, 21) no resource found matches given name: attr 'android:colorprimarydark'. error:(144, 21) no resource found matches given name: attr 'android:coloraccent'. error:(146, 21) no resource found matches given name: attr 'android:colorcontrolactivated'. error:(147, 21) no resource found matches given name: attr 'android:colorcontrolhighlight'. error:(145, 21) no resource found matches given name: attr 'android:colorcontrolnormal'. error:(142, 21) no resource found matches given name: attr 'android:colorprimary'. error:(143, 21) no resource found matches given name: attr 'android:colorprimarydark'.

all of these seem showing in:

\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v11\values.xml

and

\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0\res\values-v21\values.xml

appcompat v21 builds themes require new apis provided in api 21 (android 5.0). compile application appcompat, must compile against api 21. recommended setup compiling/building api 21 compilesdkversion of 21 , buildtoolsversion of 21.0.1 (which highest @ time - want utilize latest build tools).

android android-studio appcompat

php - cURL Request: POST data is received by server, but returns invalid request -



php - cURL Request: POST data is received by server, but returns invalid request -

i attempting query notam database (https://www.notams.faa.gov) in order have server parse notams display on map, code php.

i'm using curl send post data, however, server returning "invalid request". here post info i'm sending server. sent during request homepage (discovered using fiddler). notams needed "rkrr" icao (airport code incheon center here in korea).

what missing here?

$url = "https://www.notams.faa.gov/dinsqueryweb/queryretrievalmapaction.do"; $ch = curl_init($url); $header = array('host: www.notams.faa.gov', 'content-type: application/x-www-form-urlencoded', 'connection: keep-alive', 'cache-control: max-age=0', 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/*;q=0.8', 'user-agent: mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/37.0.2062.124 safari/537.36', 'referer: https://www.notams.faa.gov/dinsqueryweb/', 'accept-encoding: gzip,deflate', 'accept-language: en-us,en;q=0.8', 'origin: https://www.notams.faa.gov'); $data = 'retrievelocid=rkrr&reporttype=raw&submit=view+notamss&actiontype=notamretriealbyicaos'; curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, 1); $response = curl_exec($ch); echo $response; curl_close($ch);

thanks help!

seems have typo in variable $data value

$data = 'retrievelocid=rkrr&reporttype=raw&submit=view+notamss&actiontype=notamretriealbyicaos';

its

$data = 'retrievelocid=rkrr&reporttype=raw&actiontype=notamretrievalbyicaos&submit=view+notamss';

its not notamretriealbyicaos

its notamretrievalbyicaos

give try

php curl

java - GWT platform independent newline character -



java - GWT platform independent newline character -

in 1 of java classes, want write result looks this:

string line_separator = system.lineseparator(); stringbuilder result = new stringbuilder(); result.append("some characters"); result.append(line_separator);

the class using code passed gwt based frontend. gwt compiles java classes used gwt (e.g. classes in fronted) javascript. however, gwt cannot compile system.lineseparator() there no equivalent method in javascript.

string line_separator = system.getproperty(line.separator);

and

string line_separator = string.format("%n");

also cause gwt compiler exceptions. however,

string line_separator = "\r\n";

works, not platform independent.

how can platform independent newline character compatible gwt?

simplest thing perchance work (out of top of head):

class="lang-java prettyprint-override">string line_separator = gwt.isclient() ? "\n" : getlineseparator(); @gwtincompatible private static string getlineseparator() { homecoming system.lineseparator(); }

that require recent version of gwt (2.6 @ least, maybe 2.7).

the alternative utilize super-source simple provider class:

class="lang-java prettyprint-override">public class lineseparatorprovider { public final string line_separator = system.lineseparator(); } // in super-source public class lineseparatorprovider { public final string line_separator = "\n"; }

note in future version of gwt, system.getproperty work (for properties) perchance create work line.separator.

…or, utilize \n everywhere , when need have \r\n replace("\n", "\r\n").

(if inquire me, i'd utilize \n everywhere, on windows)

java javascript gwt

java - replacement for import.sql file in spring/hibernate project -



java - replacement for import.sql file in spring/hibernate project -

in spring projects, have hibernate configured create tables in database based on entity classes. also, when need insert initial values on tables, set file named import.sql on classpath sql commands insert info in database. wonder if there way accomplish import feature without need place import.sql file within project, using java classes. knows if possible?

you can consider 2 alternatives,

first 1 not java only, since you're using stack, can consider spring dbunit

@runwith(springjunit4classrunner.class) @contextconfiguration(locations = {"/context.xml"}) @testexecutionlisteners({dependencyinjectiontestexecutionlistener.class, dirtiescontexttestexecutionlistener.class, transactionaltestexecutionlistener.class, dbunittestexecutionlistener.class}) @dbunitconfiguration(datasetloader = columnsensingflatxmldatasetloader.class) public class templateit { @before public void after() throws exception { idatabaseconnection connection; idatabasetester databasetester = new jdbcdatabasetester(jdbc_driver, jdbc_url + "&sessionvariables=foreign_key_checks=0", user, jdbc_password); connection = databasetester.getconnection(); querydataset partialdataset = new querydataset(connection); databaseoperation.delete_all.execute(connection, partialdataset); } @databasesetup("../dbunit/data.xml") @expecteddatabase("../dbunit/expected.xml") @test public void testdbunit() throws exception { ... } }

the info handled through xml, library focused around test offers many utilities outmatch dealing sql directly. easier dealing partial data, simplified assertion @expecteddatabase etc.

secondly, 1 "java only" setup utilize prepare info through hibernate entities. i'm assuming you're using generic daos, if not, easy set up. in @before methods of test set db you're liking, snippet

@before public void before() throws daoexception { company company = new company(); companydao.makepersistent(company); }

i favour approach in view increases portability (often utilize in memory dbs testing), readability , maintaince. downside lot of code in tests, , preparing info can tedious complex objects.

java spring hibernate spring-mvc

locate Eclipse's Preferences menu item programmatically in OS X -



locate Eclipse's Preferences menu item programmatically in OS X -

in windows/linux, utilize workbenchwindow.getmenumanager() navigate windows menu , locate preferences menu item. in os x, preferences menu item located in eclipse’s application pulldown menu. api locate preference item in os x? thanks!

the actions preferences (and help , quit) still added in normal places on mac action marked not visible (code in workbenchactionbuilder).

the mac code cocoauihandler sets mac menu items, searches hidden actions when action invoked.

so may not need special mac.

note: workbenchwindow internal class isn't part of official api, not concern testing code (it substantially different between eclipse 3.x , 4.x).

eclipse

javascript - Modify value in directive's scope from separate directive -



javascript - Modify value in directive's scope from separate directive -

let's have chart directive (like pie chart) , settings directive contains form used modify settings chart directive. settings directive displayed in modal dialogue.

how can create changes in settings directive take effect in chart directive?

there can multiple chart directives, each independent settings. settings each chart shown tabs in settings modal, left out maintain illustration simple.

here things have tried/considered:

"use mill share settings values." fails because might have multiple chart directives, each separate settings.

"have settings directive kid of chart directive." settings directive cannot kid of chart directive because needs rendered in modal.

here plunkr along w/ relevant snippets:

<div ng-controller="controller"> <a href ng-click="showsettings()">settings</a> <chart></chart> <chart></chart> </div>

js:

app.controller("controller", function ($scope, $modal) { $scope.showsettings = function () { $modal.open({ scope: $scope, template: "<h1>settings modal</h1><settings></settings>" } ); } }); app.directive("chart", function () { homecoming { restrict: 'e', template: '<h1>chart directive</h1><p>somechartsetting: {{somechartsetting}}</p>', controller: function chartcontroller($scope) { // value represents setting need modify via settings modal. $scope.somechartsetting = "on"; } } }) app.directive("settings", function () { homecoming { restrict: 'e', template: '<a href ng-click="togglesettings()">toggle somechartsetting</a>', controller: function settingscontroller($scope) { $scope.togglesettings = function () { console.log("toggle clicked"); // need modify somechartsetting value chart. } } } })

try hope helps:

<!doctype html> <head> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.css" rel="stylesheet"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.2/ui-bootstrap-tpls.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controller"> <a href ng-click="showsettings()">settings</a> <chart></chart> <chart></chart> </div> <script> var app = angular.module("app", ['ui.bootstrap']); app.controller("controller", function ($scope, $modal) { $scope.showsettings = function () { $modal.open({ scope: $scope, template: "<h1>settings modal</h1><settings></settings>" } ); } }); app.directive("chart", function () { homecoming { restrict: 'e', template: '<h1>chart directive</h1><p>somechartsetting: {{somechartsetting}}</p>', controller: function chartcontroller($scope) { // value represents setting need modify via settings modal. $scope.somechartsetting = "on"; } } }) app.directive("settings", function () { homecoming { restrict: 'e', template: '<a href ng-click="togglesettings()">toggle somechartsetting</a>', controller: function settingscontroller($scope) { $scope.togglesettings = function () { // need modify somechartsetting value chart. } } } }) </script> </body> </html>

http://plnkr.co/edit/g0ogmzlsgyaskumh4aho?p=preview

javascript angularjs angular-directive

.net - How to get window handle of minimized window -



.net - How to get window handle of minimized window -

i need window handle of minimized window in tray. know process name, has not mainwindowhandle set because minimized. how know window handle?

if goal close main window end process, there's pretty straightforward way of doing using system.diagnostics.process object. illustration closes first instance finds of notepad.

var procs = system.diagnostics.process.getprocessesbyname("notepad"); if (procs.length > 0) procs[0].closemainwindow(); foreach (var proc in procs) proc.dispose();

.net windows

touch - Android logging touches -



touch - Android logging touches -

i seek build ui testing environment , log touch events , coordinates.

at moment have scenarios: 1. utilize transparent overlay logs i'm not able click buttons etc. on view below. 2. can click buttons below overlay doesn't log coordinates...

unfortunately both doesn't work. hence know if there way both works?

thanks!

code snippet of overlay window:

oview = new linearlayout(this); oview.setbackgroundcolor(0x88ff0000); // translucent reddish color windowmanager.layoutparams params = new windowmanager.layoutparams( windowmanager.layoutparams.match_parent, windowmanager.layoutparams.match_parent, windowmanager.layoutparams.type_system_alert, windowmanager.layoutparams.flag_not_touchable | windowmanager.layoutparams.flag_not_focusable | windowmanager.layoutparams.flag_watch_outside_touch, pixelformat.transparent); windowmanager wm = (windowmanager) getsystemservice(window_service); wm.addview(oview, params);

moreover create ontouchlistener oview...

the flag_watch_outside_touch "trick" security exploit , patched out in android 4.2+

here's relevant section in andoird source.

as can see comment, if touch not within overlay special flag set nulls coordinates. done stop keylogging , other touch-hijacking exploits.

the alternative know of have rooted device , read straight underlying linux kernel event interface calling like:

getevent -lt /dev/input/eventx

from root shell. l flag makes output more human-readable , t flag attach timestamps output, in case need them. note x id of touchscreen device. can info on available devices using command getevent -lp, touchscreen 1 has abs_mt_position_x , abs_mt_position_y events.

note info you'll low-level , you'll have parse useful. can check out linux kernel documentation on multi-touch devices info on various event codes mean.

android touch listener overlay monitor

c# - How to prevent Visual Studio from adding SAK to prj files -



c# - How to prevent Visual Studio from adding SAK to prj files -

i want next gone prj files:

<sccprojectname>sak</sccprojectname> <scclocalpath>sak</scclocalpath> <sccauxpath>sak</sccauxpath> <sccprovider>sak</sccprovider>

i using source command explorer , not want bindings metadata in prj , sln files.

no matter do, have removed bindings via file -> source command -> advanced - alter source control, , manually removed scc stuff prj , sln files, visual studio keeps altering prj files , sln file when opening solution.

part of solution might involve altering registry, hkey_current_user\software\microsoft\visualstudio\11.0\sourcecontrol alwaysaddprojectslocatedoutsideofsolutiontree changing 0 stopped 18 of 28 prjs getting auto updated scc stuff opening solution.

another thing tried prevent visual studio reloading sln , prj files after removing bindings. visual studio detected edits sln , prjs , effort reload, including on checkin if kind of automerge executed.

a part of solution me when removed bindings on sln, tfs of sudden treat sln not latest. when commit clean sln without scc bindings, automerge occur bringing scc bindings part of latest on tfs server.

so part of attempted solution utilize notepad edit sln, ignore prompts reload visual studio, , checkout edit in source command explorer until tfs 1 time again recognized work space version have latest sln. checkout edit did not work first time treat sln latest in workspace version sec time did.

so worked @ first, solution bindings removed, until added existing project, part of solution before , did have scc info in it, , added source command bindings sln file , other related projects.

well can is nasty. part of solution prevent visual studio reloading sln , prj files after removing bindings. visual studio detected edits sln , prjs , effort reload, including on checkin if kind of automerge executed.

part of solution might involve altering registry, hkey_current_user\software\microsoft\visualstudio\11.0\sourcecontrol alwaysaddprojectslocatedoutsideofsolutiontree changing 0 stopped 18 of 28 prjs getting auto updated scc stuff opening solution.

a part of solution me when removed bindings on sln, tfs of sudden treat sln not latest. when commit clean sln without scc bindings, automerge occur bringing scc bindings part of latest on tfs server.

so part of solution utilize notepad edit sln, ignore prompts reload visual studio, , checkout edit in source command explorer until tfs 1 time again recognized work space version have latest sln. checkout edit did not work first time treat sln latest in workspace version sec time did.

after , of import , straight forwards part of solution lies. remove bindings, might have done that, save all. alter source command plugin none in visual studio options,now close solution. open sln in notepad , create sure there no scc stuff. delete solution level .suo. open sln again, should have no bindings , should have pending changes commit sln , or of prj files in source command explorer , warning saying have no source command plugin set. finally, go source command options , set team foundation server source control. commit sln , prj files scc stuff removed.

c# asp.net-mvc visual-studio-2012