Posts

Showing posts from August, 2013

sql - Include a string in Select Query -

i'm wondering can query below? select america, england, distinct (country) tb_country which (my intention to) display : america england (list of distinct country field in tb_country) so point display (for example) america , england if distinct country field returns nothing. need query list select dropdown, , give sticky values user can pick, while allowing add new country wish. it goes without saying, should 1 row in tb_country has value of america or england, not show duplicate in query result. if tb_country has list of values : germany england holland the query output : america england germany holland you need use union: select 'america' country union select 'england' country union select distinct(c.country) country tb_country c union remove duplicates; union not (but faster it). the data type must match each ordinal position in select clause. meaning, if first column in first query int, first column unioned sta...

View detailed warnings in MySQL Workbench? -

how view detailed warnings in mysql workbench? when execute command, see brief summary of /how many/ warnings there were. i'd see detailed report of actual warnings contained. thanks. mysql has great documentation showing warnings http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html

c# - How do I start a program with arguments when debugging? -

i want debug program in visual studio 2008. problem exits if doesn't arguments. main method: if (args == null || args.length != 2 || args[0].toupper().trim() != "rm") { console.writeline("rm must executed rsm."); console.writeline("press key exit program..."); console.read(); environment.exit(-1); } i don't want comment out , and in when compiling. how can start program arguments when debugging? set startup project. go project-><projectname> properties . click on debug tab, , fill in arguments in textbox called command line arguments .

java - Setting a custom browser as default browser in blackberry -

i have made own browser - trying set own browser default browser when user clicks on blackberry default browser, brower open. is possible this? thanks in advance unfortunately, can't replace system browser own browser. and polling in background other answer says bad idea several reasons, including needless use of battery charge.

generating google api key in android -

i developing android application involves google map activity.i have done coding part.now want generate google api key system.can in regard.thanks in advance tushar sahni everything need know explained in documentation . copying there: run command generate certificate: $ keytool -list -alias alias_name -keystore my-release-key.keystore (rename alias_name , my-release-key.keystore meaningful) the result above command this: certificate fingerprint (md5): 94:1e:43:49:87:73:bb:e6:a6:88:d7:20:f1:8e:b5:98 then go http://code.google. com/android/maps-api-signup.html , follow instructions register certificate.

ExtJS - Custom Column Renderer on TreeGrid isn't being fired -

i have extjs treegrid , i'm trying add custom renderer particular column. unfortunately it's not working - event isn't being fired , no warnings given off. couldn't find api treegrid either. has else experienced this? here's code: var tree = new ext.ux.tree.treegrid({ title: 'my tree grid', loader: treeloader, columns:[{ header: 'title', dataindex: 'title', width: 500 },{ header: 'testing', width: 100, dataindex: 'testing', renderer: function(value) { console.log('test'); }, align: 'center' }] }); thanks! there no api treegrid because it's user extension (ext.ux). you'll have take @ source code more information. if don't have source in project, go following page: http://dev.sencha.com/deploy/dev/examples/treegr...

java - How to detect presence and location of JVM on Windows? -

i'm trying detect if there jvm installed , located can run java.exe . all i've managed find hkcu\software\javasoft\java runtime environment\<ver> . safe assume installed in %programfiles%\java\jre<ver> ? i'm trying in c#, assume answer pretty language agnostic, answer appreciated. edit: ok silly me, found how detect whether java runtime installed or not on computer using c# pointed me @ hklm\software\javasoft\java runtime environment\currentversion works hklm\software\javasoft\java runtime environment\<ver>\javahome . managed find these instead underneath hklm\software\wow6432node\javasoft\java runtime environment . there way detect of these should checking without trying sniff @ cpu type? i'm going throw hat in ring code i've ended using: string javadirectory = null; // native registry key - 32b on 32b or 64b on 64b // fall on 32b java on win64 if available registrykey javakey = registry.localmachine.opensubkey("s...

.net - Checkboxes to indicate inclusion in a list? -

i have 2 tables, called machine , type . since have many-many relationship, have machinetype resolution table in db. no problem. the end user needs able manage these - create new types , assign them machines. have xtragridview using display machine master , type detail. initially used lookup add type dropdowns machinetype detail view. creates duplicates , not best way display information. i'd series of checkboxes (one each type options available) user can click appropriate ones each machine, avoiding duplicates. upon saving, appropriate machinetype rows can generated. i going code manually if there's kind of binary collection mapping in either devexpress or .net framework can use, i'd prefer reinvent wheel. cheers edit: this mean. this thread . however, store collection (a string delineated commas) , not series of db rows. are interested in returning values bind linq query? from m in machine t in type select new {m,t} this give cross jo...

c++ - C++0x has no semaphores? How to synchronize threads? -

