Posts

Showing posts from September, 2011

filesystems - Create a new tmpfs and mount it -

when "df" command in machine can see following: filesystem 1k-blocks used available use% mounted on tmpfs 491520 127240 364280 26% / i want create tmpfs. how should it? i using flash contains bootloader, kernel , rootfs. @ stage of booting should make changes tmpfs created. you add line /etc/fstab: none /mnt/mytmp tmpfs defaults 0 0

Sorting a 2 dimensional array in PHP -

wonder if can help; i have 2 dimensional array need group common "job number" element; here's example - i'm playing idea @ moment, $i counter iterates through array results; $galleryitems[$i][0] = 'example title';//the title $galleryitems[$i][1] = 'example description';//description $galleryitems[$i][2] = 'the client';//client $galleryitems[$i][3] = '00000';//job number any ideas on how group these toegther, eg if had number of 00000 job items stick these toegther, , 00001 group etc. thanks $galleryitemsgrouped = array(); foreach($galleryitems $k => $v) { $galleryitemsgrouped[$v[3]][] = $v; } var_dump($galleryitemsgrouped); or maybe that's mean usort($galleryitems, function($a,$b) { if($a[3] == $b[3]) return 0; return $a[3]<$b[3] ? -1 : 1; }); var_dump($galleryitems);

.net - Is this a recommended way to use a Stored Procedure with Entity Framework 4? -

