Posts

json - Getting the number of properties in JQuery object -

i'm trying figure out how many properties in following object. obviously, can see 2, need know dynamically. var test = $.parsejson('{ "ddsize": "size", "ddcolor": "color" }'); if try: var mylen = test.length; .length undefined. number of properties in object change. it's 1, 2 or 3, can't figure out how test it. this javascript json object. length function not available. first solution pure javascript: var data = $.parsejson('{ "ddsize": "size", "ddcolor": "color" }'); var keys = []; (key in data) { keys.push(key); } // numberofkeys should equal 2 var numberofkeys = keys.length; second solution if prefer jquery: var data = $.parsejson('{ "ddsize": "size", "ddcolor": "color" }'); var keys = []; $.each(data, function(key, value) { keys.push(key) }); // numberofkeys should equal 2 var numberofkeys = keys.length; documenta...

objective c - Locating the nearest open space within a UIView -

i have uiview user can add subviews to. need application automatically place subview user @ first found open location. a location considered open if frame of subview placed not intersect other subviews. the calculation locate open area not need instant - run when user first enters scene, @ point saves location if user placed it. the container uiview large enough have open space place subview (there limited number of subviews user can add). what simplest way determine location place subview? i posted description of algorithm commonly used solve these sorts of problems in answer question: finding largest rectangle in 2d array . it's easy adapt solution problem. in question filled spaces on grid, made determining amount advance scan line little easier, have more careful. other question looking empty rectangle maximal area, can exit algorithm find first fit. of course, if subviews same size, solutions identical. hope helps.

javascript - How do I detect IE 8 with jQuery now that $.browser is deprecated? -

possible duplicate: best way detect html5 <canvas> not supported now $.browser is being taken out of jquery in favor of $.support, how detect ie8 jquery, or plain javascript? if ($.browser.msie && parseint($.browser.version, 10) === 8) { alert('ie8'); } sorry, html not work me. can not this: <!--[if ie 8]> <script type="text/javascript"> ie = 8; </script> <![endif]--> specifically, looking work canvas tag , ie8 not support canvas, jquery.support not detect canvas support. test feature instead: var el = document.createelement('canvas'); if (el.getcontext && el.getcontext('2d')) { // canvas supported } edit: as in link suggested in comments brandon boone, here's function it: function iscanvassupported(){ var elem = document.createelement('canvas'); return !!(elem.getcontext && elem.getcontext('2d')); }

c# - Returning a value from a stored procedure to a method -

i have stored procedure returns whether student locked or not: return @islocked i execute stored procedure like: public int isstudentlocked(string studentname, int lockouttime) { sqlconnection connobj = new sqlconnection(); connobj.connectionstring = util.studentdatainsert(); connobj.open(); sqlcommand comm = new sqlcommand("uspchecklockout", connobj); comm.commandtype = commandtype.storedprocedure; comm.parameters.add(new sqlparameter("@studentname", studentname)); comm.parameters.add(new sqlparameter("@lockouttime", lockouttime)); comm.executenonquery(); connobj.close(); //how can return @islocked value below? return ((int)(@islocked)); } to use return statement in t-sql (which can return integer values), have add parameter retrieve it: public int isstudentlocked(string studentname, int lockouttime) { sqlconnection connobj = new sqlconnection(); connobj.connectionstring = util.studentdatainsert(); connobj.open(); sqlcommand comm = new sqlcomma...

jquery - li element hover event and show sub menu? -

html codes <ul class="menu"> <li>deneme</li> <li>deneme <ul> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> </ul> </li> <li>deneme <ul> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> </ul> </li> <li>deneme</li> <li>deneme</li> <li>deneme <ul> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> <li>alt menu</li> </ul> </li> <li>deneme</li> </ul>รข€‹ javascript: $(document).ready(function(){ $("ul.menu > li").css("color","red"); $("li ul li").css("color","blue") $("li ul li").hide(); $("u...

Android : how to edit the bar at the top of the screen? -

i'm beginning learn android development , have bar @ top of app, containing title of activity , app icon. want know how edit (change text, background color, etc), , remove ? want know how edit title of app, because it's name of main activity... thanks lot. edit androidmanifest.xml <application android:icon="@drawable/icon" android:label="@string/app_label" > ... <activity android:name="foo.myactivity" android:label="@string/activity_label" > </activity> </application> if don't want titlebar, add attribute: android:theme="@android:style/theme.notitlebar" to application tag.

cuda - Conversion from Matlab CSC to CSR format -

i using mex bridge perform operations on sparse matrices matlab. need convert input matrix csr (compressed row storage) format, since matlab stores sparse matrices in csc (compressed column storage). i able value array , column_indices array. however, struggling row_pointer array csr format.is there c library can in conversion csc csr ? further, while writing cuda kernel, efficient use csr format sparse operations or should use following arrays :- row indices, column indices , values? which on give me more control on data, minimizing number for-loops in custom kernel? compressed row storage similar compressed column storage, transposed. simplest thing use matlab transpose matrix before pass mex file. then, use functions ap = mxgetjc(spa); ai = mxgetir(spa); ax = mxgetpr(spa); to internal pointers , treat them row storage. ap row pointer, ai column indices of non-zero entries, ax non-zero values. note symmetric matrices not have @ all! csc , csr same. which format use heavily...