is true c++0x come without semaphores? there questions on stack overflow regarding use of semaphores. use them (posix semaphores) time let thread wait event in thread: void thread0(...) { dosomething0(); event1.wait(); ... } void thread1(...) { dosomething1(); event1.post(); ... } if mutex: void thread0(...) { dosomething0(); event1.lock(); event1.unlock(); ... } void thread1(...) { event1.lock(); dosomethingth1(); event1.unlock(); ... } problem: it's ugly , it's not guaranteed thread1 locks mutex first (given same thread should lock , unlock mutex, can't lock event1 before thread0 , thread1 started). so since boost doesn't have semaphores either, simplest way achieve above? you can build 1 mutex , condition variable: #include <mutex> #include <condition_variable> class semaphore { private: std::mutex mutex_; std::condition_variable condition_; unsigned long count_ = 0; // initialized...

base64 - Descrypt SagePay string vb.net -

i have been having problems trying decrypt string returned sagepay. i used asp.net kit included encrypt , decrypt functions using base64 - sending information sagepay not problem having number of problems trying descrypt string. here function using descypt: private function base64decode(byval strencoded string) string dim ireallength integer dim strreturn string dim iby4 integer dim iindex integer dim ifirst integer dim isecond integer dim ithird integer dim ifourth integer if len(strencoded) = 0 base64decode = "" exit function end if '** base 64 encoded strings right padded 3 character multiples using = signs ** '** work out actual length of data without padding here ** ireallength = len(strencoded) while mid(strencoded, ireallength, 1) = "=" ireallength = ireallength - 1 loop '** non standard extension base 64 decode allow + sign space character subst...

Scala - how to get a list element -

i'm trying element list: data =list(("2001",13.1),("2009",3.1),("2004",24.0),("2011",1.11)) any help? task print separatly strings , numbers like: print(x._1+" "+x._2) but not working. scala> val data =list(("2001",13.1),("2009",3.1),("2004",24.0),("2011",1.11)) data: list[(java.lang.string, double)] = list((2001,13.1), (2009,3.1), (2004,24.0), (2011,1.11)) scala> data.foreach(x => println(x._1+" "+x._2)) 2001 13.1 2009 3.1 2004 24.0 2011 1.11

authentication - Persistent login implementaion in ASP.NET MVC application -

i want implement type of authentication explained here in asp.net mvc application. http://jaspan.com/improved_persistent_login_cookie_best_practice my current implementation having users , userlogintokens tables: create table [users].[users] ( id int not null, username nvarchar(30) null, -- not unique. login email. email nvarchar(100) not null, passwordhash nvarchar(512) not null, passwordsalt nvarchar(512) not null, ) create table [users].[userlogintokens] ( id int not null, userid int not null, token varchar(16) not null, series varchar(16) not null, ) after user log in, issued user cookie content: t=@token&s=@series . now, have persistentloginmodule search cookie each request, validate token , series valid build user it. my questions: in order implement this, idea implement own authentication module , don't use formsauthentication @ all? s...

javascript - Why are the buttons of the type submit? -

this html: <button>static</button> <form> <span id="test"> </span> </form> this jquery - runs in document.ready: $('#test').append('<button>dynamic</button>'); $('button').live('click', function(){ alert($(this).attr('type')); }); //even one: alert($('<button>test</button>').attr('type')); the alerts says 'type' 'submit', haven't specified type. how come? @ least ie , chrome consequent in giving type "submit". don't have form, seems weird make submit-button. the default value type attribute <button> elements defined 'submit' in specification. submit: creates submit button. default value. http://www.w3.org/tr/html4/interact/forms.html#h-17.5

javascript - How do I use PHP to build a website menu with dynamic highlighting? -

i need change color of selected menu whenever page active , should stay until menu clicked.i have used jquery like $('.navigation ul li a').click(function(){ $(this).css({"background-color":"#ffffff"}); $('.navigation ul li a').css({"background":"transparent"}); }); but works click function only.i need active till move menu .plz help!!! php only let assume website has following menu: home pistols rifles at top of home html page, insert: <?php $this_page = "home"; ?> at top of pistols html page, insert: <?php $this_page = "pistols"; ?> at top of rifles html page, insert: <?php $this_page = "rifles"; ?> in css-file, add id, accompanying format, menu item page 1 displayed in browser. call id #cur_item , example. edit navigation html this: <ul class="navigation"> <li <?php if ($this_page == "home"):?...

Data SMS Message body not received in Android phones -

when send data sms android pones, message body not received. trigerring onreceived method of broadcastlistner , able senders address message body not received. returns null. faced similar issues? my manifest file includes entries fro receiving data sms. <action android:name = "android.intent.action.data_sms_received"/> <data android:scheme="sms"/> <data android:host="localhost"/> <data android:port="16000"/> </intent-filter> </receiver> does know might problem? how extract message body? data sms, should use 'getuserdata() instead of 'getmessagebody()' message body.

Merge PDF files with PHP -

my concept - there 10 pdf files in website. user can select pdf files , select merge create single pdf file contains selected pages. how can php? i've done before. had pdf generated fpdf, , needed add on variable amount of pdfs it. so had fpdf object , page set (http://www.fpdf.org/) , used fpdi import files (http://www.setasign.de/products/pdf-php-solutions/fpdi/) fdpi added extending pdf class: class pdf extends fpdi { } $pdffile = "filename.pdf"; $pagecount = $pdf->setsourcefile($pdffile); for($i=0; $i<$pagecount; $i++){ $pdf->addpage(); $tplidx = $pdf->importpage($i+1, '/mediabox'); $pdf->usetemplate($tplidx, 10, 10, 200); } this makes each pdf image put other pdf. worked amazingly needed for.

python - Unit testing Django JSON View -

i'm trying write unit tests django json_view views , i'm having trouble passing json_string view. posted related question yesterday passing json string django view js, issue in js passing json string needed passing string attribute of object, because failing string being taken key resulting query dict. i'm having similar problem again except time form django unit test django view. here simplified version of code produces same result. class mytestcase(testcase): def setup(self): self.u = user.objects.create_user('test','test','test') self.u.is_active = true self.u.save() self.client.login(username='test',password='test') def test_create_object_from_form(self): """test creation of instance form data.""" import json json_string json.dumps({'resource':{'type':'book','author':'john doe'}}) pri...

PHP: Dealing special characters with iconv -

i still don't understand how iconv works. for instance, $string = "löic & rené"; $output = iconv("utf-8", "iso-8859-1//translit", $string); i get, notice: iconv() [function.iconv]: detected illegal character in input string in... $string = "löic"; or $string = "rené"; i get, notice: iconv() [function.iconv]: detected incomplete multibyte character in input string in. i nothing $string = "&"; there 2 sets of different outputs need store them in 2 different columns inside table of database, i need convert löic & rené loic & rene clean url purposes. i need keep them - löic & rené löic & rené convert them htmlentities($string, ent_quotes); when displaying them on html page. i tried of suggestions in php.net below, still don't work, i had situation needed characters transliterated, others ignored (for weird diacritics ayn or hamza). adding //translit...

java - JDBC support on J2ME -

currently trying run existing java application on windows mobile 6.1 device. java application had been developed server side , uses jdbc. problem java application uses java.sql.drivermanager not supported either j9 runtime or cdlc/cdc implementation. after doing lot of research seems there not standard way that. jsr 169 not support class well. so, wondering whether of have similar problems , if have mention appropriate software stack support java.sql.* package on mobile devices. seems specifications not support , way hacking up... thanks in advance there no official jdbc support cldc-based environments. there jdbc optional package cdc-based environments. database support cldc/midp sketchy. see there's 1 here: http://developer.mimer.com/platforms/productinfo_19.htm but that's not want. i think you'll have roll own web service based system interact java code running in web server, acting proxy jdbc communication database.

c# - How do I measure the power of the network (the WIFI signal) in windows-CE? -

how measure power of network (the wifi signal) in windows-ce ? building wi-fi discovery application .net compact framework 2.0 nice tutorial on using opennetcf query network adapters - should cover need.

PHP API acess multiple calls -

i running calls onto paypal's transactionsearch api through php curl. unfortunately, api slow respond, taking anywhere 30 seconds more 5 minutes (depending on number of records returned api) single customer. at moment, script running off cron job, , looping through each customer 1 one. however, if number of customers scale up, entire process take long time (few hours) complete. not enough. essentially, need run (and process) multiple api calls simultaneously. what's best way achieve this? since bottleneck remote server, suggest using curl_multi_exec . you'll processing big number of http connections @ once , process results in 1 thread. this not fastest solution, process responses they're available in multiple threads, approach can make processing 50+ times faster without significant changes.

java - Selenium clicking on javascript link -

i'm having issue writing selenium test using java , spring. i need selenium click on delete button on page contains multiple delete buttons (a list of files). using selenium ide generates following code selenium.click("link=delete"); which useless. haven't been able figure out how target specific element contained in table. here's source: <tr onmouseover="mouseover(this)" onmouseout="mouseout(this)"> <td class="thumbnail" align="center"><img src="/services/images/nav/resources.gif" /></td> <td colspan="3" onclick="nav('filename'); return false"> <a href="javascript:nav('filename')">basics</a></td> <td> <a class="actionbutton" href="javascript:del('filename')">delete</a></td> <td>&nbsp;</td> </tr> i need either a) find w...

char - Determining if a device is a touchscreen device in linux -

i trying determine /dev/input/eventx device touchscreen. looking @ return of eviocgname device name. looking @ return values of eviocgbit ioctl don't think there generic way determine touchscreen. interested in sort of solution problem. in advance time!!! take at: /dev/input/by-path/ /dev/input/by-id/ /sys/class/input/event?/device/ these might have enough info needs. wish had touchscreen test ;)

How do you pull data from SQL Server to Oracle? -

i'm wanting take data sql server table , populate oracle table. right now, solution dump data excel table, write macro create sql file can load oracle. problem want automate process , i'm not sure can automate this. is there easy way automate populating oracle table data sql server table? thanks in advance yes. take @ ms sql's ssis stands sql server integration services . ssis allows sorts of advanced capabilities, including automated sql server jobs, moving data between disparate data sources. in case, connecting oracle can achieved variety of ways.

java - Use of a4j:commandbutton vs h:commandbutton to present-new-pages in richfaces -

i have substituted h:commandbutton a4j:commandlink in application reasons not relevant issue. since seeing flaky peculiar side-effects in ie8 such select menus losing focus , select items cannot selected. does think bad idea use a4j:commandbutton instead of h:commandbutton reason? have prior experience on this? any answer welcome. have here: http://community.jboss.org/wiki/commonajaxrequestsproblems#navigation

data migration - How to unit test a Django South "datamigration" -

i created data migration using south, takes versions table , converts from: major: 1, minor: 2, micro: 3, release: into simpler: name: 1.2.3.a now want test datamigration using django unit testing (1.3beta). how can use south programatically roll migrations forward , backward while specifying custom fixtures use can validate? i've asked question on django south irc didn't answer; did make me question "why" of unit testing data migrations (since it's 1 time thing , you're not going refactor anyway, might manual checks). however, found 2 reasons to "real testing": writing assumptions down beforehand forces me explicit, hence more correct. i can read assumptions in place other actual code (which complicated rather large datamigration) in end decided on tacking on number of assertions (i.e. regular python statement) @ end of datamigration. has advantages mentioned above, , additional advantage of doing rollback if 1 of ass...

xcode - Compatible with iPhone, iPod touch and -

i uploaded app on app store iphone , ipod touch on app store write compatible iphone, ipod touch , ipad why? necessary in iphone sdk ? don't worry. iphone (and ipod touch) applications "automagically" compatible ipad. in other words, can run unmodified. when executed in ipad, zoomed in order fill whole screen.

java - XML schema location best practices -

after seeing quite more cryptic error message, realize may due bogus uris present here: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://activemq.apache.org/camel/schema/cxfendpoint" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd http://activemq.apache.org/camel/schema/cxfendpoint http://activemq.apache.org/camel/schema/cxf/cxfendpoint.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd "> is practice refer online schemas? ...

iis 7 - Is there a limit to Asp.Net 4.0 or IIS7 response redirect calls you can use in a row -

in our application have broken our app several modules. when logout.aspx page called, builds stack of logout pages call, 1 in each module. redirects each module's logout page redirects caller. this has been working fine in our new app, uses aps.net 4.0 redirects seem stop working. fiddler shows redirect sent... browser doesn't send next get. strange thing if remove , 1 module things work. doesn't matter remove, know no error occurring in of logout pages. so, difference seems less redirects being used in row. here final 302 browser receives... doesn't loginredirect.htm: > /amsiweb/logoutcoordinator.aspx > http/1.1 accept: > application/x-ms-application, > image/jpeg, application/xaml+xml, > image/gif, image/pjpeg, > application/x-ms-xbap, > application/vnd.ms-excel, > application/vnd.ms-powerpoint, > application/msword, > application/x-shockwave-flash, */* > accept-language: en-us user-agent: > mozilla/4.0 (compatible; ms...

c# - MVC contextual "help" framework for site -

sorry bad title. not sure how title this. i have web site going public facing, throughout site, want add "help" icons , when user clicks them, show contextual page on. using mvc, dry , design principles, have ideas (at high level) how this? i'm partial qtip ( http://craigsworks.com/projects/qtip/ ) means of displaying these hints. far specific implementation of content of these tips, well, they're contextual. can have sort of term repository, or hard-code contents if not foresee need translate different languages or reuse contents.

iis - ASP.NET MVC3 Chart Web helper doesnt work when hosted on IIS7 -

i'm using new chart helper method available in system.web.helpers assembly shown here http://www.dotnetcurry.com/(x(1)s(jm1obicbiav03qq3dnxug2ap))/showarticle.aspx?id=597&aspxautodetectcookiesupport=1 it works fine when run app in visual studio's inbuilt server. when publish website virtual directory in iis on local machine, image doesnt show , in place "red cross" mark shows up. i'm not using relative paths , static content available on server since can see other images displayed in app when published. here's view {img src="/home/getrainfallchart" alt="chart" /} this action public actionresult getrainfallchart() { var key = new chart(width: 600, height: 400).addseries( charttype: "area", legend: "rainfall", xvalue: new[] { "jan", "feb", "mar...

c# - Issue with setting a DateTime? to null using ternary operator -

possible duplicate: type result conditional operator in c# i working on pop-up modifying user, when ran following issue while attempting modify user's date of death : in scenario, property death user datetime? (nullable date time). user.death = (model.death != null) ? datetime.parse(model.death) : null; so figured able check if value contained in model (model.death string ) contained value, set date value, otherwise set null, demonstrated above. however, unable use syntax, not allow me explicitly set user.death null, using ternary operator, although user.death = null worked fine. solution used : replaced : null : new nullable<datetime>() i guess wondering, why unable explicitly set nullable datetime property null using ternary operator? this doesn't work because compiler not insert implicit conversion on both sides @ once. you want compiler convert datetime value datetime? on 1 side, , null datetime? on other side. cann...

How can I secure static content in Rails 3? -

i have html user guide application. don't want not logged in able access it. using devise authentication , cancan authorization. i store outside public folder , serve through simple controller performs authentication check. doing x-sendfile ( https://tn123.org/mod_xsendfile/ ) should minimize additional server load. here's rough guide: http://elivz.com/blog/single/mod_xsendfile/

sql - MySQL ORDER BY keyword match -

i have table this: mysql> select * test; +-------------+ | name | +-------------+ | 1 | | 2 | | 3 | | tic tac toe | | tac toe tic | +-------------+ 5 rows in set (0.00 sec) i query rows rows matching keyword first. got far: mysql> select * test order instr(name, 'tac') desc; +-------------+ | name | +-------------+ | tic tac toe | | tac toe tic | | 1 | | 2 | | 3 | +-------------+ 5 rows in set (0.01 sec) the problem prefer order matching rows how close beginning of field keyword occurs. since instr() returns 0 no match, non-matching rows come first when order instr(name, 'tac') asc. haven't been able figure out way around this. i need mysql order this 1 2 3 4 0 0 0 or need instr() return null instead of 0. you need order 2 columns, first 1 indicate whether match made (to make 0s go bottom) select * test order case when instr(name, 'tac') = 0 1 else 0 end, i...

Insert into MySQL database with jQuery and PHP -

i'm experiencing kind of problem here, have no idea what's wrong code. i'm pretty sure it's client sided since not getting php errors, may wrong. i'm trying form, once submitted, insert information contained in text field mysql database via ajax request php file. here's i'm at: /* index.php */ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="scripts/ajax.js"></script> //... <div class="success" id="success"></div> <div class="err" id="err"></div> <!--create form--> <form action="" method="post" name="create" id="createform" onsubmit="createnew(document.create.create2.value); return false;"> <h5>create new file</h5...

ios - Apple IOS4 UI Automation: Executing a specific test case inside Javascript test file -

i'm using apple ios4 ui automation framework test iphone app controls , have set javascript file follows: // functions ... function test_testcase1() { ... } function test_testcase2() { ... } function test_testcase3() { ... } function test_testcase4() { ... } etc when set target , script file inside instruments, executes 4 test cases. there way execute 1 test case? thanks! write controller or master script calls functions want run? how approach it.... :)

tsql - Group By but include "missing" values -

suppose have following. select case when fcompany = 'acme' 'red' when fcompany = 'acme rockets' 'blue' else 'green' end color ,sum(fann_sales) slcdpm group case when fcompany = 'acme' 'red' when fcompany = 'acme rockets' 'blue' else 'green' end let's returns 2 colors. what's best way pull 3 colors , include 0 missing value? union all? yes, union may best bet. select 'red' color, sum(fann_sales) slcdpm fcompany = 'acme' group fcompany union select 'blue' color, sum(fann_sales) slcdpm fcompany = 'acme rockets' group fcompany union select 'green' color, sum(fann_sales) slcdpm fcompany <> 'acme' , fcompany <> 'acme rockets' group fcompany

php - Disable PHPMailer error messages -

how disable error messages phpmailer class? i'm displaying own error messages , don't want users see errors such "smtp error: not connect smtp host." my code: http://pastie.org/1497819 thanks this not best solution, works. in phpmailer library folder open "class.phpmailer.php", find public function send() inside comment line echo $e->getmessage()."\n";

C# IO Exception -

im trying save file download mailbox. hasnt been problems, i'v built gui upon modell , authorization exception: saved file: c:\tempnorlander system.unauthorizedaccessexception: access path 'c:\tempnorlander' denied. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.filestream.init(string path, filemode mode, fileaccess access, int32 rights, boolean userights, fileshare share, int32 buffersize, fileoptions options, security_attributes secattrs, string msgpath, boolean bfromproxy) @ system.io.filestream..ctor(string path, filemode mode, fileaccess access, fileshare share, int32 buffersize, fileoptions options, string msgpath, boolean bfromproxy) @ system.io.filestream..ctor(string path, filemode mode) @ a.a0.b(string a_0, byte[] a_1, int32 a_2, int32 a_3) @ mailbee.mime.attachment.save(string filename, boolean overwrite) @ mail2db.connect2exchange.collectdata() in c:\users\marthin\documents\visual studio 2010\projects...

ruby on rails - Iterate over records created_at dates and update with half of time from Time.now -

i want iterate on large collection of records in console, divide date half of time since time.now , save it. records created_at 2 months ago 1 month old, 1 day becomes 12 hours etc. this doesn't work example: log.all.each{|l| l.created_at = l.created_at - (time.now - l.created_at * 0.5); l.save} try: log.all.each{|l| l.created_at = time.at( l.created_at.to_f + (time.now.to_f - l.created_at.to_f)/2 ); l.save} which should same as: log.all.each{|l| l.created_at = time.at( (time.now.to_f + l.created_at.to_f)/2 ); l.save}

php mysql optimisation -

i optimize php scripts, i'm implementing memcached(it reduce time from: 30 secs 5 secs) php. first think must see script @ app.promls.net, takes 3 seconds on build it(view source @ end , you'll se comment box time execution). next thinks optimize select statement using explain: select sql_calc_found_rows p.id , p.type, p.bathrooms, p.bedrooms, p.for_sale, p.for_rent, p.rent_price, p.sale_price, p.min_price, p.mid_price, p.hig_price, p.units, p.negotiation, p.status, p.square_meters, p.commission, p.address, p.currency_type, p.creation_date, p.modified_date, p.parent, p.property_name, p.area_id, p.amenities, p.unit_number, p.levels, p.for_vacational, p.construction_year, p.construction_density, p.plot_meters, p.community_fees, p.garbage_tax, p.mortage, p.accompanied_visit, p.sale_sign, (select up.path uploads up.property_id = p.id order position asc,id asc limit 0,1) image, p.ref_catastral, p.vacational_term, p.property_keys, p.owner_id, p.property_type , pt.name_es cate...

