Posts

Showing posts from January, 2013

php - Print number of records in a table? -

how print number of records in mysql table? modified php: mysql_result <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('could not connect: ' . mysql_error()); } if (!mysql_select_db('database_name')) { die('could not select database: ' . mysql_error()); } $result = mysql_query('select count(*) mytable'); if (!$result) { die('could not query:' . mysql_error()); } $rowcount = mysql_result($result, 0); // count echo $rowcount; // echo count mysql_close($link); ?> check out php mysql functions if you're getting started. if you're using kind of framework, check out database documentation framework.

algorithm - How should I specify rectangles in a 3D scene? -

when rendering 3d rectangles (i.e. rectangles in 3d space), of course, specified list of vertexes 2 triangles. however, representation contains lot of extraneous information gets tiresome code multiple times. i'd create "rectangle" object allow me specify texture, size, position, , orientation in space , export list of vertexes (and indexes), i'm not sure of best way it. should specify position of lower left corner (pre-rotation), or center of rectangle? how should specify orientation, vector containing rotation angles? such simple , standard requirement i'm sure people have thought before, can't find on site or elsewhere on subject. plan use these objects lot, primary goal (apart performance) ease of use rather internal representation. wouldn't hard me code first thing can think of, don't want miss , make unnecessarily difficult. so, how should represent rectangle object? opinions welcome, sources helpful. edit: if helps, believe i'd using

c - Interpreting an FT_UNIT32 field as little endian -

i'm in middle of writing wireshark dissector custom protocol. however, have field unsigned 32-bit integer. it's transmitted in little endian form. how force wireshark interpret such? i.e. hf_register_info struct contains &hf_foo_length, { "length", "foo.length", ft_uint32, base_dec, null, 0x0, null, hfill } and in dissect function i'm calling proto_tree_add_item(foo_tree, hf_foo_length, tvb, offset, 4, false); to answer last question. discovered if last parameter of proto_tree_add_item if non-zero make interpret field little-endian. see proto.h /* * might also, in future, want allow field specifier * indicate encoding of field, or @ least default * encoding, fields in protocols use * same encoding (although that's not true of fields, * still need able specify @ run time). * * so, now, define enc_big_endian , enc_little_endian * bit flags, combined, in future, other information * specify encoding in last argume

iphone - How can I have an IBAction that has more than two 'if' statements? -

i creating quiz app display depending on results of quiz. right stuck @ something. quiz app simple, 4 answers, , question. having each button switch view next question seemed code, came this. if each button, when pressed, change question , answers? how this? right now, code answer 'a' goes this: -(ibaction)a { switch(questionnumber) { case 0: { question.text = @"how use suppressed weapons?"; } break; case 1: { question.text = @"do sleight of hand?"; answera.text = @"yes"; answerb.text = @"no"; [answerc sethidden:yes]; [answerd sethidden:yes]; [answerbutton3 sethidden:yes]; [answerbutton4 sethidden:yes]; } break; } } this isn't working, hoping go 'if' statement path. how code each letter answer? thinking this: -(ibaction)a { if(questionnumber = 0) { question.text = @"whatever question is"

Element type replace with Mootools -

one of web page carries multiple forms same elements under different form id such as <form method="post" action="" style="" enctype="application/x-www-form-urlencoded" id="comment-form-1"> <textarea rows="1" cols="45" id="body" name="body" ></textarea> <button class="post-comment-sml" type="submit" id="submit" name="submit"></button> </form> <form method="post" action="" style="" enctype="application/x-www-form-urlencoded" id="comment-form-2"> <textarea rows="1" cols="45" id="body" name="body" ></textarea> <button class="post-comment-sml" type="submit" id="submit" name="submit"></button> </form> --- <form method="post" ac

memory management - difference between drain and release -

i want know difference between drain , release in memory management..please me suitable example. in garbage collected environment, release no-op. nsautoreleasepool therefore provides drain method in reference-counted environment behaves same calling release , in garbage collected environment triggers garbage collection (if memory allocated since last collection greater current threshold). typically, therefore, should use drain rather release dispose of autorelease pool. source: http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/memorymgmt/articles/mmautoreleasepools.html

iphone - MKMapView's user location is wrong on startup or resume -

