Posts

Showing posts from 2010

MySQL Question (joins) -

i'm not mysql joins, maybe give me hand. i've got following tables: table fields id,name table b fields aid,cid,id,found table c fields id,name the result want following: want records b.found = 1. of these records don't want a.id or a.name, want number of records have been returned if have wanted so. if there 5 records have b.found = 1 , c.id = (for example) 3, want returned value of 5, c.id , c.name. someone able this? actually want database: list of records in table c , count of records in table b has found = 1 , b.c_id = c.id table: fields: id, name table: b fields: aid, cid, found table: c fields: id, name select c.id, c.name, count(1) b join c on c.id = b.cid , b.found=1 group c.id

sqlalchemy - SqlSoup relate() for many-to-many relation throwing exception -

i'm using following code use sqlsoup existing database. import sqlalchemy sqlalchemy.ext.sqlsoup import sqlsoup sqlalchemy.orm import backref engine = sqlalchemy.create_engine('postgresql:///test') db = sqlsoup(engine) db.books.relate('author', db.authors) db.books.relate('tags', db.tags, secondary=db.tags2books, backref=backref('books', lazy=false)) however, last relate() call throws exception: traceback (most recent call last): file "sqlsoup-test.py", line 10, in <module> db.books.relate('tags', db.tags, secondary=db.tags2books, backref=backref('books', lazy=false)) file "/usr/lib64/python2.6/site-packages/sqlalchemy/ext/sqlsoup.py", line 384, in relate class_mapper(cls)._configure_property(propname, relationship(*args, **kwargs)) file "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py", line 758, in _configure_property prop.init() file "/usr/lib64/py

c++ - Where to get a list of boost libraries included into VS2010 as part of STD? -

where list of boost libraries included vs2010 part of std? this should it: http://msdn.microsoft.com/en-us/library/bb982198.aspx strictly speaking these tr1 headers included vs2010, believe of types renamed boost counterparts. <array> defines container template class array , several supporting templates. <functional> (tr1) defines several templates construct function objects, objects of type defines operator(). function object can function pointer, more typically, object used store additional information can accessed during function call. <memory> (tr1) defines class, operator, , several templates allocate , free objects. <random> defines many random number generators. <regex> defines template class parse regular expressions, , several template classes , functions search text matches regular expression object. <tuple> defines template tuple class instances hold objects of vary

windows phone 7 - WP7 Shoutcast with MediaStreamSource -

i trying implement shoutcast streaming mediaelement via mediastreamsource. here code basics. readdata method can download raw audio data (mp3 samples), question how can set stream mediastreamsource. in way doesn't work (it compiles , there no errors on mediafailed event can't hear sound). maybe should implement of these in custom shoutcastmediastreamsource? there no problem fixed stream, non-fixed. can give me advice? on wp7 there no possibility set "useunsafeheaderparsing" can't http headers shoutcast metadata - raw data. in shoutcastmediastreamsource have implemented code of managedmediahelpers. thanks private void phoneapplicationpage_loaded(object sender, routedeventargs e) { httpwebrequest request = (httpwebrequest)webrequest.create("http://radiozetmp3-02.eurozet.pl:8400/;"); request.method = "get"; request.headers["icy-metadata"] = "1"; request.useragent = "winamp

c++ - What is best approach for performing operations on pairs of 2d lines? -

so have 10 000 lines defined on 2d plane each line presented (a1, a2, b1, b2) (a, b points). have array of functions need perform on each pair of lines: angle(a,b) return atan((b.y-a.y) / (b.x-a.x)) nearlyparallel(angle1, angle2) delta = abs(angle1-angle2) return (delta < threshold) or (delta > pi-threshold) collinear(a,b, c,d) return nearlyparallel(angle(a,c), angle(b,d)) , nearlyparallel(angle(a,d), angle(b,c)) so need line collinear , 1 nearlyparallel each line. i need in c++ using boost , opensource library needed. under windows in visual studio 2010. what library, , part can me in organizing fast calculations data? example boost graph lib helpful? mean need perform thread/processors optimizations speeding up. , not have fancy video card perform all... you use angle function on every line , store result in std::map, using angle key. bring lines similar angles close together, can choose pairs test nearlyparallel , collinear.

database - phpMyAdmin Removing an index -

i have column in 1 of tables has been assigned index. preventing me having 2 of same id number. i assuming reason not letting me have 2 entries of same id because has been set unique. i wondering how remove rule can insert same id number several times. cheers below list of "columns" in table structure have small table called "indexes". every row index. find there unique index , drop using "drop" symbol (red x). if have on more 1 column drop , recreate without column don't want unique

soap - Python JIRA SOAPpy annoying redirect on findIssue -