c# - Changing elements of a toolbar from collapsed to visible doesn't change their visibility -

i've spend whole evening trying understand , fix issue i'm encountering toolbar : i've created tiny vector based drawing program in user can choose tool (selection, line, text, image, etc...), clicking on corresponding icon located in toolbar before using it. when tool selected, new controls appear in toolbar (they have visibility, set collapsed, changed visible), allowing user change parameters. for instance when clicking on text tool, field appear user can write content. when image tool selected, button appears opens openfiledialog (in order select source file), etc etc... the problem that, in particular situation, elements should appear when corresponding tool selected, stay hidden, visibility set true in code. , missing controls not in overflow part of toolbar either. it's pretty hard explain here source code example, mimics app , shows issue : create new c# wpf project, copy following code in mainwindow.xaml <window x:class="ddi.mainwindow...

c# - WinForms Validating event prevents Escape key closing the form -

i have simple form single textbox, plus ok , cancel buttons. form's acceptbutton , cancelbutton set correctly, , ok , cancel buttons have dialogresult set 'ok' , 'cancel'. i want add validation textbox prevent user ok-ing form when validation fails, allow them cancel usual. the causesvalidation property true default on controls, have changed false on cancel button. sure enough, clicking ok or pressing enter key run validating event wired textbox. pressing cancel button bypasses validating, perfect. however, pressing escape cancel form not perform same pressing cancel button - raises validating event , prevents user exiting. is there way of making escape key perform intended, i.e. not raise validating event, if cancel button had been pressed? a complete worked solution is: create new windows forms app. add second form project. paste code form1's constructor, after initializecomponent(): messagebox.show((new form2()).showdialog().tostring())...