when start application fresh, or resume after long time, mkmapview's notion of userlocation wrong , shows me in middle of sea. i using following code: self.mapview.centercoordinate = self.mapview.userlocation.location.coordinate; [mapview setcentercoordinate:self.mapview.userlocation.location.coordinate zoomlevel:zoom_level animated:yes]; happens after lengthy resume of app or brand new start.... that's expected behavior : user location isn't tracked iphone using gps (it consume battery). map displayed, mkmapview instance shows last 'best' user position knows , then, improves accuracy activating tracking (this seamless process, don't have care it) . you can monitor when mkmapview updates user location on map implementing mkmapviewdelegate protocol . implement : - (void)mapview:(mkmapview *)mapview didupdateuserlocation:(mkuserlocation *)userlocation { cllocationaccuracy accuracy = userlocation.location.horizontalaccuracy;

jquery - jsonp callback problem -

i'm trying following code retrieve client ip, , works fine <script type="text/javascript"> function getip(json) { var ip = json.ip; // alerts client ip address alert(ip); } </script> <script type="text/javascript" src="http://jsonip.appspot.com/?callback=getip"></script> but when try $.ajax nothing... $.ajax({ type: "get", url: 'http://jsonip.appspot.com/?callback=getip', datatype: "jsonp", success: function getip(json) { alert("sucess"); var ip = json.ip; alert(ip); } }); }); plz help $.ajax({ type: "get", url: "http://jsonip.appspot.com/?callback=?", // ^ // ---- note ? symbol ----------------| // jquery responsible replacing symbol // name of auto generated callba

android - How to avoid .IllegalStateException -

02-09 12:06:38.745: warn/dalvikvm(198): threadid=3: thread exiting uncaught exception (group=0x4001b188) 02-09 12:06:38.766: error/androidruntime(198): uncaught handler: thread main exiting due uncaught exception 02-09 12:06:39.415: debug/dalvikvm(198): gc freed 1522 objects / 308248 bytes in 400ms 02-09 12:06:39.574: error/androidruntime(198): java.lang.illegalstateexception: not execute method of activity 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2031) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.performclick(view.java:2364) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.ontouchevent(view.java:4179) 02-09 12:06:39.574: error/androidruntime(198): @ android.widget.textview.ontouchevent(textview.java:6541) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.dispatchtouchevent(view.java:3709) 02-09 12:06:39.574: error/androidruntime(198):

Programatically get 14 hive path in sharepoint 2010 -

i need 14 hive path using code in c#.net. can 1 tell me how can this? you can access physical path using sputility - web path looking @ spweb object. using sputility setuppath of sharepoint so: using microsoft.sharepoint.utilities; string spsetuppath = sputility.getgenericsetuppath(string.empty); //e.g. returns "c:\program files\common files\microsoft shared\web server extensions\14 msdn documentation sputility.getgenericsetuppath example usages of sputility.getgenericsetuppath (e.g. getting templates dir) or can use spweb's server relative url method: using microsoft.sharepoint; string spserverurl = spweb.serverrelativeurl; msdn documentation spweb.serverrelativeurl also have overview of sharepoint 2010 14 hive structure .

java - HttpClient response only one line of XML -

i'm using httpclient fetch xml file , i'm having issues getting entire document returned (it returns 1 line of xml file). so: defaulthttpclient c = new defaulthttpclient(); basicresponsehandler r = new basicresponsehandler(); string s = null; try { s = c.execute(new httpget("http://localhost/activity.xml"), r); } catch (exception e) { e.printstacktrace(); } log.i(tag, s); the resulting string <?xml version="1.0" encoding="utf-8"?> is there need tell httpclient load entire file or process newlines or something? xml super simple: <?xml version="1.0" encoding="utf-8"?> <project> <group-id type="integer">2187</group-id> <icon type="integer">2</icon> <name>android</name> <overview>android app</overview> <permalink>codebase</permalink> <start-page>tickets</start-page> <statu

Equivalent to R findInterval() function in SAS IML -

is there similar r's findinterval (or cut ) in sas, in iml? i'm converting r program of mine monte carlo simulations iml, , uses findinterval convert numbers random number generator output state. can write in iml replace it, it's terribly slow compared original. because findinterval takes advantage of compiled c code; there similar can use in sas? are breaks uniform (equal probability) or not? uniform breaks, can use ceil(k*u) u vector or random uniform numbers. example, if want 10 observations randomly assigned numbers 1-4 equal probability, can say y = ceil(4*ranuni(j(10,1))); or, if want use newer random number generator, u = j(10,1); /** allocate **/ call randgen(u, "uniform"); /** fill u[0,1] **/ y = ceil(4*u); for unequal probability, use "table" distribution. example, p = {0.1 0.5 0.2 0.2}; /** 4 categories given probabilities **/ y = j(10, 1); call randgen(y, "table", p); /** fills 1-4 probability p **/ yo

jquery - Html checkBox onchange not working -

<input class="jproblemclass" id="checkbox{%= id %}" type="checkbox" onchange="problempicker.onchangeproblemcheckbox('{%=id %}');"/> after first check or uncheck nothing happens. afetr second click, call function problempicker.onchangeproblemcheckbox , id first check. why? can me anybody? onchangeproblemcheckbox: function(id) { if ($('#checkbox' + id).attr("checked") == true) { problempicker.addtocheckproblems(id); var checkboxes = $('.jproblemclass:checked'); if ((checkboxes.length > general.limit) && (general.limit != 0)) { alert('the limit of ' + general.limit + ' problems exceeded. please deselect ' + (checkboxes.length - general.limit).tostring() + '.'); } } else { problempicker.delfromcheckproblems(id); } }, bro use onclick event instead onchange.. reason... according javascript refere

css - Resize unknown number of elements to fill width of parent container -

