Posts

Showing posts from June, 2012

PHP/MYSQL Prevent sql injection attacks function -

i want upgrade , make more systematic, protection against sql injection attacks. gather 3 main methods pdo, prepared statements , mysql_escape_string, pdo considered best mysql_escape_string considered adequate if meticulous. don't think ready go pdo or prepared statements have lot of complicated queries involving multiple tables huge task. want make use of mysql_escape_string more programmatic. rather escape every individual variable users submit, thinking of escape sql commands standard function might require modification handle punctuation sound approach or escaping whole query create problems-i use apostrophes, backticks , %, example. seem standard function every sql statement more systematic , standard variable variable approach. question modifications handle punctuation might needed? also, there else ought go function such htmlspecialchars , strip_tags gather mysql_escape_string not 100% complete? here basic function. function safe($sql) { $safesql = mysql_r...

jquery ajax post multi dimensional array to php -

i having download csv button exporting results csv. till using server side code this. sending selected dropdowns ids csvdownload.php page writing results in excel. but now, want utility selecting search results using checkbox , selected results should written csv. i planning table data in array , post php using ajax, rest of things. how possible post multiple rows of data php. i have following piece of code getting table data alerting data dont know how make array , pass php $('#tblsearchresults tr').filter(':has(:checkbox:checked)').each(function() { $tr = $(this); //alert($tr.find("td").eq(4).html()); var risk_cat = $tr.find("td").eq(1).html(); var risk_type = $tr.find("td").eq(2).html(); var risk_desc = $tr.find("td").eq(3).html(); var treat_desc = $tr.find("td").eq(4).html(); var treat_cat = $tr.find("td").eq(5).html(); selectedda...

performance - Grizzly and Jersey standalone transport data very slow, and how to improve/configurate it? -

i using jersey 1.12 grizzly, using jackson generate json output. if generated result bigger, data transport speed slow. i run server , client on same box, , transport speed 350kb data around 350kb/sec, pretty slow, right? how tuning this? monitored api generate list of object ready serialized json, 50ms after first time. i set number of grizzly nio worker threads 40. i run server on linux 2.6.18-274.7.1.el5 #1 smp thu oct 20 16:21:01 edt 2011 x86_64 x86_64 x86_64 gnu/linux this server has 8 cores. maybe running out of heap space, causing vm try gc more aggressively causing longer , more frequent gc cycles? how big data? using logging filter (it buffers entity - loading memory)? try increasing heap size or ensuring send/receive data in streaming fashion rather keeping in memory.

php - How to extract num part of a string -

i have string "my string 2" , num value "2". try see below result egal 0. $alphasurv1="my string 2"; $numsurv1=intval($alphasurv1); echo $numsurv1; can me solve that? thanks in order capture last group of digits in string, can use regular expression: $str = "123 test 29"; preg_match("/[0-9]+$/", $str, $matches); var_dump($matches[0]); # 29 this work correctly following cases, including lack of whitespace, leading digits , multiple digits @ end of string: "1" => 1 "test 2" => 2 "test 34" => 34 "5 test 6" => 6 "7test8" => 8 note if want last character in string , treat number can use following: $str = "my string 2"; $digit = intval(substr($str, -1));

iphone - Unable To Parse Using NSXML Parser -

i have following xml file : <?xml version="1.0"? encoding="utf-8"?> <api> <count count="55" /> <spa> <opt>aa</opt> <opt>bb</opt> <opt>cc</opt> </spa> </api> m using following lines of code : nsstring *path = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"space.xml"]; nsdata *data = [[nsdata alloc] initwithcontentsoffile:path]; nsxmlparser *xmlparser = [[nsxmlparser alloc] initwithdata:data]; //initialize delegate. xmlparser *theparser = [[xmlparser alloc] initxmlparser]; //set delegate [xmlparser setdelegate:theparser]; //start parsing xml file. bool success = [xmlparser parse]; if(success) nslog(@"no errors"); else nslog(@"error error error!!!"); however, m getting output "error error error" in gdb. new objective c , unable through erro...

c# - Federation Fan Out Query -

i new in sql azure. facing big problem because of sql azure federation. in 1 of project want use federation. want read data federation. how can check total number of federation in server , read data federation? , how can insert data federation? using: string strsql = @"select f.name, fmc.federation_id, fmc.member_id, fmc.range_low, fmc.range_high " + "from sys.federations f " + "join sys.federation_member_distributions fmc " + "on f.federation_id=fmc.federation_id " + "order fmc.federation_id, fmc.range_low, fmc.range_high"; string strtablename = "federation_member_distributions"; try { using (sqlconnection connection = new sqlconnection(csb.tostri...

configuration - Proper way to set two Rails applications on same server -

i have 2 (same) applications running on dev.example.com , beta.example.com different databases. set run passenger using apache web server. what have done copy code 1 directory other (myapp_dev , myapp_beta) , seems working fine, until have migrate table. error data want migrate migrated. trying migrate on same database. maybe have re-configure way run applications, don't know how , do. hints appreciated. thanks! you can change used database in config/database.yml

css - Best Way to Position ASP.NET Panels Side by Side -

i'm looking best solution position 2 or more containers side side (left , right) opposed on top of eachother. i've looked other posts , add style="float:left;" ok, others suggest adding style="display:inline;" doesn't anything. there better suggestion? thank in advance. i use kind of style often: .rightcol { width: 60%; float: right; height: 30px; } .leftcol { width: 40%; float: left; height: 30px; text-indent: 10px; } define own dimensions , go! hope helps!

Kicking off method in javascript which uses jQuery -

basically i'm trying kick off jquery dialog box via javascript. have graph paper grid in users can choose color , fill in each square color chosen. when color chosen , filled i'd open jquery dialog can store name, type of art, image in chosen block. var $dialog = $('<div></div>') .html('this dialog show every time!') .dialog({ autoopen: false, title: 'basic dialog' }); instead of this: $('#opener').click(function() { $dialog.dialog('open'); // prevent default action, e.g., following link return false; }); i'm doing: opener(){ $dialog.dialog('open'); return false; } am able way? know lot of times these done having document.ready in waits event click instead of form button, etc. want open via javascript.

c# - Trying to implement a CustomObjectEvent handler -

i'm following guide except i'm writing code objects rather documents. here code: using cms.treeengine; using cms.settingsprovider; [customobjectevents] public partial class cmsmoduleloader { /// <summary> /// attribute class ensures loading of custom handlers /// </summary> private class customobjecteventsattribute : cmsloaderattribute { /// <summary> /// called automatically when application starts /// </summary> public override void init() { // assigns custom handlers appropriate events objectevents.getcontent.execute += category_get_content; //error here } private void category_get_content(object sender, documenteventargs e) { // add custom actions here } } } the line above throwing compile time error: error 1 cannot convert method group 'category_get_content' non-delegate type 'cms.setting...

java - Parse JSON to array of objects -

currently i'm receiving following json data in action: [ { "civilstatus": "m" }, "and", { "familysize": "2|bw|4" }, "or", { "civilstatus": "d" } ] i've been trying use play.libs.json parse string receive @ server, can't find way obtain array nor objects. i have looked @ org.codehaus.jackson.jsonnode documentation, didn't figure way. i'm using java, not scala. i have found using gson easier. add dependency in build.scala file: val appdependencies = seq( ... other dpenedencies ... "com.google.code.gson" % "gson" % "2.1", ... other dpenedencies ... ) then parse like: gson gson = new gson(); list<yourcustombean> data = gson.fromjson(jsonstring, new typetoken<list<yourcustombean>>(){}.gettype());

internet explorer 8 - Force IE 7 Compatiblity Mode in IE8 -

i have c# asp.net website , needs run in compatibility mode. website runs (forced) in popup. have searched on google , stackoverflow how force compatibility mode , found scripts like: <meta http-equiv="x-ua-compatible" value="ie=7"> <meta http-equiv="x-ua-compatible" content="ie=7" /> <meta http-equiv="x-ua-compatible" content="ie=emulateie7" /> <meta http-equiv="x-ua-compatible" value="ie=8"> i have tried of above when start website in browser , pres on f12 key, see following mode: browser mode: ie8 document mode: quirks so browser mode not changed compatibility mode. does know problem is? compatibility mode 1 of browser mode settings; don't have ability change users browser compatibility mode. can control document mode of page - you're seeing in examples provided. <meta http-equiv="x-ua-compatible" content="ie=7" /> thi...

c++ - Makefile 'fdopen: Bad file descriptor' error -

i'm making makefile, , getting error: list.h:10:18: error: calling fdopen: bad file descriptor i have no idea why happens. here's beginning of list.h: #ifndef list_h__ #define list_h__ #include "data.h" #include "general.h" where #include "data.h" 10th line. data , general order in dependencies written in makefile: list.o: list.cpp list.h data.h general.h g++ list.cpp $(f) data doesn't include , general includes iostream, , no other class includes iostream. here's data.h: #ifndef data_h__ #define data_h__ class data { private: public: //default constructor data() {} //destructor virtual ~data()=0; /***************************************************************************** * function name: operator< * input: data, other data * output: operator compare between 2 datas. comparison * used create sorted list. *****************************************************************...

objective c - Receive remote control events without audio -

here background information, otherwise skip ahead question in bold. building app , have access remote control/lock screen events. tricky part app not play audio itself, controls audio of device nearby. communication between devices not problem when app in foreground. found out, app not assume control of remote controls until has played audio playback audio session, , last so. presents problem because said, app controls device's audio , has no need play own. my first inclination have app play silent clip every time opened in order assume control of remote controls. fact have makes me wonder if going allowed apple or if there way achieve without fooling system fake audio clips. question(s): apple approve app plays silent audio clip in order assume control of remote/lock screen controls purpose of controlling device's audio? there way of assuming control of remote controls without audio session? p.s. prefer have functionality on ios 4.0 , up. p.p.s have seen this simil...

jQuery reload the DOM? -

i have page has button on it. when user clicks button dynamically render's form (ie it's not showing hidden form.. it's creating using jquery). my issue newly created form doesn't respond jquery commands. code have rendered form @ moment. $("#savenewlang").click(function(e) { console.log("savenewlang has been clicked"); }); so should console.log when click submit button it's not running. any idea how reload dom or assign actual event correctly fires? $("#container").on('click', '#savenewlang', function(e) { console.log("savenewlang has been clicked"); }); here #container points parent element of #savenewlang belongs dom @ page load. to specify event .on() need three arguments .on(eventname, target, callback); but ordinary binding needs two arguments .on(eventname, callback); read more .on() remainder put of code within $(document).ready(function() { }); i...

c# - Implement "not in" (aka "not exists") logic in LINQ -

Image
setup i have 2 list<t> 's. the data un-normalized , different sources explains convolution in desired logic an informal compound key in data fielda, fieldb, fieldc. the "fields" strings - reference types - values null. want drop records may matching on null. null references in c# match, in sql not. adding !string.isnullorempty() easy enough. this not question db design or relational algebra. i have other logic covers other criteria. not suggest reducing logic shown such might broaden result set. see # 5 above. the problem i want find records in lista not in listb based on informal key. want further refine lista results based on partial key match. the sql version of problem: select lista.fielda, lista.fieldb, matching.fieldc lista left join listb keylist on lista.fielda = keylist.fielda , lista.fieldb = keylist.fieldb , lista.fieldc = keylist.fieldc inner join listb matching on lista.fielda = matching.fielda , ...

button - How to pass data from function to external object (android) -

im using impimentation of zyxel barcode scanner , want pass string 'upc' edittext object out of function, how can this? protected void onactivityresult(int requestcode, int resultcode, intent data) { switch(requestcode) { case intentintegrator.request_code: { if (resultcode != result_canceled) { intentresult scanresult = intentintegrator.parseactivityresult(requestcode, resultcode, data); if (scanresult != null) { string upc = scanresult.getcontents(); } } break; } } } second question: i want call function after clicking button this: button3.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intentintegrator.initiatescan(this); ...

c# - How does ServiceContractGenerator generate namespaces -

i trying use servicecontractgenerator generate web service client in c# wsdl. new class. using code pretty appears in example on microsoft's site , have read web. when run svcutil.exe on wsdl, types in same namespace in c# code. when use servicecontractgenerator, puts client code in namespace specify, creates second namespace wsdl types. wsdl has section this: <wsdl:types><xsd:schema targetnamespace="http://tempuri.org/imports"><xsd:import schemalocation="http://devabntstapp10.psohealth.local/tz_tcs_services/adminservice.svc?xsd=xsd0" namespace="http://tempuri.org/"/><xsd:import schemalocation="http://yyy/zzz/adminservice.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/zzz.correspondence"/><xsd:import schemalocation="http:/yyy/zzz/adminservice.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/serialization/"/></xsd:schema></wsdl:types> ...

c# - Preventing .NET reverse engineering/decompilation -

is there way stop .net reflector working @ program? for example: developing program has confidential data (like gmail address , password), , don't want can see them. how can this? there various tools promise this, via different techniques. for example, many commercial obfuscators will, in addition encrypting strings , obfuscating source, introduce things il allow program run break (most/all) of current reverse engineering tools .net reflector. that being said, keeping type of data within application will never safe. best tool can make more difficult information, never make impossible. a tool "masked" , breaks obfuscation tools still not perfect - enough time , energy, can information out of program. if information available runtime, it's available enough determination , drive find it. such, important, private information passwords should not kept in executable.

How to create Android Layout dynamically in separate class other than class that extends Activity -

i have activity class has linear layout vertical orientation textview. need add layout layout dynamically .currently have activity named mainactivity. need create class returns layout not extend activity.is there way in can . in advance. just extend layout type need , have build layout want. public class mylayout extends linearlayout {......}

c++ - Why does it cause a run-time error, character to int without initializing? -

first of all, apologize poor english. at next simple program, void fx(int *a){ for(int i=*a; i<='z'; i++) printf("%c", i); } int main(){ int a; scanf("%c", &a); fx(&a); return 0; } i entered capital letter @ run-time, caused fatal error , solved killing proccess. it not cause problem @ next codes. //except fx() int main(){ int a; scanf("%c", &a); return 0; } or //initialize int void fx(int *a){ for(int i=*a; i<='z'; i++) printf("%c", i); } int main(){ **int = 0;** scanf("%c", &a); fx(&a); return 0; } i know should 'char' input character. cannot understand above situation. what happened? ps. worked vs2010, c++ you've declared uninitialized int a , , set it's lower-most byte something. result may large number, because upper-most bytes (whether 16bit or 32bit integers) left unassigned/uninit...

Redmine plugin needs to patch ApplicationController first? -

this in redmine 1.3. i patching applicationcontroller add behavior (really, include helper) in controllers. problem controllers patched before applicationcontroller patch don't new behavior. this works fine: dispatcher.to_prepare :my_plugin require_dependency 'my_plugin/application_controller_patch' require_dependency 'my_plugin/welcome_controller_patch' end but this, welcomecontroller throws error when call helper added. dispatcher.to_prepare :my_plugin require_dependency 'my_plugin/welcome_controller_patch' require_dependency 'my_plugin/application_controller_patch' end this easy fix within plugin, problem i'm having plugin patching controller , it's subsequently losing fix. worse, happens in production -- in development, think plugin order different because works fine. don't see way alter plugin order. i'm pretty sure patch fine, in case looks this: require_dependency 'application_controller' ...

grails - How to configure db-reverse-engineer plugin -

i total grails noob trying configure db-reverse-engineer plugin first project. documentation plugin indicates need configure it, don't see supposed edit configuration. is there configuration file in project need edit? have searched through ./grails-app/conf folder grails.plugin (the prefix plugin's configuration) , found nothing. or google search how configure grails plugins returns void. know lame question, how configure plugin? there ui need use, or there files somewhere edit? you need configure database in grails-app/conf/datasource.groovy . in particular, you'll need provide jdbc url, database dialect , databases's username , password. you'll have add db-reverse-engineer configuration grails-app/conf/config.groovy . file exist. append new properties @ end. finally, run reverse engineer script generate domain classes: grails db-reverse-engineer

c# - XML validation with XSD getting invalid child element error and I have no idea why? -

using following invalid child element error. new xml , have been looking around net try , figure out have had no luck. have xsd verifying xml submitted application , works wonderfully using attributes instead of elements. can't work using elements in xsd validate xml being submitted through 3rd party application have no control over. xsd <?xml version="1.0" encoding="windows-1252"?> <xs:schema attributeformdefault="unqualified" elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="sccaparticipationlist"> <xs:complextype> <xs:sequence> <xs:element maxoccurs="unbounded" name="entry"> <xs:complextype> <xs:sequence> <xs:element name="address" type="xs:string" minoccurs="0" /> <xs:element name=...

ruby - How to intercept information from a Rails logger? -

i'm using rails v2.3.5 @ work , i'm quite new both language , framework. need capture information every time user requests webpage (user's ip address, url accessed, date , time of access , time page took render) , store in database. i've noticed information contained in default rails' logfiles, i'm trying avoid having parse logfile collect information. way hook logger , intercept information or perhaps extend logger , use extended version instead of default rails 1 (activesupport::bufferedlogger). maybe ever other solutions don't require logs? thanks in advance. what need before_filter block in applicationcontroller perform whatever action need do. there can create whatever database records need. example: class applicationcontroller < actioncontroller::base before_filter :log_user_info protected def log_user_info # activate custom logging method on model useractivity.log!( # ... user parameters ) end end ho...

visual studio 2008 - Ankh Tortoise SVN hooks? -

basically i'm looking integrate client-side pre-commit hooks inside visual studio ankh svn. there question has guidance on subject already: ankhsvn client side pre-commit hook my setup follows: visual studio basic 2008 - version 9.0.30729.4462 qfe ankhsvn - 2.3.11266 tortoisesvn - 1.7.7 right now, client-side pre-commit hook works if it's invoked outside of visual studio via tortoise's folder options. can't hook invoke/process files under source control inside visual studio when svn commit though... here's question: how tell ankh use pre-commit hooks i've defined inside tortoise's config though? there option/screen should looking at? thanks in advance! ankhsvn has not implemented client-side hooks (yet?). that's feature that's available in tortoisesvn. but there's open issue this: http://ankhsvn.open.collab.net/issues/show_bug.cgi?id=453

Which runs faster ... MIN or MAX in SQL Server? -

which runs faster ... min or max in sql server? this me optimize query. thanks! please vote close question. i sure neither faster. measure on data. besides: they give different results. can't exchange 1 other. even if 1 turns out faster, micro-optimization. if want optimize query add appropriate indexes, , make sure query able use indexes efficiently. check execution plan.

dictionary - Built-in word list for AutoCompleteTextView in Android -

i want make autocompletetextview in app similar dictionary. have found many word lists, accessible 1 being dicts in /usr/share/dict. problem size of these words lists (around 1mb). since don not have specific need , regular words in dictionary suffice, hoping there mechanism use word list might available in regular android systems. the question is: there way use built-in word lists of android os, or should bundle 1mb word list file app?

r - replacing unique ID's with a sequence of numbers -

i trying make graph in x-axis date (each tick 1 day), , each tick of y-axis represents uniquely identified individual (a fish). then, each individual each day, plot point show if each individual detected on day. my issue have many thousand detections plot, , 400 individuals. individuals uniquely identifying numbers quite large (for example: 161795550 , 165705763 2 of 400 unique ids). individuals seen few days, few hundred. the issue: plotting way (using ggplot2) makes y-axis impossibly spread out between low , high unique ids, , ggplot2 there no way break axis. so, thoughts on solution renumber unique ids sequence 1 400, way of controlling spread on y-axis. manually, take long time. there way automate renaming? here code used recreate applied situation, want rename 3 unique id's (165705763,161795422,161795351) (1,2,3) (except there 400 ids in real life problem). a<-c("165705763","165705763","165705763","165705763","...

foreign keys - MySQL join four tables and get some kind of SUM result -

i have 4 tables this: mysql> describe courses; +-----------------+-------------+------+-----+---------+----------------+ | field | type | null | key | default | | +-----------------+-------------+------+-----+---------+----------------+ | course_id | int(11) | no | pri | null | auto_increment | | course_name | varchar(75) | yes | | null | | | course_price_id | int(11) | yes | mul | null | | +-----------------+-------------+------+-----+---------+----------------+ mysql> describe pricegroups; +-------------+--------------+------+-----+---------+----------------+ | field | type | null | key | default | | +-------------+--------------+------+-----+---------+----------------+ | price_id | int(11) | no | pri | null | auto_increment | | price_name | varchar(255) | yes | | null | | | price_value | int(11) | yes | | null ...

Wix custom UI for SQL Database installation -

this first wix project. downloaded wix 3.6 rc. installation project includes 2 wcf , 1 silverlight projects. works fine default wix ui. need add sql database it. works fine default values below: <component id='sqlcomponent' guid='8b72c159-1477-4a58-afae-e94d756bffa6'> <createfolder/> <sql:sqldatabase id='sqldatabase' database='master' server='.' createoninstall='yes' droponuninstall='no' continueonerror='yes'> <sql:sqlscript id='createtable' binarykey='createtable' executeoninstall='yes' /> <sql:sqlscript id='createtable1' binarykey='createtable1' executeoninstall='yes' /> </sql:sqldatabase> </component> but need present user interface sql database path, database name...

java - How to show an applet at Bonita BPM form? -

when try show applet @ bonita form through html widget data: <applet archive="jarfile-with-applet-code.jar" code="com.company.applets.myfooapplet.class" width="400" height="500"> </applet> i got error: exception: java.lang.classnotfoundexception: com.company.applets.myfooapplet.class load: class com.company.applets.myfooapplet.class not found. java.lang.classnotfoundexception: com.company.applets.myfooapplet.class @ sun.plugin2.applet.applet2classloader.findclass(applet2classloader.java:252) @ sun.plugin2.applet.plugin2classloader.loadclass0(plugin2classloader.java:249) @ sun.plugin2.applet.plugin2classloader.loadclass(plugin2classloader.java:179) @ sun.plugin2.applet.plugin2classloader.loadclass(plugin2classloader.java:160) @ java.lang.classloader.loadclass(classloader.java:247) @ sun.plugin2.applet.plugin2classloader.loadcode(plugin2classloader.java:690) @ sun.plugin2.applet.plugin2manager.cre...

asp.net mvc 3 - Exclude Entity Data from Query -

i'm querying database , have navigation properties don't want return in query. i'm including lot of navigation properties disable lazy loading, run problems producer entity. producer has 1 many relationship wine, , wine has 1 one relationship producer. when run query, want producer information (name, address, phone, etc...), don't need list of wines in associated producer query. there linq method can use include of producer fields? issue because i'm sending object via json, don't want data. wine w = db.wines.where(n => n.wineid == wineid).include(n => n.vartype).include(n => n.origin).include(n => n.app) .include(n => n.vintage).include(n => n.importer).include(n => n.reviews.select(r => r.publication)) .include(n => n.producer.name).include(n => n.docs).firstordefault(); public class producer : contact { [key] public int producerid { get; set; } public string name { get; set;...

ios - Can the url for the "Add to home screen" on iPhone Safari be customized? -

the "add home screen" shows on pages of site, , want url homepage gets saved. for example on page: http://www.domain.com/category/page.html is possible "add home screen" save url: http://www.domain.com any appreciated. i found sort-of workaround this. can detect launched home page via window.navigator.standalone , based upon potentially redirect. also, have done little testing , found on latest ios, different user agents reported server, opens possibility of faster redirect. can't find information whether has been case. launch home page: mozilla/5.0 (iphone; cpu iphone os 6_0_1 mac os x) applewebkit/536.26 (khtml, gecko) mobile/10a523 mobile safari: mozilla/5.0 (iphone; cpu iphone os 6_0_1 mac os x) applewebkit/536.26 (khtml, gecko) version/6.0 mobile/10a523 safari/8536.25 if page gets of content via ajax or notice different user-agent on server might possible skip redirect , act "as if" @ url, since in standalone mode...

jsf 2 - how to initialize jsf 2.0 textfield on runtime? -

i initialize textfield @ runtime. example, have primefaces inputtext this: <p:inputtext value="#{mybean.value}" id="inputtext" /> and bean class: @postconstruct public void onpageload() { .... .... inputtext.setmaxlength(15); inputtext.setstyle("....."); } is possible jsf 2.0? you binding component bean: <p:inputtext binding="#{bean.input}" ... /> with private inputtext input; // +getter+setter @postconstruct public void init() { input = new inputtext(); input.setmaxlength(15); input.setstyle("background: pink;"); } // ... this not recommended approach. should rather bind individual attributes bean property instead. <p:inputtext ... maxlength="#{bean.maxlength}" style="#{bean.style}" /> with private integer maxlength; private string style; @postconstruct public void init() { maxlength = 15; style = "background: pink;...

Python and UDP listening -

i have app, software defined radio, broadcasts udp packets on port tell listeners frequency , demodulation mode have been set (among other things.) i've written demo python client (code below) listens port, , dumps out information in appropriate packets console. these both running under osx 10.6, snow leopard. work there. the question/issue have is: python app has started before radio app or claims port in use (errno 47) during bind, , don't understand why. radio app broadcasting udp; want accommodate multiple listeners -- that's idea of broadcasting, or @ least, thought. so here's python code (the indent little messed due stack overflow's dumb "make-it-code" indent, assure it's ok): #!/usr/bin/python import select, socket # aa7as - sdrdx udp broadcast # sample python script captures udp messages # coming sdrdx. sdrdx tells frequency , # mode has been set to. this, in turn, used tell # radio tune frequency , mode. # udp packet sdrdx 0...

asp.net mvc 3 - C# MVC 3 Generates Link With Unnecessary Parameters -

i'm new .net. i'm close end of first project, , i've run trivial issue that's bothering me. i'm using mvc 3, razor, c#, , visualstudio 2010. the following razor code have redirecting user different rdlc reports: @html.actionlink("length of stay data packages - summary", "rptlngthstay", "reports", new { @class = "link" })<br /> @html.actionlink("packages denied registration whs reviewers", "rptpkgsdenied", "reports", new { @class = "link" })<br /> <...> it generates following html: <a class="link" href="/reg_pkgs/reports/rptlngthstay?length=7">length of stay data packages - summary</a><br /> <a class="link" href="/reg_pkgs/reports/rptpkgsdenied?length=7">packages denied registration whs reviewers</a><br /> <...> my question is, parameter "length=7" coming from? none ...

Django 1.4 Want to make birthdate field utilizing SelectDateWidget not required on my form -

i trying create form user change profile account information on own. have can update first, last , username, gender , 'birthdate'. 'birthdate' 1 can't not required. form checks if no input given in of forms fields , not update users information if no changes made. ~~models.py~~ class account(models.model): user = models.onetoonefield(user) #link (pointer) users other information in user model birthdate = models.datefield(blank = true, null = true) # true makes field optional gender = models.charfield(max_length = 10, choices = gender_choice, null = true, blank = true) profilepic = models.imagefield(upload_to = "profilepics/%y/%m/%d", default = "profilepics/default.jpg", blank = true) --form gather user setting changes class editaccountform(forms.form): username ...

c# - Emulating console in winforms, the hard way how to make it better -

im trying emulate console in windows forms applicaton. have made possible using 2 threads , delegate able interact multiline textbox. this somehow seems complicate things much. questions. is there better way of doing this? when press enter command not sent, first if press again sent? why that? ahve treid debug failed find solution. edit! im using csharpssh, ssh connection. have included full code now! using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using tamir.sharpssh; using system.io; using system.threading; using system.timers; namespace windowsformsapplication3 { public partial class form1 : form { public string mhost; sshshell mshell; public string minput; string pattern = ""; bool minputholder = false; string mpattern = "...

php - Is something wrong with my query? -

i'm working on database 3 tables, overlapping information. few columns each table can updated user via web app creating. but... there issue. not sure is, updates aren't happening. wondering if wrong query. (actually, after debugging, quite there is). if (empty($errors)) { $query1 = "update owner set name = '{$name}' ownerid= '{$ownerid}'"; $query1_result = mysql_query($query1); if (mysql_affected_rows()==1) { $query2 = "update queue_acl set date_expires = '{$date_expires}' user_id='{$ownerid}'"; $query2_result = mysql_query($query2); if (mysql_affected_rows()==2) { $query3 = "update ownerorganization set orgid = {$orgid} ownerid = '{$ownerid}'"; $query3_result = mysql_query($query3); if (mysql_affected_rows()==3) { ...

html - Is this method for having both a logo image and text good or is there a better method and/or other options or considerations? -

when try research find hard separate scenario debated image replacement discussions , debates, in case want use both , image , text. the problem want have both logo , image header wants on it's own line, i've floated image left desired effect. seems fine me don't recall coming across problem before , need 1 right first time, questions: there wrong method, there alternative methods worth considering , there further considerations, instance didn't see need clear float maybe should after h1 tag. <html> <head> <style> h1 { line-height:100px; font-size:75px; background:#eee; } img#logo { margin-right:20px; float:left; } </style> </head> <body> <img id="logo" src="http://placehold.it/100x100"> <h1>title</h1> <p>page content ...</p> </body> </html> here's jsfiddle http://jsfiddle.net/cac3e/ i don'...

parsing - Get AST from expression at runtime -

i want retrieve ast expression in ironpython @ runtime: at moment this: def sum(a, b): return + b and then: source = inspect.getsource(sum) ast = ast.parse(source) it works perfect, think bit awkward turn code string , reparse ast. is there way ast directly expression? something like: ast = ast.get_ast(sum) ?? thank much.

asp.net - Iterating over SearchResultCollection is Very Slow -

i'm running ldap query returns multiple entries , stores them inside searchresultcollection. i'm iterating on searchresultcollection so: // results searchresultcollection object foreach (searchresult sr in results) { ... things each searchresult in here ... } this seems logical way this, loop incredibly slow. when step through loop debugger, find it's first step of initializing foreach loop takes time - actual iterations instantaneous. in addition, when view contents of searchresultcollection while debugging, watch takes long load contents of variable. i have theory searchresultcollection doesn't contain complete searchresult objects, rather references entries in active directory server individually fetched when iterate on searchresultcollection object. can confirm theory? , there better (faster) way fetch set of ldap entries? there may ways decrease response time: restrict scope of search use more restrictive search filter use base ...

performance - Python subprocess module much slower than commands (deprecated) -

so wrote script accesses bunch of servers using nc on command line, , using python's commands module , calling commands.getoutput() , script ran in 45 seconds. since commands deprecated, want change on using subprocess module, script takes 2m45s run. have idea of why be? what had before: output = commands.getoutput("echo file.ext | nc -w 1 server.com port_num") now have p = popen('echo file.ext | nc -w 1 server.com port_num', shell=true, stdout=pipe) output = p.communicate()[0] thanks in advance help! i expect subprocess slower command . without meaning suggest only reason script running slowly, should take @ commands source code. there fewer 100 lines, , of work delegated functions os , many of taken straight c posix libraries (at least in posix systems). note commands unix-only, doesn't have work ensure cross-platform compatibility. now take @ subprocess . there more 1500 lines, pure python, doing sorts of checks ensure consisten...

c# - TaskWrapper - threading and delegate confusion -

can explain code me little have firmer grasp of going on in it? taskwrapper = xtthreadpool.default_pool.run((system.threading.threadstart)delegate() { //remote procedure execution , result processing code. //some vars set in here used after join() below. }, true, true); while (taskwrapper.status == xtthreadpool.task.status.none) { system.threading.thread.sleep(10); } ... taskwrapper.join(); it looks me separate thread being created , remote procedure call used within it. i'm little hazy use of delegate or syntax of taskwrapper object creation though. well it's little tricky without knowing what's in xtthreadpool class, have guess... the chances first bit... taskwrapper = xtthreadpool.default_pool.run((system.threading.threadstart)delegate() { //remote procedure execution , result processing code. //some vars set in here used after join() below. }, true, true); ...starts thread running asynchronously , passes method specified in...

javascript - using the data-custom="" to bind to events -

i'm pretty sure i'm gonna slammed on this. i love using data-whatever attribute bind events to. it feels clean me , helps reserve class attribute styling. i know selector among slowest, don't use when there lot of elements. would love hear compelling arguments against this. $("body").delegate("[data-action]", "click", function(){ var action = $(this).attr("data-action"); //route action appropriate function }); $("body").delegate("[data-action]", "click", function(){ ^^^^-------------------------- body high node. ^^^^^^^^--------------- on should used instead of delegate. ^^^^^^^^^^^^^ attribute selector slow selector.

html - website screen resolution auto resolution -

i trying make website stuff , realize when trying thru different browsers. way in looks different. used dreamweaver cs5.5 base creating it. is there element missing add. i tried glancing thru forum results. tried out : how adapt website user's screen resolution? no doughnut that. i read bit on responsive webdesign: http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/

how to pass two variables in sql command in C#? -

really simple question , have 2 variables "one_hour_ago" , "current_time", need pass these 2 variables in sql command : string commandstring = "select * mytable time between one_hour_ago , current_time"; here have syntax error string commandstring = "select * mytable ts between ' , /" + one_hour_ago + "'" + current_time + "/"; thanks string sqlstring = "select * mytable time between @before , @current_time"; sqlcommand ocmd = new sqlcommand(sqlstring , connstring); ocmd.parameters.addwithvalue("@before", date_before); ocmd.parameters.addwithvalue("@current_time", currenttime); where date_before , currenttime parameters pass method. this should take care of sql injection stuff

html - How do I set the background color for links? -

i've been trying figure out on how set current page i'm @ different background color other links, no avail. html <div id="navigation"> <ul> <li><a href="<?php echo base_url() ?>index.php/home">home</a></li> <li><a href="<?php echo base_url() ?>index.php/portfolio">portfolio</a></li> <li><a href="<?php echo base_url() ?>index.php/about">about</a></li> <li><a href="<?php echo base_url() ?>index.php/gallery">gallery</a></li> <li><a href="<?php echo base_url() ?>index.php/blog">blog</a></li> </ul> </div> what want set current active link black, , other 4 links grey. way if visit portfolio , example, link black , rest grey. how this? thankfully, there no javascript involved. html , css w...