jquery - ASP.Net MVC 3 unobtrusive client validation does not work with drop down lists -

i have simple drop down list, first item in list has empty value. if not select in list client validation ignores it. have field set required on model using annotation attributes. @html.dropdownlistfor(model => model.ccpayment.state, unitedstatesstates.stateselectlist) [required(errormessage = "state required.")] public string state { { return _state; } set { _state = value; } } any ideas? missing something? it looks legitimate bug, here's best workaround i've found in search: http://forums.asp.net/t/1649193.aspx in short. wrap source of problem, dropdownlistfor , in custom html extension , manually retrieve unobtrusive clientside validation rules this: idictionary<string, object> validationattributes = htmlhelper. getunobtrusivevalidationattributes( expressionhelper.getexpressiontext(expression), metadata ); then combine v...

c# - Why can't I update metadata on an SPFile object? -

according microsoft's documentation : the windows sharepoint services 3.0 object model supports updating file metadata. can use indexer on property set value. example, set value of mydate property given file current date , time, use indexer , call update method, follows: [visual basic] ofile("mydate") = datetime.now ofile.update() [c#] ofile["mydate"] = datetime.now; ofile.update(); but when write line of code: ofile["test"] = "test"; it errors out with: cannot apply indexing [] expression of type 'microsoft.sharepoint.spfile' am doing wrong or did microsoft screw up? i don't have sharepoint try on right now, looks sample wrong. believe should ofile.properties["test"]="test"; article talks properties property.