i need put unknown number of divs (likely limit of 5) parent container , make sure remain equally divided. i'm not sure if can done css alone figured better ask. if know 3 divs used: <style> .menu-button { float: left; width: 33%; } </style> <div> <div class="menu-button">button x</div> <div class="menu-button">button y</div> <div class="menu-button">button z</div> </div> seems work, if number of .menu-button divs unknown? there better way automatically adjusts horizontally? unfortunatly think you'll have use tables this. <td> 's resize itslef fit full width. hth

JavaScript: Initializing variable in function -

a basic question here. can see going on can't understand why work way. a = false; var k = function() { console.log(a); var = true console.log(a); }(); i expect log read "false, true" "a" undefined @ first. can please elaborate why this. ps. i'm not looking answer telling me should do, i'm looking explanation of inner workings of piece of javascript. thanks in advance this because javascript scoping works called "hoisting". when parser reads javascript function, goes through , finds variables defined in scope (using var ) keyword (remember type of scope in javascript function scope). puts them @ top of function. so parser interprets code follows: a = false; var k = (function() { var a; console.log(a); = true console.log(a); }()); (nb have corrected function call doesn't return syntax error.) obviously sets a undefined before first console.log . as mdc docs say : every defi

datagrid - How add a global "IsReadOnly" style to all DataGridTextColumns -

i have resourcedictionary file wpf application, pretty adds every style possibly want throughout of application's datagrids. except one. how can add global " isreadonly " setter, of datagrid's datagridtextcolumn columns ? basically, use few datagrids, , if want display read-only data in particular column, i'll display data using datagridtextcolumn : <wpftoolkit:datagridtextcolumn binding="{binding path=dob,stringformat='dd/mmm/yyyy'}" header="dob" width="120" /> however, if have column has editable data, i'll use datagridtemplatecolumn instead. <wpftoolkit:datagridtemplatecolumn xheader="department name" > <wpftoolkit:datagridtemplatecolumn.celltemplate> <datatemplate> <combobox width="175" itemssource="{binding source={staticresource alldepartmentsdatasource}}" selectedvalue="{binding dep

ruby on rails - Possible to undo rake db:schema:load -

i mistakenly performed rake db:schema:load on development database , wiped data have been using perform tests. can regenerate of using rake task wrote, there way undo it? thanks! i don't believe there way undo schema load. there rollbacks migrations. sorry!

c++ - send over IP immediately on different thread -

this impossible, i'm going ask anyways. have multi-threaded program (server) receives request on thread dedicated ip communications , passes on worker threads work, have send reply answers client , send when finished, little delay possible. using consumer/producer pattern , placing replies on queue ip thread take off , send client. this, gives me no guarantee when going happen, ip thread might not scheduled time soon, cannot know. makes client, blocking call, think request has failed, not point. due fact unable make changes in client, need solve sending issue on side, problem i'm facing not wish start sharing ip object (currently on 1 thread) worker threads, things overly complicated. wondered if there way can use thread sync mechanisms ensure moment worker thread finished, ip thread execute send reply client? will manual/autoreset events me or these not guaranteed wake thread immediately? if need sent immediately , best bet bite bullet , start sharing con

drupal : content type CCK - add an existing field disappeared? -

i installed drupal scratch , i'm installing additional modules according needs. the biggest problem have if go in admin/content/node-type/nodetypename/fields (the page can edit/add/delete cck fields) can't re-use defined fields option add existing fields disappeared (probably it's module don't know about) have new field , new group ..in other installation have existing field option can reuse defined fields... am missing something? my cck module page looks this: cck activado nombre versión descripción content 6.x-2.8 permitir los administradores definir nuevos tipos de contenidos. requerido por: content copy (desactivado), content permissions (activado), content taxonomy (activado), content taxonomy autocomplete (activado), content taxonomy options (activado), content taxonomy tree (desactivado), date (activado), date tools (desactivado), email (activado), fieldgroup (activado), filefield (activado), cck translation (activado), imagefield (activado)

c# - Mapping object to dictionary and vice versa -

are there elegant quick way map object dictionary , vice versa? example: idictionary<string,object> = new dictionary<string,object>(); a["id"]=1; a["name"]="ahmad"; // ..... becomes someclass b = new someclass(); b.id=1; b.name="ahmad"; // .......... using reflection , generics in 2 methods extensions can achieve that. right, others did same solution, uses less reflection more performance-wise , way more readable: public static class objectextensions { public static t toobject<t>(this idictionary<string, object> source) t : class, new() { t someobject = new t(); type someobjecttype = someobject.gettype(); foreach (keyvaluepair<string, object> item in source) { someobjecttype.getproperty(item.key).setvalue(someobject, item.value, null); } return someobject; } public static idictio

html - Function in PHP to set cookie, for my login script -

Image
i followed this guide attempt write login script hobby webpage. problem when want incorporate page, problems occur. i'm trying make admin panel. in top of frame want login form be when log in, i'd login form area change logout fields . my problem cookie-related calls has done before html code starts... so: when log in: content of page should displayed ( simple include ). when log in: login area changes logout area, hiding login fields , displaying name of user logged in... and when logging out: content , logout should disappear , show login fields again. how can done (give examples pseudo code)? ps. im not php nerd, still learning. you write login data current session. $_session["username"] = $user; but don't forget call session_start() @ top of code. after check whether "$_session["username"]" set data. if so, can change content whatever like. example: if (isset($_session['username