my code doing 2 round trips database because i'm not sure if correct way create collection of poco's first round trip hits stored procedure because of specific sql code. scenario a user enters autocomplete search query ui. code hits stored procedure (which taking advantage of f*ull text search* - hence reason i'm using stored procedure) , returns distinct primary keys of results. these go code (my irepository class ) , use ef retrieve results, these stored procedure result. firstly, don't know how in linq entities : collection of id's, retrieve foo entities. secondly, i'm doing 2 round-trips database. why? because i'm not sure how can retrieve rich results in first round trip. entity consists of few poco classes , has 2 icollection properties also, etc... is correct way should using stored procedure , retrieving rich, populated entities. i'll create dummy class diagram answers. public class person { string name; int age;

android - how to implement both ontouch and also onfling in a same listview? -

i have listview , implemented onclick , onfling.problem when fling(swipe left right), onclick event of listview getting executed.how overcome problem? how differentiate touch(tap) , fling(swipe) in listview? listclicklistener = new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v,int position, long id) { //job of onclick listener } }; mcontactlist.setonitemclicklistener(listclicklistener); mcontactlist.setadapter(adapter); // gesture detection gesturedetector = new gesturedetector(new mygesturedetector(prosnos)); gesturelistener = new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { if (gesturedetector.ontouchevent(event)) { return true; } return false; } }; mcontactlist.setontouchlistener(gestureliste

php - whitespace in select dropdown, pulled from mysql -

i'm using populate dropdown: $result = mysql_query("select user `users` order user asc") or die(mysql_error()); echo '<select name="user" class="user">'; while ($row = mysql_fetch_array($result)) { echo "<option value=".$row['user'].">".$row['user']."</option>"; } echo '</select>'; but source this: <select name="user" class="user"><option value=joe bloggs>joe bloggs</option> so when this: var user = $('.user').val(); it sees "joe" not "joe bloggs"?? ideas $result = mysql_query("select user `users` order user asc") or die(mysql_error()); echo '<select name="user" class="user">'; while ($row = mysql_fetch_assoc($result)) { echo '<option val

oop - Is serializable attribute needed in concrete C# class? -

in c#, consider have generic class , concrete class [serializable] public class genericuser { ... [serializable] public class concreteuser : genericuser { ... is necessary mark concreteuser [serializable] or inheritance take care of it? inherited set false [attributeusage] of serializableattribute , yes, need set on concrete class. see http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx more information.

batch requests answer but can't automate it? -

i'm trying copy file , cmd returns asking if c:\test\2006 indicating file name or folder name @ location (b= file, d= folder)? i know want d = folder can't seem autorun this for able read dutch code returns: geeft c:\test\2006 een bestandsnaam of een mapnaam op het doel aan (b = bestand, d = map)? you can add \ end of path indicate it's folder: copy whatever c:\test\2006\ to answer question, need pipe character standard in: echo d | copy whatever c:\test\2006

How To Make a "Enter" key by C# in ASP.net -

i wrote code in c#: using (streamwriter streamwriter = file.createtext(@"c:\file.html")) { streamwriter.writeline(textbox2.text); } this code opens file.html , copies value of textbox2 when open file.html characters on 1 line, though there multple lines of text in textbox. how newline characters show in file? try streamwriter.writeline(textbox2.text.replace(environment.newline, "<br/>"));

flex3 - In Flex 3 Textarea, how to implement Text Search functionality -

i wish implement 'find...' functionality on text present in mx:textarea control. find word using indexof() function. finding difficult to: highlight correct word continue search using shortcut key ctrl+f (or f3) wrap search functionality please let me know way overcome these issues? the text find can highlighted using textarea.setselection() . reference see this link

asp.net - how to install II7 in vista -

hi im trying setup environment pc , im trying learn asp.net , , dont know how setup in vista , in php easy in wamp, dont know here, please me..thanks any appreciated here step step tutorial on microsoft iis site : http://learn.iis.net/page.aspx/28/installing-iis-7-on-windows-vista-and-windows-7/

intermediate language - .NET IL Property setter -

consider class: public class foo { // fields private string _bar; // properties private string bar { { return this._bar; } set { this._bar = value; } } } now when go , in il code emitted compiler setter of bar property: .method private hidebysig specialname instance void set_bar(string 'value') cil managed { .maxstack 8 l_0000: nop l_0001: ldarg.0 l_0002: ldarg.1 l_0003: stfld string consoleapplication2.program/foo::_bar l_0008: ret } why ldarg.0 ? located in first (index 0) argument? since method/property setter takes 1 argument... the same goes getter: .method private hidebysig specialname instance string get_bar() cil managed { .maxstack 1 .locals init ( [0] string cs$1$0000) l_0000: nop l_0001: ldarg.0 l_0002: ldfld string consoleapplication2.program/foo::_bar l_0007: stloc.0 l_0008: br.s l_000a

php - MYsql query and DB help -

when trying execute query mysql server cpu usage goes 100% , page stalls. setup index on (client_code, date_time, time_stamp, activity_code, employee_name, id_transaction) doesn't seem help. steps can go next fix issue? there 1 index on database if matters any. thanks > $sql = "select m.employee_name, count(m.id_transaction) >from ( select distinct client_code transaction) > md join transaction m on > m.id_transaction = ( select > id_transaction transaction mi > mi.client_code = md.client_code , date_time=curdate() , time_stamp!='' , > activity_code!='000001' > order m.employee_name desc, mi.client_code desc, mi.date_time desc, > mi.id_transaction desc limit 1 ) > group m.employee_name"; i've got feeling it's due > sign next and, expression you're trying make that?

android - ProgressDialog freezes when trying to run a service with an asynctask -

i have code inside asynctask: @override protected void onpreexecute() { waitdialog = new progressdialog(context); waitdialog.settitle(r.string.wait_title); waitdialog.setmessage(context.getstring(r.string.wait_body)); waitdialog.setindeterminate(true); waitdialog.show(); } @override protected boolean doinbackground(void... unused) { intent serviceintent = new intent(context, publisherservice.class); savesettings(false); startservice(serviceintent); return serviceisrunning(); } the dialog shows while service starting (and takes few seconds) progressdialog frozen. if use simple systemclock.sleep() inside doinbackground() call works fine. can tell me why happening , how solve issue? thanks you should not start services threads or asynctasks. service start own thread , perform work there. or it's possible bind service in onpreexecute() , call methods doinbackground. read local service sample here http://d

c# - What is the DLR Layer Responsibility? -

what dlr layer responsibility? from documentation @ http://msdn.microsoft.com/en-us/library/dd233052.aspx . the purpose of dlr enable system of dynamic languages run on .net framework , give them .net interoperability. dlr introduces dynamic objects c# , visual basic in visual studio 2010 support dynamic behavior in these languages , enable interoperation dynamic languages.

asp.net - SQL Query not inputting value of my variable -

i'm having trouble writing query using variables. here's code dim bondnumber string = "69836" dim passwordcheck string = "declare @investor varchar(10), @thepassword varchar(20), @linkedserver2 varchar(25), @sql varchar(1000) " passwordcheck += "select @investor = '" & bondnumber & "', @linkedserver2 = 'binfodev', "passwordcheck += "@sql = 'select * ' + @linkedserver2 + ' bondno = ''@investor'' ' exec(@sql)" it doesn't seem passing variables in query , i'm not sure i'm going wrong any ideas? what problem seeing specifically? more info help. what can tell, you're code translates long line of sql (substituting '69836' bondnumber ) declare @investor varchar(10), @thepassword varchar(20), @linkedserver2 varchar(25), @sql varchar(1000) select @investor = '69836', @linkedserver2 = 'binfodev', @sql = 'select *

jquery - JQueryui - Manage connected sortable lists forcing only one element by list -

i'm using jqueryui connected sortable lists , drop elements when connected list empty, have force user add maximum 1 element. using jquery droppable not allowed. so, how can manage jqueryui connected list restrict number of elements inside? want sortable1 , sortable2 accept 1 element sortable0. <ul id="sortable0" class="connectedsortable"> <li> word1 </li> <li> word2 </li> <li> wordn </li> </ul> <ul id="sortable1" class="connectedsortable"> </ul> <ul id="sortable2" class="connectedsortable"> </ul> $(function() { $( "#sortable0, #sortable1, #sortable2" ).sortable({ connectwith: ".connectedsortable" }); }); thanks in advance. you use solution this $("#sortable0, #sortable1, #sortable2").sortable({ connectwith: "#sortable0, .connectedsortable:not(:has(li))" }); this enables move 1

java - How to use JDO persistence manager? -

i have 2 questions regarding how create / use jdo persistence manager (pm, hereafter). say, in java web application, if have 10 entities, can logically grouped 2 groups (for example, 5 user related entities , 5 business related entities) should need 2 different pms manage these 2 groups or 1 pm enough? regarding initialization, shall use singleton instance of pm (which shared user's using app @ given point of time) or should create pm each , every session? according jdo documentation create 1 persistencemanagerfactory per datastore. if using jdo access databases via sql , have more 1 database, need 1 persistencemanagerfactory per database (since need specify jdbc url, user name , password when create persistencemanagerfactory ). for simple use cases, can create persistencemanager when need , close in finally clause (see the persistence manager documentation ). if use transactions, , code updating entities can spread across multiple methods or objects, r

c++ - max_heapify procedure on heap -

i have these procedure #include <iostream> using namespace std; int parent(int ){ return i/2; } int left(int ){ return 2*i; } int right(int i){ return 2*i+1; } int a[]={ 27,17,3,16,10,1,5,7,12,4,8,9,10}; int n=sizeof(a)/sizeof(int); void max_heapify(int i){ int largest=0; int l=left(i); int r=right(i); if(l<=n && a[l]>a[i]){ largest=l; } else{ largest=i; } if(r< n && a[r]>a[largest]){ largest=r; } if (largest!=i){ int t=a[i]; a[i]=a[largest]; a[largest]=t; } max_heapify(largest); } int main(){ max_heapify(2); (int i=0;i<n;i++){ cout<<a[i]<<" "; } return 0; } when run compiles fine after run stops ubnormaly it's running why? please @ code max-heapify[2](a, i): left ← 2i right ← 2i + 1 largest ← if left ≤ heap-length[a] , a[left] > a[i] then: largest ← left

deploy application on jboss -

my question has not got jbpm it's example. i started jboss on port 8080 , when go http://localhost:8080/jbpm-console/ see live application. however, under server/default/deploy don't see jbpm-console folder! where can find it? it in war file (file or exploded war). if have any, jbpm-console should defined in web-inf/jboss-web.xml file <context-root>jbpm-console</context-root> more info here , more precisely chapter 9.5.: setting context root of web application

c# - db4o SODA compare field values -

class someclass { private datetime fielda; private datetime fieldb; } using soda, proper way select objects fielda greater fieldb? something this? var query = this.objectcontainer.query(); query.constrain(typeof(someclass)); query.descend("fielda").constrain(query.descend("fieldb")).greater(); var list = query.execute(); you mean how express query following (sql) select * sometable fielda > fieldb in soda, right? i afraid not possible (at least not without using evaluation or native query - which, in case, run evaluation anyway). best

unit testing - Where can I find an introduction to using DUnit with Delphi 2007 or newer? -

i'm new using , writing unit tests, i've become convinced can me write better code , save me time. understand dunit integrated delphi 2006 , newer. does know of resources writing unit tests dunit , possibly introduction unit testing in general? i found resource charlie calvert have been reading, i'm moving pictures kinda guy, , i'd see videos related dunit testing (if exist). appreciated. quick introduction on channel e: http://channel-e.embarcadero.com/index.php?option=com_jvideodirect&x=1&v=gunnlqi761klo

mysql - SQL: select all unique values in table A which are not in table B -

i have table a id | name | department ----------------------------- 0 | alice | 1 0 | alice | 2 1 | bob | 1 and table b id | name ------------- 0 | alice i want select unique ids in table not exist in table b. how can this? select distinct id tablea not exists ( select id tableb id = a.id )

.htaccess - How to do an Apache2 rewrite for ip based address -

i have development server has ubuntu server 10.10 ip of 192.168.0.175. when enable rewrite mod apache2 , change site config allow rewrite things messed up. with rewrite turned off , allow rewrites none type in 192.168.0.175/test , site loads, turned on changes address www.192.168.0.175/test , site not load. why happening? www.192.168.0.175 wrong. if type www browser assumes domain name. the ip's should prefixed www

JQuery Accordion Buried in a Table within Dynamic Page -

i'm trying access moveover property of accordion buried under divs , other stuff. here html: <body> <form id="form1" runat="server" > <div id="content" class="content"> <table style="width: 1200px"> <tr> <td style="width: 800px"> <h1>title here</h1><br /> stuff here.. blah blah.. <div id="wrapping" class="wrapping"> <p class="accordionbutton"><strong>water-related services</strong></p> <div class="accordioncontent"> item 1<br /> item 2<br/> item 3<br /> </div> <p class="accordionbutton"><strong>fire , smoke probl

How to convert this XML Definition into a C# Class -

is there 'standard' way convert set of c# classes? <!doctype messages [ <!element messages (msg*)> <!element msg (to+,body,msg_id,billing)> <!attlist msg type (content|logo|ringtone|picture|otapush|binfwd|longsms|2dcode) #required> <!element (#pcdata)> <!attlist provid (1|2|3|5|6|7) #implied > <!attlist type (npm|ems) #implied> <!element body (#pcdata)> <!element msg_id (#pcdata)> <!element billing (#pcdata)> <!element delivery (#pcdata)> <!element expdate (#pcdata)> ]> i have more information appreciate way transform element , attlist c#. if convert dtd xsd schema using this w3c tool , can use xsd.exe or xml sample code generator create classes.

python - Make OptionMenu Widget Scrollable? -

i've got option menu that's 60 items long and, needless say, can't see on screen @ once. there way can make optionmenu widget in tkinter scrollable? short answer no, try combobox mega-widget (quick search throw suitable examples there) 'good enough' alternative (in fact being combined entry field , scrolled list make 'smart' including auto-search / auto-complete - 60 items in drop down lot :)

java - select a radio button in a group -

i’m programming in java , have xml file , form. how can use data of xml file select radio button in group? thank you. best regards. take @ selenium, can generate clicks, enter data fields in form, , screen scrape data page, plus more. 'found' , find totally indispensable. link selenium site

xml - Failed to find provider info for android.server.provider.checkin error -

i keep getting exception in logcat failed find provider info android.server.provider.checkin the android dev reference seems have no info on @ all, have seen vague reference's provider tag , authorities attribute relating gettype method??? i have getbytes() method all. anyway, added 1 manifest so: android:enabled="true"> eclipse complains this, says looking missing required attribute name, required attribute name, android's dev reference not say. have example of how thing supposed setup. ma not sure if on right track here... thanks rick make sure <provider> tag inside of <application> tag. that's been biting me now.

java - Why should anybody put annotations on the getters or setters when using JPA to map the classes? -

subject says all... see no advantage of people declaring annotations on getters and/or setters far. me has disadvantage of spreading annotations on class, can make class more unreadable. putting annotations on fields reduces amount of code post when needing help. tiny advantage though. putting annotations on methods serve no purpose me. putting annotations on methods forces jpa access properties via methods. makes sense when internal state of object differs database schema: @entity public class employee { private string firstname; private string lastname; @column(name = "emp_name") // due legacy database schema public string getname() { return fisrtname + " " + lastname; } public void setname(string name) { ... } ... getters , setters firstname , lastname @transient ... } in jpa 2.0 can specify access type @ fine-grained level @access : @entity @access(accesstype.field) public class employee {

Java extends example -

i have java beginner question: parent.print() prints "hallo" in console, child.print() prints "hallo". thought has print "child". how can solve this? public class parent { private string output = "hallo"; public void print() { system.out.println(output); } } public class child extends parent { private string output = "child"; } currently you've got 2 separate variables, , code in parent knows parent.output . need set value of parent.output "child". example: public class parent { private string output = "hallo"; protected void setoutput(string output) { this.output = output; } public void print() { system.out.println(output ); } } public class child extends parent { public child() { setoutput("child"); } } an alternative approach give parent class constructor took desired output: public class parent { private string outpu

memcached - Is there an in-memory key/value store that can notify an external entity of a change? -

i have read in-memory key/value stores have never utilized one. first come uneducated mind couchdb , memcached (i know couchdb isn't in-memory, used such). i looking 1 of these in-memory stores support basic scripting, such notify external entity (through restful api) of change. preliminary research reveals couchdb supports called change notifications memcached not seem support type of feature, , more general storage-only service (again, ignorance may shine through here). does have experience doing this? words of wisdom potential pitfalls or headaches? there other software didn't list support these features? membase implements memcached tap protocol stream out mutations occur. build lot of stuff on top of (replication use case).

mysql - How to select photoalbums, count photo's, and select one photo per album? -

i'm building custom photoalbum i'm stuck mysql query. idea of query fetch list of albums, count number of pictures in it, , fetch 1 thumbnail per album. the database consist of 2 tables, 1 containing album data , 1 containing pictures (i store them in database). table: photoalbums id | album_name | album_created ------------------------------------- 1 | testalbum | 2010-11-07 19:33:20 2 | more | 2010-11-15 18:48:29 table: pictures id | file | thumbnail | name | album_id ------------------------------------------ 1 | binary | binary | test1 | 1 2 | binary | binary | test2 | 1 3 | binary | binary | test3 | 2 4 | binary | binary | test4 | 2 5 | binary | binary | test5 | 1 my current query looks doesn't work. select alb.id album_id, alb.album_name, alb.album_created, count(p.id) pcount photoalbums alb left join pictures p on p.album_id=alb.id group p.album_id order alb.album_name asc first of all, query fetch of thumbnails within a

How to look a single SQL Server query takes how much cpu time for completation -

how single sql server query takes how cpu time completion when run query via sql server management studio want see how cpu time did query consumed it pretty low need see comparing different query loads and greater if possible run query 1000 times , see total consumed time thank you ok full answer set statistics time on execute query set statistics time off and after have messages window not results window before run query, execute command in same ssms window. set statistics time on note in multi-processor environment, cpu time reported may exceed elapsed time if parallel processing occurs when executing query.

query optimization - MySQL Join is taking too long -

i need optimizing mysql query or table when run query return in .01s 650 records: select mm, name, display, year tbl d active = 1 , tbl2_id = 'val' , lvl_id = 9 order mm; when run query return in on 15s same records: select d.mm, d.name, d.display, d.year, a.year year2 tbl d left join tbl on d.mm = a.mm , a.tbl2_id = 'val2' d.active = 1 , d.tbl2_id = 'val' , d.lvl_id = 9 order d.mm; when run take on 15s: select mm, name, display, year, (select a.year tbl a.mm = mm , a.tbl2_id = 'val2') year2 tbl active = 1 , tbl2_id = 'val' , lvl_id = 9 order mm; the table has multiple records mm. need records tbl2_id = 'val' , if there record mm tbl2_id = 'val2', need value of "year" val2 record. tbl has 13k records in , there no more 10 records given mm don't think think query should taking on 15s. have indexes mm, active, tbl2_id , lvl_id. i've done similar things in mssql no

communication - Python subprocess produced output or not -

this question in relation to: python, subprocess: reading output subprocess if p subprocess started command along lines of import subprocess p = subprocess.popen ("command", stdout=subprocess.pipe) we can read output p produces p.stdout.readline (). blocking read though. how can check if there output ready reading (without blocking)? following on so: non-blocking read on subprocess.pipe in python

What is the best database query tool for PostgreSQL on OSX? -

i'm interested find best desktop database query tool postgresql. options pgadmin, razorsql. i'm interested know best ones. after evaluating bunch of gui-based options osx settled on navicat postgresql because me, has more natural ui pgadmin (at least osx). i find pgadmin has better query analysis tool though i've got installed well.

debugging - Visual Studio 2010: suddently Locals, Immediate Window and Watches don't work -

Image
i have problem week ago, when debugging, suddently "locals" window blank, "immediate window" , watches don't work , return "unable evaluate expression." also standard debugger display stopped giving me info when break execution check out stuff :-( i have played around debugger settings, none of them seems have effect ever on problem. i did install mvc3 rc1 , nupack before problem started, removing them haven't solved anything. removed extensions , addons 1 one find cause, no result.. does have idea? i'm running on win7 x64 on standard core2 based laptop. apparently problem arises when both mvc 3 rc , .net framework async ctp installed on same machine. you need uninstall mvc 3 rc since comes asp.net web pages, nuget , visual studio update have removed along it. you can automate process opening visual studio command prompt administrator privilege , running of following commands in it: wmic product name="micros

Face 3d reconstruction -

i've got webcam rotates @ given angular steps around person's head , acquires picture each step. i'm searching free , opensource library that, starting set of acquired images, makes me able generate 3d surface represents person's head, or @ least defined 3d points cloud. any 3d format accepted, if wpf xaml preferable. i've searched hours on web, found tenths of academical documents , hundreds of broken links... i tried meshlab, aforge.net, emgucv , openvis3d, no 1 contained desired function, nor implementation basic techniques (such example dense features 3d triangularizations) any suggestion ? in advance :) can't give open , shut library solve it, can point in direction of number of algorithms might useful, of have implementations available: visual hull ( code ) shape shading ( code ) structured light might of interest if can control acquisition suitably

c++ - How to make a getter function for a double pointer? -

i needing modify open source project prevent reusing code (more efficient create getgamerulesptr() function keep going engine retrieve it. problem is, stored void **g_pgamerules. ive never grasped concept of pointer pointer, , bit confused. i creating getgamerules() function retrieve pointer, im not sure if getter function should void* ret type , return *g_pgamerules, or how should go this. brushing on pointer usage now, wanted find out proper method learn from. here code, lines 58-89 sdk function retrieve g_pgamerules pointer game engine. other functions adding getter function to. // extension.cpp class sdktools_api : public isdktools { public: virtual const char *getinterfacename() { return sminterface_sdktools_name; } virtual unsigned int getinterfaceversion() { return sminterface_sdktools_version; } virtual iserver *getiserver() { return iserver; } virtual void *getgamerules() { return *g_pgam

Import HTML As String With PHP Vars -

i've got ajax call returning html. html created , returned in function so: function return_html(){ $title = 'my form'; $returnobject = array(); $returnobject['html'] = ' <form> <h1>' . $title . '</h1> <input type="text" name="title"/> </form> '; return json_encode($returnobject); } what i'd write .php file of html , vars in this... <form> <h1><?php echo $title ?></h1> <input type="text" name="title"/> </form> and in function import file string vars set sorta this: function return_html(){ $title = 'my form'; $returnobject = array(); $returnobject['html'] = my_file_as_string_but_with_vars_replaced('formfile.php'); return json_encode($returnobject); } thoughts? perhaps functio

opengl - Up-to-date GLSL tutorial? -

i've got reasonably shader doing hsl transformations, it's written in old-school glsl, , i've seen apparently lot of stuff deprecated in more recent versions of opengl. i've found kind of difficult locate information on how update shader code. opengl tutorials seem old-school gl techniques. does know find tutorial on how write modern glsl? bonus points if explains how update older shader scripts. i feel answer needs newer resource in case stumbles upon it. https://web.archive.org/web/20150215073105/http://arcsynthesis.org/gltut/ not glsl introduction modern opengl beginning. i think got #opengl on freenode.

php - Trouble adding http://mainserver/ to all (href|action|src)=, take me into a trouble! -

i have urls... $output = "href=\"/one/two/three\" href=\"one/two/three\" src=\"windows.jpg\" action=\"http://www.google.com/docs\""; when apply regular expression: $base_url_page = "http://mainserver/"; $output = preg_replace( "/(href|src|action)(\s*)=(\s*)(\"|\')(\/+|\/*)(.*)(\"|\')/ismu", "$1=\"" . $base_url_page . "$6\"", $output ); i this: $output = "href=\"http://mainserver/one/two/three\" href=\"http://mainserver/one/two/three\" src=\"http://mainserver/windows.jpg\" action=\"http://mainserver/http://www.google.com/docs\""; how can modify regular expression prevent this: http://mainserver/http://www.google.com/ ??????? try $output = preg_replace( "/(href|src|action)\s*=\s*["'](?!http)\/*([^"']*)["']/ismu", "$1=\"" . $base_url_page . &quo

iphone - Audio will play in 3.2 sim but not in 4.x -

this streaming audio app play in 3.2 simulator, not in 4.x sim or 4.1 iphone. console logs follows: 4.0 sim gdb configured "x86_64-apple-darwin".attaching process 13237. [switching process 13237] 2010-11-15 19:54:49.606 issues[13237:1c07] addrunningclient starting device on non-zero client count 2010-11-15 19:55:16.220 issues[13237:6307] aqmeio_base::dostartio: timeout 2010-11-15 19:55:16.498 issues[13237:6307] aqmedevice::startio: error -66681 2010-11-15 19:55:16.499 issues[13237:6307] ca_uisoundclientbase::startplaying: addrunningclient failed (status = -66681). 2010-11-15 19:55:46.499 issues[13237:1c07] aqmeio_base::dostartio: timeout 2010-11-15 19:55:46.777 issues[13237:1c07] aqmedevice::startio: error -66681 2010-11-15 19:55:46.778 issues[13237:1c07] audio queue start failed. err: ˇ˛˚á -66681 [switching process 13237] 4.1 device gdb configured "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001 target remote-mobile /tmp/.xcodegdbremo

Is there a way to connect MySQL to a SQL DB using PHP and not using mssql_pconnect()? -

i want connect mysql server (a gs server mediatemple) mysql server using php, cannot use mssql_pconnect() function because don't support gs servers i'm looking alternate route, don't know if it's possible. what want generate connection on mysql server using php allow me retrieve information view on different server that's running sql. they don't support mssql_pconnect() because connecting mssql , not mysql, try using mysql_connect() or mysql_pconnect(); you should able establish 2 different database connections 2 mysql servers simultaneously, long host doesn't have firewall rule blocks connection or other safeguard selinux.

Want to show Directory Tree of server (PHP) at client side using FLEX? -

using recursivedirectoryiterator of php able create directory tree , can flatten using recursiveiteratoriterator class , want create directory tree structure tree component of flex understands . following array structure in php flex understands. array('label'=>'rootdirectory','children'=>array(array('label'=>'subfolder1','children'=>array(array('label'=>'file.jpg'))),array('label'=>'emtptyfolder','children'=>array()))); please show me way create whole directory structure @ server side above array format. in advance !! you may adjust code needs. not copy & paste solution needed different usecase, should @ least halfway implementing own solution it. key lies in adjusting methods recursiveiteratoriterator call when traversing directory tree. <?php /** * prints directory structure nested array * * iterator can used wrap recursivedirectoryiterator output

Entity Framework 4 / Linq: How to OrderBy() a hierarchical Entity? -

i have viewmodel carved several entity relations: products[].prices[].others[].myfield how order products[] nested myfield? when clause, it's this: products.where( p => p.prices.any( q => q.others.any( r => r.myfield == 4))); so if wanted products.orderby() , order myfield, expression like? products.orderby( p => p.prices.selectmany( ?? as have several prices below product need select 1 sort on, like products.orderby( p => p.prices.first().others.first().myfield ) or if want order highest price products.orderby( p => p.prices.orderbydescending(price => price.value).first().others.first().myfield )

c# - understand the following lambda -

i have method like void test(func<bool> f) { f.invoke(); } i pass in test( ()=>getitem("123") ) f.invoke() called getitem("123") . i want know how f know getitem has parameter? what passing test parameter-less delegate calls getitem method. test method not know parameters getitem . knows delegate calling. test( ()=>getitem("123") ) is equal to test(delegate { return getitem("abc") ; } ); which calling test(mymethod) ... bool mymethod() { return getitem("123"); }

php - How to understand the 3 lines of c code? -

if (zend_parse_parameters(zend_num_args() tsrmls_cc, "|l", &flag) == failure) { return; } especially what's zend_num_args() tsrmls_cc doing? it looks tsrmls_cc macro might expand nothing or might expand argument comma thrown in there: http://blog.golemon.com/2006/06/what-heck-is-tsrmlscc-anyway.html

msmq - Exception occured while trying to use MsmqSubscription storage -

i newbie in nservice bus , trying create bus using msmqsubscribtion storage , getting following error. exception when starting endpoint, error has been logged. reason: error creating object name 'nservicebus.unicast.subscriptions.msmq.msmqsubscriptionstorage' : error setting property values: propertyaccessexceptionsexception (1 errors); nested propertyaccessexceptions are: [spring.core.typemismatchexception: cannot convert property value of type [system.string] required type [system.string] property 'queue'., inner exception: system.argumentexception: there problem subscription storage queue . see enclosed exception details. ---> system.messaging.messagequeueexception: format name invalid. @ system.messaging.messagequeue.mqcacheableinfo.get_transactional() @ system.messaging.messagequeue.get_transactional() @ nservicebus.unicast.subscriptions.msmq.msmqsubscriptionstorage.set_queue(string v

datetime - PHP function to check time between the given range? -

i using php's date functions in project , want check weather given date-time lies between given range of date-time.i.e example if current date-time 2010-11-16 12:25:00 pm , want check if time between 2010-11-16 09:00:00 06:00:00 pm. in above case true , if time not in between range should return false. there inbuild php function check or have write new function?? simply use strtotime convert 2 times unix timestamps: a sample function like: function dateisbetween($from, $to, $date = 'now') { $date = is_int($date) ? $date : strtotime($date); // convert non timestamps $from = is_int($from) ? $from : strtotime($from); // .. $to = is_int($to) ? $to : strtotime($to); // .. return ($date > $from) && ($date < $to); // parens clarity }

AOP learning resources -

i'm new aop , wondering if there reasorce out there me understand can use aop in projects. i work in c# i'm looking tutorials practical aop , not specific tool (i.e. postsharp or other) - i'm looking common practices/patterns (not tools) , usage examples in language - not c#/.net so far aop tied frameworks, should read documentation of aop framework rather general approach. but can specify 3 common types of aop: pre code injection (in code file) [code generators work pior pre compilation] runtime code injection (inject, swamp pointers, in memory) [spring?, own framework] post code injection [postsharp] most resources can found here: " http://csharp-source.net/open-source/aspect-oriented-frameworks " the common use plugin architecture, logging, caching domain specific aop setting specific properties on object in domain , state aop dev doesn't care it, other presistance layers can use aop generate sql command objects etc. the thing i

c# - How does SQL Server handle Network Failover in the middle of an insert statement -

i writing application executes sql queries on database in real time. if setup mirroring of sql server , setup failoverpartner in connection string , if primary database goes down, secondary kick in automatically , therefore not have re-open connection or clear down? also how handle situations insert statement running , database goes down? secodary pick or lost forever? safer transactional based insert statements? every form of high availability (mirroring, clustering) have transaction boundary: every transaction in-flight @ moment of failover rolled back. not limitation, feature . impossible write correct applications if not true. when failover occurs, every connection using database cut. clients have re-establish new connections new principal, read again current state database , start applying new operations, on current state. correctly written applications (ie. transactional ) not have issue this. poorly coded apps can lose data.

internationalization - Is there any way to detect an RTL language in Java? -

i need able detect whether current language user viewing rtl (right left) language arabic. at moment i'm detecting based on language code system property user.language, there must better way. componentorientation.getorientation(new locale(system.getproperty("user.language"))).islefttoright(); resource

jquery - How do you create a resizable and resize it in one go? (programmatically starting the resize) -

i trying create resizable div @ mouse position , resize desired size. failed attempt far: http://jsfiddle.net/yknfr/1/ any ideas on how achieve behaviour? add css above #block1 selector: #blocks > div { width: 200px; height: 200px; } no need resizable script involved until want user resize it. fyi, css clearer :not selector this: #blocks > div:not(#block1) { width: 200px; height: 200px; } but ie doesn't support :not , , i'm not sure how degrades. that's why need put first example above #block1 selector.

windows installer - Sometimes MSI exited with code "1073807364" -

i having application, deploy msi on machine msi exited code "1073807364". after msi installation machine reboot required expected exit code "1641". i have @ different links have not able got concrete answer. you should run installer logging turned on , read through errors.

drupal - t() not printing a translated string -

i currenty try make module translateable using t() hard-codes-strings. since call t() advised in documentation don't have clue might doing wrong. call in block_theme of module. hook_theme(); don't if important… /* # themes {{{*/ function catchy_overview_theme() { return array( 'catchy_overview_block' => array( 'template' => 'catchy_overview_block', 'arguments' => array('nodes' => null, 'terms' => null, 'imagecache_preset' => imagecache_preset(variable_get("catchy_overview_imagecache_preset", null))) ) ); }/*}}}*/ catchy_overview_block.tpl.php <?php /* * catchy overview block template * * defined vars: * $nodes collected nodes grouped tid * $terms taxonomy-array-map tid => name * $imagecache_preset configured imagecache preset. */ ?> <ul class="catchy-overview"> <?php foreach ($nodes $key => $value) { ?> <li c

key - C++ and GetAsyncKeyState() function -

as gives upper case letters, idea how lower case?? if user simultaneously pessed shift+k or capslock on,etc, want lower cases.. possible in way or another?? thanks, as rightly point out, represents key , not upper or lower-case. therefore, perhaps call ::getasynckeystate(vk_shift) can determine if shift-key down , able modify result of subsequent call appropriately.

loops - cshell: How do I produce a list of decimal numbers? -

i want produce list of numbers 1 5 incrementing 0.25 @ each step, this: 1.0, 1.25, 1.5, ..., 4.5, 4.75, 5.0 is possible in csh? if so, how do it? thanks help. you can use seq command as: seq 1 0.25 5 ideone link to display numbers in 1 line can use -s (separator) option of seq as: seq -s' ' 1 0.25 5 ideone link

problem in retrieving the rows in case of composite key through hibernate -

i have faced issue many times couldn't find solution where. my question how can retrieve tuple or row in database through hibernate call, for example in relation student_course(sid,sname,cid,cname, duration) here sid , cid considered composite key. please let me know solution. thanks in adv, a.raghavendra configure mapping file below, <hibernate-mapping> <class name="com.example.studentcourse" table="student_course"> <composite-id> <key-many-to-one name="student" class="com.example.student" column="student_id"/> <key-many-to-one name="course" class="com.example.course" column="course_id"/> </composite-id> ///other mappings elements in java, if retrive list of student course can details.

c# - collection copy behavior question -

in c#, after add object collection, if copy(deep copy) created? no, if class, objects are, reference same object stored in collection. if value type, int, double , structs copy made (not deep copy, if struct has reference class object in turn not copied). edit: deep copy objects first need create deep copy function. have @ create deep copy in c# or how make deep copy in c# ? can run deep copy method before adding items collection. note not need true deep copy. better rethink dataflow in application.

asp.net - Can anybody provide me exact answer of this how to insert checkbox checked value to textbox in ascending order? -

can provide me exact answer of how insert checkbox checked value textbox in ascending order ? means if check checkbox1 , checkbox3 output in textbox ia 1,2 and if check checkbox3 checkbox1 output in textbox 1,2 i have asked question ... haven't found exact working answer ... remember ,,, have use 500+ checkboxes .... in asp.net(vb) a little more information might useful. purely ui? in case javascript via jquery need. checkboxes autopostback? in case server-side solution might answer, although client-side might still appropriate in case.

javascript - jquery doesn't work after upload -

i designed website on computer xamp, uploaded host javascript , jquery stopped working. the error looks this $("#link1").fonteffect not function all required .js files imported. , script looks this: <script src="./script/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="./script/menu.js" type="text/javascript"> </script> <script src="./script/shadow.js" type="text/javascript" ></script> <script type="text/javascript" src="./script/jquery-fonteffect-1.0.0.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#wrapper").boxshadow(20,20,100,'#30302f'); $("#link1").fonteffect({outline:true, shadow:true ,shadowcolor:'#414345' ,outlinecolor1:'#a06bb5', outlineweight:2, shadowblur:2})

c++ - Delete a pointer to pointer (as array of arrays) -

i have in code: double** desc = new double* [size_out]; (int = 0; < size_out; i++) desc[i] = new double [size_in]; how delete desc ? should do: delete [] desc; or for (int i=0; i<size_out; i++) delete [] desc[i]; delete [] desc; or for (int i=0; i<size_out; i++) delete [] desc[i]; delete desc; ? simple rules follow: for each allocation, there has deallocation (ex1 therefore wrong) what allocated using new should freed using delete , using new[] should deallocated using delete[] , using malloc should deallocated using free (ex3 therefore wrong) conclusion, ex2 ok.

php - finding the path to a file residing in the wamp www directory -

i have file in project folder wampserver www directory , want create path file in php script. not sure right in accomplishing have seen use of "./", "../" , full root directory of "c:/...." foresee situation use of c: restrict usage of path local machine , therefore want use wamp's root www. to document root read $_server -superglobal. echo $_server['document_root'];

xslt - xsl:call-template: return a number rather than text to be assigned to a variable -

i'm having (minor) problem here. i'm calling named template , assigning outcome variable. so good, need type of processed template's return value integer rather text. i wonder if there's way achieve without having go temporary variable? here's sample code: <xsl:variable name="tmp"> <xsl:call-template name="mytemplate"> <xsl:with-param name="x" select="123"/> </xsl:call-template> </xsl:variable> <xsl:variable name="myvar" select="number($tmp)"/> <xsl:template name="mytemplate"> <xsl:param name="x"/> <xsl:value-of select="$x"/> </xsl:template> don't mind code oversimplification of template does. notice i've tried return <xsl:value-of select="number($x)"/> no avail. any heavily appreciated. tia first, $tmp data type result tree fragment. so, beside

c++ - Use std::vector to construct a object and use it -

i need avoid additional cost of copying , destructing object contained std::vector caused this answer . right i'm using std::vector of pointers, can't call std::vector::clear() without deleting each object before nor can use std::auto_ptr std containers. i wanted this: vector<myclass> myvec; myvec.push_back(); myclass &item = myvec.back(); this create new object default constructor , reference , work it. any ideas on direction? resolved : used @msalters answer @moo-juices suggestion use c++0x rvalue references take vantage of std::move semantics. based on this article . almost there: vector<myclass> myvec; myvec.push_back(myclass()); // decent compiler inline this, eliminating temporaries. myclass &item = myvec.back();

javascript - Issues with web application -

the previous programmer left website in pretty unusable state, , having difficulty modifying anything. new web design don't know whether skills mismatch kind of job or normal in real industry have websites these the home page includes 3 frames each of these frames have own javascript functions ( between <head> , , call other common javascript functions (using <script src=..> excessive usage of document.all - in fact elements referred or accessed document.all only. excessive usage of xslt , web services - though know using web services considered design choice - there other way can consume these services other using xslt. example, menu created using data returned web method. every <div> , <td> , every other element has id, , these id's manipulated javascript functions, , appropriate web service , xslt files loaded based on these.. from security perspective, used t-sql's xml auto of data returned web service - choice security standpoint

How to remove scrollbars from Facebook iFrame application -

i have created facebook iframe application , set dimensions auto resize in facebook application settings page still horizontal scrollbar shown @ bottom in ie , google chrome. works fine in firefox. solution ? it's explained how here: http://clockworkcoder.blogspot.com/2011/02/how-to-removing-facebook-application-i.html should use window.fbasyncinit = function() { fb.canvas.setautogrow(); }; plus make sure html , body tags set overflow:hidden don't briefly shown scroll bars annoying <html xmlns="http://www.w3.org/1999/xhtml" style="overflow: hidden"> <head> <!-- header stuff --> </head> <body style="overflow: hidden">

javascript - window.print() refreshes page in iframe when I click cancel -

i have iframe inside website following jquery code in it: $(document).ready(function() { $('#print_button').click(function() { window.print(); }); }); the problem: when click print button, print dialog opens correctly. printing works correctly well. when click cancel button in print dialog closes refreshes content in iframe. how can avoid behaviour? as stated in above comments, form being submitted when button #print_button clicked. force page refresh. to prevent this, add return value of false onclick event. cancel form submission. window.print(); return false;

javascript - Updating a data object with a new value -

i'm trying update data object new value. have if($("#articlesholder").data(event.data.id) != null) { $("#articlesholder").data(event.data.id, {name:event.data.name, nr:newnr, price:event.data.price, articlenr:event.data.articlenr}); } now want update existing data object on $("#articlesholder") want update 1 value not values. how i, example, update nr nr +1 ? i think it's possible change data value somehting like: $("#articlesholder").data(event.data.id).nr = '52';

jTemplates vs jQuery Templates. Which is one better? Is there a better? -

i've seen microsoft has created official jquery template plugin jquery. jtemplates i've read pretty popular. didn't know if should not bother jtemplates , go straight jquery template or give jtemplates go. any suggestions? note: it's first time using client-side templating framework. i've been happily using jtemplates couple years , absolutely recommend jquery templates going forward. here few of main reasons: other using ajax requests load template definitions ( which easy overcome ), jquery templates capable jtemplates. in fact, think jquery templates' {{tmpl}} tag template composition more intuitive , straightforward jtemplates' #include. going forward, massive community support , development around "official" jquery solution templating hard beat. since jquery templates rolled jquery core in 1.5, doesn't make sense include template engine in addition 1 you're getting free jquery. told authoritatively happen, appa

Simple IDE for Pascal for Linux -

i looking ide pascal. runs under linux, simple , easy run. goal setup kid learn, wouldn't require derive 10 classes make text visible on screen. i remember dos-based turbopascal being easy use. tried lazarus, interface complex. i don't need ide works multiple languages, , won't change pascal language--there's lots of textbooks in native language pascal, , little other. thanks! what using freepascal included editor or basic text editor, nano or gedit? use 1 of old "borland-ish" ides peng or rhide .

compiler theory - Is there any language where names can include space characters? -

is there programming language allows names include white spaces ? (by names, intend variables, methods, field, etc.) scala allow whitespace characters in identifier names (but possible, need surround identifiers pair of backticks). example (executed @ scala repl): welcome scala version 2.8.0.final (java hotspot(tm) client vm, java 1.6.0_22). type in expressions have them evaluated. type :help more information. scala> val `lol! works! :-d` = 4 lol! works! :-d: int = 4 scala> val `omg!!!` = 4 omg!!!: int = 4 scala> `omg!!!` + `lol! works! :-d` res0: int = 8

c - how do i suspend file writing when the file gets to a certain size and and then create a new file -

i have significant amount of data being generated in c program. want write data out 1gb files. how got doing this? at moment, go through while loop (with condition go on until 5 gbs data created). creates struct , writes file: fwrite(storedval, sizeof(keyencode),1,fp); //storedval being struct (which contains data) i each file called codes1, codes2 , increment on until while loop finished. sure include if statement based on size of current file writing to. when reaches 1gb, begins on new file. edit // actually should sort of while statement , keeps writting size, untill file reaches 1gb , starts on new one my file @ moment opened prior while loop: fp = fopen("keys.dat", "wb"); while(condition true) { //create new struct data , fwrite(storedval, sizeof(keyencode),1,fp); } something along lines of following - note there parts left out fill in. int write_count = 0; int file_idx = 1; file *fp; char filename[20]; sprintf( filename,

Zooming Image in WPF -

i try make zoom on image, create style, here : <style x:key="zoomimage" targettype="{x:type image}"> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="layouttransform"> <setter.value> <scaletransform scalex="1.5" scaley="1.5"/> </setter.value> </setter> </trigger> </style.triggers> </style> and apply style in window: <grid name="rootgrid" margin="4,4,4,4"> <grid.columndefinitions> <columndefinition width="130"></columndefinition> <columndefinition width="*"></columndefinition> </grid.columndefinitions> <grid name="infogrid" grid.column="0" margin="4,4,4,4"> &l