Posts

Showing posts from March, 2012

actionscript 3 - textarea shows 2 lines when htmlText is set -

i using textarea. set htmltext follows: textarea.htmltext = '<p align="center"><font face="_sans" size="14" color="#ffff00" letterspacing="0" kerning="0"></font></p>'; the problem there 2 lines in text area when runs. when remove usual 1 line m not able set color , all. i want use textarea, set different colors on , don't want 2 lines in that. also condensewhite option... http://www.adobe.com/livedocs/flash/9.0/actionscriptlangrefv3/flash/text/textfield.html#condensewhite

php - Removing posted by and date from posts on wordpress -

how remove date added/admin/no comments section of each 1 of posts in wordpress blog here http://www.kvylfm.com edit template file index.php , snippet: <div class="post-info clear-block with-thumbs"> when found it, this: <div class="post-info clear-block with-thumbs"> <p class="author alignleft">posted .........</p> <p class="comments alignright">.........</p> </div> just remove all. if don't know template is, on admin panel, @ appearance » editor . should see list of files on right side of page. find 'main index template' , edit it, @ snippet above remove it.

Why is Fluent NHibernate ignoring my convention? -

i have convention usertypeconvention<myusertype> myusertype : iusertype myusertype handles enum type myenum . have configured fluent nhibernate thusly sessionfactory = fluently .configure() .database(mssqlconfiguration.mssql2005.connectionstring( c => c.is(connectionstring)) ) .mappings( m => m .fluentmappings .addfromassemblyof<a>() .conventions .addfromassemblyof<a>() ) .buildsessionfactory(); where a type in same assembly usertypeconvention<myusertype> , myusertype . however, fluent nhibernate not applying myusertype properties of type myenum on domain objects. instead, applying fluentnhibernate.mapping.genericenummapper<myenumtype> these properties. what going on? for ...

Is there a way to have Apache log slow requests? -

if page takes on couple of seconds process, i'd apache log url somewhere. possible? have lot of sites, looking automatic way opposed proprietary code each site. take @ http://httpd.apache.org/docs/2.2/mod/mod_log_config.html . can setup custom log includes time took serve request. for example: logformat "%h %l %u %t \"%r\" %>s %b %d" common-time would add time in microseconds took serve request last field of logfile. you add line httpd.conf, in each virtualhost want use it, add line: customlog logs/access_log_time common-time you create new logformat contains want, maybe this: logformat "\"%r\" %d" measure-time in virtualhost, can have multiple logs, have: customlog logs/access_log common customlog logs/access_log_time measure-time all said, there's huge caveat . measure time takes server serve page. will not include time takes execute javascript in browser. if need measure javascript execution time, y...

osx - Logging Window Bounds (dimensions) with Appleccript -

it's been ages since i've dealt applescript, advanced apologies screwing terminology here. using following snippet, can resize window tell application "bbedit" activate set bounds of first window {100, 0, 700, 700} end tell i'm interested in using similar statement read , log bounds of first window. tried tell application "bbedit" activate log (the bounds of first window) set wsize bounds of first window log wsize end tell but event log listed (*bounds of window 1*) each time. expecting more {100, 0, 700, 700} my eventual goal create variable contains window bounds, , programmatically manipulate values. step 1 learning how log values. so, how can log bounds of window application in apple's script editor. use get ... tell application "bbedit" log (get bounds of window 1) end tell --> log: (*332, 44, 972, 896*)

database - Dependency of procedure in Oracle: -

hi new database. trying figure out way find procedure dependent on procedure. below query giving me dependecy of proc1. ie procedure called proc1 select referenced_name user_dependencies name = 'proc1' ; below things want know: 1) query work same function. ? 2) query recursive ie proc1 calls-> proc2 calls ->proc3 calls -> proc4 ie: when call query proc1 whill give dependency or 1 level dependency(ie proc2). 3) if procedure inside package find dependency should query ? yes no, shows level of dependency user_dependencies shows dependency @ package level, not individual procedures , functions within package. pl/scope (introduced in 11g) allows find usages @ procedure/function level within package, works if it's enabled when code compiled.

unicode - How to insert Indian Rupees Symbol in Database (Oracle 10g, MySql 5.0 and Sql Server 2008)? -

how insert indian rupees symbol in database (oracle 10g, mysql 5.0 , sql server 2008)? actually had 1 table "currency" , in 2 field "currencyname" , "currencysymbol", how insert new rupees symbol in databse. there's nothing special ₹ (u+20b9 new rupee symbol), except that, being new, there 0 font support it. if you've got database connection supports unicode, can store other character: insert currency (name, symbol) values ('inr', '₹'); (you want use nvarchar storage , n'₹' in sql server.) if haven't got unicode-safe connection (for example you're using crap tool windows console) have work around using eg. values ('inr', char(226, 130, 185)) for utf-8-collated column in mysql, or nchar(8377) unicode column in sql server.

java - Change Table Name of an Entity on runtime? -

there table being generated on monthly basis. table structure of monthly tables same. since lot of work map same entity different table name, is possible change table name of entity follows on runtime since have same table structure after all? @entity @table(name="foo_jan2010") // other ways generate dynamically? public class foojan2010table { // if can dynamically set table name can named footable ... } if not, approach can suggest? is possible change table name of entity follows on runtime since have same table structure after all? this not possible, @ least not standard jpa (which doesn't mean did non standard jpa) mentioned in questions such as: in @table(name = “tablename”) - make “tablename” variable in jpa jpa: how specify table name corresponding class @ runtime? hibernate or ibatis or else? to summarize, jpa doesn't offer way "alter" given entity of initialized persistence unit (and related ...