join - log-queries-not-using-indexes and LIKE in MySQL -

i have "log-queries-not-using-indexes" enabled in mysql. have 1 query being logged mysql such i.e. query not using indexes. thing query uses e.g. category '%fashion%' and if remove or change to category = 'fashion' then says using indexes. so when using in our query, mysql log not using indexes no matter what? thanks using clause %fashion% never use regular index. need full-text index if want kind of search. remember varchar indexes on first part of string. so, if searching ocurrence of fashion on any part of string, index offer no improve performance since need search every single string. however, if search first part this: select * table field 'fashion%' then index used , helpful.

ASP.NET Session TimeOut problem -

i have wired scenario in 1 of asp.net application. i using asp.net membership custom "rolemanager", and having below tag in web.config restrict user not having role of "keywords"(roles) access "keywords"(path) folder <location path="keywords"> <system.web> <authorization> <allow roles="keywords"/> <deny users="*" /> </authorization> </system.web> </location> if user other role allow assess url (keywords in case) redirected custom- access denied page. now things working fine when left application inactivity of 30 min not able visit "keywords", time end custom- access denied page, if close browser, login again start working fine. please me in case. thanks in advance asp.net sessions time out after 20 minutes default, think. you can extend specifying longer time (in minutes) in web.config: <system.web> <sessionstate timeou

jsp include is not working from subdirectories -

i not able include jsp file subdirectory. have include file include subfolder file in test folder. i tried code <%@ include file="../../include/file.jsp"%> inside file ../test/sample.jsp but i'm getting error like org.apache.jasper.jasperexception: /all.jsp(132,1) file "/../../include/file.jsp" not found org.apache.jasper.compiler.defaulterrorhandler.jsperror(defaulterrorhandler.java:40) org.apache.jasper.compiler.errordispatcher.dispatch(errordispatcher.java:407) org.apache.jasper.compiler.errordispatcher.jsperror(errordispatcher.java:88) org.apache.jasper.compiler.parser.processincludedirective(parser.java:300) org.apache.jasper.compiler.parser.parseincludedirective(parser.java:333) org.apache.jasper.compiler.parser.parsedirective(parser.java:442) org.apache.jasper.compiler.parser.parsefiledirectives(parser.java:1749) org.apache.jasper.compiler.parser.parse(parser.java:127) org.apache.jasper.compiler.parsercontroller.doparse(parsercontroll

html - jQuery input value switching -