i trying wsdl soap connection our jira server using soappy (python soap library). all seems fine except when try finding specific issues. through web browser looking bug id redirects bug (with different id), bug in question moved different project. attempts getissue via soappy api results in exception issue not exist. any way around this? thanks yes, there's existing bug on i've seen. use jira issue id instead of key locate it, workaround.

silverlight - VisualStateManager.GoToState doesn't work when I call it in DependencyProperty -

i create dependencyproperty (for example: myeffect) , use property textbox. <textbox grid.row="0" x:name="mytextbox" text ="{binding model.myvalue}" behaviors:myeffect="{binding effectsample}"> </textbox> in propertychangedcallback function, call mycontrol.setvalue(textbox.textproperty, "hello"); visualstatemanager.gotostate(mycontrol, "invalidfocused", true); my textbox display "hello" state doesn't change invalidfocused. how can change state of textbox ? this off top of head may type passing gottostate method. it's expecting control following, assuming mycontrol being passed in dependencyproperty. var control = mycontrol control; visualstatemanager.gotostate(mycontrol, "invalidfocused", true);

php - How to send direct messages from an application's screen_name via OAuth (Twitter) -

i'm getting little confused on seemingly simple concept. i'm building web app notify users via twitter direct message if event occurred on account me. i'm building in php cakephp underlying framework. i'd able send direct message "from" application via oauth. used twurl console (at http://dev.twitter.com/console ) send post request via http://api.twitter.com/1/direct_messages/new.xml?screen_name=<my screenname>&text=<content of dm> when check dm's dm myself. because twurl console uses screenname when sending stuff applications or because when calling direct_message/new.xml sending dm account authenticated test application in twurl. in end i'm looking accomplish same thing spontwts - notify via dm when happens on account. input, resources, links, or code samples appreciated :) you can send direct message via screen name of followers userid screen name of person, configurationbuilder cb=new configurationbuilder(); cb.

Javascript challenge. How do I achieve this with arrays? -

let's have: var directions = [ "name", "start_address", "end_address", "order_date" ]; i'm trying find slick, fast way turn array this: data: { "directions[name]" : directions_name.val(), "directions[start_address]" : directions_start_address.val(), "directions[end_address]" : directions_end_address.val(), "directions[order_date]" : directions_order_date.val() } notice pattern. name of array "directions" prefix values. i'm interested how people can either or @ least suggest way me try. any tips appreciated. thanks! edit ** thanks suggestions far. however, forgot mention array "directions" needs dynamic. for example, use: places = ["name", "location"] should return data: { "places[name]" : places_name.val(), "places[location]" : places_location.val() } alpha = ["

batch file - Question about bat or maybe schtasks on windows -

i have problem bat or maybe schtasks on windows. i want backup mysql databases every day automatically, wrote bat file this, call backup.bat : @echo off & setlocal enableextensions set backup_path=d:\backup\ set databases=database1 database2 database3 set username=root set password=123456 set mysql=d:\server\mysql\bin\ set winrar=c:\progra~1\winrar\rar.exe set year=%date:~0,4% set month=%date:~5,2% set day=%date:~8,2% set minute=%time:~0,2% set second=%time:~3,2% set dir=%backup_path%%year%\%month%\%day%\ set addon=%year%%month%%day%%minute%%second% :: create dir if not exist %dir% ( mkdir %dir% 2>nul ) if not exist %dir% ( echo backup path: %dir% not exists, create dir failed. goto exit ) :: backup echo start dump databases %%d in (%databases%) ( echo dumping database %%d ... %mysql%mysqldump -u%username% -p%password% %%d > %dir%%%d_%addon%.sql 2>nul :: winrar if exist %winrar% ( %winrar% -k -r -s -m1 -ep1 %dir%%%d_%addon%.rar %d

iphone - Adding a new dictionary to my plist file -

root ---- array   item 0- dictionary     fullname ---- string     address ---- string   item 1 ---- dictionary     fullname ---- string     address ---- string have plist looks 1 about. in view have button when clicked i'd add new "item 2" or 3 or 4 or 5 etc... want add few more names , addresses. i've spent 3 hours tonight searching perfect example came short. apple property lists samples way deep. i've seen code come close. thanks nsmutabledictionary *namedictionary = [nsmutabledictionary dictionary]; [namedictionary setvalue:@"john doe" forkey:@"fullname"]; [namedictionary setvalue:@"555 w 1st st" forkey:@"address"]; nsmutablearray *plist = [nsmutablearray arraywithcontentsoffile:[self datafilepath]]; [plist addobject:namedictionary]; [plist writetofile:[self datafilepath] atomically:yes]; - (nsstring *)datafilepath { nsarray *paths = nssearchpathfordirectoriesindomains(nsd

asp.net - How to generate and 7-digit random number/special character string in VB.Net? -

how can generate 7-digit random number , special character string in textbox on button click event, in vb.net? put characters want in string , pick that: dim chars string = "0123456789abcdefghijklmnopqrstuvwxyz!#%&()?+-;:" dim word char() = new char(6) dim rnd new random() integer = 0 word.length - 1 word(i) = chars.chars(rnd.next(chars.length)) next thetextbox.text = new string(word)

is this python code with urllib2 with cookies thread safe? -

i'm trying run multiple threads urllib2 w/ cookies. have function 1 below run in 5 threads simultaneously. i'm not installing opener running in each thread. def myfunction(inputvar): opener = urllib2.build_opener(urllib2.httpcookieprocessor()) is thread safe? if isn't because python modules need thread safe regardless of scope? that should thread-safe. if @ source code urllib2.py neither _build_opener_ function nor httpcookieprocessor () use global state. _build_opener_ function returns new openerdirector object self-contained. each thread have own set of objects won't interfere 1 another.

string - Issue with printing char *argv[n] after a function call in C -

int readoptions(char *argv[]){ file * infile; char line_buf[bufsiz]; int = 0, j = 0 ; infile = fopen("options","r"); if(!infile){ fprintf(stderr,"file read failure\n"); exit(2); } while( < 10 && fgets(line_buf,sizeof(line_buf),infile)!=0){ printf("line buf : %s",line_buf); argv[i] = line_buf; i++; } } int main(){ int j ; char *options[10]; for(j = 0 ; j< 10 ; j++){ options[j] = malloc(len * sizeof (char)); } readoptions(options); for(j=0; j<10 ; j++) printf("%s %d\n",options[j], j ); } the problem see - program print last line read in file. mistake ? , missing important pointer concept code ? every element of argv points same line_buf . use strdup() crea

ajax - Implementing a Progress bar for long running task implemented with an ASP.NET MVC 2 AsyncController -

after reading documentation on asynccontrollers in asp.net mvc 2, wondering what's best way implement ajax progress bar in scenario. seems bit odd tutorial not cover @ all. i guess implementing ajax progress bar involves requires additional action method returns status of current task. however, not sure best way exchange information on status of task between worker threads , action method. my best idea far put information on curent progress session dictionary along unique id, , share id client can poll status. perhaps there easier way did not notice. what's best way this? thanks, adrian very interesting question! seems not task asynccontroller . async controllers designed long-running single-http-query operations @ server-side. when using async action, release asp.net worker thread during long-running operation(s) , allow serve other requests while operation performed. client-side point of view doesn't matter, async controller or not. client single h

Timestamp of file in c++ -

i want check file see if been changed , if is, load again.. this, started following code getting me nowhere... #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <iostream> using namespace std; int main() { struct stat st; int ierr = stat ("readme.txt", &st); if (ierr != 0) { cout << "error"; } int date = st.st_mtime; while(1){ int newdate = st.st_mtime; usleep(500000); if (newdate==date){ cout << "same file.. no change" << endl; } else if (newdate!=date){ cout << "file changed" << endl; } } } all code print same file.. no change continuously. that's because you're calling stat() outside loop. the result stat() correct at particular moment . need call stat() again each time want check it

c - how can i see the stack trace after the process is killed? -

i using gdb command "attach" debug proceess after process crash (sigkill) can not see stack trace ("bt" command in gdb) : (gdb) bt no stack. how can see stack trace after process killed? set shell dump core making sure ulimit -c doesn't show core size of 0. if 0 run ulimit -c unlimited . next, re-run program until crashes , dumps core call: gdb /path/to/executable /path/to/core , type bt stack trace. also, you'll want compile executable debugging info turned on. if you're using gcc suggest use -ggdb3 this.

c - socket chat application i.e i want to chat with multiple clients at a time? -

Image
i working on socket chat application, i.e want chat multiple clients @ time. have written folllowing program. server accepts multiple clients, able chat latest client. not able chat previous client, can explain me why? /* tcpserver.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <pthread.h> void *thread(int *); int main() { int sock, connected, true = 1,n=1; pthread_t tid; struct sockaddr_in server_addr,client_addr; int sin_size; if ((sock = socket(af_inet, sock_stream, 0)) == -1) { perror("socket"); exit(1); } if (setsockopt(sock,sol_socket,so_reuseaddr,&true,sizeof(int)) == -1) { perror("setsockopt"); exit(1); } serv

.htaccess - Setting up htaccess file for sub-folder redirection -

i have question regarding htaccess redirecting. i have domain called www.test.com , there many subfolders in that, www.test.com/admin/ , www.test.com/users/ etc. want redirect different urls based on each url, i.e, www.test.com should redirect www.abc.com www.test.com/admin/ should redirect www.xyz.com www.test.com/users/ should redirect www.pqr.com how can write htaccess file redirect different urls based on each request (something checking condition in incoming url)? you want like: rewriteengine on rewriterule ^users/(.*)$ http://www.pqr.com/$1 [l,nc,qsa,r=301] rewriterule ^admin/(.*)$ http://www.xyz.com/$1 [l,nc,qsa,r=301] # ... add more rules needed rewriterule ^(.*)$ http://www.abc.com/$1 [l,nc,qsa,r=301]

javascript - If body class equals X then do something? -

i have code running external script image slider every page on site. $(document).ready(function() { $("#slideshow").show(); $('#slider1').anythingslider({ buildnavigation: false, delay: 8000 }) on 1 of pages don't want image slider rotate automatically need add variable. i've put class on body of page , want along lines of... if body has class of 'partnercharitiesdetail' run script instead of generic one this have tried below (without success). have 2 questions really, 1) happens in jquery when there 2 identical scripts running (like example), overwrite older 1 newer one? 2) going wrong?! approach best way it? $(document).ready(function() { $("#slideshow").show(); $('#slider1').anythingslider({ buildnavigation: false, delay: 8000 }) if ($('body.partnercharitiesdetail').length > 0){ $('#slider1').anythingslider({ buildnavigation: false, delay: 8000, startstop

iphone - UIMenuController how to show selection -

how can implement uimenucontroller selection shown below? have uiscrollview pdf loaded in in uiview (cgpdf...). menucontroller working without selection dunno how can selection on screen. not matter me selected now. want have visual selection shown. below code use uimenucontroller. uitouch *touch = [touches anyobject]; cgpoint tappoint = [touch locationinview:self]; nslog(@"\nposition of touch\nheight: %f\nwidth: %f", tappoint.y, tappoint.x); cgrect drawrect = cgrectmake(tappoint.x, tappoint.y, 20, 20); uimenucontroller *menu = [uimenucontroller sharedmenucontroller]; [menu settargetrect:drawrect inview:self]; [menu setmenuvisible:yes animated:yes];

rubygems - How access Google Contacts using OpenID in Ruby -

i using devise login omniauth, authid. when user logged in user_info: name: riccardo tacconi last_name: tacconi email: email@gmail.com first_name: riccardo uid: https://www.google.com/accounts/o8/id?id=xxxxxxxxx provider: google_apps i have found plug-in: http://stakeventures.com/articles/2009/10/06/portable-contacts-in-ruby google contacts. need use method: @client = portablecontacts::client.new "http://www-opensocial.googleusercontent.com/api/people", @access_token but need token. have uid. have idea how access token? there not doc accessing google. the answer 1 complicated. pelle's portable contacts parser relies on oauth gem. might able manually construct token object (a key/secret pair) whatever omniauth/authid gives you, it's pretty messy code. the officially supported oauth client ruby signet . however, pelle's parser designed use oauth implementation, again, story here same. might able rip out parsing code client , marry sign

Top Ten Coldfusion Programming Mistakes -

possible duplicate: common programming mistakes coldfusion programmer avoid? the purpose of question educate myself, people work with, , perhaps other coldfusion programmer's out there.. for of program in adobe coldfusion or have programmed in coldfusion, top ten mistakes made, or should never made. i mean give me worst of worst, must never do, avoid. sometimes helps show "what do" want show "what not do" or perhaps share of coding nightmares... bring on! programming if you're 1 ever work on code no comments complicated or strange sections of code using pound signs (#) unnecessarily not using cfbreak break out of loop when appropriate using customtags "business logic", when cfc more appropriate not caching singleton cfcs in application or server scope paginating large recordsets in coldfusion, when pagination should done in sql not setting output="false" on cfcs , each cffunction within creatin

I've an exception when run android application (java.io.FileNotFoundException)? -

whats file ?!!! don't delete !! java.io.filenotfoundexception: res/drawable-mdpi/scrollbar_handle_vertical.9.png 12-06 14:26:33.606: error/androidruntime(276): fatal exception: main 12-06 14:26:33.606: error/androidruntime(276): android.view.inflateexception: binary xml file line #101: error inflating class <unknown> 12-06 14:26:33.606: error/androidruntime(276): @ android.view.layoutinflater.createview(layoutinflater.java:513) 12-06 14:26:33.606: error/androidruntime(276): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 12-06 14:26:33.606: error/androidruntime(276): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:563) 12-06 14:26:33.606: error/androidruntime(276): @ android.view.layoutinflater.rinflate(layoutinflater.java:618) 12-06 14:26:33.606: error/androidruntime(276): @ android.view.layoutinflater.rinflate(layoutinflater.java:621) 12-06 14:26:33.60

html - How to style the currently selected field on a web page -

the chrome browser puts orange highlight around selected input element, how can disable highlight or change color? i think that's: .myinput:focus /*or # depending*/ { outline: #f00; /*or outline: none;*/ } i think .

Rails 2.3.X - Execute code after request was rendered and returned? -

is possible in rails 2.3.x start new chain of commands after request has been rendered , returned requestor? i need feature in order work asynchronous api on other side: expect response request , after response done rails app should send new http-request them (post api)... what possibilities here? there after_render hook? should make use of threads or background tasks , how done? i glad solutions :-) kind regards update: return-code (eg. 200) should sent requestor before other calls executed the easiest thing spawn new thread. assuming lightweight call , don't need advanced error logging or retry logic. thread.new puts "call api" end

Use PHP in UIWebview on iPhone -

is possible?? if wanted put uiwebview app, make mysql db calls , use other php functions? you can tell uiwebview load url of file sitting on web server. url can php page can do... well, php page can do. database stuff, etc. but that's happening on server. php server-based technology. php doesn't run on browser, uiwebview is.

performance - Ways to speedup Visual Studio 2010 -

there's been lot of noise visual studio 2010 being slower predecessor, vs 2008. i facing same issue last couple weeks, , after hour of searching around found couple of solutions have made ide 70% faster on operations, including code editing. 30% speedup tools > options -- check "show options" intellitrace -- disable html designer -- disable 50% startup speedup tools > options environment > add-in/macros security -- uncheck "allow add-in components load" tools > extension manager uninstall don't need. restart ide after these , should observe noticeable speed increase. do have more tricks? feel free add them answers. first, tips you've provided. also tips speedup: tools > options > environment > uncheck "automatically adjust visual experience based on client performance" then uncheck "enable rich client visual exp

architecture - File server distributed caching -

we have big file server (http and/or ftp). files used around 5 systems. example, system use files , b. system b use files , c. are there applications, preferably free or open source, can cache commonly used files inside system? i'm looking squid alternatives. thanks. have looked @ hadoop ? haven't used myself seems want.

c# - How can I determine if a string is a local folder string or a network string? -

how can determine in c# if string local folder string or network string besides regular expression? for example: i have string can "c:\a" or "\\foldera\folderb" new uri(mypath).isunc

Implementing Generic Interface in Java -

i have java generics question hoping answer. consider following code: public interface event{} public class addresschanged implements event{} public class addressdiscarded implements event{} public interface handles<t extends event>{ public void handle(t event); } i want implement handles interface this: public class addresshandler implements handles<addresschanged>, handles<addressdiscarded>{ public void handle(addresschanged e){} public void handle(addressdiscarded e){} } but java doesn't allow implementing handles twice using generic. able accomplish c#, cannot figure workaround in java without using reflection or instanceof , casting. is there way in java implement handles interface using both generic interfaces? or perhaps way write handles interface end result can accomplished? you can't in java. can implement 1 concrete realization of same generic interface. instead: public class addresshandler implements handles<

php - Using subqueries with doctrine / Errors with aliases -

i'm trying make simple query subquery in orwhere clause (with doctrine). as always, doctrine tries rename every aliases , destroys queries... here's example: $q = doctrine_query::create() ->from('actualite a') ->where('a.categorie_id =?', $id) ->orwhere('a.categorie_id in (select id cat.categorie cat cat.categorie_id =?)', $id) ->execute(); which in mysql make like: select * actualite a.categorie_id = 1 or a.categorie_id in (select cat.id categorie cat cat.categorie_id = 1); everything right it, again doctrine destroys it: couldn't find class cat every time try little complex doctrine, have errors aliases. advice or ideas how fix this? thanks! the sql example you've provided fine corresponding doctrine syntax has couple of errors. here's clean version: $q = doctrine_query::create() ->select('a.*') ->from('actualite a') ->where('a.categorie_id

asp.net - Can you receive UNC path from a browser file dialog prompt? -

we have file upload in our asp.net mvc application works fine. engages browser file dialog box , performs upload on selected file. now, we're interested receive unc path file (for different mapped drives) if possible. can done? what we'd if it's non local resource, we'd pass unc path rather upload since our server access quicker. the file input control able use whatever client computer can, unc or local. file uploaded via client. if want extract path upload, not possible due security considerations. you may need ask user input file path text field in order determine if local or on network share, decide method use in order obtain file.

Linq-to-Sql Count -

i need count on items in joined result set condition true. have "from join where" type of expression. expression must end select or groupby. not need column data , figure faster not select it: count = (from e in dc.entries select new {}).count(); i have 2 questions: is there faster way in terms of db load? i have duplicate entire copy of query. there way structure query can have 1 place both counts , getting list fields? thanks. please pay especial attention: the query join , not simple table must use select statement. i need 2 different query bodies because not need load actual fields count list. i assume when use select query filling data when use query.count vs table.count. forward understand i'm asking possible better ways , detailed knowledge of happens. need pull out logging deeper. queryable.count the query behavior occurs result of executing expression tree represents calling count(iqueryable) depends on implementation

facebook - Search events of user via FQL -

i wanted find events attended user, somehow fql not working without providing event id. knows why ? select rsvp_status event_member uid = int_user_uid link : http://developers.facebook.com/docs/reference/rest/fql.query from facebook query language (fql) - facebook developers queries of form select [fields] [table] [conditions]. unlike sql, fql clause can contain single table. can use in keyword in select or clauses subqueries, subqueries cannot reference variables in outer query's scope. query must indexable, meaning queries properties marked indexable in documentation below. ie fql queries require @ least 1 indexable column in clause. and, can see fql event table page indexable property eid.

delphi - File Transfer using winsock -

i want send files(text or binary) through winsock ,i have buffer 32768 byte size, in other side buffer size same,but when packet size <32768 don't know how determine end of packet in buffer,also binary file seems mark end of packet unique character not possible,any solution there? thx with fixed-size "packets," every packet except last full of valid data. last 1 "partial," , if recipient knows how many bytes expect (because, using davita's suggestion, sender told file size in advance), that's no problem. recipient can ignore remainder of last packet. but further description makes sound there may multiple partially full packets associated single file transmission. there easy solution that: prefix each packet number of valid bytes. you later mention tcustomwinsocket.receivetext , , wonder how knows how text read, , quote answer, calls receivebuf(pointer(nul)^, -1)) set length of result buffer before filling it. perhaps didn't

c++ - Ambiguous call to a function -

i have 4 functions: template<class exception,class argument> void allocate_help(const argument& arg,int2type<true>)const; template<class exception,class argument> std::nullptr_t allocate_help(const argument& arg,int2type<false>)const; template<class exception> void allocate_help(const exception& ex,int2type<true>)const; template<class exception> std::nullptr_t allocate_help(const exception& ex,int2type<false>)const; but when call: allocate_help<std::bad_alloc>(e,int2type<true>()); //here e of std::bad_alloc type i'm getting error: error 3 error c2668: ambiguous call overloaded function why? because call matches both: template<class exception,class argument> void allocate_help(const argument& arg,int2type<true>)const; with exception = std::bad_alloc , argument = std::bad_alloc ( argument automatically deduced), and: template<class exception>

rails 3 uninitialized constant NameError when destroying an object -

i'm getting error in rails 3 app can't pinpoint source of... when try destroy object, following: nameerror (uninitialized constant outcome::outcomeanalyasis): app/controllers/outcomes_controller.rb:141:in `destroy' rendered c:/ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.0ms) rendered c:/ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (15.6ms) rendered c:/ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (15.6ms) this destroy function have. error because of line says @outcome.destroy . def destroy @outcome = outcome.find(params[:id]) @outcome_tps = outcometimepoint.where(:outcome_id => @outcome.id).all @outcome_subs = outcomesubgroup.where(:outcome_id => @outcome.id).all @outcome_columns = outcomecolumn.where(:ou

Page.Validate() in ASP.net WebForms to run within a div? -

i developing mobile site has multiple divs. have validator set each different input, want validate elements within 1st div on click "continue." in example, want validate first name within firstpage. secondpage hidden until continue_click event. <div id="firstpage" runat="server"> <h3>*first name:</h3> <asp:textbox id="firstname" runat="server"></asp:textbox> <asp:requiredfieldvalidator id="firstnamerequiredvalidator" runat="server" controltovalidate="firstname" errormessage="please enter first name." forecolor="red"></asp:requiredfieldvalidator> <asp:button id="continue" runat="server" text="next" onclick="continue_click" /> </div> <div id="secondpage" runat="server"> <h3>*last name:</h3> <asp:textbox id=

How to get the oldest message in MSMQ using the WMI ..? -

i developing application need msmq oldest message arrival time using wmi c#. not able find out resource on internet. thanks. check out link... might point in correct direction. http://yoelarnon.wordpress.com/2008/04/02/the-msmq-wmi-provider/

iphone - Data not save in NSUserDefaults -

i having problem nsuserdefaults. when type in name in textbox , click on highscore application not response , keypad still on screen. when tried load data, data name nil. score have 90. can please tell me wrong coding. lots of thanks. -(ibaction)savehighscore_button { int i, ii = -1; struct high_score { nsstring *name; int highscore; }; struct high_score structarray[10]; nsuserdefaults *userpreferences = [nsuserdefaults standarduserdefaults]; (i=0; i<10; i++) { if ([userpreferences stringforkey :[nsstring stringwithformat:@"highscorenameentry%d",i]]!=nil && [userpreferences stringforkey :[nsstring stringwithformat:@"highscoreentry%d"]]!=nil) { structarray[i].name= [userpreferences stringforkey:[nsstring stringwithformat:@"highscorenameentry%d",i]]; structarray[i].highscore = [userpreferences integerforkey:[nsstring stringwithformat:@"highscoreentry%d",i]

need a solution to process SVN deltas -

in attempt sneak peer code review our build process, i'd way programatically grab current build, compare previous build, , generate report of deltas. anyone care pontificate on high level approach doing this? libraries/tools delta calculation can recommend? (command line or dot.net lib best). thanks in advance subversion hook available notify diff (delta) users when ever commit made. review better when precedes commit or else commits polluted far many bad commits , re-works. if want include "reviews" workflow, should check out - reviewboard . can integrated subversion. it's delta viewer capable. [not answer opinion] unless explicitly building capabilities, hooks subversion share community, better use existing capabilities , focus on work. even, if these capabilities bit limited expect. there enough tools out there reviews , delta viewer.

Gmail : Retrieve the mails from specific sender. API..? -

i stuck in middle of project , need retrieving mails particular sender in gmail. can suggest api or can share script server..?? it helpful. in advance guys.. just enable imap, gmail imap servers support server side search. take whatever imap library in language of preference , download search results :)

user interface - Alternate Perforce Client? -

can recommend p4win-like alternative perforce, supports shelving , may open source? needn't cross platform, windows fine. i'm asking i'm not fan of new p4v interface, , found p4win lot more intuitive, easier use, , more stream lined. i haven't found in google searching, i'm hoping nexus of programmers might know of hidden jewel out there. :) this isn't answer, don't have enough rep comment on original post. if primary concern support shelving, can still use shelve/unshelve through command line. hook p4win ui using simple python (or language of choice) script that's set external tool runs on changelists.

javascript - Populate an array to consist of all of the values in an html select list using jQuery -

i have html select list (let's call list a) dynamically populated list of values. need change select list (list b) depending on value of list a. part, can do. ordinarily, user selects one element of list a, , gets list b contingent on list a. however, first element of list "all values." therefore, in instance, want list b consists of aggregate of of values possible list b. because available values of list dynamically generated, can't pull list b values. need pull list b values contingent on list values shown . to this, want iterate through of values in list a, , append list b each item in list a. i'm stuck. how can populate array consist of of values in select list? again, because list populated dynamically, way list of these values pull them select list element. i tried this: iterate_models = $.map($('#lista'), function(e) { return $(e).val(); }); this did not give me array of values of each element in #lista. can't figure

java - Adding .class files to an Eclipse project -

this total newbie question, can't figure out figured ask here , see happened. here's problem: java programming class, supposed download .class file created our instructors containing custom-made class methods supposed use in assignment. know of code create class within actual program, can't figure out directory place .class file in. have tried src , bin folders inside project directory, , placed directly project directory, nothing seems work. instructors put in same directory java program, using jgrasp. doing wrong? you can place class file anywhere, sure add directory project's build path. right click on project, properties @ bottom build path, til find add class folder.

c# - Is a Semaphore the right tool for this video sequence capture/save job? -

i working on wpf project c# (.net 4.0) capture sequence of 300 video frames high-speed camera need saved disk (bmp format). video frames need captured in near-exact time intervals, can't save frames disk they're being captured -- disk i/o unpredictable , throws off time intervals between frames. capture card has 60 frame buffers available. i'm not sure best approach implementing solution problem. initial thoughts create "buffertodisk" thread saves images frame buffers become available. in scenario, main thread captures frame buffer , signals thread indicate ok save frame. problem frames being captured quicker thread can save files, there needs kind of synchronization deal this. thinking semaphore tool job. have never used semaphore in way, though, i'm not sure how proceed. is reasonable approach problem? if so, can post code me started? any appreciated. edit: after looking on linked "threading in c# - part 2" book excerpt, decided impleme

sql - MySQL select 10 random rows from 600K rows fast -

how can best write query selects 10 rows randomly total of 600k? a great post handling several cases, simple, gaps, non-uniform gaps. http://jan.kneschke.de/projects/mysql/order-by-rand/ for general case, here how it: select name random r1 join (select ceil(rand() * (select max(id) random)) id) r2 r1.id >= r2.id order r1.id asc limit 1 this supposes distribution of ids equal, , there can gaps in id list. see article more advanced examples

android - How to handle WebView not loading -

i have webview webviewclient onrecievederror method set. but if set phone airplane mode , page fails loadthe above method isn't called, there detect , deal webview being unable load pages? but if set phone airplane mode , page fails loadthe above method isn't called that method errors received web server. in case, there no accessible web server. is there detect , deal webview being unable load pages? not generically, afaik. can use connectivitymanager determine if have internet connection, in airplane mode scenario.

android - How create a View, that contains Buttons and a List within the same Activity? -

what syntax (xml , java) should use create view, have couple of buttons ("next" , "back") @ top of screen, , list, located below buttons? have tried following, did not work @ all: main.xml: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <button android:text="@+id/button01" android:id="@+id/button01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </button> <listview android:id="@+id/listview01" android:layout_width="fill_parent" android:l

c# - White font with black border in XAML -

as title says, have black font white border in textbox . how achieved? cheers. check out blacklight controls @ http://blacklight.codeplex.com/ . in particular @ sample on http://mightymeaty.members.winisp.net/blacklight.silverlight/ | visual controls | text | stroke text block (alpha).

c# - One ScaleTransform to a group of layers -

here's want - given couple of [image] layers inside scrollviewer, i'd apply same scaling factor layers. in xaml, have scroll viewer hosts grid hosts 2 image controls. have checkbox controls visibility of top image. right now, have scaletransform each image, , apply same scale both. is there way unify scaling in 1 container? sure can apply scale transform @ higher level, e.g. apply grid. <grid.layouttransform> <transformgroup> <scaletransform scalex="1.0" scaley="1.0"/> </transformgroup> </grid.layouttransform> that automatically propagate transform down child ends inside grid. regards, donovan

.net - how do i write assembly code from c#? -

i want write string of assembly code in c# , have sent win32 api compile , execute , results back. example: string str = "mov 1,2;xor ebp,ebp"... sounds hard suggestion helpful. i doubt there's win api compile & execute assembly. best write file, execute masm (or whatever it's called these days), link execute resulting program. can't imagine trying pretty last way try solve problem! if want compare native & managed code, write 2 programs more or less same thing. there no reason generate assembly .net. can use suitable tool this. masm, debug etc.

Strange behaviour when binding to ListBox in WPF -

i noticed strange behaviour when binding array listbox. when add items same "name", can't select them in runtime - listbox goes crazy. if give them unique "names", works fine. please explain why happening? the view: <window x:class="listboxtest.listboxtestview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:listboxtest" title="listboxtestview" height="300" width="300"> <window.resources> <local:listboxtestviewmodel x:key="model" /> </window.resources> <grid datacontext="{staticresource resourcekey=model}"> <listbox itemssource="{binding items}" margin="0,0,0,70" /> <button command="{binding path=add}" content="add" margi

C - Array of words -

i'm new programming, sorry if question seems trivial. have looked answer, can't straight one. we've covered in class, brain failing me right . in c, need make array each element corresponds word. edit: remembered should pointer array. i'm doing... main() { char *line[maxline]; // points beginning of words in compare[] char compare[maxline]; // words read in int counter[maxline]; // counter words appear more once char c; int = 0; int n; (n=0; c!=eof; n++){ while ((c=getchar())!=' '||c!='\n'||c!=eof){ compare[i]=c; i++; } line[n]=compare; = 0; } i'm aware that's not whole thing because need make compare have new address, how 1 suggest going doing that? need use structs or there way? should using malloc that? i apologize if asked stupid question. since first post here, input on way went asking question appreciated since respect community incred

PHP sockets problem -

hey guys, trying socket programming in php. so running socket "server": $address = '127.0.0.1'; $port = '9999'; $mastersocket = socket_create(af_inet, sock_stream, sol_tcp); socket_set_option($mastersocket, sol_socket, so_reuseaddr, 1); socket_bind($mastersocket, $address, $port); socket_listen($mastersocket, 5); $clientsocket = socket_accept($mastersocket); so open ssh , run script. running, no errors. then have php script attempts connect this: $fp = fsockopen("me.com", 9999, $errno, $errstr, 30); fclose($fp); but it's giving me: warning: fsockopen(): unable connect me.com:9999 (connection refused) how begin fix this? you haven't finished listening socket sequence, need call socket_accept accept new connections. there example in comments in php documentation. $clients = array(); $socket = socket_create(af_inet,sock_stream,sol_tcp); socket_bind($socket,'127.0.0.1',$port); socket_listen($socket); soc

C++ - Random seed at runtime -

how can generate different random numbers @ runtime? i've tried srand((unsigned) time(0)); but seems me random number on every startup of program, not on every execution of function itself... i'm trying automate tests random numbers, random iterations, number of elements, etc... thought call srand((unsigned) time(0)); at beginning of test function , bingo, apparently not. what suggest me do? srand() as others have mentioned. srand() seeds random number generator. means sets start point sequence of random numbers. therefore in real application want call once (usually first thing in main (just after setting locale)). int main() { srand(time(0)); // stuff } now when need random number call rand(). unit tests moving unit testing. in situation don;t want random numbers. non deterministic unit tests waste of time. if 1 fails how re-produce result can fix it? you can still use rand() in unit tests. should initialize (with srand()) unit t