Posts

Showing posts from June, 2011

On click - jQuery event problems -

i'm trying create function, after clicking on button, open search box, , after clicking again on same button close it. i have build this: $("#searchbutton").click(function(){ $("#searchbox").animate({top: '0px'}, 500), $(this).click(function(){ $("#searchbox").animate({top: '-47px'}, 500) }); }); it works fine first time after click on it. if i'll click on again re-open without refreshing page button automatically hide. why happening? thank in advance dom your problem never unbind first click handler. the best solution use toggle handler, this: $("#searchbutton").toggle( function () { $("#searchbox").animate({top: '0px'}, 500); }, function () { $("#searchbox").animate({top: '-47px'}, 500); } );

How to plot sunrise over a year in R? -

i have date looks this: "date", "sunrise" 2009-01-01, 05:31 2009-01-02, 05:31 2009-01-03, 05:33 2009-01-05, 05:34 .... 2009-12-31, 05:29 and want plot in r, "date" x-axis, , "sunrise" y-axis. you need work bit harder r draw suitable plot (i.e. suitable axes). have data similar yours (here in csv file convenience: "date","sunrise" 2009-01-01,05:31 2009-01-02,05:31 2009-01-03,05:33 2009-01-05,05:34 2009-01-06,05:35 2009-01-07,05:36 2009-01-08,05:37 2009-01-09,05:38 2009-01-10,05:39 2009-01-11,05:40 2009-01-12,05:40 2009-01-13,05:41 we can read data in and format appropriately r knows special nature of data. read.csv() call includes argument colclasses r doesn't convert dates/times factors. dat <- read.csv("foo.txt", colclasses = "character") ## convert imported data appropriate types dat <- within(dat, { date <- as.date(date) ## no need 'format' argument data in ...

puzzle - Given a function for a fair coin, write a function for a biased coin? -

i came across reported interview question when doing reviewing (the following quote info found problem): given function fair coin, write function biased coin returns heads 1/n times (n param) at first glance wrote: int biased_coin(n) { //0=tails, 1=heads int sum = 0; if(n==1) return 1; for(int i=0;i<n;i++) { sum += unbiased(); //unbiased returns 0 50% of time , 1 50% of time } if(sum == 1) return 1; return 0; } but doesn't work. n=4, instance, work: since probability of getting single head given 4 tosses 4/(2^4)=1/4. n=3, 3/(2^3)!=1/3. what proper way implement assuming can't use random number generator? assuming: int faircointoss(); returns 1 heads , 2 tails, writing: int biasedcointoss(int n); where heads (1) appear 1/n of time should work: int biasedcointoss(int n) { if (n == 1) { return 1; // 1/1 = 1 = heads } else if (n == 2) { return faircointoss(); // 1/2 = 50% = fair coint oss } ...

c# - make description for a property -

how can make description property , receive via system.reflection ? you use custom attribute : public class fooattribute : attribute { public string description { get; set; } } public class bar { [foo(description = "some description")] public string barproperty { get; set; } } public class program { static void main(string[] args) { var foos = (fooattribute[])typeof(bar) .getproperty("barproperty") .getcustomattributes(typeof(fooattribute), true); console.writeline(foos[0].description); } }

Python: binary tree traversal iterators without using conditionals -

i trying create module in python iterating on binary tree using 4 standard tree traversals (inorder, preorder, postorder , levelorder) without using conditionals , using polymorphic method dispatch or iterators. following examples should work. for e in t.preorder(): print(e) e in t.postorder(): print(e) e in t.inorder(): print(e) e in t.levelorder(): print(e) so far have come following def build_tree(preord, inord): tree = binarytree() tree.root = buildtreehelper(preord, inord) return tree def buildtreehelper(preorder, inorder): if len(inorder) == 0: return none elem = preorder[0] eleminorderindex = inorder.find(elem) if eleminorderindex > -1: leftpreorder = preorder[1:eleminorderindex + 1] rightpreorder = preorder[eleminorderindex + 1:] leftinorder = inorder[0:eleminorderindex] rightinorder = inorder[eleminorderindex + 1:] left = buildtreehelper(leftpreorder, leftinorder) right = buildtreehelper(rightpreorder, rightino...

c# - Why do I get the following error? Invalid variance modifier. Only interface and delegate type parameters can be specified as variant -

using system; using system.collections.generic; using system.linq; using system.text; namespace variance { class { } class b : { } class c<out t> { } class program { static void main(string[] args) { var v = new c<b>(); ca(v); } static void ca(c<a> v) { } } } this offending line: class c<out t> as error message tells you, can't apply generic variance classes, interfaces , delegates. okay: interface c<out t> the above not. for details, see creating variant generic interfaces

ios - iPhone: AudioBufferList init and release -

what correct ways of initializing (allocating memory) , releasing (freeing) audiobufferlist 3 audiobuffers? (i'm aware there might more 1 ways of doing this.) i'd use 3 buffers read sequential parts of audio file them , play them using audio units. here how it: audiobufferlist * allocateabl(uint32 channelsperframe, uint32 bytesperframe, bool interleaved, uint32 capacityframes) { audiobufferlist *bufferlist = null; uint32 numbuffers = interleaved ? 1 : channelsperframe; uint32 channelsperbuffer = interleaved ? channelsperframe : 1; bufferlist = static_cast<audiobufferlist *>(calloc(1, offsetof(audiobufferlist, mbuffers) + (sizeof(audiobuffer) * numbuffers))); bufferlist->mnumberbuffers = numbuffers; for(uint32 bufferindex = 0; bufferindex < bufferlist->mnumberbuffers; ++bufferindex) { bufferlist->mbuffers[bufferindex].mdata = static_cast<void *>(calloc(capacityframes, bytesperframe)); bufferlist...

What can I add in constructors in PHP? -

could tell me can include in constructor? i know can following. function __construct(){ parent::controller(); session_start(); } but wondering if can add variables, if statement etc. thanks in advance. knock out. add php want. can use $this refer object being created.

iTextSharp image keep pixel dimensions? -

lets have image has dpi of 72 , width/height of 100px/100px. however when add image , render pdf, image displayed bigger 100px/100px. how can ensure when adding image pdf using itextsharp keep same pixel dimensions original image, in case 100px/100px? it sounds you'll want check out scaleabsolute method of itextsharp.text.image, explicitly set height/width of image. there couple of related methods you'll want read to: scalepercent , scaletofit. these methods described in sourceforge itextsharp tutorial includes samples. see tge "scaling , rotating image" section.

How to add product description in paypal through html hidden field? -

Image
i want add product description paypal shopping cart , using html hidden fields send form data. can suggest should pass inorder display product description? thanks in advance co-operation. if mean description field "add description" on payment site @degales wrong , @aditya menon right. on0 , os0 parameters used options size:s. example: <input name="item_name" type="hidden" value="t-shirt" /> <input type="hidden" name="on0" value="size"> <input type="hidden" name="os0" value="s"> and $data['item_name'] = $_post['item_name']; $data['on0'] = $_post['on0']; $data['os0'] = $_post['os0']; result:

asp.net - How can I build an infinitely recursive listview control? -

not sure i'm asking right question, it's start. have user control listview and, ideally, nest same control inside of listview provide recursion. behave treeview child nodes. this might monumentally bad idea. :) in fact, feed msft pointing me in direction, because when try told can't it. so, how this? what's right way? sounds need treeview after all, need more functionality provides default... how extending treenode/treeview? here example that: http://www.codeproject.com/kb/tree/dropdowntreeview.aspx or can extend listview, in fact, article shows how create treelistview sounds similar you're trying do: http://www.codeproject.com/kb/list/extendedlistviews.aspx either way, sounds need custom control, based on treeview , listview. good luck!

hash of java hashtable -

the hashcode of java hashtable element unique? if not, how can guarantee 1 search give me right element? not necessarily. 2 distinct (and not-equal) objects can have same hashcode.

Java/RXTX issue Windows XP -

i'm testing java/mysql pos system i've written small bar, , having problems cash draw. the cash drawer has rj11 plug connected via usb->serial box, , writing data device triggers draw open. i'm having problems rxtx, , wasn't sure if code, library or drivers device? ideally, i'd connection created when user logs in system, , closed when log out, moment, code opens connection, writes data , closes when sale rung (there 1-2 second delay between hitting save button , drawer opening, frustrating). when app first starts, drawer works fine few sales (haven't identified pattern), stops working. shows range of exceptions occurring, mixing either nosuchport, portinuse or plain accessdenied message. usually, restarting app , disconnecting/reconnecting usb working again few more sales. i can connect device using hyperterminal, , works consistently, without issue. java code: public static void opentill() { try { portid = (commportidentifier) comm...

java - Can I do a static import of a private subclass? -

i have enum private, not exposed outside of class. there anyway can static import of type, don't have type enum type each time? or there better way write this? example: package kip.test; import static kip.test.test.myenum.*; //compile error public class test { private static enum myenum { dog, cat } public static void main (string [] args) { myenum dog = myenum.dog; //this works don't want type "myenum" myenum cat = cat; //compile error, want } } or there better way write this? if main goals reference items without qualifying enum identifier, , maintain list privately, scrap enum type altogether , use ordinary private static constants.

iis - Block empty user agent with URLScan -

i'm able block specific user agent, i'd block requests empty user agent using urlscan v3.1. does know how this? there isn't way configure using urlscan, can done custom isapi filter on iis server. here in c++: dword winapi __stdcall httpfilterproc(http_filter_context *pfc, dword notificationtype, void *pvdata) { char buffer[256]; dword buffsize = sizeof(buffer); http_filter_preproc_headers *p; switch (notificationtype) { case sf_notify_preproc_headers : p = (http_filter_preproc_headers *)pvdata; bool bheader = p->getheader(pfc,"user-agent:",buffer,&buffsize); cstring useragent(buffer); if(useragent.getlength() == 0) { // reject blank user agents p->setheader(pfc, "url", "/rejected-blank-user-agent"); } return sf_status_req_handled_notification; } return sf_status_req_next_notification; }

Easy way of getting started programming using python -

background i'm trying learn program little & python seems choice purpose. have no ambition of ever being serious programmer.i know bits , pieces of html, css, javascript (mostly how cut & paste without understanding i'm doing). last time "learned programming" ten years ago in, high school, using pascal. didn't far. did have though think programmers call "an environment" made sort of sense. there someplace type in "code" (programs), button "compile," (if worked) button "run." a python environment (is right word @ all?) have been trying set can put in hour or 2 whenever have time have utterly failed @ setup. tutorials or guides have tried using seem jump in things shell, ide, interactive shell, terminal, command line interface. my failure far example, tried follow diveintopython's setup instructions. i'm using mac. tells me fist few chapters can buy python's command line version if comfortable (i...

user interface - How do I create a pie chart in Java -

i want create pie chart displays percentages. how create pie chart using jframe in java? this have far: import javax.swing.*; import java.awt.*; import java.util.*; public class piechart extends jframe{ private int midterm; private int quizzes; private int projects; private int final; public piechart(){ setpercentage(); } private void setpercentage() { // todo auto-generated method stub } //construct pie chart percentages public piechart(int midterm, int quizzes, int final, int projects){ this.midterm = midterm; this.quizzes = quizzes; this.final = final; this.projects = projects; } //return midterm public int getmidterm(){ return midterm; } //public void setmidterm(int midterm){ //this.midterm = midterm; //repaint(); //} //return quizzes public int getquizzes(){ return quizzes; } public int final(){ return final; } public int projects(){ return projects; } //draw circle protected void paintcomponent(graphics g){ super.paintcomponen...

Visual Studio 2008 Winform designer fails to load Form which inherits from generic class -

i have winforms project, , created class on assembly a inherits system.windows.forms.form serve base class various forms on project, base class like: public partial class dataform<t> : form t : class { t currentrecord; protected t currentrecord { { return currentrecord; } set { currentrecord = value; currentrecordchanged(); } } } now, when create form on assembly b inherits dataform designer won't load, if compile app runs fine. the form looks like: public partial class sometablewindow : dataform<sometable> { public sometablewindow () { initializecomponent(); } } the error i'm getting is: the designer not shown file because none of classes within can designed. designer inspected following classes in file: cultivoswindow --- base class 'tripleh.erp.controls.dataform' not loaded. ensure assembly has been referenced , pr...

c# - ASP.NET - how to make AJAX request to the server without getting response with the information for all the update panels I have? -

for example, have 3 updatepanels on page. click button, , pretty long response, contains data 3 updatepanels, viewstate string. i want optimize query , receive response "ok" or "not ok". how can that? the short answer ms ajax , updatepanels, can't. the long answer: the core of updatepanels full post, , full page lifecycle runs whatever controls contain, , able parse out portions of reponse pertain individual viewports on page , update portions. you can reduce amount of data turning off viewstate controls don't need it. tip set updatemode property of panels " conditional ", update panels on page aren't involved in every post. if posting 1 panel , response updates panel, there no need transfer data controls in other panels. read here update panel tips , tricks better performance out of them. if want simple messages posts, @ using jquery , ajax/post methods post alternate pages or webservices. ms ajax designed around ...

javascript - Radio button and having a text box validation Ruby on Rails -

this setup have: <input id="demographics_questionary_gender_male" name="demographics_questionary[gender]" type="radio" value="male"> male <input id="demographics_questionary_gender_gender" name="demographics_questionary[gender]" type="radio" value="female"> female <input id="demographics_questionary_gender_male" name="demographics_questionary[gender]" type="radio" value="other"> other <input id="other_gender_value" name="other_gender[value]" size="30" type="text"> this produce 3 radio buttons (male, female, other). there text box if "other" radio button selected. my question deals how validate if text box filled in if "other" radio button selected. currently, in controller check if other radio button selected , if i'll change stored value value set in "other...

c# - How can i find out the Last row in a datagridview and write it to text file -

i find last row of datagridview , write particular row data text file can 1 me i give sample code, may help. list<string> lstcontents = new list<string>(); foreach (datagridviewcell cell in mydatagrid.rows[mydatagrid.rowcount - 1].cells) { lstcontents .add((string)cell.value); } string mydata= string.join(",", lstcontents.toarray()); now using streamwriter can write string file. can use separator. have used "," comma here. ///this append data text file... using (streamwriter sw = new streamwriter(filepath, true)) { sw.writeline(mydata); }

References in classic ASP -

i got tossed maintenance work on classic asp (note: not asp.net) page. page has line looks @ top: <object runat="server" progid="findasp.search" id="objfind"></object> the body of asp page has looks this: <form action="search.asp" method="post" id="frmsearch" name="frmsearch"> <% objfind.display "", "" %> </form> what world doing? looks calling display function. function spits out html. guess, display function defined through objfind object. however, can't find how objfind defined or defined. can please give me advice? have no clue go @ point. the code using server side object - com object name (progid) findasp.search assigned variable ( id in tag) objfind . this com object seems define display function, without knowing more findasp.search there isn't more can tell.

autocomplete - Textmate autocompletion and class outline for PHP project -

i'm using pdt, want switch lightweit editor. first want try textmate. eclipse has several useful features: class outlile list of properties , methods (with signature) navigate; type hierarchy , class outlile shows full inheritance tree; autocompletion custom classes names, methods etc. (not standard functions); go declaration feature does textmate provide features, or there bundles such functional? i know can frightening — me — can code efficiently vim. it's definetly not turnkey solution if have time between projects it's worth it. taglist , tagbar plugins provide code navigation. there number of solutions autocompletion. you can go declaration gd in single file or exuberant ctags , ctrl-] in more complex situations.

c# - Multiplication with .NET regular expressions -

in spirit of polygenelubricants ' efforts silly things regular expressions, try .net regex engine multiplicate me. this has, of course, no practical value , meant purely theoretical exercise. so far, i've arrived @ monster, should check if number of 1s multiplied number of 2s equals number of 3s in string. regex regex = new regex( @" ^ (1(?<a>))* # increment each 1 (2(?<b>))* # increment b each 2 (?(a) # if > 0 ( (?<-a>) # decrement (3(?<c-b>))* # match 3's, decrementing b , incrementing c until # there no 3's left or b 0 (?(b)(?!)) # if b != 0, fail (?<b-c>)* # b = c, c = 0 ) )* # repeat (?(a)(?!)) # if != 0, fail (?(c)(?!)) # if c != 0, fail $ ", regexoptions.ignorepatternwhitespace); unfortunately, not working, , @ loss why. commented show thin...

c - Running a FIFO Simulation -

i trying run simulation program test fifo algorithm, program crashing. main, other functions not shown. can spot me problem.am not familiar using main argument[ int main(int argc, char *argv[])] have testing files in folder int main(int argc, char *argv[]) { file *stream; if (argc != 3) { printf("the format is: pager file_name memory_size.\n"); //exit(1); } printf("file used %s, resident set size %d\n", argv[1], atoi(argv[2])); if ((stream = fopen(argv[1], "r")) == null) { perror("file open failed"); //exit(1); } mem_size = atoi(argv[2]); start_simulation(stream); fclose(stream); system("pause"); } uncomment calls exit. if (argc != 3) { // insufficient arguments passed..print error , exit. printf("the format is: pager file_name memory_size.\n"); exit(1); } in case(exit commented) if not provide cmd-line arguments, argv[1] null , can cause crash when used in fopen

Java ME, How to implement peer to peer communication? -

the title question.... you can open serversocketconnection , socketconnection on other side. allow 2 way direct communication between 2 mobile phones. can @ this page more details. possibly can send initial connection information sms , after switch socket communication.

delphi - How to detect TMenuItem right click? -

platform:delphi 2010 drop tmainmenu on form1 drop tpopupmenu on form1 add mainmenu1 , popupmenu items (mainmenu --> file -->item1 , popupmenu-->popup item1) item1.onrgihtclick show popupmenu f9 file-->item1 right click, popupmenu , select item1 bla bla bla.... object form1: tform1 left = 0 top = 0 caption = 'form1' clientheight = 222 clientwidth = 447 color = clbtnface font.charset = default_charset font.color = clwindowtext font.height = -11 font.name = 'tahoma' font.style = [] menu = mainmenu1 oldcreateorder = false pixelsperinch = 96 textheight = 13 object mainmenu1: tmainmenu left = 136 top = 64 object file1: tmenuitem caption = 'file' object recentfile1: tmenuitem caption = 'item 1' end end end object popupmenu1: tpopupmenu left = 24 top = 136 object popupitem1: tmenuitem caption = 'popup item' onclick = popupitem1...

How can I add a new row to an existing Excel spreadsheet using Perl? -

i have created excel sheet a.xls using perl have field as: date name eid 13/jan/2010 asa 3175 when compile next time , if date more previous date has update wise: date name eid 13/jan/2010 asa 3175 14/jan/2010 stone 3180 if date of previous row date last row date 14/jan/2010 , current date 14/jan/2010 should not insert row should update previous record only. see example in spreadsheet::parseexcel::saveparser documentation . understand, addcell method can replace existing cell or add new.

ASP.NET MVC without javascript -

we're developing site without javascript maximum support intention of layering js functionality on top. problem have single page has 2 or more pieces of functionality (as example screen capture personal details includes postcode lookup address). no ability change postback on either complete form submission or postback lookup postcode end single controller action both. doesn't feel great end index action doing more 1 thing. given js enabled client separated out nicely separate actions. i wondering if else has faced issue of producing javascript free asp.mvc site , pattern used overcome controller action bloat we're calling it? a couple options. use separate form postcode lookup, render same view had / whatever different info. can't nested identify button used post form / similar answer: how can change action form submits based on button clicked in asp.net mvc?

Fast way to execute MySQL stored procedures in Java within multiple threads? -

what fastest option issue stored procedures in threaded environment in java? according http://dev.mysql.com/doc/refman/5.1/en/connector-j-usagenotes-basic.html#connector-j-examples-preparecall connection.preparecall() expensive method. what's alternative calling in every thread, when synchronized access single callablestatement not option? the jdbc drivers use single socket per connection. think mysql use single socket. bad performance idea share 1 connection between multiple threads. if use multiple connection between different threads need callablestatment every connection. need callabalestatement pool every connection. simplest pool in case wrap connection class , delegate calls original class. can create fast eclipse. in wrapped method preparecall() can add simple pool. need wrapped class of callablestatement. close method return callablestatement pool. but first should check if call real expensive because many driver has such poll inside. create loop of prepa...

Storing SSL sessions in Android -

im pretty new ssl, in making ssl request, how prevent "handshake" happening each time call https url in android. possible store ssl session? how making requests? seeing separate handshakes every new request particular host , how frequently? i think underlying security libraries on android, sun's jsse, automatically cache tls session id when you're working particular host.

Strange Lightbox / iframe / Java applet issue on Firefox -

i'm beating head against strange issue using combination of java applet running in iframe displayed inside lightbox on firefox. when page displayed directly javascript call applet document.appletname.send functions perfectly, when called inside lighbox (actually lightwindow ) error returned error: document.appletname.send not function this occurs on firefox in windows. ie, safari , chrome fine, firefox on ubuntu for information applet wirefusion 3d presentation , can see applet running via lightbox box clicking on highland laddie 3d @ bottom of page , or directly in page containing lightbox . i've tried adding javascript diagnostic code check applet exists , has correct name (it does). odd thing can see firefox applet appears start loading twice. added: in response question. page being called in lightbox simple, <div style="position:absolute; top:0px; left:0px"> <iframe id="mainframe" src="http://www.tartanweb.com/ladd...

language agnostic - One-liner for checking if integer is of form 2^1-2^j using bitwise operators -

i want 1 line code check whether given integer of form 2 i - 2 j or not. (using bitwise operators) as andreyt says, answer can found in hacker's delight : use following formula turn off rightmost contiguous string of 1-bits (e.g., 01011000 ⇒ 01000000): ((x | (x – 1)) + 1) & x this may used see if nonnegative integer of form 2 j – 2 k j ≥ k ≥ 0; apply formula followed 0-test of result. (was debating whether post this, it's homework question, andreyt mentioned , it's googlable, figure it's more helpful quote directly; i'll let questioner deal ethical implications of accepting on homework, , expect if answer depends on this, write explanation of how works himself)

java - Red5: Create server side thumbnails of video streams? -

i have flex video streaming application using red5 streaming server. need generate thumbnails of streams every x seconds display them on web page. know, possible create client side thumbnails via flex application generates stream, possible create thumbnails on server side? try ffmpeg , can generate video thumbnails on server side.

How To Include a PHP File Site-wide Using .HTACCESS or other methods -

i want include php file googleanayltics.php on every page on webserver .php or .html document i know: a) how add right before </head> tag b) how add right right after <body> tag i'd know both methods flexibility i think .htaccess accomplish easily, , if know how, or if know of easier method please share. p.s. not want manually go in , enter code on every file, why asking question (for time saving) edit: see wanted (was hidden due formatting). although possible, clumsy thing do, , not worth effort. see other answer way that. there 2 php.ini settings might interested in: auto_prepend_file , auto_append_file they can changed via .htaccess (see other answer). notes : these included before or after whole php script; not in specific sections of output. they affect files handled go through php, means html files not included, unless server set pass html files through php. can done adding following line .htaccess: addtype app...

java - Can I somehow overwrite JMS provider behavior in messaging? -

i know might sounds ridiculous experts, however, it's been in head quite while , still no concrete answer found. in publish/subscribe messaging jms topics : jms publisher sends msg jms provider, , jms provider sends msg jms subscribers , receives acknowledgement. is possible can somehow modify jms provider, jms producer sends out every other message receives jms publisher? totally newbie in field, suggestion welcomed. if want subscriber able configure receive messages in batches, each subscriber can have different batch size, jms not provide functionality. not typical pubsub type scenario. if want accomplish this, suggest add custom buffering on subscriber side queue incoming messages , batch notify when queue full. configured on per subscriber basis. the messaging system know provides similar functionality pubsub in xmpp , batches determined timed interval instead of number.

c++ - SFINAE canAdd template problem -

i'm trying tow write sfinae template determine whether 2 classes can added together. better understand how sfinae works, rather particular "real world" reason. so i've come is #include <assert.h> struct vec { vec operator+(vec v ); }; template<typename t1, typename t2> struct canbeadded { struct 1 { char _[1]; }; struct 2 { char _[2]; }; template<typename w> static w make(); template<int i> struct force_int { typedef void* t; }; static 1 test_sfinae( typename force_int< sizeof( make<t1>() + make<t2>() ) >::t ); static 2 test_sfinae( ... ); enum { value = sizeof( test_sfinae( null ) )==1 }; }; int main() { assert((canbeadded<int, int>::value)); assert((canbeadded<int, char*>::value)); assert((canbeadded<char*, int>::value)); assert((canbeadded<vec, vec>::value)); assert((canbeadded<char*, int*>::value)); } this compiles except last line, gives fina...

javascript - how to update Sr. No. COLUMN after removing a TR from TABLE -

i have table <table> <tr> <td>sr. no.</td> <td> name</td> <td>$nbsp;</td> </tr> <tr> <td>1</td> <td>abc</td> <td>remove button</td> </tr> <tr> <td>2</td> <td>xyz</td> <td>remove button</td> </tr> <tr> <td>3</td> <td>def</td> <td>remove button</td> </tr> onclick of ' remove button ' send ajax request & after successful response remove respective tr using $('#id_of_tr').remove();. till here goes fine want update sr. no.s of each row. because order 1 2 3 , when remove second row becames 1 3 want update 1 2. i hope help. like this: // ajax call $.post('/delete', {id: 2}, function(data){ // code removes tr here $('table tr').each(function(index, el){ $(this).find('td:firs...

unix - delete the first 5 chars on any line of a textfile in Linux with sed -

i need 1liner remove first 5 chars on line of text file, dont know sed, me please? sed 's/^.....//' means replace ("s", substitute) beginning-of-line 5 characters (".") nothing . there more compact or flexible ways write using sed or cut.

windows - How to read data using ReadFile when file has disabled sharing on read -

i have problem, have file opened other process , process defined in createfile non file sharing, have other application , want read data file in same time, how do. i can't change file sharing in first application. can reach computer administrator right's, can changes in system, "code" solution better problem if can done code. can me? how using easyhook , hook in api createfile routine, in effect, code intercept api , possibly change dwsharemode parameter make file_share_read bitwise or file_share_write i.e. (file_share_read|file_share_write) , call original hook allow createfile work normally...

find left and right turn in android mobile -

how find out mobile turn left , right.depending on left , right turn need 1 ball? you need implement sensorlistener detect phone shaking. // need implement sensorlistener public class shakeactivity extends activity implements sensorlistener { // shake motion detection. private sensormanager sensormgr; private long lastupdate = -1; private float x, y, z; private float last_x, last_y, last_z; private static final int shake_threshold = 800; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ...... // other initializations // start motion detection sensormgr = (sensormanager) getsystemservice(sensor_service); boolean accelsupported = sensormgr.registerlistener(this, sensormanager.sensor_accelerometer, sensormanager.sensor_delay_game); if (!accelsupported) { // on accelerometer on device sensormgr.unregisterlistener(this, sensormanag...

asp.net mvc - If(ModelState.IsValid==false) return View(); or View(model);? -

when validation fails, 1 should return? view(); or view(model); ? i notice both work. confusing. edit: public class moviescontroller : controller { moviesentities db = new moviesentities(); // // get: /movies/ public actionresult index() { var movies = m in db.movies select m; return view(movies.tolist()); } public actionresult create() { return view(); } [httppost] public actionresult create(movie movie) { if (modelstate.isvalid) { db.addtomovies(movie); db.savechanges(); return redirecttoaction("index"); } else return view();//view(movie); } } my create.aspx: <% using (html.beginform()) {%> <%: html.validationsummary(true) %> <fieldset> <legend>fields</legend> <div class="editor-label"> <%: html...

rsync - Rsynch and SSH: Only rename folder when renamed from source -

i have been reading rsync documentation few hours, can't figure out how convey rsync how rename (and not re-upload folder , it's content) destination folders when renamed @ source. i'm connecting destination ssh, , local folder source -- , remote server destination. if rename folder containing files, rsync automatically re-uploads content of source folder. i'm not using rsync's server part, maybe works if ? i have encountered same behavior lftp, , tool doesn't seem's have these options. if based on file's date rule, files inside renamed folder removed/re-uploaded. thanks in advance if knows how manage :) how rsync or other program know constitutes renamed? if 2 directories similar candidates , somehow rsync guesses maybe either 1 rename of went before? it's not possible. think you're stuck uploading again. you know --delete option, right: --delete delete files don't exist on sending side note --force option: ...

SonarQube Category Explanations -

can suggest one/two line explanation of "five" sonarqube categories, in such way non-developer can understand percentage figure means? efficiency maintainability portability reliability usability one word "synonym" non-developers (not exact synonym though, enough give quick idea): efficiency : performance maintainability : evolution portability : reuse reliability : resilience usability : design most of metrics presented in wikipedia entry efficiency: efficiency metrics measure performance of system . effective metrics program should measure many aspects of performance including throughput, speed, , availability of system. maintainability . ease product can maintained in order to: correct defects meet new requirements make future maintenance easier, or cope changed environment . portability: the software codebase feature be able reuse existing code instead of creating new code when moving softwa...

internet explorer - <div> resize handle in AJAX RadEditor appearing in IE -

i using ajax radeditor telerik in cms working on. seems work in firefox, have noticed strange behavior in ie. namely, when content put in , becomes difficult manage. clicking on content contained in creates striped border, resize handles attached it, around full area of . tends include area outside containing radeditor. causes cursor turn drag cursor , makes content draggable. makes difficult select content. this happens in ie, , i'm wondering if there way disable behavior. frustrating clients in attempts use cms, , unfortunately switching firefox not workable solution them. has else encountered this? i don't think default editor behavior - in case can compare ie , firefox on radeditor online demos . behavior on site caused global css style, applied in editor content area.

c++ - book about smart pointers -

could let me know books explains ideas of smart pointer (beginner, intermediate , advanced level)? thank you. a little more advanced, book modern c++ design has lot of worthy content. luckily enough chapter smart pointers available online . take note however, functioning , design, not usage, should treated advanced level.

php - Programmatically adding Wordpress post with attachment -

i getting post_title, post_content , other things in $_request image file. want save post in wordpress database. have on page <?php require_once("wp-config.php"); $user_id; //getting function $post_title = $_request['post_title']; $post_content = $_request['post_content']; $post_cat_id = $_request['post_cat_id']; //category id of post $filename = $_files['image']['name']; //i got in array $postarr = array( 'post_status' => 'publish', 'post_type' => 'post', 'post_title' => $post_title, 'post_content' => $post_content, 'post_author' => $user_id, 'post_category' => array($category) ); $post_id = wp_insert_post($postarr); ?> this things in database post don't know how add attachment , post meta. how can that? can me? confused , have spent few days trying solve this. to add attachment, use wp_insert_attachment(): http:/...

c# - how to create a vpn software -

i want create application creates vpn between endpoints, hamachi and not have starting point. haven't found resource explain how create such network application.i want use c# because have experience it. need help, can put me on right way. thanks. there number of distinct elements of vpn software you'll have figure out: what technology/standard program use provide privacy? common ones ipsec, l2tp, pptp, ssh, , ssl. web searches ought turn rich information (including rfcs) on of these. if you're doing learning exercise, rather needing actual security, design own. are implementing client, server, or both? what operating system(s) support? affects need convince route packets through application. do plan interoperate software implementing standard?

mysql - Selecting a node in the nested set model through a not-unique name -

i trying manage retrieval of node in nested set model table, not through unique id, through name (a string), , other nodes within tree under different parents may called same way. as far used unique id nodes inside nested sets: select node.name, node.lft, node.rgt tbl parent, tbl node node.lft between parent.lft , parent.rgt , node.id = '{$node_id}' group node.id trying extend method more general way retrieve node through name, came query containing having clauses depth of node retrieve, checking node name , depth: select node.name, node.lft, node.rgt, count(node.id) depth tbl parent, tbl node node.lft between parent.lft , parent.rgt group node.id having (node.name = 'myparentname' , depth = 1) or (node.name = 'myparent2name' , depth = 2) or ... # , on but not perfect: having 2 nodes same name , same depth, within different parents, both retrieved, no matter hierarchy belong to. example: articles | +...

Specify order/location of swt widgets in a composite object? -

i create widgets before inserting them swt composite parent. understand parent specified in constructor when child created: composite container = new composite(parent, swt.null); gridlayout layout = new gridlayout(); container.setlayout(layout); layout.numcolumns = 3; layout.verticalspacing = 9; ... // create child @ first row leftmost location label labelconfigurator = new label(container, swt.null); labelconfigurator.settext(title); is possible somehow separate creation of widgets insertion/placement parent container? no, there isn't. there's little bit of explanation here . depending on want, factory might you; in past i've used this: public interface viewerfactory { text gettext(composite parent); contentviewer getlistviewer(composite parent); label getlabel(composite parent); } with implementation private final class viewerfactoryimpl implements viewerfactory { @ override public label getlabel ( composite parent ) { ...

ruby on rails - Check on TEST mode during runtime -

my web application writes kind of log during runtime. don't want write log when running test suite using cucumber. so, how can check current runtime environment (test, dev or prod)? i'm looking c equivalent i.e. : #ifdef debug    // run in debug mode #endif thank helping me on this. try if condition: if env['rails_env'] == "test" # insert code here end (replace 'test' 'development' or 'production' needed)

joomla contact form doesn't give confirmation -

i'm using joomla! 1.5.15 (with custom template) , i've created contact form. unfortunately can't work; when fill form in , click "send", nothing happens - form gets reloaded (empty) neither success nor error message. what can improve on this? thanks patrick check see if problem remains using 1 of default joomla templates. simle not including "message" block in own template

compiler construction - C++: debug bus error -

i trying compile c++ program in linux, using command in shell $ g++ -wall *.cpp -o prog and reason keeps on giving me weird error: g++: internal error: bus error (program cc1plus) please submit full bug report. see instructions. i searched net bus error, , says has accessing illegal memory. can maybe clarify things bit more me? this error message telling there's bug in g++ compiler itself. try narrow down removing bits , pieces of source file until problem goes away. you're not trying fix program, you're trying find part breaking compiler. once you've found it, can either give better bug description or can change code work around it. or download latest version of g++ compiler , hope it's fixed.

spring security - How to access User object in grails controller -

i'm using spring security, , need user domain object in controller. if call springsecurityservice.getprincipal() , object of type org.codehaus.groovy.grails.plugins.springsecurity.grailsuser . however, i'm looking user domain object i've defined in config.groovy so: grails.plugins.springsecurity.userlookup.userdomainclassname = 'project.auth.user' how can best @ user domain object? load user instance using cached id in grailsuser instance: def user = user.get(springsecurityservice.principal.id)

iphone - Objective C - Animation Blocks, multiparameters -

i have question... how programmatically reached animation blocks? [uiview beginanimations:@"repositionanimation" context:nil]; // ----------------------------------------------------------------------------- [view setframe:viewrect]; [view setalpha:0]; ... ... // ----------------------------------------------------------------------------- [uiview commitanimations]; how messages stored , processed on commitanimations ??? i guess begin function invokes kind of holder messages, storing messages somehow , process them in loop ? is there way work messages kind in argument lists??? you using animation proxy when call [uiview beginanimations:context:]. if want manage animations explicitly, use core animation . can monitor progress of view's layer periodically (using timer) checking layer's presentationlayer .

How to apply groupname to HTML radio buttons in asp.net? -

can please tell how apply group name html (input) radio button controls can select 1 of available radio buttons? i have input radios in table. each row contains 2 radios follows. want select 1 each row. able select 1 radio button amongst radio buttons present on rows. <input name="radiobutton" type="radio" value="radiobutton" />option1 <input name="radiobutton" type="radio" value="radiobutton" />option2 what change have make select 1 radio button on each row? thanks, ~kaps as far know, radiobuttons in html not have group names. html "name" attribute is group name. it important verify each radiobutton has unique "value" attribute. otherwise there no way tell of duplicate values selected: <input name="radiobutton" type="radio" value="radiobutton1" />option1 <input name="radiobutton" type="radio" value="radio...

ActionScript - Save webcam video to local disk without using AIR or FMS -

i save webcam captured video local disk using as. application running in standalone flashplayer 10. can save pictures bytearrays using file.save, can't find way doing video. there nice implementation using , air @ http://www.joristimmerman.be/wordpress/2008/12/18/flvrecorder-record-to-flv-using-air/ . don't want have install air before running app. ideas? thanks, basti flash designed secure, won't able save sharedobject data on local storage.

asp.net - HtmlAgilityPack expression to get this? -

hi going through html string htmlagilitypack. need between tagg. looks this. <left> <table>..</table> <table>..</table> <table>..</table> <table>..</table> <table>..</table> </left> now use expression task. edit: var htmlresult = doc.documentnode.selectnodes("//left"); foreach (var item in htmlresult) { litstatus.text += item.innerhtml; } i 6 first there 24 tables. why, ideas? <left> <table width="100%" border="0" cellspacing="0"> <tr> <td width="100" valign="top" ><font size="2" face="verdana">2010-01-29&nbsp; </font> </td> <td valign="top" width="342" > <div align="left"><font size="2" ...