Posts

Showing posts from July, 2014

python - determinating if the input is even or odd numbers -

hello trying write program in python asks user input set of numbers of 1's , 0's , want program tell me if have , number of zeros or odd number of zeros or no zero's @ all. help!! forstate = "start" curstate = "start" trans = "none" value = 0 print "former state....:", forstate print "transition....:", trans print "current state....", curstate while curstate != "you hav , number of zeros": trans = raw_input("input 1 or 0: ") if trans == "0" , value <2: value = value + 1 forstate = curstate elif trans == "1" , value < 2: value = value + 0 forstate = curstate curstate = str(value) + " zeros" if value >= 2: curstate = "you have , number of zeros" print "former state ...:", forstate print "transition .....:&q

sql - Query in MySQL for string fields with a specific length -

how can make mysql query asking string fields in column have particular length? thanks! use length() checking length in bytes: select str sometable length(str) = 5; or char_length() checking length in number of characters (useful multi-byte strings): select str sometable char_length(str) = 5;

actionscript 3 - URL opening error in Flash CS4 -

i have script loads php page variables. there no problems when swf uploaded site when run locally, keep getting "error opening url" messages. i'm using absolute pathing , if paste url script using in browser, correct page opens. started happening after site changed servers. ideas problem be? thanks. the "error opening url" seems caused number of issues. have tried keep track of different solutions have used in past fix problem. ever time encounter "error opening url" solution different. 1 of these solutions helps you. i find following solutions on google. - make sure crossdomain policy setup correctly. - set bunch of variables security.allowdomain(domainhere) - change publishing setting flash file. - make sure connecting right url. here works me... usually. 1) make sure connecting right url. use full path, don't use relative links. also, copy , paste url in web browser see if connects. you can use flash.events.httpstatuseve

web applications - How do Facebook and have these amazing features?

i'm interested in learning how these 2 things accomplished: facebook: when user logged in , sitting @ news feed, new items automatically show in news feed, red badges friend requests, messages, , notifications automatically appear, , instant messaging live. that's lot of database activity! on top of that, users have ability remotely end other sessions, of sessions have checking if they're still valid. many users, how work without killing servers? stack overflow: there 60+ badges on stack overflow based on wide variety of actions user does. seems extremely complicated check virtually of user's actions see if earned them badge or not. same question: many users, how work without killing servers? i appreciate guidance. planning: first step in process planning. facebook or stackoverflow cannot create badge today , 2 months down line, find problem. detailed planning done create category. can write long here, need tech; lets move ahead. object oriente

iphone - How to insert UIImageView between two sections of UITableView? -

i have design in application have 4 sections in uitableview , need insert uiimageview , uilabel between sections of same table. possible same? kindly show me path.thank you. see these uitableviewdelegate methods: -(uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger) section -(uiview *)tableview:(uitableview *)tableview viewforfooterinsection:(nsinteger) section you may need enclose image view , label in iuview container , return container 1 of these methods. depends on , how you'd present them.

Php Mysql Stored Procedure IN OUT -

case: stored procedure looking like: drop procedure if exists `xoffercommon`.`getcdpc`;<br> delimiter $$<br> create procedure `xoffercommon`.`getcdpc` (in in_city_id int, out out_country_id int, out out_district_id int, out out_provence_id int, out out_city_id int)<br> begin<br> declare city_id int default in_city_id;<br> select t.id, d.id, p.id, c.id out_country_id, out_district_id, out_provence_id, out_city_id ((tblcity c inner join tblprovence p on c.tblprovence_id = p.id) inner join tbldistrict d on p.tbldistrict_id = d.id) inner join tblcountry t on -d.tblcountry_id = t.id c.id = city_id;<br> end$$<br> delimiter ;<br><br> <br>--------------------------------------------------- input: int referring in_city_id<br> output: 4 x int country district provence , city id's<br> ---------------------------------------------------<br> php: want tot call procedure , store 4 returned objects 4variables

django - where can i to download the "mod_wsgi.so" -

Image
i want deploy django site apache , cant find website download "mod_wsgi.so" file , i download modwsgi in http://code.google.com/p/modwsgi/ , cant find "mod_wsgi.so" too, this file : so can , thanks! if need precompiled windows version take @ at download page of site posted

android - How to get Storage size of the Application -

how storage size of installed applications, programmatically, displayed on application's applicationinfo page? you call process process = runtime.getruntime().exec(commandline); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(process.getinputstream())); with commandline ls -l /data/app/*.apk or ls -l /data/app-private and parse resulting data information need.

html - How to get this Twitter javascript to only show 3 updates -