php - Better use of models and migration in symfony -

hey. i'm having hard time migrating changes i've done config/doctrine/schema.yml file. i added column age user table. did php symfony doctrine:generate-migrations-diff followed php symfony doctrine:migrate . looking in database, column age added, without deleting data. but, /lib/model/doctrine/base/baseuser.class.php not changed, there no age field or functions age . did command php symfony doctrine:build-model . model updated/migrated too. so wonder, way? seems lot of work, , i'm afraid miss each time doing it. could go right phpmyadmin, add changes in database there , php symfony doctrine:build-schema , , skip migration part (two commands). also when comes use of models, right /lib/model/doctrine/user.class.php can make functions , such user "data class"? like, making function isfemale . if not, kind of function be? this might bad question, why model layer inside /lib/doctrine path? far have learned, keep modules inside apps, cre...

javascript - page loading message appears when going back to the previous page -

the following works fine, except when click button on browser (to go previous start page), loading... message appear again. should rid of it? many in advance. $("#form").submit(function(){ $("#loading").show(); }); <div id="loading">loading...</div> try: $(window).unload(function(){$("#loading").hide();});

asp classic - geocoding Google Maps & ASP -

i'm trying coordinates of address google map classic asp. when write address in address bar correct result: http://maps.google.com/maps/geo?output=xml&q=32822%20usa but code 602 (bad location google) when try call same address msxml2.serverxmlhttp the asp codes: url = "http://maps.google.com/maps/geo?output=xml&q=" & server.urlencode("32822 usa") set xmlhttp = createobject("msxml2.serverxmlhttp") xmlhttp.open "get", url, false xmlhttp.send "" xml = xmlhttp.responsetext set xmlhttp = nothing your problem here not url, correctly formed, fact cannot cross-domain xmlhttprequest. request google maps geocoding service must done server, fetch xml content , return asp script. here's do: asp script might call php file queries google geocoding , fetches response curl , returns asp can process it. if don't want use solution, might @ google maps javascript api provides geocoding methods ( link ) ...