c++ - return value of NEW -

it possible in cases new returns value, example null, or throw exception? http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.6 take heart. in c++, if runtime system cannot allocate sizeof(fred) bytes of memory during p = new fred(), std::bad_alloc exception thrown. unlike malloc(), new never returns null! [unless compiler "is ancient", in case page has solution you, too]. note if disable exceptions in compiler options, should check compiler docs can expect.

testing - best way to measure (and refine) performance with PHP? -

a site working starting little sluggish, , refine it. think problem php, can't sure. how can see how long functions taking perform? if want test execution time : <?php $starttime = microtime(true); // content test $endtime = microtime(true); $elapsed = $endtime - $starttime; echo "execution time : $elapsed seconds"; ?>

xml - SOAP PHP : Generating a complex array to pass to web service -

2 distinct problems. i'm using php soap class pass xml webservice. can generate simple arrays fine, , these work webservice. 1.when try generate complex (arrays within arrays) query i'm getting errors. 2.also don't understand how insert parameter(???) xml tag. below copy of sample xml query webservice documentation <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <insertinvoice xmlns="kashflow"> <username>string</username> <password>string</password> <inv> <invoicedbid>int</invoicedbid> <invoicenumber>int</invoicenumber> <invoicedate>datetime</invoicedate> <duedate>datetime</dueda...

jquery lavalamp and autoscroll easing problem (conflict) -

i have got problem , hoping guys can help. http://ontwikkelomgeving.wijzijnblits.nl/primawonen/ here can find website creating. as can see autoscroll works (called het laatste aanbod). uses easing.min.js plugin. @ navigation use lavalamp, not work right now. the problem lies in easing plugin. if use older version of plugin, lavalamp works. great think, autoscroll script not work. how can make both work?! i stuck on one, , hope guys can me. thnx in advance i having same problem , figured out way make work, add following lines above else in lavalamp.js jquery.extend( jquery.easing, { bouncein: function(x, t, b, c, d) { return c - jquery.easing["bounceout"](x, d - t, 0, c, d) + b; }, backout: function(x, t, b, c, d) { var s = 1.70158; return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; } }); and remove easing plugin. worked me.

c - Reason for the Output -

#include<stdio.h> int main(void) { int a=5; printf("%d"+1,a); } output: d. didn't how output coming: d ? you passed first argument of printf "%d"+1 ; "%d" seen const char * points memory location %d stored. pointer, if increment one, result point following element, which, in case, d . a not used, should not problem since in general ( i don't know if it's standard-mandated edit: yes is, see bottom) stack cleanup responsibility variadic functions caller (at least, cdecl way , may or may not ub, don't know *). you can see easier way: #include<stdio.h> int main(void) { int a=5; const char * str="%d"; printf(str + 1, a); }   str ---------+ | v +----+----+----+ | % | d | \0 | +----+----+----+ str + 1 ----------+ | v +----+----+----+ | % | d | \0 | +----+...

split string with more than one Char in C# -

i want split string = "asaf_er_army" "er" seperator. split function of string doesn't allow split string more 1 char. how can split string 'more 1 char' seperator? it does. read here . string source = "[stop]one[stop][stop]two[stop][stop][stop]three[stop][stop]"; string[] stringseparators = new string[] {"[stop]"}; // split string delimited string , return elements. string[] result = source.split(stringseparators, stringsplitoptions.none); edit: alternately, can have more complicated choices (regex). here, http://dotnetperls.com/string-split .

git apply a patch as much as possible when failing -

i moving 1 repository , need port of changes. directory structure same files not identical. i using 'git format-patch' , 'git am' or 'git apply' port changes. when works, life good, when fails because of minor change or files missing, nothing gets applied. i can filter files out using --exclude, applies as can , tell me there conflicts / failure. i open other option applying patches or things that. the --reject option you're looking for. that, you'll classic .rej files failing chunks, while chunks applied.

architecture - Getting started with smart pointers in C++ -

i have c++ application makes extensively use of pointers maintain quite complex data structures. application performs mathematical simulations on huge data sets (which take several gb of memory), , compiled using microsoft's visual studio 2010. i reworking important part of application. reduce errors (dangling pointers, memory leaks, ...) want start using smart pointers. sacrificing memory or performance acceptible long limited. in practice of classes maintained in big pools (one pool per class) , although classes can refer each other, consider pool owner of instances of class. however, if pool decides delete instance, don't want of other classes still refers deleted instance have dangling pointer. in part keep collection of pointers instances delivered other modules in application. in practice other modules maintain ownership of passed instance, in cases, modules don't want take care of ownership , want pass instance collection, telling "it's yours ...

sql - ASP MVC Delete only the relation between 2 tables (many-to-many relation) -

using asp mvc active record. ive got 2 tables records related , aren't. relation defined user. 1 table has projects, other has devices. projects can created , deleted, devices cannot. when user deletes project, relations between project , devices should removed, devices should remain. how do this? my delete action looks this: public actionresult delete(int id, formcollection collection) { if (!project.exists(id)) return redirecttoaction("index/1", "error"); try { project project = project.find(id); if (project.user.id != sessionvariables.authenticateduser.id) return redirecttoaction("index/1", "error"); project.deleteandflush(); return redirecttoaction("index", "project"); } catch(exception e) { return redirecttoaction("index", "error"); } } so if understand correctly, when project deleted projects t...

