Posts

Showing posts from February, 2012

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Preventing cheating for on-line arcade high score board -

i'm going developing online arcade html5/javascript games written in to-be-released ide. the game use ajax requests server record scores when people play these games. i theoretically have complete control on design of this, including mechanics of code logs high scores, game code, everything. i know it's never impossible hack client side games such or spoof high scores, want make difficult enough competent enough wont bothered enough (wishful thinking). i've read: how can prevent bogus high scores appearing on global high score list? which slightly different question html/js specific. my initial idea ajax request checks source of request correct location, simple , effective block hacking attempts. as previous answer stated cannot trust client, therefore best bet split game levels of sort , have server control level progression. if server tracking each client , progression can limit range of scores achievable. makes more tedious cheat client has

xml - Is it possible to use wildcards with XInclude tags? -

i'm afraid it's not possible, haven't found anywhere said impossible either. i'd include set of files within xml document using wildcards. this: <?xml version="1.0" encoding="utf-8"?> <mydocument> <!-- ... --> <xi:include href="*include.xml"/> </mydocument> i know doesn't work, think expresses intentions. there way achieve this? edit: i tried use xpointer attribute, couldn't make work. is possible use wildcards xinclude tags? no. href denotes uri, , these not have concept of wildcards. otherwise possible mirror google homepage saying href="http://www.google.com/*" . hint: file systems not have concept of wildcards. shells do. heavy lifting of filling in blanks when parse path , see * . underlying file system never gets see asterisk.

Peristence Web Service for Rich Client Java (Swing) applications -

i rewriting client-server rich client database application (swing) three-tiered application netbeans rcp rich-client. by default hibernate , other jpa providers can used in very cumbersome way rich clients (native database connection not cutting through firewalls, loosing lazy-loading, conceptual problems managing session/entitymanager lifecycles...etc other problems). 1 needs kind of extension using them comfortably in rich clients. normally, rich clients call webservices in business logic tier (on server). usually, dedicated web-service methods handle crud operations of every object type. now, i wouldn't write custom web-service crud operations of each , every persistent class of application thought there may generic persistence web-service these kind of operations can handle @ least of crud operations of application. is there such persistence service??? here details of ideas/requirements: the service should work jpa-annotated pojos should use kind jpa p

c# - Filtering a collection of objects by ID -

teaching myself c# , problem have class creates person objects , adds them list (mypersonlist). have partygroup class takes personlist 1 of properties. issue mypersonlist contains whole results set @ moment each time creates new partygroup adds values in mypersonlist. there way tell add values in mypersonlist person.partygroupid matches current partygroup groupid dealing with. hope makes sense. thanks. //person using (asedatareader reader = commandperson.executereader()) { while (reader.read()) { person person = new person(); person.personid = convert.toint32(reader["person_id"]); person.partygroupid = convert.toint32(reader["party_group_id"]); person.fullname = reader["full_name"].tostring(); mypersonlist.add(person); } } //partygroup using (asedatareader reader = commandpartygroup.executereader()) {

Bash process substitution and syncing -

