Posts

Showing posts from September, 2014

c# - Page lifecycle question -

i using dropdown menu , updatepanel filter out datagrid. datagrid has buttons redirect different page. when hit button or link on top of other page, redirects me page dropdown should...but gets rid of datagrid data , have make selection dropdown again. there way make sure dropdown selection remembered when both link pressed , button selected? help! the easiest thing in case save dropdown selection in session collection , on page load, check see if there saved selection , use reapply selection. protected void dropdownlist1_selectedindexchanged(object sender, eventargs e) { session["savedselection"] = dropdownlist1.selectedindex; } protected void page_load(object sender, eventargs e) { if(session["savedselection"] != null) { int selectedindex = (int) session["savedselection"]; dropdownlist1.selectedindex = selectedindex; } }

iphone - Calculating the cells contained inside a rectangle on an Isometric Grid -

consider given isometric grid (consider diablo) of tiles. have measures grid, grid height, grid width , tile height/width. (consider image: http://2.bp.blogspot.com/_bazwykf2fdm/si2gbwd7kji/aaaaaaaabvw/bcb-eamgez4/s1600-h/isometric_grid ). center cell of grid 0,0 extending iso-north (+y), iso-south(-y), iso-east(+x), iso-west(-x). let's draw rectangle @ arbitrary location on grid. not have isometric positions rectangle, rather have normal draw coordinates grid top left hand corner 0,0 , south y+, right x+. if had top, left, height, width of rectangle in question - how calculate array of iso-cells crossed bottom edge of rectangle. any language choose demonstrate suffice. in papers , books isometric programming (isometric programming direct x7, yes old gives overview problems , techniques) use mousemaps. also there technique render area of map covered rectangle image, each tile gets unique color (and color rendered). afterwards check colors in image , extract lis...

JavaScript arrays braces vs brackets -

what difference between each of following array definitions. var myarray = []; var myarray = {}; var myarray = new array(); the first , third equivalent , create new array. second creates new empty object, not array. var myarray = []; //create new array var myarray = {}; //creates **a new empty object** var myarray = new array(); //create new array

multithreading - How do I signal a sleeping thread in Java? -

i'm writing udp client-server pair networks class, , have hit on problem. rather unorthodox networks assignment, little background first: the goal create server implement push-based notifications. key point here server has contact client @ whatever address last seen, listen client's control packets. therefore, have thread running on client periodically sending out udp packets server, logs origin when needs send out response. technique busts through nat's, send refreshes address translation. so then, here dilemma: unless i'm mistaken, nat maps own address , generated port number onto it's clients address port combination. therefore, in order traverse nat, need move packets through 1 port on client machine. updater thread have listen time, push out update packet, , go listening. then here hairy. if original thread, wants perform action, wants port, has wake announcer, blocking while waiting response. how can pull off in java? p.s.: if turns out nat al...

Working with PDO object - MySQL -

i new pdo , have pretty simple question. have simple function connecting db: function connectdb() { try { $dbh = new pdo('mysql:host='.config::$db_server.';dbname='.config::$db_name, config::$db_login, config::$db_password, array( pdo::attr_persistent => true )); $dbh->exec("set character set utf8"); $dbh = null; } catch (pdoexception $e) { print "error!: " . $e->getmessage() . "<br/>"; die(); } } after calling function connect db. later when trying send query using $dbh->query got "call member function query() on non-object ". understand - don't have instance of class @ moment. think achieve use $dbh = new pdo("settings") again, kind of stupid isn't? function has no sense than. tried return $dbh in connectdb function (before null statement) wasn't working. how s...

c# - Reset WPF Datagrid scrollbar position -

when changing .datacontext property of datagrid (to new source) selected item gets cleared, scrollbar position retained. avoid call .scrollintoview(.item(0), after changing datacontext, move scrollbar upwards. displays wrong page fraction of second, , when scroll top before changing datacontext, have same problem. so how can change .datacontext , resetting scrollbar position @ same time? edit: should mention xaml looks this: <datagrid virtualizingstackpanel.isvirtualizing="true" virtualizingstackpanel.virtualizationmode="recycling"> so maybe virtualizing cause. have tried calling scrolltotop scrollviewer in datacontextchanged event? <datagrid virtualizingstackpanel.isvirtualizing="true" virtualizingstackpanel.virtualizationmode="recycling" datacontextchanged="datagrid_datacontextchanged" ...> private void datagrid_datacontextchanged(object sender, dependencypropertycha...

php - How to transform image over object -

example: http://gyazo.com/745e6912db5bf2c1dd05a7a7537bfca4.png i wanna put image on object... looks native picture on object. give key words of these image manipulation process can google ;) it's not php, client-side programming want into. try css z-index properties.

parsing - PHP: unformat money -

is there way float value of string this: 75,25 € , other parsefloat(str_replace(',', '.', $var)) ? i want dependent on current site language, , comma replaced dot. you can use numberformatter::parsecurrency - parse currency number example manual: $formatter = new numberformatter('de_de', numberformatter::currency); var_dump($formatter->parsecurrency("75,25 €", $curr)); gives: float(75.25) note intl extension not enabled default. please refer installation instructions .

c - multiple definiton of function-error in kernel-file -

hey guys. i'm trying port tool digsig centos-kernel seems lack few important crypto-functions digsig. port newer /linux/crypto.h has functionality need plus added little code: void kzfree(const void *p) { size_t ks; void *mem = (void *)p; if (unlikely(zonp(mem))) return; ks = ksize(mem); memset(mem, 0, ks); kfree(mem); } because kernel i'm working on not have kzfree yet. now, when try compile digsig, output: /home/chris/dstest/dsi_sysfs.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: first defined here /home/chris/dstest/digsig_cache.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linu...

c# - Show Inner Test results of a Generic Test in summary -

i have little problem generic test , building project using tfs. have silverlight user control, testing using silverlight unit tests toolkit. have build machine, , using statlight, managed make run test automatically when project building(thanks author of article http://www.nielshebling.de/?p=167 ). problem in results, inner test results shown in summary(look @ screenshot below). it's showing 1 test run(the generic test). http://img705.imageshack.us/i/screenqqs.jpg/ is possible? using xml schema definition tool (xsd.exe) generated class summaryresult.xsd. maybe it's possible rewrite class results of inner test shown in summary? appreciated p.s. excuse me english have @ these 2 articles: summary results file vsts generic tests (the example coded in vb easy follow. helped me much.) manual, generic, , ordered tests (in last part of article generic test described. there useful screen shots can decide if worth implementing it, meaning if information provided...

amazon web services - Boot EC2 EBS volume locally? -

i want testing ec2 instance, download pc , run locally on virtualbox/kvm or like. possible? no, it's not. ec2 instances run on customised red hat xen layer amis tailored platform. images cannot used anywhere else.

Mixing C and objective-C -

i've been using objective c while now, , i've started learning of lower level iphone api's such core audio. of these api's in c confusing me bit, i'm not sure put lot of code , don't know rules, etc. know place start learning is? thanks, darren. does know place start learning is? buy , read " the c programming language ". it's not long , surprisingly enjoyable. read , understand apple's c-based example code. browse header files apple's classes. great way learn how apple sets enum s , string constants, etc. doing these 3 things won't make expert in c, it'll give 90% of need able confidently things done apple's low level frameworks.

java - Persistent TCP connection client / server -

i'm building client server application android device server on 3g. because of network operator providing 3g, client device behind nat. therefore, impossible server make connection client. adopt approach of polling, before doing so, want exhaust other options. there way ( haven't yet found 1 ) keep tcp socket connection open between client , server, such server able initiate communications client? the scenario there regular client/server communication based on server state updates on extremely regular basis - talking every couple of seconds. udp better option here? maybe not nat issue still knocks on head. are there other options available me? many thanks nat not mean server can not send anything. open connection client , let server send whatever events records. may want include simple heartbeat protocol make client , server register broken connection , make nat aware connection still being used.

licensing - Forking google code project which doesn't list any copyright information -

there project hosted on google's project hosting has gone inactive, , fork under different name, , include within library i'm working on. google project states published under gpl v2, (google project hosting requires choosing license create project), , library i'm working on under same license. however, within project's distributed source, distributed binaries, , source code within svn, there no mention of copyright or license blocks. i retain copyright information required under license, there no copyright information retain. should leave out , put own license block without copyright clause in it? should add copyright line ? should put line stating no copyright information listed in original source? i'd book as possible. add own copyright notice consistent gpl v2 license , reference original source. really though, if old code stated gpl , fork gpl, don't think going care nitty gritty details this. it's try right thing, reasonable undou...

PHP syntax error when installing pear on mac OS X 10.6.6 -

i'm trying (with problems) install pear on system, mac osx 10.6.6 php works ok, apache , mysql. on /usr/local followed instructions: $ curl http://pear.php.net/go-pear.phar $ php go-pear.phar and get php: syntax error, unexpected bool_false in /private/etc/php.ini on line 1050 i'm not sure what's wrong php.ini. you can use: $ php -d detect_unicode=0 go-pear.phar

osx - Mac App Testing -

is there website or service can use test mac app store apps? i've seen macdeveloper.net, being costs money want make sure there aren't other services better. thanks! i used macdeveloper.net 2 years ago, mac app (yes, there mac apps before mac app store). great experience. feedback beta-testers great, in quality , quantity. helped me spot , fix subtle bugs. great, because didn't want real users encounter them. i find price asked service (less $20) reasonable: think how cost if 1 bug not found until on app store, , user posts negative review because of it. the infrastructure provided ease beta-testing phase great. time saved enough make me feel worth it. prefer spend time coding , improving marketing deal problem else resolved better me when had questions, support replying quickly, great , appropriate answers ...

How to define datatemplates for datagrid? -

this basic question, i'm new , relying on google searches, so... i'm trying put datagrid displays rows of text containing id , multiple languages. i'm basing each row off class "textrow" contains id , collection of languagecell items, each containing language , text (i plan add more later): public class textrowclass { public string label { get; internal set; } public dictionary<string, languagecell> textcells { get; internal set; } public class languagecell { public string language { get; internal set; } public string text { get; internal set; } } } my question is: how set datagrid display information in languagecell class want? (in case, display text element in cell , using other elements (to added) various other purposes.) i'm sure has defining datatemplate, can't find information it. thanks! i found answer question in converting class datatable , usin...

iphone - wait_fences: failed to receive reply: 10004003 error - UIAlertView with UIActivityIndicatorView -

i hoped answers squeezemylime's question solve problem have uialertview without text field did not work out well. instead of text field placed uiactivityindicatorview animating on , no buttons used on creation. alert gets programmatically dismissed delegate method destroys spinner on alert , alert (which has been retained through time running). so, i'm getting these wait_fences: messages within debugger , i'm frozen in meantime because tried including valuable hints in thread won't kill these wait_fences: messages. there no crash, neither gdb nor on device. stepping through code realized wait_fences: message shown directly after delegate dismisswithclickedbuttonindex:0 animated:no releases questionable uialertview. thought similar squeezemylime 's delay technique , did this: [thealertobj performselector:@selector(dismisswithclickedbuttonindex:animated:) withobject:nil afterdelay:0.1]; and wait_fences: message gone! call dismisswithclickedbuttoninde...

How to redirect Query Strings with ISAPI Rewrite? -

i'm using following lines in httpd.ini file redirect users access example.com www.example.com: rewritecond host: (?:www\.)?example.com rewriterule (.*) http\://www.example.com [rp,l] i'd know how redirect query strings whether user access site without www, example: my user access: example.com?a=1&b=2 example.com/a/b i'd redirect to: www.example.com?a=1&b=2 www.example.com/a/b someone can me, please? thanks lot. this looks you're using isapi_rewrite v2, i'll answer version. v3 syntax different. in first line, think needs ! negative lookahead www. shown, it's matching www instead of not-www. the answer involves capturing pieces of url, using them in rewrite submatch $1, $2, etc. rewritecond host: (?!www\.)example.com rewriterule (.*) http\://www.example.com$1 [i,rp] can make more generic domain, copy other websites, capturing instead of example.com. becomes first capture $1, while rest of url $2. rewritecond host: (...

Is there an easy way to incorporate a java applet in an ASP.NET page? -

i have java applet include in asp.net page. applet works on regular old html page. when try include applet in asp.net page however, java appears start (it shows java logo , spinny blue circle), exception occurs main class: load: class com.myclass.main.class not found. java.lang.classnotfoundexception: com.myclass.main.class i putting applet in page following code - <applet code="com.xyz.main.class" width="500" height="500" archive="myjar.jar" > <param name="aparam" value="somevalue"/> </applet> note, same tag use put applet plain html page. i'm guessing reason class not found exception when asp compiles page puts somewhere else? if so, where? note still have not deployed page web server, it's running locally on development machine. why not specify absolute uri/oath applet codebase attribute ? way not have worry vagaries of relative pathing of different systems. ...

dataframe - R: Question about table reshaping -

i have following data frame: id,property1,property2,property3 1,1,0,0 2,1,1,0 3,0,0,1 4,1,1,1 d.f <- structure(list(id = 1:4, property1 = c(1l, 1l, 0l, 1l), property2 = c(0l, 1l, 0l, 1l), property3 = c(0l, 0l, 1l, 1l)), .names = c("id", "property1", "property2", "property3"), class = "data.frame", row.names = c(na, -4l)) what least cumbersome way following data frame: id,properties_list 1,property1 2,property1, property2 3,property3 4,property1, property2, property3 maybe melt or reshape fancy options? this solution assumes you're looking data frame similar how gsk3 interpreted question (pasting properties together) obligatory avoidance of for loop, cause that's how roll r: property_list <- apply(d.f[,-1],1, fun=function(x,nms){paste(nms[as.logical(x)],collapse=",")}, nms=colnames(d.f)[-1]) as.data.frame(cbind(d.f$id,property_list)) ...

Proper way to check for null dates in Flex/Actionscript? -

when working date() objects in flex/actionscript, i'm using following function check null dates. proper way check null date or there better alternative out there? public function isdatenull(date:date):boolean { if (date && date.fullyear != 0) { return true; } return false; } since date class extends object , isn't primitive type doesn't have default value , therefore should null if hasn't yet been instantiated. date being populated sort of database mapping or along lines? otherwise not just if(!date) or if(date==null) no need have function this. datefield.selecteddate value should null if no date has been selected yet. wasn't posted answer because don't entirely understand issue being encountered sounds though there's variety of cases though. depending on service layer , underlying jdbc (or other connector) db , type of db , datatype values can vary. in general date null until memory acquired through call cons...

function - CakePHP custom pagination / paginator in controller not working as expected - what am I doing wrong? -

i can find work other way, cannot working pagination. doing wrong? output in view: sql error: 1054: unknown column 'fields' in 'where clause' warning (2):** cannot modify header information - headers sent (output started at... controller action: ... $cond = array( 'fields' => array('id', 'name', 'provider_network_url', 'application_url'), 'conditions' => array('plandetail.id' => $id), 'contain' => array( 'company' => array('fields' => array( 'id', 'name', 'company_logo_url', 'plan_detail_by_company_landing')), 'plan' => array('fields' => array('id', 'monthly_cost'), 'applicant' => array('fields' => array('id', '...

xsd - Add an attribute or create a new level in the XML hierarchy? -

i working on xml document written xml hierarchy 2 levels. right now, want add one-to-many categorization break of code works file. i either add categorization new level, or can implement attribute on same level (almost tagging). current: <category> <subcategory></subcategory> <category> proposed: <supercategory> <category> <subcategory></subcategory> </category> </supercategory> or: <category supercategory=""> <subcategory></subcategory> </category> which method more maintainable? to me, 1 of strengths of xml hierarchical nature of xml elements ideally suited describing hierarchical arrangements of objects, such in case. such, tend prefer first option, xml structure more resembles structure of data. makes easier read, manage , understand, imho. that said, can if effort required make work existing codebase worth it. there's nothing sto...

linq to entities - How to create a Store Expression for entity framework -

i have this. var viewmodel = repgeneric.getlistof<companycontact>(p => p.companyid == 1).select(s => new contactviewmodel() { contacttype = _db.contacttypetexts.firstordefault(p => p.id == s.contact.contacttype.id).txt }); i put piece of code _db.contacttypetexts.firstordefault(p => p.id == s.contact.contacttype.id).txt in function. how can that.? idea. try that's give me error : linq entities not recognize method 'system.string gettxt()' method, , method cannot translated store expression. thanks try model-defined function described in this blog article julie lerman.

What is this MATLAB statement for: [M N ~] = size(imge);? -

what statement mean??? [m n ~] = size(imge); i don't understand reason use "~", , statement gives error message. in matlab versions since 2009b, can use tilde ( ~ ) to ignore outputs don't need . if gives error, means version doesn't support use of tilde , have replace dummy variable name so: [m n dummy] = size(imge); as sumona explains, m contain number or rows in image , n number of columns; dummy 1 (for 1 black-and-white image), 3 (for 1 colour image) or arbitrary integer (for image stack). usually makes sense use tilde if there other parameters interested afterwards. size exception here in checks (using nargout ) how many outputs should produce , changes behavior accordingly, as documented here. . that is, test = zeros(3,4,5); [m n dummy] = size(test); produces m=3,n=4 1 expect, but test = zeros(3,4,5); [m n] = size(test); produces m=3,n=20. in particular case, assume imge image stack , programmer wanted find out size of in...

curl equivalent code written in httpclient : java -

have web-application running in tomcat, based on actions in web-applications need write java code trigger curl (http://curl.haxx.se). curl query third-party application , return xml/json. this has read me , return appropriate response user. i know can done curl using command line tool making request web application not best way go , have written code in java, httpclient api. the curl code was curl -u username:password -d "param1=aaa& param2=bbb" -k http://www.testme.com/api/searches.xml curl default uses base64 encoding. corresponding code in java written me is import org.apache.commons.codec.binary.base64; import org.apache.commons.httpclient.httpclient; import org.apache.commons.httpclient.httpstatus; import org.apache.commons.httpclient.usernamepasswordcredentials; import org.apache.commons.httpclient.methods.postmethod; import java.io.bufferedreader; import java.io.bytearrayoutputstream; import java.io.inputstreamreader; public class ncs2 { public...

regex - How do I exclude a word from a regular expression search? -

how can create regular expression following problem: i have string, name1=value1;name2=value2;.....; somewhere, there exists pair, "begin=10072011;" need, regular expressions, parse string name=value; pairs, value number. however, want ignore name begin currently have following regexp: ([\\w]+)=([\\d]+); mine selects begin name. how can change not include begin ? (?!begin)\b(\w+)=(\d+); this uses negative lookahead, not match if string starts "begin". \b necessary regex not skip "b" , match "egin=...". note when describing regex should using single backslash escapes, although languages need use double backslashes escape backslash.

php - Intermittent 500 errors from Apache running Zend Framework with multiple virtual hosts -

we have been working on project several months without problems until set of recent updates. server running amazon linux ami release 2010.11.1, apache 2.2.16 , php 5.3.3. project divided few separate developer branches, running virtual hosts, each separate copy of code including zend framework 1.11.3. project includes doctrine 2.0.1, don't think problem is. have experimented apc in past, don't have installed right now. issue seems occur when multiple users hitting server across different branches. suspect issue related differing versions of core classes required during zend framework bootstrap process, can't figure out root cause is. have tried forcing branches @ same version our git repo, , restarted apache. temporarily resolves issue, returns. began week ago when merely installed set of mainstream updates linux, php, , zend framework. when issue occurring, propagates our phpmyadmin virtual host, doesn't have zend framework. stumped. following set of errors see in ...

php custom error handling -

i have question you. on site have following error report level // php errors reported when script run. error_reporting(0); problem when session times out blank page , user has type address again go main page , log on. is there way embed link above code when session times out echo link main page? i tried // php errors reported when script run. error_reporting(0); echo ("index.php"); with no luck, ideas? thank you. :) your session checking code should http redirect login page if user's session has expired. session_start(); // check if user logged in if (!isset($_session['current_user'])) { header("location: http://example.com/login"); exit; } // code run when user logged in ....

performance - How can I get better response times with soundManager2? -

using soundmanager2, made simple anchor onclick="mysound.play()", there big gap (almost half second) before sound heard! is, though pre-loaded sound. how can better response-time? here source code: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="shawn inder" /> <title>jeureno</title> <style type="text/css"> <!-- --> </style> <!-- include sm2 library --> <script type="text/javascript" src="soundmanager/script/soundmanager2.js"></script> <!-- configure ...

linux - resetting value of a local variable -

i using local variable record in loop like record=$(awk 'nf!=4 {print $0}' n20${i}) but everytime instead of taking new value appends last value new value. how can solve problem? in advance. record=$(awk 'nf!=4 {print $0}' n20$((i++))) that increment value of i each time line executed. or if want i+1 without changing value of i : record=$(awk 'nf!=4 {print $0}' n20$((i+1)))

java - Adding an Attribute to a JAXB Element -

i'm struggling jaxb parsing , need guidance. essentially, i'm trying add attributes class variables have declared elements using @xmlelement. far, attempt use @xmlattribute sets attribute @ class level. what i"m getting this: <dataclass newattribute="test"> <myelement>i wish element had attribute</myelement> <anotherelement>i wish element had attribute too</anotherelement> </dataclass> i'd to this: <dataclass> <myelement thisatt="this i'm talking about">this better</myelement> <anotherelement thisatt="a different attribute here">so this</anotherelement> </dataclass> i've seen other posts add attribute single element using @xmlvalue, doesn't work when have elements, , won't work on multiple elements. does have thought on how accomplished? thanks! jason this create xml: public class jaxbattributes { public stat...

python - Organizing XML data into dictionaries -

i'm trying organize data dictionary format xml data. used run monte carlo simulations. here example of couple of entries in xml like: <retirement> <item> <low>-0.34</low> <high>-0.32</high> <freq>0.0294117647058824</freq> <variable>stock</variable> <type>historic</type> </item> <item> <low>-0.32</low> <high>-0.29</high> <freq>0</freq> <variable>stock</variable> <type>historic</type> </item> </retirement> my current data sets have 2 variables , type can 1 of 3 or possible 4 discrete types. hard coding 2 variables isn't problem, start working data has many more variables , automate process. goal automatically import xml data dictionary able further manipulate later without having hard code in array titles , variables. he...

How to customize wp-signup.php Wordpress MU -

default wordpress mu signup page not allowing choice own password. i want customize following page http://blog.co.in/wp-signup.php the solution choice own password in wordpress mu recode part of ms-functions.php . when registering wordpress mu calls : wpmu_signup_user() calls wpmu_signup_user_notification() send notification , activation key. after you'll launch activation link call wpmu_activate_signup($key) , password generated : $password = wp_generate_password( 12, false ); so can try put form before launching method, or bypass activation stuff , directly call : wpmu_create_user($user_login, $password, $user_email); but i'm not sure it's best solution.

eclipse - Blackberry signing -

i have key files blackberry site. i have imported using blackberry eclipse plug-in. i have signed files. now want add files website can download application , use in mobile device. i want know file have upload website. please reply. thanks in advance the eclipse plugin automatically generates deliverables folders, includes .cod files , .alx files, can deploy applications using various ways. of ways using can deploy application end users by: 1. uploading application in blackberry world 2. using .cod file of application needs blackberry jde 3. using .alx file , browsing using blackberry desktop software 4. deliverables folder contain .jad files too, using file, can deploy applications, need follow steps 4.1 copy .jad , .cod files 1 separate folder(just make sure dont miss files) 4.2 rename .cod file .zip file eg : abc.cod should renamed abc.zip 4.3 once .zip done, need extract files , copy extracted files , .jad folder(just safe) 4.4 now, upload folde...

php - Check if number is decimal -

i need check in php if user entered decimal number (us way, decimal point: x.xxx) any reliable way this? you can of want is_float , if really need know whether has decimal in it, function above isn't terribly far (albeit wrong language): function is_decimal( $val ) { return is_numeric( $val ) && floor( $val ) != $val; }

Explain this Groovy code? -

def foo(n) { return {n += it} } the code defines function/method foo returns closure. purpose of understanding code, can think of closure method has no name , not attached object. the closure can invoked passing single argument. value returned closure n += it it default name used refer closure's argument. if wanted closure's argument have different name, e.g. closureparam need define explicity: def foo(n) { return {closureparam -> n += closureparam} } the -> separates closure's parameter list closure body. if no parameter list defined, default single parameter named it . maybe example of invoking closure help: closure closure = foo(2) def closurereturnval = closure.call(4) assert closurereturnval == 6 // because 4 + 2 == 6 // can omit .call when calling closure, following works closure = foo(3) assert 8 == closure(5)

ajax - jQuery selector -

i have following html: <tr> <td> <img id='1' class='promote' src='/images/plus.png' /> <span>0</span> <img id='1' class='demote' src='/images/minus.png' /> </td> <td> <img id='2' class='promote' src='/images/plus.png' /> <span>0</span> <img id='2' class='demote' src='/images/minus.png' /> </td> ... </tr> next, i'm using jquery ajax: $('img.promote').click(function() { $.ajax({ url: '/promote/' + this.id, success: function(data) { $(???).text(data.rating); }, datatype: 'json' }); }); $('img.demote').click(function() { $.ajax({ url: '/demote/' + this.id, success: function(data) { $(???).text(data.rating); }, datatype: 'json' }); }); so, combination of jquery selectors should ...

android - How can I add my apps functionality into other applications easily/legally? -

i'm experimenting text speech applications on android, app speak pre determined piece of text. is there way can have other applications use functionality? example, if using browser, select text , somehow pass activity in application? thanks if define proper intent filters , third party apps launch intents matching info, users given option use app. i use following intent filter make url shortening app available many places in android, including share menus on youtube, browser, , google reader: <intent-filter> <action android:name="android.intent.action.send"/> <category android:name="android.intent.category.default"/> <data android:mimetype="text/plain"/> </intent-filter> more info available here .

mysql , perl script freezing when retrieving data -

hi have code. perl scripts hangs somewhere in @row section. printed next query statement , works in sql. why hanging? foreach $device (...) $sth2 = $dbh->prepare(qq|select distinct s,`w(m)`,`l(m)`,v `$sql_table_name` device='$device'| ); $sth2->execute( ); %temp = (); while ( @row = $sth2->fetchrow_array( )) { $temp{s}{$row[0]} = 1; $temp{w}{$row[1]} = 1; $temp{l}{$row[2]} = 1; $temp{v}{$row[3]} = 1; } you seem have syntax error in query ( vfrom rather v from ). if query fails, there's no result set fetch row from. might want build error handling code.

iphone - Hacks to access iOS APIs through Flex? -

i building flex iphone application in ideal world need open iphone sms interface send texts, make calls, access phone information (such phone number) , access contact lists... realise there isn't in way of accessing phone specific api's through flex @ moment, know if or when coming? my main question: seen interesting article on extending air access android apis , wondering if there similar accessing ios apis? people doing @ moment if need access ios apis? waiting update flex/air? i'd prefer not splash out on mac! thanks phil you can use url syntax flex app open 'native' controls sending / receiving text messages. can somthing this: navigatetourl(new urlrequest("sms:6175551212")) it's not perfect, , still not give access address book, though. add message text, can use body attribute url variable: navigatetourl(new urlrequest("sms:6175551212?body=hello%20there")) ( source body url variable ) i realise there i...

How to fire validation on Save button in Silverlight? -

how fire validation on save button in silverlight? i not using data forms. using ria domain service other operations want validate on save button before saving data. how can it? here i've used validate multiple things within page before save commits changes. follow zoltan's blog more complete structure. he's presented @ mix '11 this.

c# - ADODB failure when trying to access Fields -

i using cdo , adodb generate smil sending mms messages. working fine (i think) after windows server 2008 r2 updates, things stopped working error: unable cast com object of type 'system.__comobject' interface type 'adodb.fields'. operation failed because queryinterface call on com component interface iid '{00001564-0000-0010-8000-00aa006d2ea4}' failed due following error: no such interface supported (exception hresult: 0x80004002 (e_nointerface)). here's breaks: private const string mccdocontentlocation = "urn:schemas:mailheader:content-location"; part.fields[mccdocontentlocation].value = "smil"; any ideas? maybe alternative on how generate smil documents? in case having same issue, microsoft provided backwards compatible library, here's solution: an ado application not run on down-level operating systems after recompile on computer running windows 7 sp 1 or windows server 2008 r2 sp 1 or has kb983246...

view - GWT & MVP - Best practices for displaying/editing complex objects? -

all gwt / mvp examples i've learned seem simplistic give clear view best practises regarding displaying , handling more complex model objects. for example, examples presenter attaches click handler few textboxes on view...if save clicked, presenter's save() called gets updated values, , we're done, mvp style. that's not realistic though. for example, let's have: presenterx - gets 'model' object, let's object unknown number of various primitives or whatever viewx - should show model object in table, and/or allows edited/re-saved ...so sounds very, basic. but, don't know amount of fields in model object need display. might relate dynamic number of rows/columns. no problem table...but how should presenter give view's table? model object view understands, or break down bunch of lists...that view still has understand. also, fields might editable, of unknown until model object (something in model determines fields editable, say) -- sho...

javascript - redirect PS3 via user agent -

i want users redirected different webpage if using ps3 here code have been trying use <script language=javascript> <!-- if ((navigator.useragent.match(/imozilla/i)) || (navigator.useragent.match(/iplaystation 3/i))) { location.replace("http://example.com"); } --> </script> a list of user agents ps3 can found here http://www.useragentstring.com/pages/playstation%203/ i cant seem work doing wrong? you try this: <script language=javascript> var uagent = navigator.useragent; if (uagent.indexof("playstation") != -1) { window.location = ("http://example.com"); } </script> it may easier attempt server side (c# ex below) if (request.useragent.toupper().contains("playstation")) //send correct page response.redirect("http://www.example.com/"); }

php - Inserting specific values into a DB, and displaying it on a table? -

i'm trying insert specific values(knife, , blanket) database, but's not inserting db/table @ all. also, want display inserted values in table below, , not working well. dependant on insert show on table. sure, because inserted value through phpmyadmin, , displayed on table. please, need fix insert aspect. the insert code/error handler <?php if (isset($_post['collect'])) { if(($_post['object'])!= "knife" && ($_post['object'])!= "blanket") { echo "this isn't among room objects."; }else { // makes sure uses sign have own names $sql = "select id objects object='".mysql_real_escape_string($_post['object'])."'"; $query = mysql_query($sql) or die(mysql_error()); $m_count = mysql_num_rows($query); if($m_count >= "1"){ echo 'this object has been taken.!'; } else{ $sql="insert objects (object) values ('$_post[object]')"; e...

portlet - Linking to a Page that "contains" a specific Web Content Article in Liferay 6 -

i'm building portlet site powered liferay ee 6.0 sp1 suggest related or otherwise interesting content depending on user looking at. for example, suppose user on page contains web content display portlet displaying web content article 5. portlet contain html links pages user can view web content articles 6 , 7 (which contain content determined similar content in web content 5). the problem comes in because don't want portlet display html links web content articles 6 , 7 (assuming such concept valid), want portlet display links to pages on items displayed (i.e., links pages contain web content display portlets configured show web content articles). is there way to: associate web content article page if have former, can fetch latter? or, determine page(s) contain portlets display web content article? alternatively, if there way portlet instances associated particular page, might lead solution well. one approach problem appears to add "link page...

unix - tc shell script: undefined variable -

can tell me doing wrong set flag1.. getting error of flag1: undefined variable. if($notloaded1 > 0) echo "rows not loaded due data errors in first load: $notloaded1" set flag1=1 endif if($notloaded2 > 0) echo "rows not loaded due data errors in second load: $notloaded2" set flag2=1 endif if($notloaded3 > 0) echo "rows not loaded due data errors in third load: $notloaded3" set flag3=1 endif echo $flag1 echo $flag2 echo $flag3 is there way check 3 of them in 1 if statement or rather using 3 if statements if ($flag1 > 0) exit 1 endif if ($flag2 > 0) exit 1 endif if ($flag3 > 0) exit 1 endif thank you what need 3 flag variables for? set error=0 if ($notloaded1 > 0) echo "rows not loaded due data errors in first load: $notloaded1" set error=1 endif if ($notloaded2 > 0) echo "rows not loaded due data errors in second load: $notloaded2" set error=1 endif if ($notl...

asp.net mvc - jQueryUI Modal open event & MVC.NET causing error ".dialog is not a function" -

i hope can i'm @ wits end this. i'm trying this. "draggable" item dropped "droppable" area (this works) this posts id of item controller returns type of item (this works) i pass returned item name function opens modal , renders partial view in modal depending on particular item. the last bit issue is. steps above work fine, modal popped , partial view rendered modal. button close dialog throws error ".dialog not function" , after closing modal using 'x' in corner subsequent attempts open modal not work throwing similar error. here's example i'm working try working. $(function () { $('.draggable').draggable({ containment: '#imageboundry', revert: 'valid' }); $('#droppable').droppable({ drop: function (event, ui) { $.ajax({ type: "post", url: '/home/addtocart/' + $(ui.draggable).attr(...

colors - "00" becomes "0" in PHP function, but it must be "00" for RGB to work. How? -

Image
this php rgb brightness altering function works partially: it misses 1 0 "0" @ end: should "00" how solve this? $color = "#a7a709"; // constant $color1 = brightness($color,+25); // brighter, echoes #c0c022, correct rgb value $color2 = brightness($color,-25); // darker echoes #8e8e0, incorrect rgb value!! how fix this? appreciated! the function brightness(); ### credits go cusimar9 wrote function brightness($colourstr, $steps) { $colourstr = str_replace('#','',$colourstr); $rhex = substr($colourstr,0,2); $ghex = substr($colourstr,2,2); $bhex = substr($colourstr,4,2); $r = hexdec($rhex); $g = hexdec($ghex); $b = hexdec($bhex); $r = max(0,min(255,$r + $steps)); $g = max(0,min(255,$g + $steps)); $b = max(0,min(255,$b + $steps)); return '#'.dechex($r).dechex($g).dechex($b); } return sprintf("#%02x%02x%02x", $r, $g, $b);

php - Displaying an image with different name -

on website let users upload images. i save images under hashed (based on name + timestamp) name. i store both original name hashed name in database. i display image on page using original name. case user uploads test.jpg image saved /img/6eabd22d35b4132cc58e4dff75e466cc1e444d93053ca80087b12ff620bd3451 on server both original , hashed names stored in database display image on page using original name ( <img src="/img/test.jpg" alt="" title=""> ) /img/6eabd22d35b4132cc58e4dff75e466cc1e444d93053ca80087b12ff620bd3451 is possible? yeah, that's possible. it's quite easy, have to: rewrite requests conform pattern (php) script using apache module mod_rewrite; in script fetch real name database , display image. don't forget send correct header, otherwise won't work.

asp.net - Is it worth to write a custom Profile Provider? -

i wrote custom membership provider , relatively easy. now need create users first name, last name , other fields not considered in of membershipprovider.createuser overloads. i read should not overload createuser. instead, should write own profile provider. it seems lot of work , not sure of benefits. can me decide right way go? (it mvc 3.0 web app.) it depends. if isn't lot of info, create custom membershipuser class appropriate additional fields. can @ codeplex.com find examples of custom profile implementations.

how do i add html page in my iphone xcode project? -

can tell how add html in iphone project?? , no html option click on add new file in class group...why that??? simply create blank file , rename html or add existing html file project. next step depends on how wish use html file. say if want load local file called page.html, first add file project,and in build phases of project, , page.html copy bundle resources , , run in app, writes file documents dictionary of app/ nsstring *html = [[nsstring alloc]initwithcontentsoffile:[[nsbundle mainbundle] pathforresource:@"page" oftype:@"html"] encoding:nsutf8stringencoding error:null]; [html writetofile:[[self docpath]stringbyappendingpathcomponent:@"page.html"] atomically:yes encoding:nsutf8stringencoding error:null]; [html release]; and webview should call load file: nsarray *docpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docpath = [docpaths objectatindex:0]; [mywebview loadrequest:[nsur...

javascript - GetElementById of ASP.NET Control keeps returning 'null' -

i'm desperate having spent on hour trying troubleshoot this. trying access node in dom created asp.net control. i'm using same id , can see match when looking @ html source code after page has rendered. here's [modified according suggestions, still not working] code: asp.net header <asp:content id="headercontent" runat="server" contentplaceholderid="headcontent"> <script type="text/javascript"> $(document).ready( var el = document.getelementbyid('<%= txtbox.clientid %>'); el.onchange = alert('test!!'); ) </script> </asp:content> asp.net body <asp:textbox id="txtbox" runat="server"></asp:textbox> resulting javascript & html above <script type="text/javascript"> $(document).ready( var el = document.getelementbyid('maincontent_txtbox'); el.onchange = alert('test!!'); ) ...

repository - Git: gitolite have mess things up? working on two different servers -

i new in using git, here context: in situation in work on 2 projects stored in different repositories on different servers. on both servers used gitolite handle administration on repositories. when had 1 project handle push commits server command: git push --all git@myserver1.com:project1 , ok. now, when handle 2 projects, thought should ok, if using same command, changing server name , project, deploy on server. however not ok, when write git push --all git@myserver2.com:project2 (i running command root folder of project) asking me password: git@myserver2.com's password: , after type password get: permission denied (publickey,password). behavior not right because have set public key on second server. i don't know problem, maybe gitolite have mess things up? combining on pc configuration 2 servers? when write git push --all git@myserver2.com:project2 (i running command root folder of project) asking me password. that means public key hasn't bee...

php - What do the __'s mean in this context? -

throw new exception(__('exception')); what __'s do? called? i've seen in several implementations , common throughout magento codebase. thanks __ common name localization function. __ valid function name other. function __($text) { // return localized text } how works depends on framework in question.

c# - Best way to do a setting in ASP.net -

with settings, i've had const variable in file somewhere. possible create new config file settings website? ie: const imageprefixpath = "http://img.domain.com/" is sort of thing want store , use on web code use appsettings in web.config instead: <configuration> <appsettings> <add key="imageprefixpath" value="http://img.domain.com/" /> </appsettings> </configuration> then access in code access appsettings variables using openwebconfiguration system.configuration.configuration config = system.web.configuration.webconfigurationmanager.openwebconfiguration(null); string imagepath = config.appsettings.settings["imageprefixpath"] + "myimage.jpg";

c# - How to show a form in windows service. -

i want load form in onstart() method in windows service; here code. not working. can please provide ? protected override void onstart(string[] args) { form1 fr = new form1(); fr.show(); } you can't use services way. services can't interact desktop directly, because run in windowsstation logged in users session. need create application communicate service. how make communication can read on msdn , in example . ideas described on stackoverflow .

ruby on rails - has_many through help, what am I doing wrong? -

my models this: user has_and_belongs_to_many :roles role has_and_belongs_to_many :users tables: roles_users user_id role_id rolegroups id role_id some_column now want create association on user model, collection of rolegroups user belongs to. i.e. if user in roles id's 1 , 2, fetch rolegroups role_id = 1 , 2. i think need use through because based on user's role association right? i tried: user has_many :rolegroups, :through => :roles role has_many :rolegroups, :through => :user but error saying: activerecord::hasmanythroughsourceassociationmacroerror: invalid source reflection macro :has_many :through has_many :rolegroups, :through => :roles. use :source specify source reflection. update ok models now: user habtm :roles has_many :rolegroups, :through => :roles role habtm :users has_many :rolegroups rolegroup belongs_to :role mysql tables: roles_users user_id role_id role_groups ...

php - Can print web page using POS/Receipt printer? -

i have intranet web page consist of text (no images). need print page using receipt\pos printer print it. is possible or not? thanks sure. 2 simple ways it, depending on how interference you're willing accept in interface. firstly, can use javascript trigger receipt page/iframe print. option little klunky, requires cashier confirm print in system dialogue. but secondly, have option of sharing each station's printer on network. server-side component can print directly it. , if it's *nix server, it's pretty easy once each station's printer has added / shared server. in php (with cups installed, imagine): // attempt pipe 'lp -d printername' if (`echo "{$text}" | lp -d {$printer_name}`) { // print successful return true; } else { // print failed return false; } if you're running windows server, it's more complicated.