wpf - Best way to do a boolean-or-to-visibility -

i have control want visible if atleast 1 of series of properties return true. implement own booleanortovisibilitymulticonverter, feels there must better (and obvious) way this. please enlighten me! the mvvm way of doing return single boolean model contains logic works out whether control should visible or not. normally if have kind of logic, it's because there's domain concept i'm trying express - instance: it's in country it's ready process it still needs work it complete outfit all authors attributed etc. by keeping logic leads domain concept out of gui, make easier test , maintain. otherwise you'll end replicating same logic everywhere use domain concept, , it's not easy in xaml.

iphone - Adding items to string not showing characters -

(nsstring *item in items) { nsstring *ref = [item stringbymatching:myregex1 capture:2]; nsstring *value = [item stringbymatching:myregex1 capture:3]; nslog(@"%@ : %@", ref, value); allorderitems = [allorderitems stringbyappendingformat:(@"%@: %@ \r\n", ref, value)]; } the allorderitems not showing : or new lines(\r\n) ref & value strings ? please thanks remove brackets around format: allorderitems = [allorderitems stringbyappendingformat:@"%@: %@ \r\n", ref, value];

html - Simple CSS z-index example not working -

i'm trying make simple html 2 images 1 above other on z-index: <html> <head> <title>test</title> <style type="text/css"> { position: absolute; left: 0px; top:0px; z-index:0; } front { position: absolute; left: 0px; top:0px; z-index:1; } </style> </head> <body> <img id="front" src="loading.gif"> <img id="back" src="plasma.jpg"> </body> <html> but why z-index not working? you forgot add # before ids in css. #back { ... } #front { ... }

html5 - HTML 5 File Attachment store in a WebSQL Database -

i trying build web page (accessed android phone) user can upload photo phone. then want store image websql database on phone , send server via xmlhttp.send. can point me in right direction? do somehow need save image canvas tag , use urltodata function? thanks i'm not sure if can reference local image in android browser. if can, canvas & todataurl work.

php - How to create a share folder for multiple domains on Dreamhost -

i have virtual private server dreamhost. i'm trying create shared folder of domains can access. in folder i'd put php classes, , static files javascripts. i've created directory on same level domain folders. i'd call file via this... /home/username/shared/file.php . isn't working however, , i'm hoping magic (like .htaccess maybe) make work. edit: oops, ok, able include php files using method above. how can include static files javascript, css, images, etc same directory? this works: <?php include('/home/username/shared/file.php'); ?> this doesn't work: <link rel="stylesheet" type="text/css" href="/home/username/shared/reset.css" media="screen" /> alternatively, realize place static files inside of domain, , point them, i'd know how make other configuration work. you should happy <link rel="stylesheet" type="text/css" href="/home/usernam...

language agnostic - Is there any way to display a function call graph? -

while browsing through source code in ide i'll wish see call stack/s or function call graph particular point in code (while program isn't running) me understand sequence of events better. an example of functionality i'd see is: click function called 'sendnotificationemail' , 'stack' of functions displayed (owner right): sendnotificationemail->emergencynotificator->checkifserversonfire->updatethread->main my question is: can ides/plugins/or otherwise display such information, , if not - why? this question isn't ide or language specific. this tend ide / language-specific. intellij , eclipse both have call hierarchies available java methods, lets @ callers , callees given method. visual studio offers similar facilities ms languages. for less mainstream languages, might need swallow rich programmer food if available tools aren't it.

Simple class using php -

hello i'm new php , need understand basics of php class. i want have example of class uses private public protected , static. , how work.. thanks in advance. oh forgot how extends also. i'm talking parent , child or what.. again. http://php.net/manual/en/language.oop5.php http://php.net/manual/en/language.oop5.basic.php http://www.w3schools.com/php/php_exception.asp google has ton of examples

Asp.NET AJAX control update field on form -

i have form several text fields, couple of drop down lists, , custom asp.net control. the requirement have when values of fields ( in main form, inside control ) user alerted settings not take place unless restart processing , have option reset it. if exercise option pressing on restart button, execute additional restart() method call on server side on top of else. in order create alert system need know when these required fields have changed. fields in main form/page store original values in hidden fields when page gets created (possible because page static). when submit button pressed check current values against original values stored. if of them differ alert user. for fields in custom control, created boolean property indicates whether changes in fields of interest took place. control highly dynamic contains variable number of lists, of them on 100 items can selected or deselected. boolean property able identify if changes looking took place. the problem need value of ...

dependency injection - Google GIN AbstractGinModule & GWT.Create() -

i have class extends abstractginmodule like: public class clientmodule extends abstractginmodule { public clientmodule() { } @override protected void configure() { ... ... bind(...class).annotatedwith(...).to(...class).in(singleton.class); ... } } the idea have bind 1 class class based on value stored in property file. like: param contains value coming property file if(param.equals("instanceb")) bind(a.class).to(b.class) else bind(a.class).to(c.class) i have class access property file , return string value. class called: instanceparameters.java i instance of class within clientmodule. don't find way it. tried with: - instanceparameters param = new instanceparameters (); - gwt.create(instanceparameters.class); (error because method should used on client side) is there way access instanceparameters class within clientmodule? thank help you don't need read file before launching application - before creatin...