(possibly related do programs not accept process substitution input files? ) in bash unit test scripts i'm using following trick log and display stdout , stderr of command: command > >(tee "${stdoutf}") 2> >(tee "${stderrf}" >&2) this process produces output stdout, $stdoutf file gets data. run command not output data: diff -r "$source" "$target" > >(tee "${stdoutf}") 2> >(tee "${stderrf}" >&2) however, doesn't process finishes before test emptiness run (using shunit-ng ): assertnull 'unexpected output stdout' "$(<"$stdoutf")" in 100 run test failed 25 times. should sufficient call sync before testing file emptiness: sync assertnull 'unexpected output stdout' "$(<"$stdoutf")" ... and/or should work forcing sequence of commands: diff -r "$source" "$target" \ > >(tee &

html - Able to float td elements consistently? -

it's getting late , i'm rapidly losing ability think. is possible float <td> elements consistently across few decent browsers? seems work in firefox, hear bad things ie i'm free of shackles project. really, i'm concerned chrome's lack of want play. edit: if helps @ all, extremely lax browser compliance time 'round, expect deploying app controlled user group, , tool, not model of perfect code - i'm willing blind-eye dirty hack if there's 1 going. while floating td weird , shouldn't done, call make them display:block before trying else. i'd need see code in order more specific do.

select - Why is TOAD faster than my java code? -

i want execute select query , able count of results, without using "count(*)", toad does. concept give option user input 'select query' wants , count number of results him. try { selectstatement = globalconnection.createstatement(resultset.type_scroll_insensitive, resultset.concur_read_only); resultset selectresultset = selectstatement.executequery(selectstatementstring); selectresultset.last(); int countofresults = selectresultset.getrow(); writeinlabel(kllstatuslabel, "count finished: found " + countofresults + " inserts"); } catch (sqlexception ex) { writeinlabel(kllstatuslabel, "error executing select query."); } this code delays in line: "selectresultset.last();". toad less delay. (right-click -> record count). when scroll results table way down in toad faster. how toad record count? ok got it, use count(*) , have second resultset show results. resultset selectresultset = selectstatement.e

ios - Server side database for iPhone -

i have problem connection of server-side database @ iphone application, trying create application shows database informations. should works @ read-only procedure.i have jsp page @ login , think should wrote web-service api json. not know how reach system using authorization method (user,pass---server side , personal database). please me solve problem. probably want: basic http authentication on iphone

iphone - How to move an image inside the imageview to the upper end of the imageView? -

i have imageview contentmode uiviewcontentmodescaleaspectfit. resizes image without changing aspect ratio. image inside imageview horizontally , vertically centred. i don't want vertically centred. how can move image upper end of imageview? i think should make custom uiview in can have uiimage property (just uiimageview has) , need on ride 'drawrect' method of uiview , draw image @ appropriate position using [image drawinrect:rect]; method, check documentation find stuff aspect ratio while drawing... in uiimageview, image's x,y position can't changed..

OpenID setup possible with default trusted sites? -

this may obvious some, @ stage of putting spec , not have direct experience in setting openid server or consumer. we have central members' database used authentication, , number of satellite sites need authenticate users against members' database. intention use openid (one of standard php libraries) provide single-signon across group of sites. now, sites trusted. user logging in of sites should automatically trusted central authorisation site, , members details should passed across without question or further prompting. there no advantage exposing openid server other consumers group of trusted sites, if end doing that, usual requests permission , management screens presented user. so, going simple enough thing do, i.e. make these sites trusted server? "simple", asking whether fights against core principles or operation of openid. how openid key list of trusted sites - url consumer, or kind of coded "trust key" put unique user , consumer site? i

Clicking <input type="image" /> using WebDriver , InternetExplorerDriver -

i trying click on image input type using webdriver , not working. html code : <input type="image" onclick="validationandsubmit('next'); return false;" alt="continue" src="/subscriptions/versions2/commonlab/images/buttons/continue.gif" name="continue"> the code using click : driver.findelement(by.name("continue")).click(); i invoke javascript below ,but not intent. ((javascriptexecutor)driver).executescript("validationandsubmit('next'); return false;"); i simulate end user experience on ie as possible. what should in order click image input. thanks jenga

deadlock - Small openmp programm freezes sometimes (gcc, c, linux) -

just write small omp test, , not work correctly times: #include <omp.h> int main() { int i,j=0; #pragma omp parallel for(i=0;i<1000;i++) { #pragma omp barrier j+= j^i; } return j; } the usage of j writing threads incorrect in example, there must nondeterministic value of j i have freeze. compiled gcc-4.3.1 -fopenmp a.c -o gcc -static run on 4-core x86_core2 linux server: $ ./gcc , got freeze (sometimes; 1 freeze 4-5 fast runs). strace: [pid 13118] futex(0x80d3014, futex_wake, 1) = 1 [pid 13119] <... futex resumed> ) = 0 [pid 13118] futex(0x80d3020, futex_wait, 251, null <unfinished ...> [pid 13119] futex(0x80d3014, futex_wake, 1) = 0 [pid 13119] futex(0x80d3020, futex_wait, 251, null <freeze> why have freeze (deadlock)? try making private each loop has it's own copy. now have more time, try , explain. default variables in openmp shared. there couple of

git - Hosting-specific code in projects: push to Github too? -

imagine common scenario: hacked cool project want share world. so: put on github, , fetch github on own website people can see demo. makes updating easy: push local box github, fetch on server. i'd track visitors add google analytics , maybe other site-specific stuff (like global header pages on site) project. however, checks out project github gets stuff too. there few solutions prevent that. make specific 'deployment branch' website, that's cumbersome. make kind of switch in code ( if ip === myip showstats() ), that's ugly. another option might use githooks, haven't got experience that. any other suggestions? people bothered when getting deployment-specific code in checkouts? similar breun's suggestion, (so question double answered) deploy python projects settings.py file defines settings needed on production machine. (debug=false, proper database settings , file paths...) at end of file, try import developmentsettings.py this: try

java - build maven project with propriatery libraries included -

this question has answer here: how add local jar files maven project? 20 answers how create maven pom, make project buildable, can include propriatery jars project directly without having take them repository? did before ? edit : i don't want make runnable building assembly dependencies jar, want buildable. having project able build it, if jars found @ repository. 1 either can include jar in classpath of application 2 can install particular jar file in maven reopos by mvn install:install-file -dfile=<path-to-file> -dgroupid=<group-id> \ -dartifactid=<artifact-id> -dversion=<version> -dpackaging=<packaging>

actionscript 3 - How to organize multiple flash projects sharing common lib as for classpaths -

let's have multiple projects organized as commonlib superorg org1 suborg11 suborg12 org2 suborg21 how declare import , manage classpaths classes in commonlib package ? in either flash ide or flash builder can specify global classpaths. way import statements same across projects without having million copies of files. heres tut - http://asgamer.com/2009/easily-use-frameworks-in-multiple-projects-by-setting-a-global-class-path

Linq help with SQL in() statement -

i need writing linq statement same following sql query... select col1, col2, col3 table1 col1 = 'foo' , col2 = 0 , isnull(col3, '') in('a','') thanks from t in context.table1 t.col1 == "foo" && t.col2 == 0 && (new string[]{"a", string.empty}).contains(t.col3.defaultifempty(string.empty)) select new {t.col1, t.col2, t.col3};

logging - How to log an int on Android? -

log.d(getclass().getname(), "bla bla bla"); to log. how can show int value? equivalent of c's %d , on? you can use string concatenation: log.d(getclass().getname(), "value = " + intvar); or more flexibly (and similar c-style printf) can use java's string.format() : log.d(getclass().getname(), string.format("value = %d", intvar));

ruby on rails - Turn omniauth facebook login into a popup -

i'm using omniauth gem rails , works great loging in users, everytime takes fb login page redirects back. wondering if there way pages , show fb login in popup , reload parent div once complete. ideas? thanks! sure, can easily. in view: =link_to "log in facebook", omniauth_authorize_path(:user, :facebook), :class => "popup", :"data-width" => 600, :"data-height" => 400 in application.js: function popupcenter(url, width, height, name) { var left = (screen.width/2)-(width/2); var top = (screen.height/2)-(height/2); return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top); } $("a.popup").click(function(e) { popupcenter($(this).attr("href"), $(this).attr("data-width"), $(this).attr("data-height"), "authpopup"); e.stoppropagation(); return fa

C/C++ function using float or double or int -

i have seperate functions reading text file (depending on whether int, float or double). one function additional argument (without using subsequent if statement). have ideas? below form of current functions. float * read_column_f (char * file, int size_of_col){ ... col = (float*) malloc (height_row * sizeof(float)); ... return(col);} double * read_column_d (char * file, int size_of_col){ ... col = (double*) malloc (height_row * sizeof(double)); ... return(col);} int * read_column_i (char * file, int size_of_col){ ... col = (int*) malloc (height_row * sizeof(int)); ... return(col);} edit: want implement in c++, c-style syntax used due memory preference. you can't overload on return types. either return value reference function parameter: void read_column (char * file, int size_of_col, float&); void read_column (char * file, int size_of_col, int&); ... or create template: template<class t> t read_column (char * file, int size_of_

detailsview - Details View in Asp.net, Set it to NEW -

i have grid view on page, , hidden details view. when user wants add new entry, click button, , gridview become hidden , details view become visible. problem want details view automatically set empty in new mode, without them having click new in details view form. in rowcommand event of gridview: mydetailsview.visible = true; mydetailsview.currentmode = detailsviewmode.insert; mygridview.visible = false;

wix - Display files in a directory list control -

is there way user select specific file using browsedlg? can find can select folder!! believe file selection 1 of "common" functionality in use. can provide suggestion on how can achieved. thanks! update i thinking of creating c# custom aciton this, other ca in project in c#. not sure few things.... how can sequence ca dialog exsiting ui sequence. how trigger ca on button click 1 of custom dialog. how file path file browse ca further used wix. the other cas have created not have ui associated. please advice. thanks! actually, windows installer doesn't have built-in "browse file" dialog. various vendors offer custom solutions, advanced installer , installshield . anyway, ends in custom dialog , custom action browse button. can find example of here (search "file browse dialog" on page). package you'll find contains custom action, sample solution , notes. based on installshield, can take @ least custom action there (

c# - Why can't I return only in a nested body of my Method and not be forced to return in the scope of the main method? -

why if declare return type on method, have specify return in scope of method? meaning, if have if/switch in method can't specify return there "alone" , not in main method body? way around assign value returned nested procedure variable , return variable in main body of method? example: public int getnum() { var = 1; switch(a) { case 1: return 1 + 5; default: return a; } return a; //why must specify return if going hit switch statement //and return int. } if have default , that's not necessary. if don't have default , need outer return in case none of case s execute.

c++ - invalid conversion from 'DWORD (*)(void*)' to 'DWORD (*)(void*)' -

invalid conversion 'dword (*)(void*)' 'dword (*)(void*)' . cake==lie 1==0 i have no idea means ... in code handle cplugin::createwinampthread() || { __vvvvvvvv__ hwinampthreadhandle = (handle)createthread(null, 0, startwinampthread, (void*)this, 0, &dwwinampthreadid); if (!hwinampthreadhandle) return 0; closehandle(hwinampthreadhandle); return hwinampthreadhandle; } . dword winapi cplugin::startwinampthread(void* lpparam)[...] startwinampthread must static if member function.

url rewriting - Making Clean URLs in this situation -

this question hard search don't know keywords use, altho ive tried still cant find answer. i have database driven website: www.abc.com , every page this www.abc.com/?page=somepage www.abc.com/?page=another_page www.abc.com/?page=yet_another_page i use index.php read value of "?page" , load required page according value of "?page" since "?page" common how can simplify urls like www.abc.com/somepage www.abc.com/another_page www.abc.com/yet_another_page thanks edited on further thinking, want bit more specific it... problem is... how make in way when address www.abc.com/somepage typed in address bar, should process address if www.abc.com/?page=somepage , not go direct /somepage if folder try : # rewrite urls of form 'x' form 'index.php?q=x'. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !=/favicon.ico rewriterule ^(.*)$ index.php?page=$1

javascript - Select element with specific data by using jQuery -

is possible set data using jquery data method , later query it? ... find elements data foo == true? you can use .filter() select elements want, this: $("someselector").filter(function() { return $.data(this, "foo"); }); in case since you're checking boolean it's simple, checking against value add comparison, this: $("someselector").filter(function() { return $.data(this, "foo") == "value"; });

asp classic - Use asp include to include asp.net page -

i have asp page uses includes include pages depending on query string. have built addition page in asp.net , want include new page in asp page, error. active server pages error 'asp 0140' page command out of order /d//default.aspx, line 1 @ command must first command within active server page. you can't include asp.net pages inside of asp page. do, however, have couple of options. the easiest include asp.net page iframe on asp page. can use asp dynamically set url of iframe on server side. the other option write wrapper .net dll render page via method. register dll in com+ called vbscript in asp pages. more complicated. if first option works, go it. otherwise might have figure out how implement second.

c# - Loading XML or XHTML content with html encoded or escaped characters -

i'm developing class content management system. input content supplied in xhtml format. , can contain valid escaped characters &#163; see example below. <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head xmlns=""> <meta name="attr_documenttitle" content="hello world books" /> </head> <body> <div>british pound &#163;</div> <div>registered sign &#174;</div> <div>copyright sign &#169; </div> </body> </html> my objective write method loads xml .net object processing , save database. want maintain escaped characters are. , here method: public static xmldocument loadxmlfromstring(string xhtmlcontent) { byte[] xhtmlbyte = encoding.ascii.getbytes(xhtmlcontent); memorystream mstream = new memorystream(xhtmlbyte); xmlreadersettings settings = new xmlreadersettings(); //

WPF Binding: How to databind to Grid? -

i have created class account . next, have created class reorderwindowcontroller has field/property selectedaccount of type account . finally, have written reorderwindow wpf window xaml file: <window ... <window.resources> <contollers:reorderwindowcontroller x:key="windowcontroller" /> <datatemplate datatype="{x:type entities:account}"> <grid width="140" height="50" margin="5"> <textblock text="some awesome text" /> <textblock text="{binding name}" /> <textblock text="even more awesome text" /> </grid> </datatemplate> </window.resources> <grid> <grid name="accountgrid" datacontext="{binding source={staticresource resourcekey=windowcontroller},

java - IntelliJ IDEA - caret behavior -

Image
i trying figure out 1 thing in intellij idea 10: current caret position where caret moves after pressing down arrow where want caret be is such setting possible? file | settings (or preferences on mac) | editor | allow placement of caret after end of line :

prevent page repositioning after editing with jQuery -

i'm updating several image src attributes on page, , updated properly, when jquery updates items, page scrolls down items (they below 'fold') - how can stop page auto-scrolling down changes i'm making jquery? see same behavior ie , firefox // insert images current page $("img.nominphoto",$(".nominwrap")).each(function(){ var useritemid=$(this).attr("title"); $(this).attr("src",hashimageurls[useritemid]); }); thanks you may able fines using $(window).scrolltop , maybe hooking image's load method using .one() triggers releases (reset scrolltop when it's completed loading)--but hack @ best. if you're not (and assuming images fixed-height , width) it's "proper" specify width/height of image. allows renderer layout page (despite missing or updated content), prevents image(s) [re]loading having adverse effects later on.

django - Get all object with empty set of related ones -

i've got 2 models: class content(models.model): content_type = models.foreignkey(contenttype) object_id = models.positiveintegerfield(db_index=true) content_object = generic.genericforeignkey() show = models.booleanfield(default=false) class foo(models.model): rel = generic.genericrelation(content) and want foo methods that's related content object (there one) has show==true or doesn't have related object @ all. like: foo.objects.filter(q(rel__show=true) | q(rel__hasnone=true)) but of course there's nothing hasnone in django. is there other way in can accomplish (unfortunately aggregation doesn't work generic relations , can't count items). ok, think i've answer satisfy of (unfortunately not me). what need left outer join django doesn't support (all joins declared user inner ones), like: select *, `foobar_bar`.`show` `show` `foobar_foo` left outer join `foobar_bar` on (`foobar_foo`.`id` = `foobar_bar

Java algorithms -

i server side java programmer. in recent job search, have come across few postings mention : ' candidates expereince in algorithm development preferred'. refer to? posting bank...so not job research laboratory...just clarify bit. asked headhunter ...he not have idea this. when use java in applications, use apis implement algorithms...so technically not developing algorithms. right? "algorithm development" sounds vague. maybe original technical requirement knowledge of algorithms, , somewhere along way, thought didn't sound impressive enough, , rewrote "candidates experience in algorithm development preferred". i don't think means "the ability create new algorithms scratch". rather, need able recognize when program benefit use of known algorithm or data structure, or slight modification of one, , ability done. crucial skill on many projects, , speed important. the generic algorithms provided java class library (like arrays

html - If I have 3 <tr> elements, how do I only allow one to be highlighted when clicked at any one time? - CSS, jQuery -

might bit difficult understand based on description jsfiddle here: http://jsfiddle.net/n8a76/4/ basically want do, when click on of elements in first 3 boxes, want 1 element highlighted @ time. if click on 2 or 3 elements (names, projects, etc) right now, highlights 2 or three. unhighlights element when click again. so see, click element 1, element 1 highlighted. click element 2, element 1 (in same box) unhighlighted, , element 2 highlighted. so each box, code called dashed-panel , should independent of other. so in theory, john brown , jack's app ui highlighted @ same time. anyone have suggestions? you can remove class th sibling <tr> elements in same table, this: $(document).ready(function() { $('#clients table tr, #stages table tr, #projects table tr').click(function() { $(this).toggleclass('dash-elem-selected').siblings().removeclass('dash-elem-selected'); }); }); you can test out here , still allows toggl

c++ - How to check if a mouse is over a control -

how 1 check if mouse on hwnd? have tried using wm_mouseleave , wm_mousemove messages keep track, if click button , drag mouse out of button, doesn't receive wm_mouseleave until mouse released, late, because: when click button, wm_command message sent if: 1. mouse depressed on button 2. mouse on button 3. mouse released on button i need replicate functionality. to duplicate functionality, call setcapture() mouse messages sent window if mouse leaves it. can read current mouse position moves , determine if still on window/button (i'm still not 100% sure doing). and, when mouse button released, can call releasecapture() restore mouse messages sent. edit: oh, , can use windows api function windowfrompoint() determine window mouse over.

java - Why does Android's onItemClick want a long for row Id? -

for listview, when register onitemclicklistener, method specify looks this: public abstract void onitemclick (adapterview parent, view view, int position, long id) the id corresponds row user clicked on. question why long , not int? when use long? i've been casting int when use it, makes me think maybe i'm using wrong. i think comes straight sqlite : in sqlite, every row of every table has 64-bit signed integer rowid. rowid each row unique among rows in same table. given that, seems natural android apis specify 64 bits id database row.

html - Cloning with jQuery -

i have form allows users refer friends. want add link below 2 input fields, "friend email" , "friend name", clone "friend-box" 1 time , add below. in addition, name attribute of "friend email" , "friend name" name="friend_email[0]" , name="friend_name[0]" suggested here . what's best way clone , increment subscript? here's code: <div class="friend-box"> <div class="field"> <span><label for='friend_name'><strong>friend's name *</strong></label> </span> <input id='friend_name' name='friend_name[0]' type='text' /> </div> <div class="field"> <span><label for='friend_email'><strong>friend's email *</strong></label></span> <input id='friend_email' name='friend_email[0]&#

Can someone explain to me the pack() function in PHP? -

i know more pack() function in php: http://fi.php.net/manual/en/function.pack.php i know packs data binary, i'm not sure v v n n c c mean , wondering if kind , give me practical demonstration when use formats? the online documentation, change, lacks of information, in opinion. those represent how want data packing represented in binary format: so $bin = pack("v", 1); => 0000000000000001 (16bit) where $bin = pack("v", 1) => 00000000000000000000000000000001 (32 bit) it tells pack how want data represented in binary data. code below demonstrate this. note can unpack different format packed data as. <?php $bin = pack("s", 65535); $ray = unpack("s", $bin); echo "unsigned short val = ", $ray[1], "\n"; $bin = pack("s", 65536); $ray = unpack("s", $bin); echo "overflow ushort val = ", $ray[1], "\n"; $bin = pack("v", 65536); $ray =

Loading files in Prolog -

i going through prolog tutorial. telling me can load other prolog files typing: [filename]. but every time try getting error: load_files/2: arguments not sufficiently instantiated. the file in same directory 1 working in. here copy of entire query , error: 12 ?- [kb5]. error: load_files/2: arguments not sufficiently instantiated what doing wrong? $ cat junk.pl test(ok). $ prolog welcome swi-prolog (multi-threaded, 64 bits, version 5.8.0) copyright (c) 1990-2009 university of amsterdam. swi-prolog comes absolutely no warranty. free software, , welcome redistribute under conditions. please visit http://www.swi-prolog.org details. help, use ?- help(topic). or ?- apropos(word). ?- [junk]. % junk compiled 0.00 sec, 24 bytes true. it seems work fine me. of course i'm using atom file name, not variable. (kb5 variable name, not atom.) first try ['kb5'] , see if helps. next try [kb5] , see if helps. try absolute minimal example 1 provided , s

c# - -event- can only appear on the left hand side of += or -= -

i have event in loop. trying prevent same method being added event more once. i've implemented add , remove accessors. however, error stating that: itemsprocessed can appear on left hand side of += or -= when try call them, within same class. itemsprocessed(this, new eventargs()); // produces error public event eventhandler itemsprocessed { add { itemsprocessed -= value; itemsprocessed += value; } remove { itemsprocessed -= value; } } with explicit event, need provide own backing store - either delegate field or eventhandlerlist . current code recursive. try: private eventhandler itemsprocessed; public event eventhandler itemsprocessed { add { itemsprocessed-= value; itemsprocessed+= value; } remove { itemsprocessed-= value; } } then (and noting i'm being little cautious "about turn null " edge-case re threading): var snapshot = itemsprocesse

ssl - cURL/PHP Request Executes 50% of the Time -

after searching over, can't understand why curl requests issued remote ssl-enabled host successful 50% or of time in case. here's situation: have sequence of curl requests, of them issued https remote host, within single php script run using php cli. when run script requests execute successfully, reason of times run following error curl: * connect() www.virginia.edu port 443 (#0) * trying 128.143.22.36... * connected * connected www.virginia.edu (128.143.22.36) port 443 (#0) * set certificate verify locations: * cafile: none capath: /etc/ssl/certs * error:140943fc:ssl routines:ssl3_read_bytes:sslv3 alert bad record mac * closing connection #0 if try again few times same result, after few tries requests go through successfully. running script after again results in error, , pattern continues. researching error 'alert bad record mac' didn't give me helpful, , hesitate blame on ssl issue since script still runs occasionally. i'm on ubuntu server 10

multithreading - Stopping thread that doesnt throw Exception Android -

so im getting location fix phone , problem comes if never finds location or takes wayy long. below sample code loading screen how set timer stop thread(load screen) once amount of time has passed? lm.requestlocationupdates(locationmanager.network_provider, 1000, 10f, this); handler handler = new handler(); runnable showwaitdialog = new runnable() { int wait = 0; @override public void run() { while (loc == null) { } // after receiving first gps fix dismiss progress dialog dialog.dismiss(); } }; // create dialog let user know we're waiting gps fix dialog = progressdialog.show(weather.this, "please wait...", "retrieving gps data ...", true); thread t = new thread(showwaitdialog); t.start(); if want stop thread instead of using normal thread background jobs use android sdk's asynctask , there can find cancel() .

winapi - c++ create text fits edit box -

well.. know title not clear, couldn't think of better one. wanna know how this... when have edit box , can show 10 characters. this ssssssssss let have more 10 characters. of them go in back. have string "123456789010" show these ones "3456789010". problem characters small , don't take space , do. can't find way break string , characters in back. idea? you can calculate display-length of string in control (there several function that) , adjust size of control accordingly.

objective c - How to find the 404 error cause, when I am using a webview based application and the server fails in iphone sdk -

i implementing webview based application, in need find out way when 404 error occurred. anyone's appreciated. thanks all, monish. here need check status of request when finishes or fails in webview delegate method.` - (void)webviewdidfinishload:(uiwebview *)webview { int status = [[[webview request] valueforhttpheaderfield:@"status"] intvalue]; if (status == 404) { } } if doesn't out. check one. create nsurlrequest url want load. make connection using nsurlconnection. nsurlconnection has delegate method - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response which give the response server. please note if making connection on http, response of class nshttpurlresponse. nshttpurlresponse can used status using following instance method - (nsinteger)statuscode then check if status = 404 or not , if yes show alert view. in way able show html page , alert view both.

IIS Virtual Directory map to network drive (with drive letter) but fail to create file -

Image
i using c#/asp.net, iis6 on windows server 2003. map data server shared folder webserver driver letter v:\ on webserver, iis created virtual directory , pointed 'local location' v:\ . since there no 'connect as', not sure user used in webmethod, want create file on shared folder filestream.write(). i got io exception on action, hint? p.s. have added aspnet/network service on data server shared folder. thanks! gavin mapped network drives specific user account created them: using mapped drives iis - ms kb257174 the preferred method of accessing content web server exists on remote computer use shares follow universal naming convention (unc). it's network service (or if you're running asp.net under impersonation, site anonymous account) hasn't got mapping. to change location virtual directory points to, browse site in iis manager, right click on virtual directory , select properties. can select "a share located on c

JQuery create a form and add elements to it programmatically -

hi need create form , add elements programatically. $form = $("<form></form>"); $form.append("<input type=button value=button"); this doesn't seem work right. the 2nd line should written as: $form.append('<input type="button" value="button">');

java - HQL query for entity with max value -

i have hibernate entity looks (accessors ommitted brevity): @entity @table(name="featurelist_version") @secondarytable(name="featurelist", pkjoincolumns=@primarykeyjoincolumn(name="featurelist_key")) public class featurelist implements serializable { @id @column(name="featurelist_version_key") private string key; @column(name="name",table="featurelist") private string name; @column(name="version") private integer version; } i want craft hql query retrieves date version of featurelist. following query sort of works: select f.name, max(f.version) featurelist f group f.name the trouble won't populate key field, need contain key of record highest version number given featurelist. if add f.key in select won't work because it's not in group or aggregate , if put in group whole thing stops working , gives me every version separate entity. so, can help? t

wpf - MVVM framework AND Prism 4? -

i read question . has nice answers, on 1-year-old, , lot have changed in space on last year. of popular frameworks have come out in new mayor release such prism , mvvm light toolkit. my question somehow same, 1 twist, i'm using prism 4.0 because of region , module features. prism 4.0 embraces mvvm, feel there things "not lightweight", instance interaction requests. i'm thinking better use mvvm framework either substitute or supplement prism 4.0? there's nothing stop using mvvm framework in addition prism. we're using caliburn.micro , prism - there crossover in functionality provided, , many differences too. use whatever tool appropriate problem you're solving.

iphone - fetch request performance issues -

i have serious performance issues when querying sqlite database approx. 25k rows. want following: user types textfield want give him autocompletition suggestions in tableview inputaccessoryview of keyboard. each time enters new character, 4 new queries go off search appropriate suggestions. in seperate thread using gcd , blocks. performance low. here's code 1 query: - (void) querydatabase:(nsstring *) searchstring { [self.fetchedresults removeallobjects]; dispatch_queue_t fetchqueue = dispatch_queue_create("fetch queue", null); dispatch_async(fetchqueue,^{ nserror *error = nil; nsmanagedobjectcontext *context = [[nsmanagedobjectcontext alloc] init]; context.undomanager = nil; [context setpersistentstorecoordinator: self.persistentstorecoordinator]; nspredicate *predicate = [nspredicate predicatewithformat:@"reducedtownname %@", [searchstring stringbyappendingstring:@"*"]]; nsfetchrequest *request = [[nsfetchrequest a

css - Problem aligning divs next to each other? -

i want design: div1: auto-size div2: 160px divnumberonediv divtwo divnumberonediv divtwo divnumberonediv divtwo divnumberonediv divtwo divnumberonediv divtwo divnumberonediv divtwo how solve problem? i've tried stuff floating left & right, can't them on same line. i want div 2 there, , div1 have max-width of 40em, resize allow div 2 show @ times if necessary. my code: <style="text/css"> #mainbulk { padding: 1.5em 2% 1.5em .5em; } #ads { width: 7.5em; float: left; display: table-cell; padding: 0 0 0 2em; } #textcontent { width: 70%; float: left; display: table-cell; } </style> and <div id="mainbulk"> <div id="textcontent"> <p>this amazing site in world. has nice design, , perfect everything. if there's site can't do, nothing can it, i'd suggest try of site's features before complaining.</p> </div> <div id="ads"

java - Element removing while collection iterating -

i'm wondering going on behind scene when i'm executing following peace of code: list<object> list = new arraylist<object>(); fillthelist(); // filling list 10 objects int count = 0; (object o : list) { count++; if (count == 5) { list.remove(count); } o.tostring(); } once element removed i'm getting concurrentmodificationexception exception. i don't understand why after 1 of elements removing impossible take next 1 available in collection , proceed cycle. get iterator instead of using iterator in for loop: int count = 0; for(final iterator iterator = list.iterator(); iterator.hasnext();) { final object o = iterator.next(); if (++count == 5) { iterator.remove(); } o.tostring(); } edit : reason why concurrentmodificationexception because for loop using different iterator created before modification being made list.remove() , iterator has st

c# - Exception in property when setting a binary value -

i have following method gives me stackoverflow exception on setting value. can't step , debug application crashes few seconds later. here code public byte[] imagetiff { { try { string filepath = imagetiffdir + imageid + ".tiff"; if (file.exists(filepath)) { return file.readallbytes(imagetiffdir + imagecollectionid + ".tiff"); } else { return null; } } catch (exception e) { logger.log("can't read tiff image file.", e); throw; } } set { try { imagetiff = value; } catch (exception e) { logger.log("can't set image tiff.", e); throw; } } } this gets called during export , fails on first call: someimage.imagetiff = file.readallbyt

regex - PHP function to remove key from a query string -

i have query string, like: n1=v1&n2=v2&n3=v3 etc i want php function accept query string , name (key), , remove name value pair querystring. every example have found uses regexes , assumes value exist , not empty, in case (and possibly in general, know) valid query: n1=v1&n2=&n3 i don’t know in advance how many keys there be. i convinced regexes monsters eat time. matter in universe end in regex. parse_str('n1=v1&n2=&n3', $gets); unset($gets['n3']); echo http_build_query($gets); note: unset($gets['n3']); show-case example

c# - Displaying month-wise date in ASP.NET GridView -

i have asp.net gridview in want show dates selected month , year. month , year fields dropdownlist , bound xml data source. there easy or have use code behind add dates using iteration. you should able to, although (may) have careful xml. take @ this thread , darin indicates there bug in xmldatasource means can use attributes rather node values -- , see if helps.

WPF Binding - StringFormat - Not Formatting -

i have tooltip value set as: value="{binding path=dataitem.equitysold, stringformat=reserved (equity share: \{0\}%)}" the toolip displaying as: 72 but expect be: reserved (equity share: 72%) what wrong binding? have tried: <tooltip> <textblock text="{binding path=dataitem.equitysold, stringformat=reserved (equity share: \{0\}%)}" /> </tooltip>

namespaces - Execute a method of a different namspace by dynamic code in C# winforms -

i implementing dynamic code execution in c# allows users write own c# particular application. i using c# code compiler executing dynamic codes. c# compiler reads code file , construct code in new namespace (a complete new code), compiles , runs it. in other view base application host these. i have few methods present in host application want executed dynamic code. there way method of other namespace or application can executed? could force author of script implement interface, or wrap code own implementation.. something like public interface imyapplication { void dosomethinginmymainapp(); } public interface iscriptkiddie { void init(imyapplication app); } then l33t scripters can write public class myscript : iscriptkiddie //< emit { public void init(imyapplication app) //<could emit if scripter knows app keyword { app.dosomethinginmymainapp(); } } and in app can provide concrete implementation of imyapplication pass

What is the actual MSMQ address used by the respective WCF binding? -

this question related this one . given wcf binding uses net.msmq:// url, instance net.msmq://server/private/nc_queue , how can 1 know actual msmq address url translated? there kind of trace can activated? or external tool 1 capture address? thanks. edit1 ok, owe clarification. 1 can talk directly msmq through respective .net api. in case of msmq on native port 1801, use msmq address: formatname:direct=os:server\private$\nc_queue when msmq configured on http, address changes this: formatname:direct=http://server/msmq/nc_queue but wcf binding uses standard url describe address, like: net.msmq://server/private/nc_queue so, how can know actual msmq address (the 1 formatname) net.msmq:// translated? i don't understand question.... if use wcf netmsmqbinding , you're dropping off msmq messages msmq queue. have queue name you're dealing - not url..... net.msmq://server/private/nc_queue this translates msmq private queue called nc_queue on se

python - PyQt4.QtCore doesn't contain many of its classes and attributes -

i have built pyqt4 source , went smoothly until tried use of classes , attributes located in qtcore. reason qtcore missing lot of functionality , data should there. example pyqt4.qtcore import qt_version_str import error. there no errors or warnings given when building packages , have tried pyqt packages yum have same problem. has else encountered problem before? thanks. if it's importerror , suggests it's failing import library altogether. check it's somewhere that's in sys.path , , from pyqt4 import qtcore works. if library exists, , qt_version_str doesn't exist, give nameerror rather importerror .

linux - Disabling self-reception of UDP broadcasts -

i wish know there way can disable udp broadcast packet node not rcvd node itself. braodcast using inaddr_broadcast , on rcvr side using ai_passive | ai_numerichost. thanks arpit no, fundamental property of broadcasting - every host on subnet, including sender, have process packet way network stack. options are: switch multicast . preferred since multicast reduces load on whole network compared broadcast, , because can explicitly control multicast loopback ip_multicast_loop socket option. don't bind(2) destination port on sending machine. works sort of kludgy since puts restrictions on application design and/or deployment.

WPF trigger on datagrid to hide/show columns according to bindings -

i have data grid this: <datagrid autogeneratecolumns="false" canuserdeleterows="true" horizontalscrollbarvisibility="hidden" margin="10,10,10,10" verticalscrollbarvisibility="visible" canuseraddrows="false" itemssource="{binding listgestores}" tooltip="selecione uma linha e pressione delete para remover uma unidade."> <datagrid.columns> <datagridtextcolumn binding="{binding tb_unidade.ds_nome_unidade}" canuserresize="false" header="setor" isreadonly="true" x:name=""/> <datagridtextcolumn binding="{binding tb_unidade.tb_unidade2.ds_nome_unidade}" canuserresize="false" header="unidade" isreadonly="true" x:name=""/> <datagridtextcolumn binding="{binding tb_contatos.ds_nome}" canuserresize="false&

FTPS (FTP-SSL) in Qt 4.6 -

im trying ftp-ssl work qt 4.6.3. i've compiled qt openssl support. there resources ftps qt? seems qftp not provide ssl support. dont want create own ftps implementation. // edit: discovered qnetworkaccessmanager (ty @ frank) cant find useful documentation or examples ssl it. thats i'm trying: qurl url = qurl("ftp://localhost/filex.txt"); url.setusername("root"); url.setpassword("root"); qnetworkrequest request(url); qsslconfiguration sslconfiguration(qsslconfiguration::defaultconfiguration()); request.setsslconfiguration(sslconfiguration); manager->get(request); but filezilla wont let me connect. fz console says: (000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> user root (000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> 530 ssl required filezilla configuration: ftp on ssl/tls support enabled explicit ftp on tls enabled plain unencrypted ftp disallowed ssl forced roots login i @ least expe

c# - How do i architect automatic update of my clients -

i have distributed application written in c# (4.0). has become substantial task update clients each time create new release. not want go clickonce way, since organisations has bought software in cases not wish upgrade clients. how build such update mechanism, clients? thoughts implement kind of launcher application checks server newest version, updates if required, , starts new one. if no updates available simple starts client application. see problem of updating launcher application, should client 1 responsible this? how solve in proper , robust way, ensures customer can configurate clients updates or not, , allow clients function autonomically? is, without user supervision. cheers, create separated multi tier application. add business logic in classlibrary. add library reference application. afterwards create checkfunction in ui. (e.g. check version "number" calling webservice) in case remote version > localversion download new dll (register in gac i

Git reference in chm format -

is there version of git documentation in chm format? i know can compile existing html reference, takes time properly. thanks in advance there no reference in chm format, unfortunately. should create one.

timeout in sql server and attachment of db in sql express 2005? -

intro. i have made application in vs 2008 using c# , @ end using sql express 2005. application background: just report tool in user select parameters , results in cube after can import result excel or in formats. problem: user processing 15 70 months report takes 45 mints 1.25 hours complete sometime result generated 9 months , sometime 11 months not selected months -- show alert: timeout.... how attach , deattach database file when software installing (or after installation) application installer installs apps. , sql express 2005 use sp_attach_db attach database sql server: http://msdn.microsoft.com/en-us/library/ms179877.aspx if you're connecting server using sqlcommand object, can set commandtimeout 0 indefinite execution. not advised though! http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

sql server - two updates using the same CTE -

i have "unremove" folders in arborescence (thay have been flagged removed, change value of flag). each folder can contain files or folders (which stored in different tables). have cte defines folders need updated. arbre(id) as( select iddossier portail_managers_dossier iddossier = @id union select d.iddossier portail_managers_dossier d inner join arbre on a.id = d.idparent) then have 2 update request, 1 each table update portail_managers_dossier set dtdatesuppr = null iddossier in (select id arbre); update portail_managers_document set dtdatesuppr = null iddossier in (select id arbre); my problem : don't know how merge 2 update requests on different tables. cte exists until end of request, have define twice. there way write of above code in single request ? as have discovered, cte's lose scope after first update. but, instead of using cte, why not write results of query within cte temp table, , upda

Can you call a WCF service from an SQL Server 2008 query? -

and return data like? afaik, possible call ws stored procedure in ms sql. similiar calling web services c# or other .net language. here can find more detailed scenario.

iphone - unloading a view in app delegate -

i have following delegate files. aboutviewcontroller in mainwindow.xib loads aboutviewcontroller.xib , aboutviewcontroller outlet connected it. also, navcontroller loaded viewcontroller.xib. aboutviewcontroller's view displayed @ start , removed after 1 second, release view controller setting ivar nil. as view controller loaded xcode automatically, doing wrong(leaking memory etc.) setting nil manually myself? why or why not? thanks - myprojappdelegate.h #import <uikit/uikit.h> @interface myprojappdelegate : nsobject <uiapplicationdelegate> { uiwindow *window; uiviewcontroller *aboutviewcontroller; uinavigationcontroller *navcontroller; } @property (nonatomic, retain) iboutlet uiwindow *window; @property (nonatomic, retain) iboutlet uiviewcontroller *aboutviewcontroller; @property (nonatomic, retain) iboutlet uinavigationcontroller *navcontroller; @end - myprojappdelegate.m #import "myprojappdelegate.h" #import "aboutviewcontro

iphone - IOS SDK: Container view with 3 UI View area how to? -

i'm newbie in ios dev. need windows tree views on it. created view-base application, , added uiview controls in master view. added 3 view controllers views view definition in separated xib files. how link views separated xib files view areas on master view? should manually create controller instances , load controller's view view areas? or maybe possible create them in ib? thank you. you should able drag instances of 3 controllers nib file of master view, , resize them in order create desired layout. however, make sure properties on subviews correct or overlap. in library window of ib, go classes tab, , drag classes want (view controllers) nib. i prefer method on manually adding them through code, allows better functionality resizing such rotation.

oop - When would you use the $this keyword in PHP? -

when use $this keyword in php? understand $this refers object created without knowing objects name. also keyword $this can used within method? an example great show when can use $this . a class may contain own constants, variables (called "properties"), , functions (called "methods"). <?php class simpleclass { // property declaration public $var = 'a default value'; // method declaration public function displayvar() { echo $this->var; } } ?> some examples of $this pseudo-variable: <?php class { function foo() { if (isset($this)) { echo '$this defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this not defined.\n"; } } } class b { function bar() { // note: next line issue warning if e_strict enabled. a::foo(); } } $a = new a(); $a->foo();

semantic markup - What's the best HTML5 tag to use for marking up blog excerpts? -

it's common pattern blogs have archive pages (eg date or category) list relevant blog posts, along excerpts (a paragraph or) , link. can't quite work out of html5 elements it's best use individual posts, however. the <article> tag might seem fit (and if displaying whole content), i'm not sure whether it's appropriate excerpts. specification says: the article element represents self-contained composition in document, page, application, or site , is, in principle, independently distributable or reusable, e.g. in syndication. is excerpt self-contained , independently distributable piece of content? i'm not sure. other options might <blockquote> tag (but it'd weird quoting own posts), or <ol> list (ordered publication date) containing headers , paragraphs. any thoughts? i'd use: <li> <blockquote cite="original url"> </blockquote> </li> <blockquote> appropr

c# - Terminate a thread after an interval if not returned -

i have thread grabs data network or serial port. thread must terminate (or return false) if no data received within 5 seconds. in other words, if running thread taking more 5 seconds must stop. i writing in c#, .net language ok. there 2 approaches: 1. encapsulated timeout the thread reading data network or serial port can measure time elapsed time of start , wait data no more remaining time. network communication apis provide means specify timeout operation. hence doing simple datetime arithmetic can encapsulate timeout management within worker thread. 2. external timeout use thread (or in main thread if that's feasible) wait worker thread finish within time limit, , if not, abort it. this: // start worker thread ... // give no more 5 seconds execute if (!workerthread.join(new timespan(0, 0, 5))) { workerthread.abort(); } recommendation: i'd stick first solution, leads cleaner , maintainable design. however, in situation might necessar

How to sort SPFileCollection in sharepoint? -

i guess question says ? any ideas appreciated ;) what little bit of linq ? something should work : var sortedfiles = filecollection.cast<spfile>().orderby(file => file.name).tolist();

data structures - What datastructure should i use storing and recording events? -

i want record events based on on date. want people able search event based on particular date , person recorded event. for example: person logs in , sees calendar, click on day/date , records event day. person b logs in , sees calendar, click on day/date , records event day. person c comes , same thing. note either of these persons can record more 1 event. i want able record data in database , search these events based on number of different criteria. please can me data structure problem? person id name personalevent id person name date

php - preg_match_all with surrounding data -

i have large amount of log data need relevant information out of. syntax is: word1 text keyword text word2 word1 text keyword text word2 word1 text keyword text word2 word1 text keyword text word2 would possible use regex block out of - when queried keyword return word1 text this_keyword text word2 ps: there multiple instances of 1 keyword, should return of blocks (preg_match_all, preg_set_order?). as per comment there starting , finishing word each block. you can following: split input string blocks (array). end of block identified whitespace followed word2 , preceded word1 . search array got above keyword. . $arr = preg_split('/(?<=word2)\s+(?=word1)/',$log); $keyword = 'keyword1'; $result = preg_grep("/\b$keyword\b/",$arr); ideone link