Posts

Showing posts from August, 2012

android - NetworkInfo.isAvailable() for Ethernet is always false even if Ethernet is available and connected -

here code: connectivitymanager conman = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo info = conman.getactivenetworkinfo(); log.e("test","=================info================\n"+info.tostring()); the logcat looks like e/test ( 2113): =================info================ e/test ( 2113): networkinfo: type: ethernet[], state: connected/connected, reason: (unspecified), extra: (none), roaming: false, failover: false, isavailable: false do think weird? not available connected... try code check network connectivity public boolean isnetworkonline() { boolean status=false; try{ connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo netinfo = cm.getnetworkinfo(0); if (netinfo != null && netinfo.getstate()==networkinfo.state.connected) { status= true; }else { netinfo = cm.getnetworkinfo(1); if(netinfo!=null ...

traceback - Wavelet Transform in Python -> IndexError: list assignment index out of range -

i trying run code student project: the authors blog complete python-code only function: def fwt97(s, width, height): ''' forward cohen-daubechies-feauveau 9 tap / 7 tap wavelet transform performed on columns of 2d n*n matrix signal s via lifting. returned result s, modified input matrix. highpass , lowpass results stored on left half , right half of s respectively, after matrix transposed. ''' # 9/7 coefficients: a1 = -1.586134342 a2 = -0.05298011854 a3 = 0.8829110762 a4 = 0.4435068522 # scale coeff: k1 = 0.81289306611596146 # 1/1.230174104914 k2 = 0.61508705245700002 # 1.230174104914/2 # k used p. getreuer 1.1496043988602418 col in range(width): # 1d transform on cols: ''' core 1d lifting process in loop. ''' ''' lifting done on cols. ''' # predict 1. y1 row in range(1, height-1, 2): s[row][col] += a1 * (s[row-1][col] + s[row+1][col]) s[height-1][col] += 2 * a1 * s[h...

android - MJPEG using AsyncTask02 in a VideoViewer/CustomViewer -

first "thanks @bbodenmiller!" ( android ics , mjpeg using asynctask ) code mjpeg-viewer works well. have problem. "mjpegactivity.java" works in new contentview: private static final string tag = "mjpegactivity"; public static mjpegview mv; public static string url = "http://trackfield.webcam.oregonstate.edu/axis-cgi/mjpg/video.cgi?resolution=800x600&amp%3bdummy=1333689998337"; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button b01 = (button) findviewbyid(r.id.btn01); b01.setonclicklistener(new view.onclicklistener() { public void onclick(view view) {...}}); button cam01 = (button) findviewbyid(r.id.btncam01); cam01.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { setcontentview(mv); new doread().execute(url); }}); } that means old conte...

C# Winform - Smiley box like messenger -

Image
i want make smiley box live messenger. how can that? want selected picture? thanks? i use toolstrip , toolstripsplitbutton control , i'd create own control inhrited form panel show smiles contained in picturebox when happen click on toolstripsplitbutton. i tried simulate behaviour do. here code: public partial class form1 : form { public form1() { initializecomponent(); this.suspendlayout(); list<bitmap> smiles = new list<bitmap>(); //add images toolstripsplitbutton _toolstripsplitbutton = new toolstripsplitbutton(); _toolstripsplitbutton.size = new size(23, 23); //_toolstripsplitbutton.image = myimage; //add image of stripsplitbutton toolstrip _toolstrip = new toolstrip(); _toolstrip.size = new size(clientsize.width, 10); _toolstrip.location = new point(0, this.clientsize.height - _toolstrip.height); _toolstrip.backcolor = color.lightgray; _tools...

handlers - When should we use Looper in Android? -

can please tell me when should use looper in handlers? have codebase in there multiple threads , handlers. looper.prepare() , looper.loop() not called of them. my doubt need looper continously process messages in handlemessage method? if not have looper, won't handlemessage() called when message sent handler? additional purpose looper serving here? thanks, shamy class used run message loop thread. threads default not have message loop associated them; create one, call prepare() in thread run loop, , loop() have process messages until loop stopped. most interaction message loop through handler class. below there run method of thread @override public void run() { try { // preparing looper on current thread // current thread being detected implicitly looper.prepare(); log.i(tag, "downloadthread entering loop"); // now, handler automatically bind // looper a...

Richfaces dataTable works fine, but ExtendedDataTable is not showing data -

we using richfaces 4.1.0, , trying use extendeddatatable. started (for simplicity's sake) datatable. code below works fine, , shows data in table, expected. <rich:datatable value="#{recipientbean.recipientlist}" var="recipient" selectionmode="none" id="recipienttable"> <rich:column sortable="false" id="col_1" label="name"> <f:facet name="header"> <h:outputtext value="name" id="name" /> </f:facet> <h:outputtext value="#{recipient.name}" id="rec_name" /> </rich:column> <!-- more columns below, removed post brevity --> </rich:datatable> we expecting large number of records, table scrollable. thought change datatable extendeddatatable, however, when that, no data shows @ all. i started inspect element in chrome, , of sudden data showed up. when inspect ...

iphone - CocoaAsyncSockets creating Connection on app startup but Reading/Writing from a view(s) -

i using cocoaasyncsockets library in order create tcp socket connection in app. currently, have created connection opening socket connection in didfinishlaunchingwithoptions method in appdelegate.m file. code looks so: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions: (nsdictionary *)launchoptions { socket = [[asyncsocket alloc] initwithdelegate:self]; [self connect]; self.window = [[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; // override point customization after application launch. self.viewcontroller = [[[tekmatrixviewcontroller alloc] initwithnibname:@"tekmatrixviewcontroller" bundle:nil] autorelease]; self.window.rootviewcontroller = self.viewcontroller; [self.window makekeyandvisible]; return yes; } and here's connect method: - (void)connect { [socket connecttohost:@"9.5.3.6" onport:11005 error:nil]; } now, have been struggling how use...

PhP/Login empty input box issue -

i'm creating website requires user enter username , password access site. works perfectly. if right password , username entered, access granted. if not, redirects user same login form page. however, problem i'm facing in following code in php: if (!$_post['username'] | !$_post['pw'] ) { die("at least 1 box left empty"); } this piece of code checks if user left of 2 input boxes empty. kills site , outputs wanted sentence. however, redirect user login form page. that? folks you haven't tried redirect. use header("location: login.php"); (with whatever location of login page is, if it's not login.php ), exit .

gwt - Passing parameters in mvp pattern -

this might general mvp places , activities question, show case i'm trying understand here gwtphonegap-showcase-gwt example . how pass parameter view one? for example, let's want when user clicks on cell on overviewactivity , take them same place everytime ( aboutplace ), text should different (let's contains cell number). i added settext(string text) aboutdisplay interface corresponding label , settext() in aboutdisplaygwtimpl , have no idea call it. tried calling in aboutactivity start() method , clientfactorygwtimpl getaboutdisplay() method, seem called once when app first loads, end same text each time. you should not use view directly that. you can add field on place , set value there , access same value in next activity.

performance - php-clamav - gets loaded into *each* Apache process -

php-clamav php5 extension allows incorporate virus scanning features php5 scripts. in http://sourceforge.net/projects/php-clamav/reviews/?sort=usefulness&filter=all#reviews-n-ratings it's mentioned: "the problem clamav virus database gets loaded each apache process. means memory usage per process has jumped ~16mb, ~170mb!! unacceptable. however, think project can recommended if can made "production" ready." is there way fix this? one obvious solution not load extension in every php instance . or run scanner via popen/exec/...etc without having looked @ project in detail, sounds if uses standalone scanner rather scanning daemon+light weight client - standalone scanner not make sense in context.

pass argument to the parent class in javascript modular pattern -

i have made 2 classes, person - parent class , student class - child class. trying implement inheritance. trying implement in modular pattern. not getting properly. code block please check below. person.js var person = function() { var details, constructor, getdetailsbyattribute, setdetailsbyattribute, setdetails, getdetails, cleardetails; cleardetails = function() { details = { uid : '', name : '', email : '' }; }; getdetailsbyattribute = function(attr) { return details[attr]; }; setdetailsbyattribute = function(key, value) { if(details.hasownproperty(key)) { details[key] = value; }else { console.log('invalid key'); } }; setdetails = function(param) { cleardetails(); for(var attr in param) { if(details.hasownproperty(attr)) { details[attr] = par...

c++ - An Array of ALLEGRO_BITMAP type objects -

so i'm making game using allegro , trying create array of allegro_bitmap type objects represent board, load images files @ once in beginning of game , not have load them every time want redraw them. attempted so: allegro_bitmap files[10]; which gets following compilation error: 'field has incomplete type allegro_bitmap' i tried: allegro_bitmap* files = new allegro_bitmap[10]; which gets compilation error: 'allocation of incomplete type allegro_bitmap' i have feeling has compiler not knowing size of allegro_bitmap type , therefore not knowing how allocate memory array of type (but can please correct me if i'm wrong). wondering if knew way around this? or way achieve goal of storing allegro_bitmap objects upfront rather loading image files when want redraw tile? can create 10 different variables , store files in them gross. have tried use vectors well, did not work either. most of allegro 5 data types opaque. you need create array of poi...

iphone - How to releas the memory allocated in for appDelegate shared instace -

in app have created appdelegate shared instance , allocating memory array appdelegate = (appdelegate_shared *)[[uiapplication sharedapplication] delegate]; appdelegate.allserviceapplist_array = [[nsmutablearray alloc]init]; appdelegate.blockxmldata_array = [[nsmutablearray alloc]init]; appdelegate.notesxmldata_array = [[nsmutablearray alloc]init]; now not getting how release arrays have allocated. it's showing potential leaks alloc , init memory. what correct way release these objects. thanks in advance if appdelegate properties defined (retain), do appdelegate.something = [[[something alloc]init]autorelease]; this common pattern in objc. retained properties retain new object, autorelease releases object in future, end result object retain count of 1 released in dealloc method.

html - I do not know how to use media selectors in my css file correctly to decide which image to load for iPhone or iPad -

there several html files guide user through our app , introduce him new features. universal app iphone , ipad. if user selects section iphone version, want show him images scaled iphone device. but there problem. in css file there 1 class boximage images. how decided image load? should stuck each image in own class? thanks in advance 4 ideas! regards, buk you can try this. <style type="text/css"> @media , (max-width: 800px) { .boximage{ background:url(image_name1.jpg)} } @media , (min-width: 800px){ .boximage{ background:url(image_name2.jpg)} }</style> or use javascript find user-agent , set image script.

c++ - Does it really inverse a transform matrix? -

void inverse44( double *inverse, double *matrix ) { double trans[3], trans_xf[3]; mtx3_t matrix3; inverse[0] = matrix[0]; inverse[1] = matrix[4]; inverse[2] = matrix[8]; inverse[4] = matrix[1]; inverse[5] = matrix[5]; inverse[6] = matrix[9]; inverse[8] = matrix[2]; inverse[9] = matrix[6]; inverse[10] = matrix[10]; inverse[15] = 1.0; inverse[12] = inverse[13] = inverse[14] = 0.0; trans[0] = matrix[3]; trans[1] = matrix[7]; trans[2] = matrix[11]; mtx4_mtx3(mtx4_cast_pc(matrix),&matrix3); mtx3_vec_multiply_t(vec3_cast_pc(trans),&matrix3,vec3_cast(trans_xf)); inverse[3] = -trans_xf[0]; inverse[7] = -trans_xf[1]; inverse[11] = -trans_xf[2]; } what function do? mtx3_t definition of 3*3 matrix. mtx4_mtx3 gets sub matrix. mtx3_vec_multiply_t multiply vector , matrix. yes. please see this link compute inverse of transformation matrix. basic idea scaling/rotation combination of transformation matrix (first 3x3 sub-matrix) orthonormal matrix , inverse of on orthonorma...

asp.net mvc - MVC3 (Razor) How to do something with json passed data in Controller -

i've passed model in view controller following jquery ajax code: $.ajax({ data: model, type: "post", url: '@url.action("createdoc")', datatype: "json", contenttype: "application/json; charset=utf-8", success: function (result) { alert('done '+ result.tostring()); } }); the problem is: in controller method "createdoc" [httppost] public actionresult createdoc(ienumerable<movie> movies) { createwordprocessingdocument(movies); return json(new { result = movies.count()}); } i can't movies enumerable data. call createwordprocessingdocument create document movies data. not. method code: public void createwordprocessingdocument(ienumerable<movie> movies) { httpcontextwrapper context = new httpcontextwrapper(system.web.httpcontext.current); context.response.clear(); context.response.buf...

web services - How to retrieve JSON result after file upload via actionscript -

i know how upload file using action script see upload zip file using http post via actionscript 3.0 details. code replicated here: var urlrequest:urlrequest = new urlrequest(publish_zip_file_url); // set method=post urlrequest.method = urlrequestmethod.post; var params:urlvariables = new urlvariables(); params['data[file][title]'] = 'title1'; params['data[file][description]'] = 'desc'; // include non file params , data urlrequest.data = params; // upload file // how set form field expected file upload file.upload(urlrequest, "data[file][filename]"); the web app responsible accepting file upload return json string containing details such file size, id number, etc. how access json result string in actionscript? from filereference docs , need add handler filereference instance uploadcompletedata event: import flash.events.*; // upload file // how set form field expected file upload file.addeventlistener(dataevent...

Adobe InDesign hangs indefinitely when I try to duplicate pages using ExtendScript -

i have simple extendscript script creates new document out of subset of current active document: var sourcedocument = app.activedocument; var i, j; for(i = 0; < sourcedocument.layers.length; i++) { sourcedocument.layers.item(i).locked = false; } for(i = 0; < sourcedocument.spreads.length; i++) { for(j = 0; j < sourcedocument.spreads.item(i).textframes.length; j++) { if(sourcedocument.spreads.item(i).textframes.item(j).locked) { sourcedocument.spreads.item(i).textframes.item(j).locked = false; } } } var destdocument = app.documents.add(); var firstpageindex = 0; // in actual script, chosen user. var lastpageindex = 5; // in actual script, chosen user. destdocument.importstyles(importformat.paragraphstylesformat, new file(sourcedocument.filepath + "/" + sourcedocument.name), globalclashresolutionstrategy.load_all_with_overwrite); destdocument.importstyles(importformat.characterstylesformat, new file(sourcedocument.filepath + "/" +...

spring - @Valid and Binding Result for Data from DB -

i using spring validation(jsr 303) in 1 of web apps.i have no issues when user submits data , spring validation works pretty neat.but have scenario have fetch data service , validate , bind them view.(something non-form validation).how can use @valid in case or have done differently? here sample code,i started @requestmapping(value = "/{id}", method = requestmethod.get) public modelandview getview( @pathvariable("id") final string id, @user user, httpsession session) { user user= getuser(); bindingresult result = new beanpropertybindingresult(user, "user"); validator.validate(user, result); if(result.haserrors()){ logger.log(level.error, "errors"); } modelandview view = new modelandview ("home"); view.addobject("user",user ); view.addallobject(result.getmodel()); return view; as far understand need inject default org.springframework.validation.validat...

python - how to simulate image upload to google app engine blobstore -

i'm uploading images gae blobstore using create_upload_url uploadurl = blobstore.create_upload_url('/upload') for purpose of unit testing gae code, can simulate image upload? or should insert image data in test bed , assume upload successful? if so, how upload image test bed? agree @fredrik on you're testing there. anyway, if you're doing functional/blackbox/similar testing, use webtest framework (see post method) , actual upload, e.g. payload = [(fieldname, filename)] test_app.post(uploadurl, upload_files=payload) have @ handler testing python details on how initialize above test_app.

oop - JavaScript OO - How to make a huge object oriented app and use static members -

i'm trying huge web application in javascript, , think must in object oriented way if don't want mess everything. so, searched lot , found lots of different ways declare classes , make instances in js, environment variables, functions, functions in functions ... know best way of achieving big object oriented structure (a bit java/c# or other object oriented languages) , more precisely how declare static members can access in instances of class. thank much read "javascript - parts" , learn module pattern heart: http://www.adequatelygood.com/2010/3/javascript-module-pattern-in-depth

java - How to disable arrow keys for JSliders? -

i want use arrows keys move on screen after click on jslider use , use arrows keys, moving slider instead of object. can’t find method disable this. (after clicking on slider, sliding arrow changes black outline blue 1 {my presumption indicating arrows keys “locked” onto slider.}) try slider.setfocusable(false); but complex application, ensuring have control on arrows may require keyboardfocusmanager , keyeventdispatcher apis. these let divert arrow (or any) keystrokes normal handling, must used carefully.

java - giving null pointer when using InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); -

hi i'm trying input piece of code hide soft keyboard on android, it's returning null pointer. code: public void testsettestenvironment (){ solo.clickinlist(4); solo.clickonmenuitem(configvariables.catalogserver); asserttrue(solo.searchtext(configvariables.catalogserverurl)); //enter keycode solo.clickinlist(5); view myedittext = solo.getviews().get(0); inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service); imm.hidesoftinputfromwindow(myedittext.getwindowtoken(), inputmethodmanager.hide_implicit_only); solo.entertext(solo.getedittext(0), ""); solo.entertext(0, configvariables.keycode); asserttrue(popupclickbuttonhandler("enter keycode", "ok")); the logs show: java.lang.nullpointerexception thanks. maybe little bit late hope helpful someone. code bug-prone because relies on focused view window token from. try using: inputmethodmanager im...

jquery - Do you have any idea how Google Docs Javascript do the interval data autorefresh? -

alright, here goes: i'm implementing software autorefresh/autopull/autoreload data keep screen live using ajax. this working, know i´ve used simplest approach is: setinterval (javascript) call refresh method on , on each n seconds. read json data, rebuild html , update it. this can done calling settimeout (javascript) , end of ajax request. in refresh method internally check it´s not being called simultaneously, etc. however... simplest approach, works but, in slow computers, firefox , ie, can see activity freezes browser, , know might not necessary because of ajax call , how "intensive" javascript operation overall... but, after running profiler, overall javascript (using jquery way) seem fine. if disable autorefresh, browser wont freeze short seconds in slow computers. i decided investigate how several of majors ajax applications works out there. facebook instance.. do request time, every n seconds, interpret json , update screen, but, google d...

asp.net mvc - In MVC what is difference between partial view and strongly typed view? -

question title itself. new mvc , following self learning. kindly give me answer clear fresher mvc. thanks. a partial view nothing more "piece" of html can keep in separate file can reuse in other views. sort of usercontrols in asp.net webforms. a typed view means has viewmodel associated controller passing , elements in view can use viewmodel properties you can have typed partials well. meaning piece of html needs specific data type viewmodel here example of typed view @model someviewmodel ...// html comes after a view not typed not have @model someviewmodel line here's example of controller action renders normal view without viewmodel public actionresult index() { return view(); } here's 1 renders typed view public actionresult index() { var model = new someviewmodel(); return view(model); } and view makes use of viewmodel having @model someviewmodel @ top of file. so view has viewmodel can display elements bound view...

asp.net - Green Bar for Self-Made SSL -

so, considering pricing ssls, chose try creating own ssl certificate (still in works). once part done, how ev , green bar aspect of certificate set up? it can make sense create own certificates (and use own ca) if you're in environment users can import own ca certificate in way can verify independently. typically, works fine on institution's network installs ca certificate part of os configuration when configuring centrally-administered machines (and similar cases). under these conditions, blue bar without problem. extended validation certificate (which produce green bar) rely on 2 things: extra policy attributes in certificate: technically, define oids yourself, although getting others recognise problem, obviously. oid policies , root certificate fingerprints hard-coded in browser . this second point prevent doing yourself. non-ev certificates potentially implement on machines under control using few configuration steps. ev certificates require control ...

javascript - Div not showing on click -

i having trouble displaying div on click using jquery. code looks correct me. on website have searchbar trying add search suggestions to. default hidden. if user selects "show suggestions", appear. form action being empty irrelevent. not work if remove form together. not getting errors. have been trying fix problem on hour, appreciate this. html <form action=""> <input type="text" id="txt1" onkeyup="showhint(this.value)" /> <input type="submit" value="search" /><button id="hint"/>show suggestions </button> </form> <div id="searchhint" style="display:none; border:1px solid red; width:300px;" > suggestions:<span id="txthint"></span></font></div> jquery $(document).ready(function(){ $("#hint").click(function(){ $("#searchhint").show(); }); }); your html mal...

javascript - Internet Explorer 8 & 7 is converting tabs to spaces -

i'm trying use javascript jquery convert tab delimited string html table. in input string rows separated <br/> , columns tabs . here's have far: $(function(){ $('div.jstable').each(function(){ var text = $(this).html(); var rows = text.split(/<br>/i); var htmlstring = "<table class='display datatable'>" var starttbody = true; for(i = 0; i< rows.length; i++){ // build header section if (i == 0){ htmlstring += '<thead>'; }else { if (starttbody){ htmlstring += '<tbody>'; starttbody = false; } } htmlstring += '<tr>'; var row = rows[i]; var columns = row.split('\t'); // build columns (j = 0; j < columns.length; j++ ){ if (i == 0){ htmlstring += '<th>' + columns[j] + '</...

statistics - python matplotlib - contour plot - confidence intervals -

Image
i'm trying plot contours (doable) on grid of data using matplotlib.pyplot.contour, contours placed @ 1, 2 , 3 sigma away peak value. there neat way apart brute force? thanks! python version is python 2.7.2 |epd 7.2-2 (64-bit)| (default, sep 7 2011, 16:31:15) [gcc 4.0.1 (apple inc. build 5493)] on darwin you can specify list of z-values contours drawn. have collect correct z-values distribution. here example '1, 2, , 3 sigma away peak value': code: import numpy np import matplotlib.cm cm import matplotlib.mlab mlab import matplotlib.pyplot plt #set 2d gaussian: delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-3.0, 3.0, delta) x, y = np.meshgrid(x, y) sigma = 1.0 z = mlab.bivariate_normal(x, y, sigma, sigma, 0.0, 0.0) #get z values contours 1, 2, , 3 sigma away peak: z1 = mlab.bivariate_normal(0, 1 * sigma, sigma, sigma, 0.0, 0.0) z2 = mlab.bivariate_normal(0, 2 * sigma, sigma, sigma, 0.0, 0.0) z3 = mlab.bivariate_normal(0, 3 * sigma, s...

objective c - Prevent small negative numbers printing as "-0" -

if following in objective-c: nsstring *result = [nsstring stringwithformat:@"%1.1f", -0.01]; it give result @"-0.0" does know how can force result @"0.0" (without "-") in case? edit: tried using nsnumberformatter, has same issue. following produces @"-0.0" : double value = -0.01; nsnumberformatter *numberformatter = [[nsnumberformatter alloc] init]; [numberformatter setnumberstyle:nsnumberformatterdecimalstyle]; [numberformatter setmaximumfractiondigits:1]; [numberformatter setminimumfractiondigits:1]; nsstring *result = [numberformatter stringfromnumber:[nsnumber numberwithdouble:value]]; i wanted general solution, independent of configuration of number formatter. i've used category add functionality nsnumberformater; @interface nsnumberformatter (preventnegativezero) - (nsstring *)stringfromnumberwithoutnegativezero:(nsnumber *)number; @end with implementation: @implementation nsnumberformatter (pre...

iis - Search in bindings with get-website? -

why can't simple: get-website | { $_.bindings -like "*domain*" } on bindings? works fine on name , physical path? way search on bindings get-website? because there can multiple bindings. have iterate through each of them: get-website | select-object bindings | { $_.bindinginformation -like '*domain*' }

java - Error message 'Cannot be resolved or is not a field' -

right i'm studying chain of responsibility design pattern , using eclipse . and i'm trying compile code, have compiling error "islast cannot resolved or not field": public class overfive implements discount { private discount next; // public boolean islast = false; public void setnext(discount next, boolean last) { this.next = next; this.next.islast = last; // here error. } public double dodiscount(budget budget) { if (budget.getvalue() > 500) { return budget.getvalue() * 0.10; } if (this.next.islast == false) { return next.dodiscount(budget); } else { return 0; } } } and now, here interface: public interface discount { double dodiscount(orcamento orcamento); void setnext(discount next, boolean last); } here's 1 recommendation: study sun java coding standards , take them heart. you're breaking t...

How can I judge the javascript object whether have a child object -

suppose have object: obj:{ child:{ x:12, y:50 }, key1:"value1", key2:"value2" } if want traverse object,like: for (var in obj) { } how can judge whether object have child object,so traverse it.i know use hasownproperty method, in situation, have no idea child object name . you can use check if property contains object: for (var in obj) { if(obj.hasownproperty(i) && obj[i] instanceof object) { // obj[i] child object } } a note of precaution: remember functions , arrays both objects in javascript. can test individually using instanceof function , instance of array .

c - Pointers pre/post increment -

can please explain following code completely? #include<stdio.h> #include<stdlib.h> int main() { int *a, *s, i; = s = (int *) malloc(4 * sizeof(int)); (i = 0; < 4; i++) { *(a + i) = * 10; printf(" %d ", *(a + i)); } printf("\n"); printf("%d\n", *s++); printf("%d\n", (*s)++); printf("%d\n", *s); printf("%d\n", *++s); printf("%d\n", ++*s); printf("\n"); printf("%d\n", *a++); printf("%d\n", (*a)++); printf("%d\n", *a); printf("%d\n", *++a); printf("%d\n", ++*a); return 0; } output: 0 10 20 30 0 10 11 20 21 0 11 12 21 22 1) how pointer 's' printing values, *(a+i) been assigned values in loop? 2) value go , stored when *(a+i) assigned? 3) what's difference between *s++ , (*s)++ , *++s , ++*s ? 4) why values incremente...

ios - keychain certificate -

i creating new csr (certificate signing request) using keychain access tool: certificate assistant -> request certificate certificate authority... in certificate information fill in email address , name, selecting "save disk" option. save csr desktop wizard completes successfully, no file saved disk! i've done before, time isn't working. tried restarting keychain tool, restarting computer ....but n't find anything... thanks in advance... after created certificate in keychain access tool can export disk. select appropriate keychain, select created certificate export , chose file - > export items on main menu. after follow steps of export wizard. you can choose type of file export certificate .cert or .p12.

jquery - RaphaelJS scale a path on hover -

i add pop effect when hover on svg path. have tried causes paths fly off past bottom of browser window. i have read post , attempted compensate coordinate increase failed setup. link example of path: var paths = { lakes: { name: 'lakes', value: 'notselected', path: 'm199,606l121,-45l18,60l-32,60l-52,157l-99,-9l-13,-70l-17,8l-22,0l-11,-30l9,-26l61,-45l12,-6l21,-35l4,-19z' }, etc. and use hover (only hover shown) obj.hover(function(){ if(paths[arr[this.id]].value == 'notselected') { this.animate({ fill: '#32cd32' }, 300); } which works fade in chosen colour. first added: this.animate({transform: 'scale(1.1)'}, 300); and when spotted path moving bottom tried translate coordinates this.animate({transform: 'translate(-199,-606)'}, 300); and still move away. member pointed out paths drawing large y, problem? (i redraw svg obj.attr(attributes).attr( { transform: ...

c# - create an array of anonymous type -

i trying data database google charts in program. create array of anonymous type (var) instead of repeating code on , on again: public jsonresult getchartdata(int sid, int regionid) { var testpathone = p in _rep.getmetricsdata().getlhdb().page_loads p.t_3id == sid && p.test_path_id == 1 select new { time = p.time, created_at = p.created_at }; var testpathtwo = p in _rep.getmetricsdata().getlhdb().page_loads p.t_3id == sid && p.test_path_id == 2 select new { time = p.time, created_at = p.created_at }; var tone = testpathone.toarray(); var ttwo = testpathtwo.toarray(); var name = new { test1 = tone, test2 = ttwo }; return json(name); } i know need loop can go through test path id's instead of hard coding them p.test_path_id ...

android - Tabs as views or Activity? -

i'm developing app requires nested tabs (tabs within tabs). example 1 of tabs message tab have 4 tabs- inbox, compose, sent, trash. have around 3-4 of such nested tabs in app. i'm looking few suggestions whether make these tabs separate activities or views. i've read issue , i'm aware problem specific need of application. beginner i'm skeptical approach. wasn't sure if should have many activities in code hamper performance. of i've created main tabs separate activities , nested tabs views. of inner tabs want user select list of options, though there couple of tabs involve more user interaction. can can achieved activity approach possible via view approach? if so, how? suggestions helpful. it sounds make nested tabs different options menus each of parent tabs. in each of activities in first tab menu, can add this... @override public boolean oncreateoptionsmenu(menu menu){ menuinflater inflater = getmenuinflater(); inflater.inflate(r.m...

Check volume serial number within a bat file -

im writing batch script run on flash drive. need validate volume serial number of flash drive inside code, therefore nobody should able run different location. does know how validate serial number inside batch file? example: if %vol%==abcd goto else exit although there several different ways achieve same thing, original dos/windows command intended manage volumes , serial numbers vol : @echo off /f "skip=1 tokens=5" %%a in ('vol %~d0') set serial=%%a if %serial% equ abcd-ef01 ( echo valid serial number! )

java - Setting OnClickListeners for Dynamically added views -

i adding small view linearlayout. have apply view.onclicklistener it, though view has been added, onclick still not fire. here's method for (streams stream : streamarray) { streamcount++; if (!(streamcount > 3)) { // add item view v = li.inflate(r.layout.stream_item, thelinearlayoutforstreamitems, false); //set onclick v.setonclicklistener(new android.view.view.onclicklistener() { public void onclick(view v) { log.i("onclick", ""+position ); } }); txtstreamitem = (textview) v.findviewbyid(r.id.txtviewstream_item); txtstreamitem.settext(stream.name); thelinearlayoutforstreamitems.addview(v); } the onclick() does not fire. not know why, , cannot find thing on internet on it. i think want achieve is: txtstreamitem.setonclicklistener(new android.view.view.onclicklistener() { public void onclick(view v) { log.i("onclick", ""+position );...

asset pipeline - Sprockets/Rails: Find all files Sprockets knows how to compile -

for konacha, rails engine testing rails apps, need way find files sprockets can compile javascript. right use like dir['spec/javascripts/**/*_spec.*'] but picks .bak , .orig , , other backup files. can sprockets tell somehow whether knows how compile file , backup files automatically excluded? content_type_of doesn't help: rails.application.assets.content_type_of('test/javascripts/foo.js.bak') => "application/javascript" you can iterate through files in sprockets::environment 's load path using each_file method: rails.application.assets.each_file { |pathname| ... } the block invoked pathname instance expanded path of each file in load path. each_file returns enumerator , can skip block , array to_a , or call include? on it. example, check whether file in load path: assets = rails.application.assets pathname1 = pathname.new("test/javascripts/foo.js").expand_path pathname2 = pathname.new("test/javas...

c# - How to keep files without overwriting in Azure -

we using azure our application. everytime deploy new version of application through visual studio removes files azure storage , puts fresh version local files. want leave files on server un-touched, when deploy new version these special files won't overwritten local version. possible? have lucene indexes don't want overwrite , dont want move blob storage either. set localstorage::cleanonrecycle attribute of service definition false: worker role service definition

java - Reset TextView position (scrollable) on new text load -

my page loads textview scrollable. unfortunately position appears stick when loading new text view, text appears offscreen or invisible entirely. there way reset "viewed" text top? textview have method inherited view use, called scrollto(x,y) so put: mytextview.scrollto(0,0)

asp.net mvc - How can ViewBag data be saved after a form post? -

so have viewbag.something , data randomly generated. in view, set label @html.labelfor(m => m.something, (string)viewbag.something) . works out when submit form there errors , if there errors, need label remain same, don't want dynamic/random data anymore wouldn't call controller method generated viewbag. there way retain value without having private variable in controller? nice way mvc/razor it? option 1: pass value of "viewbag.something" controller using route values: @html.actionlink("buttontext", "actionname", new { = @viewbag.something }) option 2: can use tempdata . public actionresult index() { var = "yourvalue"; tempdata["something"] = something; ....... } public actionresult otheraction() { var = tempdata["something "]; ........... } passing state between action methods action methods might have pass data action, such if error occurs when form being posted, or if ...

c# - Copy file(s) from one project to another using post build event...VS2010 -

Image
i have solution 3 projects in it. need copy view 1 project another. i'm able copy created dll via post build events so: so want copy file in project 1 '/views/modulehome/index.cshtml' folder in project 2. how copy file(s) desired project via post-build event? thanks xcopy "$(projectdir)views\home\index.cshtml" "$(solutiondir)mefmvcpoc\views\home" and if want copy entire folders: xcopy /e /y "$(projectdir)views" "$(solutiondir)mefmvcpoc\views" update: here's working version xcopy "$(projectdir)views\moduleahome\index.cshtml" "$(solutiondir)mefmvcpoc\views\moduleahome\" /y /i here commonly used switches xcopy : /i - treat directory if copying multiple files /q - not display files being copied. /s - copy subdirectories unless empty. /e - copy empty subdirectories. /y - not prompt overwrite of existing files. /r - overwrite read files.

Is it possible/advised to store a vector in a struct? C++ -

i have thought of struct fixed sized object , while there doesn't seem glaring compiler errors, wondering if doing in practice. changing struct class more advisable or struct well? the code, because people fussy: struct sprite { float x; float y; std::vector<sprite> sprite; } the essence of doing having children of class same type parent. when parent dies, children too. an std::vector has specific known size, , class or struct contains has specific known size. std::vector allocates memory on heap act variable sized array , stores pointer said memory. difference between struct , class struct defaultly public, , class defaultly private.

java - Declarative OSGi Services -

i have question declarative osgi services. have following interface : public interface printservice { public void print(); } and implementation: public class printserviceimpl implements printservice { @override public void print() { system.out.println("hello printserviceimpl!"); } } osgi-inf/component.xml : <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="service"> <implementation class="service.printserviceimpl"/> <service> <provide interface="print.printservice"/> </service> </scr:component> manifest.mf : service-component: osgi-inf/component.xml after install service , start nothing happend. how can activate , print " hello printserviceimpl! " console. why expect print method invoked? part of interface of service, not invoked until can client binds , calls it. if type services c...

java - How to load a class by classname string from OSGi runtime environment? -

i'm making bundle plug on osgi provide user function: usercase: user input classname string , click "list" button, corresponding class decompiled , show text on gui user. so here problem: have classloader of bundle, how can osgi container classloader can load class name whole osgi container? (i expect when osgi starts, load bundles , class memory, class can loaded osgi container classloader if exists , able to) anyone knows how job? sample codes highly appreciated. i can see 2 possible situations you. any visible class you can add statement like dynamicimport-package: * to manifest, , try load class using class.forname("com.company.class"); all classes, exported or not if need find every available class, i'm not sure why want this, try asking each bundle whether 'knows' given class. since in situation end multiple classes same name, it's pick right one. you like private list<class<?>> findclass(bun...

php - EasyPHP custom java extension -

i using easyphp test purposes, , wish apply xslt 2.0 processor in php code. easyphp 5.3.9 standard xslt processor of 1.0 version though. what have apply xslt processor in saxon9he.jar or xslt2processor.jar (found on sourceforge.net)? stuff know: which directory place jar in where change config include jar (probably using extension functionality) what put code in order declare new instance of xslt processor code using <?php $xml = new domdocument(); $xml->load('test.xml'); $xslt = new xsltprocessor(); $xsl = new domdocument(); $xsl->load('test.xslt'); $xslt->importstylesheet( $xsl ); print $xslt->transformtoxml( $xml ); ?> which errors because have xslt 2.0 version stylesheet. errors like warning: xsltprocessor::importstylesheet() [xsltprocessor.importstylesheet]: compilation error: file file:///c:/program%20files%20(x86)/easyphp-5.3.9/www/test.xslt line 99 element function in c:\program files (x86)\easyp...

html - symbol issue in php -

is there way convert symbol – in php $payment_url = "https://www.paypal.com/cgi-bin/webscr"; $currencycode = get_option('wpoupon_currency'); $countrycode = get_option('wpoupon_country'); $paypalid = get_option('wpoupon_payment_email'); $notifylink = getpermalink('&mode=notifyurl&user_id='.$current_user->id,$itemid); $returnlink = getpermalink('&mode=returnurl',$itemid); $cancellink = getpermalink('&mode=cancel',$itemid); $form_custom = ''; $form_custom .= '<input type="hidden" name="cmd" value="_xclick">'; $form_custom .= '<input type="hidden" name="business" value="'. $paypalid .'">'; $form_custom .= '<input type="hidden" name="item_name" value="'. htmlspecialchars($itemname) .'">'; $form_custom .= ...

php - Issue with CakePHP model validationErrors property -

i using cakephp 2.1.3 1 of project, want model validation errors returned in json format via controller, when try access validation errors via cakephp's model property validationerrors returns valid errors array when primary , other associated models has validation errors. when primary model valid , associated models has validation errors results invalid validation errors array. below example: if ($this->request->is('post') || $this->request->is('put')) { if ($this->primarymodel->saveall($this->request->data, array('validate' => 'first'))) { echo json_encode(array('success' => true)); } else { $errors=array(); $tablestomodels=$this->primarymodel->tabletomodel; //list of table names included in model description. used associations. foreach($tablestomodels $tabel => $model) { $errors[$model]=$this->{$model}->validationerrors; } ...

c# - Generic implementation of System.Runtime.Caching.MemoryCache -

is there generic alternative / implementation memorycache? i know memorycache uses hashtable under hood, take transition using dictionary<,>, generic version of hashtable. this provide type safety , provide performance benefits no boxing/unboxing. edit: thing i'm interested in having different key type. default system.string. is there generic alternative / implementation memorycache? not in base class library. you'd have roll own, though i, personally, make wrapper around memorycache provides api wish. this provide type safety , provide performance benefits no boxing/unboxing the type safety can handled in wrapper class. boxing/unboxing issue if storing value types (not classes), , then, minimal, it's unlikely you're pushing , pulling cache enough have true performance issue. as type safety , usability, i've written own methods wrap memorycache item's calls in generic method , allows bit nicer usage api standpoint. e...