bash - I'm having trouble performing arithmetic expressions in UNIX -

i have following script: #!/bin/sh r=3 r=$((r+5)) echo r however, error: syntax error @ line 3: $ unexpected. i don't understand i'm doing wrong. i'm following online guide letter http://www.unixtutorial.org/2008/06/arithmetic-operations-in-unix-scripts/ this sounds fine if you're using bash , $((r+5)) might not supported if you're using shell. /bin/sh point to? have considered replacing /bin/bash if it's available?

c# - How to execute server side code just before the asp.net session variable expires? -

in asp.net website creating session upon user login , perform operations in database before session expire.i having problem in determining should write code , how know session going expire. i not sure if 'session_end' event of 'global.asax' suits requirements session want check created manually(not browser instance). could please put me in right direction? thanks. this pretty tricky, namely because session_end method supported when session mode set inproc. do, use ihttpmodule monitors item stored in session, , fires event when session expires. there example on over codeproject (http://www.codeproject.com/kb/aspnet/sessionendstatepersister.aspx), not without limitations, instance doesn't work in webfarm scenarios. using munsifali's technique, do: <httpmodules> <add name="sessionendmodule" type="sessiontestwebapp.components.sessionendmodule, sessiontestwebapp"/> </httpmodules> and wire module @ appl...

c# - How to convert chained static class names and a property value to a string? -

context: suppose 1 has following class structure: public static class somestaticclass { public static class someinnerstaticclass { public static readonly string someproperty = "somestringvalue"; } } question: is there easy way convert reference somestaticclass.someinnerstaticclass.someproperty string value of "somestaticclass.someinnerstaticclass.somestringvalue"? the first thing posted wrong because static types wrote little code , works. public static class { public static class b { public static string c { { return "hi"; } } } } class program { static void main( string[] args ) { console.writeline(typeof(a.b).fullname.replace("+",".") + "." + a.b.c ) ; } }

java - Can not retrieve CellID and LAC for the current cell -

i tried retrieve cid , lac connected cell, using public void getcid(){ int cid; int lac; gsmcelllocation xxx = new gsmcelllocation(); cid = xxx.getcid(); lac = xxx.getlac(); toast output = toast.maketext(getapplicationcontext(), "base station lac "+lac+"\n" +"base station cid " +cid, toast.length_short); output.show(); } the thing -1 value both parameters (i on 2g). may wrong or there way cid , lac of current cell? telephonymanager telephonymanager = (telephonymanager) context.getsystemservice(context.telephony_service); celllocation location = telephonymanager.getcelllocation(); gsmcelllocation gsmlocation = (gsmcelllocation) location; int cellid = gsmlocation.getcid(); int lac = gsmlocation.getlac();

posix - What is select supposed to do if you close a monitored fd? -

i can test find behavior that's not point. in my answer question, commenter recommended closing monitored fd thread wake select . commenter couldn't find reference behavior in standard, , can't find 1 either. can provide pointer standard on behavior? from description of select in "the open group base specifications issue 7": a descriptor shall considered ready reading when call input function o_nonblock clear not block, whether or not function transfer data successfully. (the function might return data, end-of-file indication, or error other 1 indicating blocked, , in each of these cases descriptor shall considered ready reading.) so, method portable.

Azure Worker Role generating writing unexpected error to Trace log storage -

we have worker role running in cloud polls azure cloudqueue periodically retrieving messages web role has put on there us. worker role , web role housed in same cloud service application , running 1 instance. as testing have our logging switched on , contents of messages , other useful information appear in our cloud storage view using cerebrata azure diagnostics manager. (great product btw) diagnosticmonitorconfiguration diagconfig = diagnosticmonitor.getdefaultinitialconfiguration(); diagconfig.logs.scheduledtransferloglevelfilter = loglevel.verbose; it appears work remarkably actually, see verbose message in trace log has "fail"as message. code appears generated wrapped in try catch odd aren't seeing message through means. it appear happening out of our code's control, perhaps worker role being restarted, or cloud op system detecting major error can deal restarting our worker role. recovers , carries on of mystery might happening. what haven...

sql - How do you store variables fields? -

Image
i've database i've comments, votes, galleries, images, etc... examples, galleries , images can commented using same form, i'll store in single table, comment. i'm wondering how store type information in comment table? using enum type, foreign key against type table, hardcoded on insert, etc.. ? foreign key against type table vote. this:

C++ preprocessor concatenation -

i have function build function pointers. think might faster try exchange function pre processor macro. @ least, try out macro can measure if generates faster code. it's more or less this: typedef int (item::*getterptr)(void)const; typedef void (item::*setterptr)(int); void dostuff(item* item, getterptr getter, setterptr setter, int k) { int value = (item->*getter)(); // .. stuff (item->*setter)(newvalue); } and it's called like // ... dostuff(&item, &item::a, &item::seta, _a); dostuff(&item, &item::b, &item::setb, _b); dostuff(&item, &item::c, &item::setc, _c); // ... i think might possible swap like: #define do_stuff(item, getter, setter, k) { \ int value = item ## -> ## getter ## (); \ //... \ item ## -> ## setter ## (newvalue); \ } while(0); but gives me errors like: error: pasting ")" , "seta" not give valid preprocessing token there's way concatenate function n...

sql server - Basic management scripts that you run in your database / instance? -

what kind of basic management/audit scripts run in databases or in instance? there may lots of them, know (get hints) kind of task valuable when managing databases or instance. , kind of reporting have databases (in management perspective)? i'd start maintenance plans index maintenance statistics maintenance integrity checks backups i'd worry reports later once have basics in place...

asp.net - Urls get corrupted with Outputcache when folder changed -

i noticed serious bug outputcache on user control level. code simple <a runat="server" href="~/app/view/login.aspx">login</a> when first page domain.com/app/view/login.aspx fine , see getting link domain.com/app/view/login.aspx in output see following html: <a href="login.aspx">login</a> but go page in folder generates same html , in browser see: domain.com/somewrongfolder/login.aspx what correct syntax href allows me use @outputcache?

Select element with given attribute using linq to xml -

i've got following xml structure: <artists> <artist> <name></name> <image size="small"></image> <image size="big"></image> </artist> </artists> i need select name , image given attribute (size = big). var q = c in feed.descendants("artist") select new { name = c.element("name").value, imgurl = c.element("image").value }; how can specify needed image attribute(size=big) in query above? it's quite simple when know how! var artistsandimage = in feed.descendants("artist") img in a.elements("image") img.attribute("size").value == "big" select new { name = a.element("name").value , image = img.value}; this return names , big images artists....

mysql - How to combine several time spans -

lets say, have following table | start | end | activity +---------------------+---------------------+--------- | 2010-07-26 09:10:00 | 2010-07-26 09:21:00 | 6 | 2010-07-26 09:35:00 | 2010-07-26 09:47:00 | 5 | 2010-07-26 10:05:00 | 2010-07-26 10:45:00 | 5 | 2010-07-26 10:50:00 | 2010-07-26 11:22:00 | 6 | 2010-07-26 13:15:00 | 2010-07-26 13:43:00 | 7 | 2010-07-26 14:12:00 | 2010-07-26 14:55:00 | 2 i want combine small time spans, getting average minutes activity per hour. that: | start | minutes_activity | avg_activity +---------------------+---------------------+--------- | 2010-07-26 09:00:00 | 42 | {avg value} | 2010-07-26 10:00:00 | 50 | {avg value} | 2010-07-26 11:00:00 | 22 | {avg value} | 2010-07-26 13:00:00 | 28 | {avg value} | 2010-07-26 14:00:00 | 43 | {avg value} note records can have activity minutes in 2 hours, i.e 10:50:00 - 11:22:0...

c# - Producer Consumer queue does not dispose -

i have built producer consumer queue wrapping concurrentqueue of .net 4.0 slimmanualresetevent signaling between producing (enqueue) , consuming (while(true) thread based. queue looks like: public class producerconsumerqueue<t> : idisposable, iproducerconsumerqueue<t> { private bool _isactive=true; public int count { { return this._workerqueue.count; } } public bool isactive { { return _isactive; } set { _isactive = value; } } public event dequeued<t> ondequeued = delegate { }; public event loggedhandler onlogged = delegate { }; private concurrentqueue<t> _workerqueue = new concurrentqueue<t>(); private object _locker = new object(); thread[] _workers; #region idisposable members int _workercount=0; manualreseteventslim _mres = new manualreseteventslim(); public void dispose() { _isactive = false; _mres.se...

jquery - Remove or hide a div if it's empty -

i know should simple can't figure out. here's code. <div class="cols lmenu_item1" id="leftmenuwrapper"> <div id="leftmenu"></div> </div> i need remove "leftmenuwrapper" if "leftmenu" empty. here's i've been using. $('#leftmenu').empty().remove('#leftmenuwrapper'); sorry if simple question. having monday! thanks! you can this: $('#leftmenu:empty').parent().remove(); this selects #leftmenu if it's :empty , , grabs .parent() of that .remove() . if wasn't empty, first selector won't find anything, or parent remove either.

c# - Why Thread.Sleep() is so CPU intensive? -

i have asp.net page pseduo code: while (read) { response.outputstream.write(buffer, 0, buffer.length); response.flush(); } any client requests page start download binary file. ok @ point clients had no limit in download speed changed above code this: while (read) { response.outputstream.write(buffer, 0, buffer.length); response.flush(); thread.sleep(500); } speed problem solved now, under test 100 concurrent clients connect 1 after (3 seconds lag between each new connection) cpu usage increases when number of clients increases , when there 70 ~ 80 concurrent clients cpu reaches 100% , new connection refused. numbers may different on other machines question why thread.sleep() cpu intensive , there way speed done client without cpu rising ? i can @ iis level need more control inside of application. just guess: i don't think it's thread.sleep() that's tying cpu - it's fact you're causing threads tied responding request long, , s...

Turning on error reporting for a JavaScript segment? -

i haven't worked in js since 1999, i'm quite rusty. remember working in in past, , able enable kind of error reporting. right now, when have syntax error in script, no error reported in browser. there directive or enable error reporting in js file? most scripts in wild full of crass errors browsers don't bother complain them more. in ie default error indicator in left hand side of status bar can used display error. or can turn error alerts on internet options -> advanced -> browsing -> display notification every script error, make rest of internet unusably annoying. in firefox, tools -> error console bring familiar javascript console.

What is the best way to stop multiple form submissions using PHP? -

i wanted know best way stop multiple form submissions using php, can please give example. on client side can disable form button after clicked. however, provides basic level of security. your next step prevent via php. in case, best have hidden field within form consists of unique , identifiable token. in order perform check, have keep list of tokens have been used in past , check if has been submitted before.

MySQL data storage question -

how store following code below its output in mysql table? how field made? md5(uniqid(microtime(),1)) example. field char(128) not null field char(32) not null the output of md5() 32 characters long but of course can save in binary format, in case should use: field binary(16) not null

linux - How do I list the output of ps -U root -u root -eo pid in a single line seperated by comma's -

when execute cmd ps -u root -u root -eo pid output in multiple lines eg: 1 2 3 4 i see output in 1 line 1,2,3,4,5 ... one possible way ps -u root -u root -eo pid | tr -s "\n" ","

64bit - Why would some DLL functions fail on 64-bit Windows? -

i'm trying run lotusscript code (very similar visual basic) in lotus domino on windows servers. code calls windows api functions, , works fine on 32-bit windows 2003 servers, doesn't work on 1 64-bit server we've tried on. here's 1 of our external function declarations: declare function findexecutable lib "shell32.dll" alias "findexecutablea" _ (byval lpfile string, byval lpdirectory string, byval lpresult string) long when trying call function, lotusscript produces error message "external function not found". have tried both removing alias declaration, , changing alias "findexecutable" same result. i have also: - comparison, tried calling getforegroundwindow function in user32.dll - works. - used dir function confirm shell32 exists path "c:\windows\syswow64\shell32.dll", then... - changed lib in declaration dll's full path - produces "error in loading dll" when calling function. is there...

ruby on rails - How can I simulate the browser back button in Capybara? -

we have issue on our e-commerce site users hit "checkout" twice , have card charged twice. it's common enough bug , easy fix, i'd test solution in our capybara setup. once i've called click_button('checkout'), possible me pretend i'm user hitting browsers button , call click_button('checkout') second time? you may want try: when(/^i go back$/) page.evaluate_script('window.history.back()') end this require running senario in javascript capable driver (selenium/celerity/akephalos)

c# - Sesssion Variables and preventing asp:button from reloading page -

i don't have real world problem, yet, i'm trying learn more context.session[] variables , postback mechanism writing basic little image deally. have asp:image control imageurl set "image.aspx" on test.aspx page. image.aspx reads context.session["test"] variable , calls gfx.drawstring(context.session["test"],...) canvas. part easy. then on test.aspx have asp:button. when button pressed, onclick method changes context.session["test"] current time using datetime.now. now here i'm trying do. want button perform postback can update context.session["test"] variable don't want page reload, in javascript want refresh src field on image after small time delay allow session variable change. i'm trying update session variable , image on button click without page appearing reload. is possible update session variables without page refresh? is possible, or off base? to update session variables, have se...

encoding - php encoded post param values -

was experimenting basic http post stuff php , ran problem. 1.php: <head> <script src="/scripts/jquery.js"></script> </head> <body> <script> function hw(){ $.ajax({ type: 'post', url: '/2.php', data: 'param=a+b+c', success: function(d){ console.log('server said ' + d); } }); } </script> <button onclick="javascript:hw();">click me</button> </body> 2.php: <?php echo $_post['param']; ?> the ajax call returns 'a b c' instead of 'a+b+c'. why '+' encoded ' '(space) ? i tried using content type of post request 'text/plain' instead of default 'application/x-www-form-urlencoded' . in case, $_post['param'] comes out empty ? want understand going on in both th...

iphone - How do I modify the background color of an empty UITableViewCell object based on it's position? -

i'm trying write code modify background color of cell based on it's position in table. while following code 'works', effects cells passed it. empty cells don't effected. - (void)tableview: (uitableview*)tableview willdisplaycell: (uitableviewcell*)cell forrowatindexpath: (nsindexpath*)indexpath { if(!indexpath.row%2) { cell.backgroundcolor = [uicolor colorwithred: 0.0 green: 0.0 blue: 1.0 alpha: 1.0] ; nslog(@"blue"); } else{ cell.backgroundcolor = [uicolor whitecolor]; nslog(@"white"); } cell.textlabel.backgroundcolor = [uicolor clearcolor]; cell.detailtextlabel.backgroundcolor = [uicolor clearcolor]; } how can effect rest of cells displayed, if empty, when there few items in list? by 'empty' cells, mean placeholder cells displayed when data source doesn't have enough data fill entire view given table view. example, if can fit 10 cells, have 5 worth of data, eve...

Creating PDF file in PowerBuilder -

i new powerbuilder. got assignment create pdf file using powerbuilder. how can that? as suggested alberto megia, download pdf creator , dont use save as. after install pdf creator install printer, use printer save datawindow print function. after call print function, see "save as" dialog. if use "saveas" function, pdf not have format datawindow shows.

javascript - How does the load() function allow the user to provide a callback? -

in javascript it's popular libraries/frameworks let define callback function post-processing of data. eg. load("5", function(element) { alert(element.name); }); i wonder how load() function looks able let user provide callback? are there tutorials this? well, load function this: function load(arg, callback) { var element = { name: "foo " + arg }; // pass if (typeof callback == 'function') { callback(element); } } with typeof check make sure callback argument object can invoke, function. then example: load("5", function(element) { alert(element.name); // show `"foo 5"`. });

compression - 7z extension for php? -

i can't find 1 , don't know if of php compression , archive extensions work. do think use compression stream read data 7z file? update 7z forums have lot of requests php extension the 7z file format can use various compression algorithms , might able decompress archive 1 of existing utilities bzip2 or deflate. i found 7z php class well, , lucky since it's still being developed . here latest version .

How to call a WCF Service methods on a test server (without VS2010) in C# -

i created wcf service writes log file. put on iis , run svc file check if runs ok , does. how simulate methods? create web site calls methods, , use log file trace steps ? can install wcftestclient on test server ? what best way simulate wcf methods without vs2010 installed ? in asmx services "browse" service , input parameters in service methods, can in wcf methods ? you don't need install wcftestclient on server. use remote machine call service. if service uses interoperable binding take @ soapui .

multithreading - Threading in Rails - do params[] persist? -

i trying spawn thread in rails. not comfortable using threads need have in-depth knowledge of rails' request/response cycle, yet cannot avoid using 1 request times out. in order avoid time out, using thread within request. question here simple. thread i've used accesses params[] variable inside it. , things seem work ok now. want know whether right? i'd happy if can throw light on using threads in rails during request/response cycle. [starting bounty] the short answer yes, degree; binding in thread created continue persist. params still exist if no 1 (including rails) goes out of way modify or delete params hash. instead, rely on garbage collector clean these objects. since thread has access current context (called "binding" in ruby) when created, variables can reached scope (effectively entire state when thread created) cannot deleted garbage collector. however, executing continues in main thread, values of variables in context can changed main t...

Face Detection Library with C/C++ interface -

can please point me library(ies) face detection (no recognition needed!)? good-working libraries except opencv(!!!). preferably free of charge - open source not required. what bothers opencv? api or else? there libface opencv wrapper face detection , recognition.

.net - CopyFileEx in windows 7 -

i'm trying use function copyfileex kernel32.dll in windows 7 using .net interop. msdn says: if lpprogressroutine returns progress_stop due user stopping operation, copyfileex return 0 , getlasterror return error_request_aborted. in case, partially copied destination file left intact. on windows xp code works ok, on windows 7 partial file being deleted automatically. have missed something? using system; using system.runtime.interopservices; namespace copy { class program { static void main(string[] args) { var result = extendedcopy.xcopy("c:/original.rar", "c:/copy.rar"); } } class extendedcopy { [dllimport("kernel32.dll", setlasterror = true, charset = charset.unicode)] private static extern bool copyfileex(string lpexistingfilename, string lpnewfilename, copyprogressroutine lpprogressroutine, intptr lpdata, ref int32 pbcancel, copyfileflags dwcopyflags); delegate ...

c# - OpenXML: Read text between two document fields using OpenXML SDK -

i'm new programming openxml sdk , i've tried excessively locate , read text between 2 document fields, never succeeded. there tons of samples , tutorials on web can think of doing openxml sdk, setting watermarks doing merge mail, not 1 processing document fields. my word document looks this: { field1 } data { field2 } and want do, read data between field1 , field2 . i succeeded point locate fields need this: var qryfieldcode = (from p in procdoc.maindocumentpart.document.body.descendants() p.gettype() == typeof(fieldcode) select p).tolist(); but can read text between fields found? any appreciated. find first field (much above) , .elementsafterself.takewhile until p.gettype() doesn't = typeof(fieldcode) . .value of query , you'll have text. won't great solution if have things tables between 2 fields, example above, work.

configuration - RabbitMQ database files -

i'm running rabbitmq v.2.0.0. on linux machine. mnesia base current default, within directory rabbit creates directories, eg. rabbit@ip-123.1.1.123. the ip in directory name based on inet addr of machine. directories hold information user, exchanges, vhost (i think). my question is, how can fix/config these directory names ip not based on ip? to change mnesia directory, set mnesia_dir in /etc/rabbitmq/rabbitmq.conf. also, great place ask rabbitmq related questions on rabbitmq-discuss mailing list.

synchronization - Entity Framework and Synchronizing a database solution? -

i have n-tier application using entity framework 4.0 , we're looking @ synching contents of database between redundant servers. have experience on tips on how best approach solution? from architecture point of view, need consider if want @ application level or database level. at application level write both databases time made change. at database level use replication tools build database use. you use 3rd party tool. there sync framework available microsoft.

flex - Facebook Graph API and friend's email -

there question on stackoverflow facebook & email, after reading them still have problem retrieving users emails. our app implemented on flex , uses rest api. , used notifications.sendemail. app has publish_stream , email permissions (checked users.hasapppermission). i tried users.getinfo proxied_email address. function not return email address of friend.. then performed following test using graph api , web browser: opened following link authorization extended permissions: https://graph.facebook.com/oauth/authorize?client_id=[app_id]&scope=publish_stream,offline_access,email&redirect_uri=http://www.facebook.com/connect/login_success.html it returned code retrieving access_token oppened following link retrieving access_token graph.facebook.com/oauth/access_token?client_id=[app_id]&client_secret=[secret]&code=[code]&redirect_uri=http://www.facebook.com/connect/login_success.html it returned access_token. , can use graphapi. test...

javascript - What is the difference between “this”, “$this” and “$(this)”? -

what difference between these 3 forms: this $this $(this) in typical usage you'll see them (the $this usage may vary): this - refers dom element in handler you're on, may object entirely in other situations, it's context. $this - created var $this = $(this) cached version of jquery wrapped version efficiency (or chain off $(this) same in many cases). $(this) - jquery wrapped version of element, have access all methods (the ones in $.fn specifically).

How to create a script for the command line in PHP with Zend Framework? -

i need create script run on command line using php , want take advantage of zf , models (classes) have written using it. how do elegantly possible? you have duplicate code of public/index.php without calling run method of zend_application (which mvc stuff) , load resources need. #!/usr/bin/php <?php define('application_path', realpath(dirname(__file__) . '/../application')); set_include_path(realpath(application_path . '/../library')); require_once 'zend/application.php'; $application = new zend_application( application_env, application_path . '/configs/application.ini' ); // load ressources need $application->getbootstrap()->bootstrap( array( 'db' ) ); // stuff take care of adapt location of cli script.

ruby - How to reference an embedded document in Mongoid? -

using mongoid, let's have following classes: class map include mongoid::document embeds_many :locations end class location include mongoid::document field :x_coord, :type => integer field :y_coord, :type => integer embedded_in :map, :inverse_of => :locations end class player include mongoid::document references_one :location end as can see, i'm trying model simple game world environment map embeds locations, , player references single location current spot. using approach, i'm getting following error when try reference "location" attribute of player class: mongoid::errors::documentnotfound: document not found class location id(s) xxxxxxxxxxxxxxxxxxx. my understanding because location document embedded making difficult reference outside scope of embedding document (the map). makes sense, how model direct reference embedded document? because maps own collection, need iterate on every map collection search...

android - AdMob Ads not displaying -

i'm adding admob ads (say 5 times fast) finished, published android app. added code pdf included admob, following instructions tee. test ads show fine on emulators , specified test devices. don't appear in published marketplace app when download , run it. still impressions on admob page however. ideas? admob doesn't have ads display. worse apps others. there few things mitigate problem: enable adsense ads - gives larger pool of ads ensure have house ads available of apps in admob. way, if can't find paying ads, they'll @ least show house ads. raise fill rate, not directly raise income (depends on house ads).

ios - How can I get the monday of a week in a special date in Objective-C? -

e.g. 01.10.2010 friday => 27.09.2010 monday. i have no idea how manage one. btw: how can calculate dates? for time/date calculations use nsdatecomponents. listing 2 getting sunday in current week nsdate *today = [[nsdate alloc] init]; nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; // weekday component of current date nsdatecomponents *weekdaycomponents = [gregorian components:nsweekdaycalendarunit fromdate:today]; /* create date components represent number of days subtract current date. weekday value sunday in gregorian calendar 1, subtract 1 number of days subtract date in question. (if today's sunday, subtract 0 days.) */ nsdatecomponents *componentstosubtract = [[nsdatecomponents alloc] init]; [componentstosubtract setday: 0 - ([weekdaycomponents weekday] - 1)]; nsdate *beginningofweek = [gregorian datebyaddingcomponents:componentstosubtract todate:today options:0]; /* optional step: beginningofweek has s...

How does google add the light blue colored vertical and horizontal bars (html/Css) -

Image
as shown in screenshot: i tried looking in source code , couldn't find myself. for header, use empty div s class .gbh , provides style border-top: 1px solid #c9d7f1; firebug's parsing <span id="ghead" style="visiblity:visible;"> <div id="guser" width="100%">...</div> <div class=gbh style=left:0></div> <div class=gbh style=right:0></div> </span>

Tutorials/manuals for writing class and style files in LaTeX? -

i've searched net , stackoverflow , found number of great latex sources, couldn't find decent manual writing own class , style files. issues have part of code should in class file , in style file, how finetune macros, how define , use variables,... i figured things out looking @ other peoples code, i'd have comprehensive overview. ideas should look? ps : have not short introduction latex, introduction beamer , latex tutorial - primer. none of these answers questions. sorry, found related questions , answers here , here . courtesy matt pointer.

ruby on rails - How to know if Spork is running -

i'm trying speed "rspecing" in rails 2.3.8 app spork. when run spork in root of project get: (...stuff...) no server running running specs locally: spork ready , listening on 8989! and then, if run specs, message no server running running specs locally which appears if run them without spork doesn't appear, spec startup slow without spork. in spork's terminal no further output appears. my question is, spork running? if so, specs running there?, , finally, if answer both true, how can speed tests? here config files involved: spec/spec.opts --colour --format progress --loadby mtime --reverse --drb spec/spec.helper require 'rubygems' require 'bundler/setup' require 'spork' spork.prefork env["rails_env"] ||= 'test' require file.expand_path(file.join(file.dirname(__file__),'..','config','environment')) require 'spec/autorun' require 'spec/r...

asp.net - Handling Images and file attachments in a Content Management System -

assumptions: microsoft stack (asp.net; sql server). some content management systems handle user-generated content (images, file attachments) storing in file system. others store these items in end database. some examples of both: in filesystem: community server, graffiti cms in database: microsoft sharepoint i can see pros , cons of each approach. in filesystem lightweight avoids bloating database backup , restore potentially simpler in database all content in 1 repository (the database) complete separation of concerns (content vs format) easier deployment of web site (e.g. directly subversion repository) what's best approach, , why? pros , cons of keeping user files in database? there approach? i'm making question community wiki because subjective. if using sql server 2008 or higher, can use filestream functionality best of both worlds. is, can access documents database (for queries, etc), still have access file via file system (usin...