iphone - Retrieving score value when using presentModalViewController to switch views in xcode -

i face problem of retrieving game "highscore" after finishes game. what did this: i call presentmodalviewcontroller method when time reaches 0. gameendingviewcontroller *gameendingview = [[gameendingviewcontroller alloc] initwithnibname:@"gameendingviewcontroller" bundle:nil]; gameendingview.modaltransitionstyle = uimodaltransitionstylecoververtical; [self presentmodalviewcontroller:gameendingview animated:yes]; [gameendingview release]; i want show score attained in main gameloop in gameendingview have. however, seems when use presentmodalviewcontroller method switch view. variable, score, update during gameloop gets reseted. whole game loop in view gamemainview. could explain me use of presentmodalviewcontroller , how should better solve problem? thank much. this not problem modal view. have problem in app logic. should better check out again. idea declaring score property , set breakpoint see changed.

.net - Should Interfaces Live In The Same Namespace As The Concrete Classes That Implement Them? -

is there standard how solutions/projects organized in regards interfaces , classes implement them? i'm working on mvp, ddd application , love hear feedback how others layout projects , why way. thanks!! they should live in namespace logical them; means there's no firm rule whether or not should reside in same namespace. you'll find relatively abstract namespaces don't live alongside implementation, whereas interfaces more 1:1 implementors more remain alongside 1 another. a more important consideration keep interfaces consumable reuse--normally means more consideration given goes assembly alongside interfaces, rather namespaces.