i've been using code switch value of inputs onfocus , blur: $('input, textarea').focus(function() { value=$(this).val(); $(this).attr("value","")}; }); $('input, textarea').blur(function() { if($(this).val()=="") { $(this).val(value); } }); only problem is, when type these inputs, refocus after typing another, field goes blank. there way edit code inhibit this? example here :) i tried this, didn't have effect desire: $('input, textarea').focus(function() { value=$(this).val(); if($(this).val(value)) { $(this).attr("value",""); }); $('input, textarea').blur(function() { if($(this).val()=="") { $(this).val(value); } }); you need set initial value , check against that.. $('input, te

winhttp.dll a standard windows file? -

is winhttp.dll standard windows file? application depends on it, i'd rather not deploy in application setup, unless neccessary. as per: http://msdn.microsoft.com/en-us/library/aa384273(v=vs.85).aspx winhttp 5.1 offers improvements on version 5.0. included in operating system

nsarray - iPhone - Iterating through Array of dictionaries and getting an object -

in application, i'm having nsarray holds objects of nsdictionary. in each dictionary, there's 1 "primary" holds value of type nsnumber stores "yes" or "no" (boolean value). , dictionary object in array can have value "yes". without using loops how can dictionary object "primary" key yes? you can call convenience method on nsarray find object, aware, such method still uses loop internally find object. nsuinteger indexofprimary = [array indexofobjectpassingtest:^(id obj, nsuinteger idx, bool *stop) { return [[obj objectforkey:@"primary"] boolvalue]; }]; nsdictionary *primary = nil; if (indexofprimary != nsnotfound) { primary = [array objectatindex:indexofprimary]; } another option -[nsarray filteredarrayusingpredicate:] .

Database connection through PHP & HTTPS for iPhone -

would sufficient data through https connection iphone app via php (the php files located on same web server mysql database)? i'm speaking in terms of security. also, tideous process (with many overheads) or can work in terms of performance? thanks in advance. i have added http authentication security scheme describe--so directory containing php scripts receive web requests iphone app , emit json in return behind basic web-server-level authentication. not lot stronger, @ least prevents nosy url-twiddlers finding way in there. i recommend following third-party libraries this: asihttprequest json framework using 2 things, -viewdidload method might contain this: nsstring *urlstr = @"http://username:password@myrequest.com/myjsonscript.php"; asihttprequest *r = [asihttprequest requestwithurl: [nsurl urlwithstring:urlstr]]; [r setcompletionblock:^{ nsdictionary *results = [[r responsestring] jsonvalue]; //do whatever displ

serverxmlhttp - get and post request to a https site using vb6.0 -

hi using msxml2.serverxmlhttp40 , post request url.when post http site works fine when post https site throws me error stating operation timed out.i not able response.kindly me out.thanks in advance i found solution have set ..setproxy , setproxycredentials along , need session id .when used 3 worked fine.

c# - Retrieve value from attribute in HTML tag in asp.NET -

i have large string containing custom html tag (xxx). tag has 2 attributes. how retrieve value of 2 attributes , place tag , content new string derived 2 attributes? thanks time. where want retrieve it? in code behind? if tag runat="server", can do: mytag.attributes["nameofmyattribute"]

Problems with my PHP script - newbie fails? -

hey guys have problem php script doesn't work ... don't know why doesn't work or skills have improove. i thankfull help the code here : http://pastebin.com/gkfbejs0 thanks loot chris your first fatal error easy, calling $db->query($db_var_one) , $db not object. it looks need $db_cnct_one instead.

xcopy - Can sombody enlighten to why two of lines in batch dont work -

hi have following bat file works except lines 70 , 78 can help tnx- @echo off ; reseting system color configuration... @color 17 echo =============================== echo == autocad 2010 de mar setup == echo =============================== echo. echo creating backup directory, please wait... echo. mkdir c:\"autocad 2010 backup" echo. echo autocad 2010 backup directory created... echo. echo backing nessesary files, please wait... echo. xcopy /s/y c:\"program files\autocad 2010\support\acad2010doc.lsp" c:\"autocad 2010 backup" xcopy /s/y c:\"program files\autocad 2010\support\acad.lsp" c:\"autocad 2010 backup" xcopy /s/y c:\"program files\autocad 2010\support\acad.pgp" c:\"autocad 2010 backup" echo. echo nessesary files backed-up... echo. echo deleting conflicting files, please wait... echo. del c:\"program files\autocad 2010\support\acad2010doc.lsp" del c:\"program files\autocad 2

javascript - "Fields" in tinyMCE -

when editing document in ms word, can insert `field' , insert references it. when field's value changed, can update values in references without editing them manually. is there similar functionality available in tinymce, example via 3rd party plugin? as far know there no such plugin available. cannot difficult implement functionality in custom tinymce plugin.

c# - ASP.NET Debugging Multiple Projects - Error -

i have 2 seperate asp.net applications on single solution. change startup order of projects menu in order debug them. although first asp.net application can start on debug mode, second 1 gets error this: " unable start debugging on web server. unable autoattach. make sure server operating correctly. verify there no syntax errors in web.config doing debug.start without debugging.you may want refer asp.net , atlserver debugging topic in online documentation" how can fix it? check answer out here: http://www.velocityreviews.com/forums/t65889-auto-attach-aspnet_wp-exe-in-visual-studio.html hope helps edit: here's text site requested: since default web application ok , problem occurs in specific web application, please check following settings of problem project. open problem project in vs.net ide. select project->"project name" properties... select configuration properties->debugging. please make sure "start action" s

join - Can I combine these two Linq queries -

i trying combine sharepoint data legacy database data , can data, need in 2 queries. here 2 linq queries: var query = (from dteai in result.asenumerable() join allap in dtallairports.asenumerable() on dteai.field<int>("airportid") equals allap.field<int>("id") select new { region = allap.field<string>("region") } ); and second gets me result: var join = ( table in query group table table["region"] groupedtable select new { key = groupedtable.key, count = groupedtable.count() } ); not being expert in linq converted sharepoint lists datatables join. can combine single query? i had

image - Display ImageIcons in jTables -

i have tried using code below display imageicons in jtable. when run program jtable displays empty space. p1.getpicture(); comes database. basically, there way modify below code such there way display imageicon in picture??? package tables; import javax.swing.imageicon; import javax.swing.jlabel; import javax.swing.table.abstracttablemodel; import java.util.arraylist; import entity.*; public class profiletable extends abstracttablemodel{ private static final long serialversionuid = 1l; private int rowcount, colcount; private string[] columnnames = {"clickid", "name", "gender", "website", "hobbies","favourite food", "dp"}; private object [][] data; private imageicon [][] icons; public profiletable(arraylist<profile> listofobjects) { rowcount = listofobjects.size(); colcount = columnnames.length; data = new object[rowcount][colcount]; //icons = new

Deploying multiple rails applications on a single domain -

i beginner ruby on rails developer. so far have created several rails applications on computer localhost. now, want deploy applications professional server. i have 1 domain , wondering if can deploy multiple rails applications on single domain? if yes, best way it? should put every application in folder? and server need specific requirement? thanks, oded one solution use subdomain each application. app1.yourdomain.com point application 1, app2.yourdomain.com point application 2, , on.

7zip - Does GZip support multi-part file compression? -

i have been looking around if gzip supports multi-part file compression. have seen far not, how come 7z allows multipart compression when gzip selected compression? mean 7z takes care of multi-partitioning internally? gzip doesn't support multipart archives, can still create them using split : split -–bytes=20m /path/to/large/archive /path/to/output/files now, put together, cat parts one: cat files* > archive as far can tell, 7-zip when creating archives. might add header information, dumps 20mb of data file , appends number after name. then, internally, assembles parts , reads archive.

eclipse - How I can change the Background in runtime in Android? -

i want make simple program 2 radiobutton ( rd1 , rd2 ), can change background picture s1, or s2, depend on selected. how can make it? tried background.setbackground (background radiogroup's name), didn't work. try changing android wallpaper. http://developer.android.com/resources/samples/apidemos/src/com/example/android/apis/app/setwallpaperactivity.html and if want change background current activity means if layout lay means then, lay.backgrounddrawable(r.drawable.abc); in onclick listenerof ur radio button sure dude..let me know happened... thank you.

php - Passing parameters from an outside file to a class -

i need have 2 files. let's call file controlling second one: main.php , let's call secondary file, 1 code: second.php in second.php have: <?php class tags{ var $theuser; var $thebarname; var $theplace; var $thetime; var $themail; function __construct($theuser,$thebarname,$theplace, $thetime, $themail){ $this->theuser=$theuser; $this->thebarname=$thebarname; $this->theplace=$theplace; $this->thetime=$thetime; $this->themail=$themail; } function give_tags_theuser(){ return $this->theuser; } function give_tags_thebarname(){ return $this->thebarname; } function give_tags_theplace(){ return $this->theplace; } function give_tags_thetime(){ return $this->thetime; } function give_tags_themail(){ return $this->themail; } } $tags = new tags("john", "starbucks", "ny", "

jquery - How to better structure multilingual Javascript code? -

we rewriting jquery code of our web service , thinking on better way organize it. we've been reading several questions, articles, etc; , first approach, love receive feedback. we going have class each object of page (place, user, etc). planning use low pro ( article ) have code in 1 place. however there variables need pass php (user.id, user.name, etc). have thought best way print json , pass general class. var array = { 'key1' => 'value', 'key2' => 'value', 'key3' => 'value', }; var te = new te(array); te.js assign variables there other classes can use them. have multilingual web, need have messages in several languages. similar answers of multilingual alert messages in javascript what think? there better way load initial array? other suggestion or article? thanks! i store translated words in separate js can cached client, , wont suffer repeated data (ie, multiple jquery classes can reference

java - Do two classes of the same class have the same hashcode and are they considered equal? -

i want create hashmap of classes (object.class). wondering whether object.class considered equal object.class? can there instance of object.class leads have different hashcode? the literal object.class return same reference within same classloader. from section 15.8.2 of jls : a class literal evaluates class object named type (or void) defined defining class loader of class of current instance. note definite article ("the") in quote above - there's one class object particular class, within same class loader. so yes, you'll same hashcode - because you'll have 2 references same object.

multithreading - Making massive numbers of HTTP requests in Python -

i'm trying test web application, part of involves making ~10k requests, taking few <1k return 200 ok , going through data. webapp buggy , there false positives, each 200 ok needs @ least triple-checked. working in python trying threading , urllib, on linux thread errors after ~920 threads. (my theory it's /proc/sys/kernel/threads-max divided thirty eerily accurate, it's perturbing each thread register 30 threads os). in case, i'm looking solution task. i've looked twisted, seems still bound threading. any ideas? i testing whit apache ab web server tornado , unable go on 1000 connections per second on dual core athlon @ 2ghz . 30% resources took testing tool ab , remaining server. pretty convinced resources spent os , ip-eth layer. http://amix.dk/blog/post/19581 non blocking servers have better performance blocking servers since not spawn tread each connection. in theory can run in single tread.

objective c - highlight and make note in UIwebview -

i deveoping ebook app ipad/iphone loads epub file. know how highlight text background color , make notes similar ibook or kindle in uiwebview , not uiview. able drag select text long tapping. can see "copy" option. add highlight , add note menu. how hightlight text background color?... document loaded in uiwebview. thank you. what need add note , highlight options shared menu. in viewcontroller viewdidload (or anytime after view has been added). following adds 2 menu items 2 selector methods menu. uimenuitem *custommenuitem1 = [[uimenuitem alloc] initwithtitle:@"highlight" action:@selector(dohighlight:)]; uimenuitem *custommenuitem2 = [[uimenuitem alloc] initwithtitle:@"note" action:@selector(donote:)]; //[myarray addobject:custommenuitem2]; nsmutablearray *myarray = [[nsmutablearray alloc]initwithobjects:custommenuitem1,custommenuitem2, nil ] ; [uimenucontroller sharedmenucontroller].menuitems = myarray; you may want use bit of ja

php - Uploading multiple photos in a form -

i have photo-upload form allows user upload 1 photo. users complaining want upload many photos. how can allow them that? right have form uploading: http://www.hikingsanfrancisco.com/account/upload_hike_photos.php?hike_id=58 (i tried paste code, didn't work somehow) any thoughts how best go it? there way loop through selected files maybe? (i using php) thanks, alex add more fields uploading files, don't know, maybe file or six, , upload button check through php of them have information start upload, 1 @ time or course, in php loop.

Android - Idle time? -

how know idle time android device? idle time time human interaction last made device (touch on screen or keyboard click) partial or full code appreciated. i bet implementing accessibilityservice.

python - simple inter-process communication -

i'm looking simple way pass messages 1 process (perl script, short-lived) (python script, long-running) - both processes local same machine. i've done research, i've found either on head or seemed unnecessarily complex - leaving me bit lost , confused. i imagine minimal example following: # listener.py class listener: def __init__(self, port) self.port = port def on_message(self, msg): print "%s: %s" % (timestamp, msg) recipient = listener(1234) # sender.pl sub send_message { ($msg, $port) = @_; # ... } send_message("hello world", 1234); any pointers on how solve and/or read on appreciated! in general interested in sockets. place needed rough information documentation of io::socket::inet or more basic socket-stuff in perl perldoc perlipc

Problems trying to assign **varname to *varname[]. c++ -

in .h, have variable, texture ** skyboxtextures . assign texture pointers in 1 method, , use them right away: texture *skt[] = { tleft, tright, tfront, tback, tup, tdown }; skyboxtextures = skt; for(int = 0; < 6; i++) { skyboxtextures[i]->load(); } then later in method try use textures again. texture *skt[] = skyboxtextures; // render front quad skyboxtextures[0]->activate(); this issue cannot access objects more. not compile because of error: error c2440: 'initializing' : cannot convert 'texture **' 'texture *[]' if comment out line texture *skt[] = skyboxtextures; , invalid texture pointers. then later in method try use textures again. you cannot that. converting array pointer it's first element 1 way process. while array still array compiler has information size of array available @ compile time. once it's pointer, compiler no longer has information. you either have reference skt

telephonymanager - How to find the mobile phone number in android? -

i developing small android application in want find mobile phone number used in particular phone i tried following telephonymanager tmgr =(telephonymanager)this.getsystemservice(context.telephony_service); string mphonenumber = tmgr.getline1number(); it working fine in emulator not working in phone please me how that you may want @ question, there no better way, , may need ensure app has read_phone_state permission, but, sim may not returning it. i nervous phone trying value. why need it, there may better way want. programmatically obtain phone number of android phone

Add html Using JQuery -

i have this: <span class="mad">2</span> stuff </li> i want this <a href="/my/website"><span class="mad">2</span> website</a> </li> can give me jquery this? "/my/website" has changed different each li...is possible? using each, can give each li span.mad different website url $("li span.mad").each(function(i,e) { $(e).html( "<a href='/my/website/"+ (i+1) +"'>"+$(e).html()+"</a>"); }); http://jsfiddle.net/6ezds/ (or using wrap ) $("li span.mad").each(function(i,e) { $(e).wrap("<a href='/my/website/"+ (i+1) +"' />"); });

sql - Oracle: What's the problem with this join? -

i can't join work in oracle. can't figure out, why it? select e."ci", e."nombre" empleado e e."ci" in (select e."cisupervisor" empleado e); inner join empleado on "ci"= t."ciempleado" select e."nombre",e."apellido",p."nombreproy" empleado e, proyecto p e."cisupervisor" in (select e."ci" empleado e, proyecto p, trabajaen t e."sexo"='f' , e."ci"=t."ciempleado" , t."horas">60 , t."codproy"=p."codproy" , p."fechaini"=2010 ); as @cyberwiki correctly noted, trying join 2 individual queries. the first 1 ends @ line 3 because it's terminated semicolon. this part: inner join empleado on "ci"= t."ciempleado" doesn't work on it's own since need where clause after join if want more conditions. everything after part query executes on own. yo

C# equivilent to Java's java.awt.image.DataBuffer -

here's java code: import java.awt.image.databuffer; public class b extends databuffer { public float[][] a; public float[] b; public float[] a() { return this.b; } } question plain , simple. c# equivalent java.awt.image.databuffer? or need 1 level , find equivalent java.awt.image? tia, keithc it sounds trying sort of image manipulation. seem need direct access pixel data bitmap because method calls slow. .net provides bitmap.lockbits purpose. here’s example how might use this: var bmp = new bitmap(width, height, pixelformat.format32bppargb); unsafe { var data = bmp.lockbits(new rectangle(0, 0, width, height), imagelockmode.readwrite, pixelformat.format32bppargb); (int y = 0; y < height; y++) { var b = (byte*) data.scan0 + y * data.stride; (int x = 0; x < width; x++) { var blue = b[4 * x]; var green = b[4 * x + 1]; var red = b[4 * x + 2]; var alpha =

cmd - how to remove a few lines from a Unicode registry file using batch commands in Windows? -

i have program who's generating data in registry. save "reg export hkcu\software\programname\data data.reg" (unicode format). need take other computer , import there program computer use data. have remove text lines data.reg. text lines easy find because contain strings (for example paths exe , dlls, specific program settings "name1=value1", "name2=value2",...). i'm doing manually (using wordpad) every few days maybe there way... oh , can't install other programs on these computers (the access restricted) have use batch/cmd files. tried far: - redirecting export "con" visual not in variable; - using "for /f ..." works ansi , removes blank lines. the lines must removed before importing because settings of program first computer must not loaded registry keys of program second computer. can please me...? thank you. use code loop file contents line line for /f %z in (yourfile.reg) ... then use conditionals d

php - php_mysql_assoc ignores first record -

hi there i'm trying query database records share same "itemid" table transaction list of operations done on items in database. i've checked sql query in phpmyadmin , works correctly when run php code ignores first record every time. here's code <?php // quantity of each item $sql1 = 'select `idpentered` , `itemid` , `qty` , `value` `tblpieceentered` `itemid` =307 ' ; echo $sql1."<br>"; // retrieve data table $result1 = mysql_query($sql1) or die(mysql_error()); // store record of table $row1 $row1 = mysql_fetch_array( $result1 ); $i = 1; $num = mysql_num_rows ($result1); echo "num rows: $num <br>"; while ($row1 = mysql_fetch_assoc ( $result1)) { $data_array[$i] = $row1; $i++; } echo "<pre>"; print_r ($data_array); echo "</pre>"; ?> the result is: select `idpentered` , `itemid` , `qty` , `value` `tblpieceentered` `itemid` =307 num row

couchdb - Problem listing documents in a CouchApp -

i in bit of trouble not able find resources and/or tutorials give me enough knowledge how properly: i building couchapp uppon contact database. need have unordered list of contacts(only names) on landing page. after examining quite time , examining http://kansojs.org framework, think might have ask here @ stackoverflow how done properly... here ended (not working): i started setup view (file 'views/contactslist/map.js ): function(doc) { if (doc.displayname) { emit(doc.displayname, {displayname: doc.displayname}); } }; ... gives me response: {"total_rows":606,"offset":0,"rows":[ {{"id":"478d86edbbd94bbe627f3ebda309db7c","key":"al yankovic","value":{"displayname":"al yankovic"}}, {"id":"478d86edbbd94bbe627f3ebda30bb5cb","key":"al-qaeda","value":{"displayname":"al-qaeda"}} ]} afterwards, cre

iphone - How to perform network task in background thread while updating UITableView? -

just trying figure out best way design such functionality? send asynchronous nsurlconnection hits server sends bunch of data. once data have perform work on pretty expensive , rather in bg thread prevent ui locking. lastly need have uitable update dynamically response server received , processed. my question how go doing work in background thread as data arrives table doesnt wait until data has loaded before being updated?? this pseudo code have far. in viewcontroller have 2 bool flags newdatareceived , datafinisheddownloading. have 2 variables, string contains current data , nsarray kept results of processing data. then, in didreceiveresponse: spawn new thread calling performselectorinbackground: processing method selector. in method have loop first check newdatareceived see if new data has arrived , if work on it. once finished processing set nsarray results , call method updates table datasource , reloads table using performselectoronmainthread: lastly check datafini

Amazon EC2 multiple instances with SVN app -

heya, quick question. i've got multiple instances on ec2 load balancer between them. use svn app used push live env. @ will. with multiple ec2's, how push codebase of them @ once? thoughts/links appreciated. there few different ways this. if using elastic load balancers write script that: removes machine pool updates svn repository re-adds machine pool repeats additional machines you fancy , remove 1 machine, update it, remove other machines , update them, if you're concerned consistency. if using custom load balancing application look capistrano . don't need use ruby/rake -- can write custom cap files can parallel deploys.

Format DateAsOrdinal xAxis labels in ZedGraph -

i have changed x axis dateasordinal , improve label format. handle xaxis.scaleformatevent this: private function onxscaleformatevent(byval pane graphpane, byval axis axis, byval val double, byval index integer) string dim result string = "" if val < pricebars.count dim time date = date.fromoadate(pricebars(val).x) result = [string].format("{0:d2}{1}{2:d2}", time.hour, ":", time.minute) end if return result end function how can make labels print every whole 30 minutes? or every 2 hours in image below? believe still need reference bar x-values, because need plot multiple days continuously, hours each day, image shows; 09:00-23:00. http://i53.tinypic.com/2jcwknd.png i think, do: chart.graphpane.xaxis.scale.majorstepauto = false chart.graphpane.xaxis.scale.majorunit = dateunit.minute chart.graphpane.xaxis.scale.majorstep = 30 chart.graphpane.xaxis.scale.basetic = 0

C++ unexplained variations in template function matching with enums -

i have following code containing template function. when calling function second parameter being enum: in cases finds template specialization , in cases not. i had verified enums same enums in both cases (e.g there no redefinitions) , other parameters have correct values, found 1 compilation done -winline set (i did not try changing yet) else at? class { public: template <typename t> int f(uint32_t id, t const& t, bool cond); ... }; template <typename t> int a::f(uint32_t id, t const& t, bool cond) { ... } template <> inline int a::f<int>(uint32_t, int const& t, bool cond) { .... } for starters, typically, it's inadvisable use template specialization way of overloading template function. template specializations interact poorly function overloading , have pretty arcane rules dictating when they're chosen, , in general it's considered better provide regular function overload specialize function tem