i found easy use javascript www.twitter.com updates place on website. when edited code username , placed in index.html code showing of status updates. have script show 2 or 3 of newest updates. how can make work? needs added script? <script type="text/javascript" src="http://www.gtaero.net/twitter/twitter.php?user=username"></script> <div id="twitfeed">optional placeholder text</div> <script type="text/javascript">twitter2id("twitfeed");</script> enter url browser: http://www.gtaero.net/twitter/twitter.php?user=username see script full of documentation the answer: <script type="text/javascript" src="http://www.gtaero.net/twitter/twitter.php?user=username&count=3"></script>

array value in php -

in following code , in echo of preview why getting h. echo "<pre>"; print_r($thumb); echo $thumb=$thumb['thumb']."<br/>"; echo $preview=$thumb['preview']; exit; array ( [thumb] => http://dtzhqpwfdzscm.cloudfront.net/4d52463406ce5.jpg [preview] => http://dtzhqpwfdzscm.cloudfront.net/4d5246345dac0.jpg ) http://dtzhqpwfdzscm.cloudfront.net/4d52463406ce5.jpg h please suggest because you've overwritten $thumb variable. change to: echo "<pre>"; print_r($thumb); echo $thumb['thumb']."<br/>"; echo $thumb['preview']; exit;

mysql - Automatic db connection close in php? -

i have following in config.php file 1 of web app. //db settings $host = 'localhost'; //database location $user = 'example'; //database username $pass = 'example12'; //database password $db_name = 'example'; //database name //create db connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); //sets encoding utf8 mysql_query("set names utf8"); i including config.php in pages of application @ top (1st line of code). i want know php/mysql maintain connection open , close automatically or need explicitly call them. connection opening itself, doing db based tasks properly. not closing connection anywhere, high traffic website. please correct me if wrong anywhere. thanks! the connection close automatically upon termination of script. the notes on mysql_connect() state that: the link server closed execution of script ends, unless it's closed earlier explicitly ca

how should i call a javascript function into a kohana view? -

i having simple kohana view, , javascript makes countdown of 30 minutes. hava put javascript file directory /media m , name countdown.js . problem is: how can call javascript? form view? or controller displayed in view? , how may address in controller or view js function or functions? thank you the countdown js: var javascript_countdown = function () { var time_left = 10; //number of seconds countdown var output_element_id = 'javascript_countdown_time'; var keep_counting = 1; var no_time_left_message = 'no time left javascript countdown!'; function countdown() { if(time_left < 2) { keep_counting = 0; } time_left = time_left - 1; } function add_leading_zero(n) { if(n.tostring().length < 2) { return '0' + n; } else { return n; } } function format_output() { var hours, minutes, seconds; seconds = time_left % 60; minutes = math.floor(time_left / 60) % 60; hours = ma

c# - How to create in memory XML document and get string out of it -

i create xml string special characters handling. turned out complicated , causing issues generating wrong xml. thinking build string using object system.xml , stringify() or string it. guess me special character cases. //psudo code xmldoc doc = new xmldoc(); element ele= new element("xyz"); ele.value(oob.property) doc.appendnode(ele); ... doc.getxmlstring(); can 1 please let me know how in c# .net2.0+ . i find xmltextwriter more intuitive xmldocument editing. e.g.: string xmlstring = null; using(stringwriter sw = new stringwriter()) { xmltextwriter writer = new xmltextwriter(sw); writer.formatting = formatting.indented; // if want indented writer.writestartdocument(); // <?xml version="1.0" encoding="utf-16"?> writer.writestartelement("tag"); //<tag> // <subtag>value</subtag> writer.writestartelement("subtag"); writer.writestring("value"); write

objective c - How to pass touch event to a pie chart -

i new core plot framework , facing issue: i cpgraphhostigview draw pie chart. cpgraphhostigview doesn't detect touch events have uiview on can detect touches. how can pass touch events pie chart cppiechartdelegate method. - (void)piechart:(cppiechart *)plot slicewasselectedatrecordindex:(nsuinteger)index gets invoked. any appreciated. in advance. -ravi cpgraphhostingview inherits uiview , inherits uiresponder . therefore, cpgraphhostingview does detect touch events. here steps should follow in order detect touch events on pie chart slices : add cpgraphhostingview view in interface builder. can achieve adding simple uiview , change class manually cpgraphhostingview ; declare hosting view in code: // in view controller .h file: ... cpgraphhostingview *graphhosting; } @property (nonatomic, retain) iboutlet cpgraphhostingview *graphhosting; // in view controller .h file: @synthesize graphhosting; make connection iboutlet in interface bu

android - how to fetch position of the image inside the grid view? -

i have set of imageviews placed in row inside grid view. if touching on imageview in , moving forward or backward through image set, should image have touched right now(eg: position in grid view). how achieve it? can please help? the position parameter in onitemclick() method position .

sap - Roles and profiles -

what difference table agr_prof table agr_1016? both tables deal generated profiles role. role sap_bc_jsf_communications not come pre-generated profile, unless generate 1 or else has done on system, it's expected tables not contain information role. agr_prof contains language-dependent description text of generated profile profile id. can see looking @ primary key, 1 entry can exist each profile , language. entry defines "master profile name". agr_1016 can contain multiple entries single role, it's technically not surprising there more entries in table in agr_prof. conceptual reason behind there's size limit single profile. size limit hard-wired kernel @ time there comparatively few authorization objects. nowadays, it's easy create role generated profile exceeds size limit. instead of changing kernel structures, sap decided generate multiple profiles single role, of can seen in agr_1016. you'll notice counter > 1, profile+10 incremented.

opengl - Selectively rotating 2d objects in openGLnGL -

i new opengl. have far studied how draw basic shapes , how rotate them etc. i want create application there half circular dial , clock hand rotate continuously on it. (may 0-180 degrees , back). how go it? there might several ways best way given broader picture of trying build. a user create layers. in above example circular dial background layer. clock hand foreground layer. some layers static means never move. layer movement provided user (may in config file). in above example user provide (some point , angle range clock hand layer , layer rotate in range around provided point). please suggest how possibly can achieved. since using 2d object wonder if each layer can plane along z axis etc. opengl not scene graph. it's more pencil, brushes, dye , masks. , programming opengl means breaking down scene drawing steps needed creating desired picture. in case it's simple using painter's algorithm draw in order dial first hand second hand thrird

wordpress django currenct_active_page -

in wordpress template automatically kicks out '.current_page_item' on menu. i wondering if there django way of doing this? well django not wordpress , not cms, used one. in case have on own, depends how designed templates?

flex - Date and time conversion accroding to Zone using Flex3 -

i sending date , time in ( mm/dd/yyyy hh:mm) format india australia( booking date , time future), user in australia should show him according local time. australia 5 hrs , 30 mins past india. how using flex3. in advance. -lavi flex has no timezone calculation support built-in (you can local clock's offset , convert between utc time , local time , that's it), best bet conversion via server-call (with joda handling timezone calculations, includes dst offsets).

iphone - how can I put particular action as I select any row of UITableViewController? -

i have table , item on it, want call method select particular row , sort of alert msg index in selected, any solution???? all need implement method: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath; for more details, can search in xcode's developer documentation.

c++ - expression must have pointer-to-object type,subscript requires array or pointer type -

class rc5 { public: rc5() : _bufkey(new unsigned __int32[4]), _bufsub(new unsigned __int32[26]) { } unsigned __int8 test(unsigned __int8 data); virtual ~rc5() { delete [] _bufkey; delete [] _bufsub; } private: unsigned __int32 *const _bufkey; unsigned __int32 *const _bufsub; }; unsigned __int8 rc5::test(unsigned __int8 data) { (int = 0; < 4; i++) { _bufkey[i] = (unsigned __int32)(data[i * 4] + (data[i * 4 + 1] << 8) + (data[i * 4 + 2] << 16) + (data[i * 4 + 3] << 24)); } } i got errors : expression must have pointer-to-object type,subscript requires array or pointer type it looks problem in test function you're passing in data unsigned __int8 rather array of these values. subscripting square brackets what's causing error. changing functi

svn - Setting up AnkhSVN with Visual Studio 2010 -

i have created repository in server using visualsvn server. installed ankhsvn in local machine , i'm trying add local source repository. right clicked on soulution , clicked on add "solution subversion" , "add subversion " popup appear. once typed in repository url, doesn't show repository down below , cant add repository. the url https://gp-ws16.gp.com.lk/svn/test i tried port number https://gp-ws16.gp.com.lk:443/svn/test i checked server , svn server running on there. i have not installed tortoisesvn or other in local machine other ankhsvn. need to? doing wrong? thanks. try opening view -> repository explorer. there use + button add url. confirm communication server.

c# - Xceed GridControl -

i have xceed gridcontrol, groupbyrow control on there. when groups populated, groupbyrow width, width columns on there. there not seem option expand width size of actual gridcontrol. does know way around this? i suggest setting last column width * can stretch last column end. should stretch groupbycontrol way end of datagridcontrol.

parameters - Skip download if files exist in wget? -

this simplest example running wget: wget http://www.example.com/images/misc/pic.png but how make wget skip download if pic.png is available? try following parameter: -nc , --no-clobber : skip downloads download existing files. sample usage: wget -nc http://example.com/pic.png

windows - Can IsLoggingEnabled() change at runtime? -

i'm encapsulating entlib 5 logging application block. i've seen in documentation every time want log, should give "isloggingenabled()". fact it's method , not property, tell me operation takes time done, but... cache value in local variable , check if it's possible log or not based on it? cheers. you can not, through code, change logging settings, said @ enterprise library document . there can read that: note: run time changes configuration of logging application block automatically detected after short period, , logging stack updated . however, cannot modify logging stack @ run time through code. details of using configuration mechanisms can update @ run time, see updating configuration settings @ run time. that is, while can't enable/disable programatically logging, can change @ run time if configuration edited manually. so, why you'll need access isloggingenabled() operation every time, , it's not i

php - Problem with PHP_CodeSniffer and SVN pre-commit hook -

i've downloaded latest version of codesniffer (1.3.rc0). prefer version , not stable 1 (1.2.2) because want "severity" feature. i've modified existing drupal standard package compatible version of codesniffer , stablish own severity policy. when run phpcs command-line, i've no problems @ all. sniffs code correctly, filters severity , works fine. the problem comes when try automate sniffs subversion pre-commit hook. seems phpcs-svn-pre-commit script coming release not working @ all. i've followed guide in http://pear.php.net/manual/en/package.php.php-codesniffer.svn-pre-commit.php step-by-step, when commit file coding standard errors (detected command-line execution of phpcs , drupal standard package), subversion lets file pass , commits changes. has been in same problem? thanks in advance. edited: execution examples. $ phpcs --standard=drupal --severity=4 ak_gourmet.module php deprecated: comments starting '#' deprecated in /etc/ph

ios - NSDateFormatter crashes when used from different threads -

we keep getting random, weird crash nsdateformatter . relevant stack trace is: program received signal: “exc_bad_access”. #0 0x00000005 in ?? () #1 0x0213e3c3 in udat_parse () #2 0x01d4e1ca in cfdateformattergetabsolutetimefromstring () #3 0x01d4e225 in cfdateformattercreatedatefromstring () #4 0x003e2608 in getobjectvalue () #5 0x003e2921 in -[nsdateformatter getobjectvalue:forstring:errordescription:] () #6 0x003e21cd in -[nsdateformatter datefromstring:] () the date formatter still in memory (i.e. not released or corrupted). thing can think of strings upon crash not conform format, doubt make formatter crash. (it non trivial check format beforehand). any thoughts? thanks previous answerers. this not memory problem. turned out synchronization issue. nsdateformatter s not thread safe; there background thread attempting use same formatter @ same time (hence randomness). hope helps in future!

asp.net - System.Web.HttpException: Unable to validate data - after publishing site -

i have written following code login: session["islogin"] = false; system.configuration.configuration config = system.web.configuration.webconfigurationmanager.openwebconfiguration("~"); if (txtpassword.text.trim() == string.empty) { // display error } else { string pwd = config.appsettings.settings["pwd"].value.tostring(); formsauthenticationticket formauthtk = formsauthentication.decrypt(pwd); string strdcryptedpwd = formauthtk.name.trim().tostring(); if (txtpassword.text.trim() == strdcryptedpwd) { session["islogin"] = true; response.redirect("anypage.aspx"); } else { // error, wrong password } } which running fine while running through visual studio. when published it showing below error: system.web.h

iphone - UIInterfaceOrientation method not working -

call not going uiinterfaceorientation delegate method please here code - (bool) shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation { return yes; } - (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration { if (tointerfaceorientation == uiinterfaceorientationportrait) { nslog(@"potrait"); } else { } } is view controller inside view controller? look technical q&a qa1688 why won't uiviewcontroller rotate device? in developer documentation that give hint of why isn't working in case.

c# - Does using a no-op lambda expression for initializing an event prevent GC? -

one can use following construct declaring event: public class myclass { public event eventhandler<eventargs> someevent = (s,e) => {}; public void somemethod () { // interesting... ;) someevent (this, new eventargs); } } that allows raising event without need check if event null. now, let's object holds reference object of myclass, registers event , unregisters later on. var myclass = new myclass(); myclass.someevent += myhandler; ... myclass.someevent -= myhandler; myclass = null; will gc collect myclass if there no-op lambda expression still on event? i guess because object root no longer reference other objects... can confirm or prove otherwise? with code in question gc collect myclass if don't unsubscribe. relation other way around. myclass's event holds reference subscriber theoretically should worried subscriber not being collected. if unsubscribe subscriber collected.

c# - Why is it useful to access static members "through" inherited types? -

i'm glad c# doesn't let access static members 'as though' instance members. avoids common bug in java: thread t = new thread(..); t.sleep(..); //probably doesn't programmer intended. on other hand, does let access static members 'through' derived types. other operators (where saves writing casts), can't think of cases helpful. in fact, actively encourages mistakes such as: // nasty surprises ahead - won't throw; unintended: // creates httpwebrequest instead. var ftprequest = ftpwebrequest.create(@"http://www.stackoverflow.com"); // wrong here. var arerefequal = dictionary<string, int>.referenceequals(dict1, dict2); i keep committing similar errors on , on when searching way through unfamiliar apis (i remember starting off expression trees; hit binaryexpression. in editor , wondering why on earth intellisense offering me makeunary option). in (shortsighted) opinion, feature: doesn't reduce verbosity; programmer

png - image and graphics format -

what best format save image , graphics visually consistant in multiple browsers? have been using png's , great in google chrome, not in other browsers. thanks you should save... photos in jpeg. images not photos (large slabs of 1 colour, etc), transparencies png. gif animated (can emulated javascript). ang not supported yet.

c# - .NET implementation of the active object pattern -

i'm looking implementations of active object pattern, haven't far. came with: http://geekswithblogs.net/dbose/archive/2009/10/17/c-activeobject-runnable.aspx need little bit more involved. preferably .net version <= 3.5. see system.threading.tasks.task .

Make Google Searchbox code compatible with ASP.NET WebForms -

i provided following code integrate asp.net webforms page: <form action="http://www.google.com/cse" id="cse-search-box" target="_blank"> <div> <input type="hidden" name="cx" value="partner-pub-8127518365728966:9snx3s9v6fx" /> <input type="hidden" name="ie" value="iso-8859-1" /> <input type="text" name="q" size="25" /><br /> <input type="submit" name="sa" value="search" class="formoutput"/> </div> </form> <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script> however, i'm not sure how because of form element poses. has translated work asp.net webforms previously, , if can me out? thanks! take here: http://am22tech.com/s/22/blogs/post/2010/05/2

drupal - Theming view, block id -

i've created block in view, in de source code block has folowing id: block-views-work-block_1 'work', name of view identifies block 'block_1', isn't there way change name of block example? when see block_1 in css file isn't clear is. in views 3, can change under basic settings -> machine name. it doesn't appear possible change machine name in views 2.

Different class size between Eclipse IDE and javac -

when compile java sources under eclipse ide have bigger generated class-files, when compile javac in console. could give me reason behind that? because eclipse doesn't use javac, own compiler. other thread: how set other-than-eclipse java compiler eclipse ide from jdt website : an incremental java compiler. implemented eclipse builder, based on technology evolved visualage java compiler. in particular, allows run , debug code still contains unresolved errors. keep in mind library itself, eclipse still use 1 sun's compiler can set using procedure explained answers (nimchimpsky , elite).

C# LINQ Question -

i have following code var query = lookup in dataset.tables["mbddx_lookup"].asenumerable() lookup.field<string>("lookup_value") == "oncology" select new { lookupid = lookup.field<long>("id") }; this returns want. however, want check field within clause , 'select new' also. how can this? thanks. edit: second piece of data wish extract within mbddx_lookup field. if trying check same field 2 possible values, use or operator || : var query = lookup in dataset.tables["mbddx_lookup"].asenumerable() lookup.field<string>("lookup_value") == "oncology" || lookup.field<string>("lookup_value") == "zoology" select new { lookupid = lookup.field<long>("id"), l

objective c - NSTableView and backspace event (delete row) - fieldeditor/firstresponder? -

is possible make nstableview accept deleteevnt (backspace og cmd+backspace) ? have nsmenu have delete-menu-item connected first responder object in nib. any pointers? you create subclass of nstableview, overriding keydown so: - (void)keydown:(nsevent *)theevent { unichar key = [[theevent charactersignoringmodifiers] characteratindex:0]; if(key == nsdeletecharacter) { [self deleteitem]; return; } [super keydown:theevent]; } then make sure nstableview want have delete functionality uses subclass in interface builder instead of regular nstableview. you can implement - (void)deleteitem method example this: - (void)deleteitem { if ([self numberofselectedrows] == 0) return; nsuinteger index = [self selectedrow]; [documentcontroller deleteitemwithindex:index]; }

asp.net mvc 3 - Unexpected "foreach" keyword after "@" character -

i have partial view done in razor. when run following error - seems razor gets stuck thinking i'm writing code everywhere. unexpected "foreach" keyword after "@" character. once inside code, not need prefix constructs "foreach" "@" here view: @model ienumerable<somemodel> <div> @using(html.beginform("update", "usermanagement", formmethod.post)) { @html.hidden("userid", viewbag.userid) @foreach(var link in model) { if(link.linked) { <input type="checkbox" name="userlinks" value="@link.id" checked="checked" />@link.description<br /> } else { <input type="checkbox" name="userlinks" value="@link.id" />@link.description<br /> } } } </div> inside using block, razor expecting c# source, not html. therefore, should write foreach without

when using ftplib in python -

here relevant code that's causing error. ftp = ftplib.ftp('server') ftp.login(r'user', r'pass') #change directories "incoming" folder ftp.cwd('incoming') fileobj = open(fromdirectory + os.sep + f, 'rb') #push file try: msg = ftp.storbinary('stor %s' % f, fileobj) except exception inst: msg = inst finally: fileobj.close() if '226' not in msg: #handle error case i've never seen error before , information why might getting useful , appreciated. complete error message: [errno 10060] connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond it should noted when manually (i.e. open dos-prompt , push files using ftp commands) push file same machine script on, have no problems. maybe should increase " timeout " option, , let server more time response.

Find number of areas in a matrix -

assume have matrix : 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 if 2 '1' next each other (horizontally , vertically only) , therefore belong same area. need find how many of these areas there in matrix. can see there's 2 areas of '1' in matrix. i've been trying solve hours code gets big , disgusting. there algorithms out there adopt problem ? if don't care about: keeping input matrix intact performance , optimisations then here's take on problem in c: #include <stdio.h> #define x 8 #define y 4 #define ign 1 int a[y][x] = { { 1, 1, 1, 0, 0, 0, 0, 1 }, { 1, 1, 1, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 1, 1, 1 }, }; int blank(int x, int y) { if ((x < 0) || (x >= x) || (y < 0) || (y >= y) || (a[y][x] == 0)) return 0; a[y][x] = 0; return 1 + blank(x - 1, y) + blank(x + 1, y) + blank(x, y - 1) + blank(x, y +

JQuery 1.5 Data Api Changes Impacting JQuery UI -

i've upgraded jq 1.5 , jqui 1.8.9 , sortables have started behaving oddly. i've got linked sortables , when drag items across randomly seem stop , seems flaky. there changes required upgrade? update -- getting number of errors in jquery ui js file cannot read property 'sortables' of undefined on line 1504 cannot read property options of undefined on line 1585 , 1627 cannot read property 'element' of undefined on 1461 update -- here's minimal example instructions: drag item red box (draggables) on first blue sortable box , second blue sortable box. drag should terminate when trying mouse second box. it seems jquery ui not @ fault here, changing jquery reference 1.4.4 fixes issue think may problem in jquery itself, changes data api. <!doctype html> <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <link t

Maven 3: Generate Javadoc for defined artifacts -

i want generate javadocs artifacts of project within dedicated docs-project. that means have independent project called "docs" example. in docs/pom.xml define artifacts should included in generated javadocs. so far learned have generate seperate sources.jar projects want include. there on can't figure out how go one. for can imagine 2 approaches: get artifacts (sources.jar) want include, unpack them , somehow point javadoc plugin source directory. define artifacts interested dependecy , use "dependencysourceinclude" option of javadoc-plugin. not sure if usage intended. any suggestions how solve problem? i have found solution self. bit of hack work me. chose go first idea: get artifacts (sources.jar) want include, unpack them , somehow point javadoc plugin source directory. this solution has 4 differents parts i'll explain in more detail later: generate sources.jars in artifacts want include unpack sources.jars generate

scala - Ternary Operator Similar To ?: -

i trying avoid constructs this: val result = this.getclass.getsimplename if (result.endswith("$")) result.init else result ok, in example then , else branch simple, can image complex ones. built following: object ternaryop { class ternary[t](t: t) { def is[r](bte: branchthenelse[t,r]) = if (bte.branch(t)) bte.then(t) else bte.elze(t) } class branch[t](branch: t => boolean) { def ?[r] (then: t => r) = new branchthen(branch,then) } class branchthen[t,r](val branch: t => boolean, val then: t => r) class elze[t,r](elze: t => r) { def :: (bt: branchthen[t,r]) = new branchthenelse(bt.branch,bt.then,elze) } class branchthenelse[t,r](val branch: t => boolean, val then: t => r, val elze: t => r) implicit def any2ternary[t](t: t) = new ternary(t) implicit def fct2branch[t](branch: t => boolean) = new branch(branch) implicit def fct2elze[t,r](elze: t => r) = new elze(elze) } defined that, can replace above sim

c++ - Failing the template function lookup -

consider following example. #include <iostream> #include <boost/optional.hpp> template < typename > int boo( const boost::optional< > &a ); template < typename > int foo( const &a ) { return boo( ); } template < typename > int boo( const boost::optional< > & ) { return 3; } int main() { std::cout << "foo = " << foo( 3 ) << std::endl; std::cout << "boo = " << boo( 3 ) << std::endl; } compiling using g++ 4.3.0 throws next compiling errors: dfg.cpp: in function ‘int main()’: dfg.cpp:25: error: no matching function call ‘boo(int)’ dfg.cpp: in function ‘int foo(const a&) [with = int]’: dfg.cpp:24: instantiated here dfg.cpp:12: error: no matching function call ‘boo(const int&)’ what should differently (if possible references c++ standard)? why happening , how fix it? edit the fix create correct type in foo : template < typename >

php - File Upload Size Validation -

validations big problem, if validate in php has functions etc need make work.. uploads file first on temporary location , checks, sucks. if uploads file of 100mb has wait time no error, internal php screw hanging page. one way: js //file id of input file alert(document.getelementbyid('file').files[0].filesize); this works in firefox, safari, chrome guess too, not: in opera, quite sure ie ie can taken care of activex file size opera still stuck. pretty unusable, anyways around it? second: thinking, can give php custom alert or setting max size in php.ini or that, solve problem. thats looking for. another update: i have been fooling around rapidshare understand whats going on, realized use javascript file size checking :p works great firefox, , others said, ie has fall activex method opera victim :p cant give fancy javascript error in case. have fall server side validation takes few seconds more, not smooth show small error finally. so need find out server side

How to add soap basic auth request to WSDL -

how can had soap auth basic auth wsdl, ever reads wsdl knows require operation specific method ? using example bellow have managed pass soap basic autentication php webservice on other end. php.net/soapclient has simple working example, in csharp found link solution problem. link michaelis.mockservice webservice library extracted may see example on how in: link mono project website. michaelis.mockservice service = new michaelis.mockservice(); // create network credentials , assign // them service credentials networkcredential netcredential = new networkcredential(“inigo.montoya”, “ykmfptd”); uri uri = new uri(service.url); icredentials credentials = netcredential.getcredential(uri, “basic”); service.credentials = credentials; // sure set preauthenticate true or else // authentication not sent. service.preauthenticate = true; // make web service call. service.method();

What is the cleanest way to make a dynamic list of buttons in asp.net? -

i want change list dynamically populated: <ul> <li id="tab1" class="selected" runat="server"> <asp:linkbutton id="linkbutton1" onclick="linkbutton1_click"runat="server"> tab1 text </asp:linkbutton> </li> <li id="tab2" runat="server"> <asp:linkbutton id="linkbutton2" onclick="linkbutton2_click" runat="server"> tab2 text </asp:linkbutton> </li> <li id="tab3" runat="server"> <asp:linkbutton id="linkbutton3" onclick="linkbutton3_click" runat="server"> tab3 text </asp:linkbutton> </li> </ul> i tried using code: <asp:listview id="listview_tabs" onitemcommand="listview_changetab" runat="server"> <layouttemplate> <div class=&q

javascript - Attaching multiple draggable/droppable to one element -

the following shows attempt add 2 draggable stop event handlers paragraph. second fire... how can both fire? <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ var dragg1 = { stop: function(event, ui){alert('stop dragg1')} }; var dragg2 = { stop: function(event, ui){alert('stop dragg2')} }; $(".makedraggable").draggable(dragg1); $(".makedraggable").draggable(dragg2); }); </script> </head> <

java - JUnit + Maven: accessing ${project.build.directory} value -

in unit tests want create tmp directory inside ${project.build.directory}. how can access value of ${project.build.directory} inside unit test? one way, think of, provide filtered properties file in test resources, holdes value. (i haven't tried yet, think should work.) is there direct way access/ pass property value? regards, florian i've used success before. unit test still run if not using maven, target directory still created 2 dirs relative cwd of wherever tests run. public file targetdir(){ string relpath = getclass().getprotectiondomain().getcodesource().getlocation().getfile(); file targetdir = new file(relpath+"../../target"); if(!targetdir.exists()) { targetdir.mkdir(); } return targetdir; }

python - Is there somewhere an index of Py3k-only libraries? -

i'm curious if there important libraries support python 3, since appears many libraries support it, happen support python 2. no, there no such index, create 1 classifier data on pypi. you make list of packages has "programming language :: python :: 3" or programming language :: python :: 3.0" or "programming language :: python 3.1", none of python 2 classifiers. http://pypi.python.org/pypi?:action=browse&c=214 possibly xml interface can useful: http://wiki.python.org/moin/pypixmlrpc

Go: Can you use range with a slice but get references? (iteration) -

say want change value objects in array. range syntax lot more named loops. so tried: type account struct { balance int } type accountlist []account var accounts accountlist ... .... // init balances _,a := range( accounts ) { a.balance = 100 } that did not work since copy of entries accountlist , updating copy only. this work need to: for := range( accounts ) { accounts[a].balance = 100 } but code has lookup inside loop. is there way iterator gets references structs in accountlist? just let accountlist []*account. you'll pointers each account inside range.

Java: static nested classes and reflection: "$" vs "." -

if have class com.example.test.enum2.test in code below, why getcanonicalname() return com.example.test.enum2.test class.forname() requires "com.example.test.enum2$test" argument? is there way consistent, can serialize/deserialize enum value name, without having check each $ vs . possibility, when enum nested class? package com.example.test; import java.util.arrays; public class enum2 { enum test { foo, bar, baz; } public static void main(string[] args) { (string classname : arrays.aslist( "com.example.test.enum2.test", "com.example.test.enum2$test")) { try { class<?> cl = class.forname(classname); system.out.println(classname+" found: "+cl.getcanonicalname()); } catch (classnotfoundexception e) { e.printstacktrace(); } } system.out.println(tes

mysql - SQl Left Join Query -

these tables have(i got this): table building: b_id(key relation table build-works b_id):1 2 3 field1: buildinga, buildingb, buildingc table build-works: b_id:1 1 2 3 3 3 w_id: 1 2 1 1 2 3 table works: w_id(key relation table build-works w_id): 1 2 3 4 field1: electricity, sanitary, shell, roofing now want know works per building? how can sql, , can give example zend_db? thanks using left joins since in title select * building b left join buildworks bw on b.b_id = bw.b_od left join works w on bw.w_id = w.w_id

redirect - redirecting html page to another html -

i have redirect website website, before shown. have tried using .htaccess giving me problems. have used javavscript , meta not work before loading of page want transfer. help? try one <meta http-equiv="refresh" content="n; url=other-web-address"> where n approximate number of seconds want current web page displayed before browser automatically goes other web address. if n = 0, browser should go other web address. i hope solve problem

java - How do I close a UDP server without throwing an exception? -

i have server waits incoming client messages , uses udp. when try close udp connection ioexception.. public void run(){ string user_message = null; try { connection = startserver(); system.out.println("server started"); while ((true) && (serverstarted) ){ try { user_message = receivemessage(); check_query( user_message , "," ); } catch ( ioexception ex ) { system.out.println("error1 "+ex.getmessage()); seterror( "error establishing connection " ) ; txt_log.settext(txt_log.gettext() + "\n error establishing connection0") ; break; } } system.out.println("server stopped....."); } catch ( socketexcep

javascript - Is link pointing to this page? -

for website's navigation want give links current page color. how find links pointing current page? link's href "../index.php" current page http://mysite.myserver.com/index.php . this current approach, doesn't want work: string.prototype.endswith = function(str) { return ( this.match(str + "$") == str ); } string.prototype.startswith = function(str) { return ( this.match("^" + str) == str ) } string.prototype.trim = function(sec) { var res = this; while (res.startwith(sec)) { res = res.substr(sec.length); } while (res.endswith(sec)) { res = res.substr(0, res.length - sec.length); } return res; } and, when document ready: $("a").each( function (i) { if (window.location.pathname.endswith($(this).attr("href").trim("."))) { $(this).addclass("thispage"); } } ); and yes, know might color home link

entity framework with SP -

i'm using vs 2008 sp1. want use sp in entity framework. problem sp returns more 1 result set. how multiple result sets? online examples showing single result. please me. entity framework unfortunately not support multiple result sets stored procedures - not in .net 4 release. you need either rewrite stored procs, or access them using standard, bare-bones ado.net - , ask microsoft support multiple sp result sets in ef 5 !! i'll cast vote in favor, too!

c# - What is the most efficient way to ask a MethodInfo how many parameters it takes? -

what efficient way ask methodinfo if accepts parameters and, if so, how many? my current solutions be: methodinfo.getparameters().any() , methodinfo.getparameters().count() . is efficient way? since don't need of parameterinfo objects, there way without call getparameters() ? the 2 listed linq. any() returns bool - stating there @ least one. count() used on ienumerable<t> . length (the property) fastest because getparameters() returns parameterinfo[] . it not appear methodinfo have other way access number of parameters other getparameters() .

Rails 3 - How to embed inline Images that are hosted on S3 -

in rails 3 app, send out emails include user profile pictures. problem gmail shows "click allow images display" type of warning. how can embed images inside email there no external url calls images? also, images on s3 paperclip , not stored locally. thanks unfortunately can't force email client accept kind of picture, whether it's embedded or external url. can include pictures attachments email instead of embedding them. said, different email clients handle attachments in different ways, gmail example scan attachments , display them below message. if want have images embeded text you'll have settle 'click allow images display', since it's there security reasons , out of control.

How To: Maven project to build JavaScript in Eclipse -

how configure pom have folder act javascript build path? i have developers import project eclipse , automatically have javascript root folder in eclipse build path auto-complete , other javascript support works. here do, , seems work okay. i'm using eclipse juno sr2 (java ee web developers), , maven 3.0.5, right now. (i'm not expert in either eclipse or maven, i'm sure there more elegant way of doing this. please let me know!) we want have project structure below, per maven conventions: - src +-- main +-- java +-- js +-- webapp +-- web-inf +-- test +-- java +-- js and want have web application deployed structure like: - / +-- js +-- web-inf +-- classes the key portion of maven pom.xml in maven-war-plugin, copies on src/main/js files: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.