php - a way to create a dynamic loop for a drupal cck field with multiple values -

i have list of links want print similar drupal: associating grouping more 1 cck field multigroup module no longer active (as of month after post) have been printing them so: <?php if($node->field_committee_link[0][value]): ?><h4>1) <a href="<?php print $node->field_committee_link[0][value] ?>"><?php print $node->field_committee_link[0][value] ?></a></h4><?php endif; ?> <?php if($node->field_link_descriptor[0][value]): ?><?php print '&nbsp;&nbsp;&nbsp;&nbsp;'. $node->field_link_descriptor[0][value] ?><?php endif; ?> and changing numbers is way loop through such for $node->field_committee_link[0][value] $node->field_committee_link[x][value] print $node->field_committee_link[x][value] x= i++ next or need preprocess this? help appreciated try... foreach ($node->field_committee_link $link) { print $link[value]; }

iphone - Add a row to a TableView from a Detail view -

so have tableview , detail view. have row in tableview "add" record. when click on new button send nil object detail view same use editing existing row. use following code that: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { new = no; nsuinteger row = [indexpath row]; savedcardetailcontroller *detailcontroller = [[savedcardetailcontroller alloc] initwithnibname:@"savedcardetailcontroller" bundle:nil]; if(indexpath.row >= [listofcars count]){ nslog(@"new car"); detailcontroller.car = nil; new = yes; } else { new = no; detailcontroller.car = [listofcars objectatindex:row]; } detailcontroller.managedobjectcontext = self.managedobjectcontext; [self.navigationcontroller pushviewcontroller:detailcontroller animated:yes]; [detailcontroller release]; } when save core data stuff execute in detailcontroller - (void)viewwilldis...

java - Servlet Post parameters : what case can a parameter have several values? -

here function on servlet test various things (i'm new servlets althought understadn logic) public void testparameters(httpservletrequest request, httpservletresponse response) throws ioexception{ printwriter out = response.getwriter(); enumeration paramnames = request.getparameternames(); while(paramnames.hasmoreelements()) { string paramname = (string)paramnames.nextelement(); out.println("\n>>>" + paramname); string[] paramvalues = request.getparametervalues(paramname); if (paramvalues.length == 1) { string paramvalue = paramvalues[0]; if (paramvalue.length() == 0){ out.print("no value"); }else{ out.print(paramvalue); } } else { system.out.println("number of parameters "+paramvalues.length); for(int i=0; (this code took tutorial , tweeked might stupid) i working fine wandering in cases parameter have several values? example: http://myhost/path?a=b&a=c&a=d parame...

multithreading - How can Python continuously fill multiple threads of subprocess? -

i'm running app, foo, on linux. bash script/terminal prompt, application runs multi-threaded command: $ foo -config x.ini -threads 4 < inputfile system monitor , top report foo averages 380% cpu load (quad-core machine). i've recreated functionality in python 2.6x with: proc = subprocess.popen("foo -config x.ini -threads 4", \ shell=true, stdin=subprocess.pipe, \ stdout=subprocess.pipe, stderr=subprocess.pipe) mylist = ['this','is','my','test','app','.'] line in mylist: txterr = '' proc.stdin.write(line.strip()+'\n') while not proc.poll() , not txterr.count('finished'): txterr += subproc.stderr.readline() print proc.stdout.readline().strip(), foo runs slower , top reports cpu load of 100%. foo runs fine shell=false, still slow: proc = subprocess.popen("foo -config x.ini -threads 4".split(), \ shell=false, stdin=subprocess.p...

javascript - How do I format date in jQuery datetimepicker? -

i use jquery datetimepicker extended jquery datepicker pick not date time too. i want set date/time format way: dd-mm-yyyy @ hh:mm $('#timepicker').datetimepicker({ dateformat: 'dd:mm:yyyy', separator: ' @ ', mindate: new date() }); but not work. date/time in following format: thu jan 27 2011 02:05:17 gmt+0100 is there javascript function format date/time? if not how do using plugin? check out code: fiddle here go . $('#timepicker').datetimepicker({ // dateformat: 'dd-mm-yy', format:'dd/mm/yyyy hh:mm:ss', mindate: getformatteddate(new date()) }); function getformatteddate(date) { var day = date.getdate(); var month = date.getmonth() + 1; var year = date.getfullyear().tostring().slice(2); return day + '-' + month + '-' + year; } you need pass datepicker() date formatted correctly.

Installation problem with C# application -

i have designed c# application using visual studio 2010 .net framework 4.0 , works on pc. used dll connect oracle db. created setup project application deploy it, when tried install application on second pc, asked me install .net framework client, , have installed it. after when tried run application works each time code try call function dll throws exception: system.io.fileloadexception: not load file or assembly 'system.data.oracleclient, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089' or 1 of dependencies i added dll setup file, didn't work. have tried add code config file: <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyassembly partialname="system.data.oracleclient" fullname="system.data.oracleclient, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" /> </assemblybinding> </runtime> but didn't work too. help, ...

How to combine PHP and Prolog -

i'm trying call prolog using php script. i'm using syntax found here , is: $cmd = "nice -n15 /software/bin/pl -f /home/popx/cgi-bin/test.pl -g test,halt"; the program /bin/pl have prolog installed, , /home/popx/cgi-bin/test.pl location of file consulted. after changing paths accordingly, no output. can me, , give me pointers? i'm conversant questions how use prolog php? , , invoking swi-prolog php , not answer question. you cannot retrieve output system() . use exec() instead. http://docs.php.net/manual/en/function.exec.php