Posts

Showing posts from July, 2010

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

loops - What is the right way to add an `if` to a generator expression in Python? -

this code : s = ''.join('%s: %s </br>' % (a,getattr(user, a) ) in dir(user)) and want add if in code , write : s = ''.join('%s: %s </br>' % (a,getattr(user, a) if !a.index('__') ) in dir(user)) i think not right , what right way add if in loop , thanks you want condition evaluate on each iteration through loop @ end, this: s = ''.join('%s: %s </br>' % (a,getattr(user, a)) in dir(user) if '__' not in ) edit: sorry, fixed parentheses appropriate nesting. edited: changed conditional (didn't pay attention before, falmarri.

sql server - Set a DateTime database field to "Now" -

in vb.net code, create requests sql parameters. set datetime parameter value datetime.now, request ? update table set date = "2010/12/20 10:25:00"; or update table set date = getdate(); in first case i'm sure every record set exact same time. in second case depends on how dbms processes request. leads me second question : sql server set same date , time when updating large table now() ? edit : replaced now() (which doesn't exist in sql server) getdate(). in sql need use getdate() : update table set date = getdate(); there no now() function. to answer question: in large table, since function evaluated each row, end getting different values updated field. so, if requirement set same date (untested): declare @currdate datetime; set @currdate = getdate(); update table set date = @currdate;

How do I write a "tab" in Python? -

let's have file. how write "hello" tab "alex"? this code: f = open(filename, 'w') f.write("hello\talex") the \t inside string escape sequence horizontal tabulation.

string - Case-insensitive NSString comparison -

using code able compare string values. [elementname isequaltostring: @"response"] but compares case-sensitively. there way compare string without case sensitivity? there’s caseinsensitivecompare: method on nsstring , why don’t read the documentation ? method returns nscomparisonresult : enum { nsorderedascending = -1, nsorderedsame, nsordereddescending }; typedef nsinteger nscomparisonresult; …ah, sorry, realized asking case sensitive equality. (why don’t i read question? :-) default isequal: or isequaltostring: equality should case sensitive, gives?

osx - Eclipse IDE for JavaScript Web Developers + Subclipse + JavaHL on Mac OS X 10.6 -

i want use eclipse plugin subclipse on snow leopard. installed eclipse ide javascript web developers (helios service release 1). i should mention subversion server ist ssl protected, have use personal certificate (p12 file). i tell system find certificate file in /users/<username>/.subversion/servers with lines: [groups] servername = 999.999.99.99 ... [servername] ssl-client-cert-file = /users/<username>/desktop/<certificate> using svn in command line works. so first try use subclipse plugin offered subclipse.tigris.org within eclipse's "install new software" dialogue. offers me subclipse 1.0.0. ended error in eclipse's console view when trying connect svn repository: svn: propfind request failed on '/blahblahblahrepositorydirectory' svn: received fatal alert: handshake_failure i thought might idea use newer svn version + javahl (snow leopard's preinstalled svn 1.0) according http://subclipse.tigris.org/wiki/javahl#

python - Framework for user defined relationships -

i'm thinking creating django-powered website users able relate entities each other. examples instance include: "john married mary" or "john works @ google". users should able define entities , relationships (and typically define relations of other people, not of themselves). ideally, users enter these relations free text (where subject , object perhaps autocomplete field, based on entered existing entities). django's model framework ideal storing entities , relations, how 1 make such thing manageable on higher level? is there python-powered ontological framework (thanks duffymo) me derive structure out of these user-generated relationships? i'm looking ways example derive reversible relations, aggregate relations (e.g. "3 persons family relations of john"), classify types of relations (family relations, work relations, ...), , based on user generated input , not (known) predefined set of relations. thanks in advance, mathieu

c# - Array of structs - struct? -

if pass array of structs method parameter, in method body have reference array of structs, or new array of structs? you'll have reference array of structs. array reference type, array of structs object values stored inline. if pass array method, pass reference array object. reference passed value.

java - Android ProgressDialog thread -

how show progressdialog in separate ui thread? i have following code: public boolean mymethod() { // show here progressdialog in thread // long operation, must not in thread, there's return value... return value; } using handler, thread, asynctask didn't help... is there way run progressdialog in separate thread , main (long) operation in main thread? thanks, there 1 ui thread. should never run heavy in it. i'm afraid have run in background , progress bar in ui thread. you might have bit redesigning achieve that. can use callbacks rid of return values.

random - several ordenation needs in the same request -

i have doubt solr possibilities. need request special issues: i need first: promoted records terms typed user (ordered randomly). second: promoted records term typed user (ordered randomly). third: promoted records found stemming search (ordered randomly). fourth: promoted records found phonetic search (randomly). fifth: free records ordered alphabeticly (having or term typed user). these results need paginated. is possible in same request? after finding out random ordering support in solr via: <fieldtype name="random" class="solr.randomsortfield" /> <field name="random" type="random" indexed="true" stored="false"/> those queries possible not in 1 query although 1 use facet , facet.query feature, returns count ... not docs. i setup separate advertising index instead of normal way implement 'advertising' elevation component promoted records terms typed user (ordered randomly)

activerecord - Rails active record: update a list of records -

i have 2 tables: 'countries' , 'airports'. want set countries, have @ least 1 airport, 'active'. not work: def self.activate_by_airports update_all('active = 1', ['country_code in (?)', airport.select('distinct(country_code)').where(:active => 1)]) end as understand, airport.select(...) returns list of airport objects, when need list of country codes. what right syntax in case? use airport.select('distinct(country_code)').where(:active => 1).toarray or airport.select('distinct(country_code)').where(:active => 1).all - rails 3 only

domain driven design - Unit of work in Nhibernate -

i using nhibernate persistence, read somewhere nhibernate acts unitofwork container. need create separate unitofwork implementation. ? or continue nhibernate's unitofwork. you don't need create separate uow implementation. suggest read post: nhibernate.info

spring - Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource -

problem : i creating pointcut execution of method in class . class controller class , denoted annotation @controller , hence no bean needed same required aspect. attaching dispathcher servlet code , aspect , controller class.can identify problem is. dispatcher servlet : <?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:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/sprin

tags - Automatic Tagging Algorithm -

does know how build automatic tagging (blog post/document) algorithm? example appreciated. i agree wooble saying. naïve solution write algorithm calculates lexical similarities , differences of given blog post compared corpus of text. lexical difference give words found in blog post more frequency found in corpus. , words, can infer tag. but recommend against it. automatic tagging doesn't seem work in practice. outsource tagging work users or services mechanical turk

Scala 2.8.1 implicitly convert to java.util.List<java.util.Map<String, Object>> -

i have scala data structure created following: list(map[string, anyref]("a" -> somefoo, "b" -> somebar)) i implicitly convert (using scala.collection.javaconversions or scala.collection.javaconverters ) java.util.list<java.util.map<string, object>> passed java method expects latter. is possible? i have created following method it, wondering if can done automatically compiler? import scala.collection.javaconversions._ def converttojava(listofmaps: list[map[string, anyref]]): java.util.list[java.util.map[string, object]] = { asjavalist(listofmaps.map(asjavamap(_))) } how writing implicit def converttojava... ?

ruby - Cucumber feature on form with Captcha -

if form has captcha (i'm using humanizer gem). how fill form , send , expected result when writing cucumber feature. scenario: sign valid data given not authenticated , on sign in page when follow "sign up" , fill in following: | name | administrator | | email | admin@admin.com | | password | 123456 | | password confirmation | 123456 | , fill in captcha correctly , press "sign up" should on new_company page , should see "hello manoj" now can write step definition matching /^i fill catcha correctly$/ must put there? be gentle, i'm new cucumber , it's been frustrating far. i'm not new rails or programming otherwise. you're right, aditya. putting environment dependent code in models not solution. can "stub" bypass_humanizer? when needed: # user.rb class user include

mysql - I created several stored procedures in phpmyadmin, how to call them using an sql query? -

i created several stored procedures in phpmyadmin, how possible call them using sql query (mysql) ? call name_of_stored_procedure(parameters); try on 'sql' tab: create definer=`root`@`localhost` procedure `storedprocedure1`(out myvar1 char(64)) set myvar1="it "; create definer=`root`@`localhost` procedure `storedprocedure2`(out myvar2 char(64)) set myvar2="works"; then call: call procedure1(@var1); call procedure2(@var2); select @var1,@var2;

javascript - Capturing Mouse and Keyboard Events Simultaneously -

i in situation have detect control key pressed or not while dragging object in javascript ,,, if control key pressed need perform other action.. can me out on this,,, thanks in advance vinay check event.ctrlkey .

create function sql server 2005 disable errors -

i'm trying write *.bat file runs sql-scripts in given folder (every file in folder has create function script): for /r "%~dp0\production\functions" %%x in (*.sql) ( sqlcmd -s%1 -d%2 -b -i "%%x" ) but functions in folder depended on others. invalid object name error. there way disable error? rename files they're listed in correct order of precedence. so, example, if funca.sql uses funcb.sql , rename files 001-funcb.sql , 002-funca.sql .

winforms - Changing Tabs in a Tab Control does not send Child a Message -

in c# windows forms application using framework 2.x, clicking on tab control not send message child controls (such lost focus event). using microsoft spy++, not see messages sent child control. messages when click on tab hosting control. any ideas on need have child control know not displayed after tab changed. code in control, not parent. guessing missing out on event or registration. thanks in advance, craig i guessing missing out on event or registration. i don't think are. the lost focus event since happens before page changes. the child control's visiblechanged event fires when parent tabpage shown , not when hidden not want. you can handle either tabpage.visiblechanged or tabcontrol.selectedindexchanged . of course parent not child, not want. incidently believe tcm_setcursel message sent control on tab change (again not helping "not in parent requriement"

How do I tweak CSS on the Django 1.2.3 admin media? -

i make css-only adjustments admin interface (on rhel box don't have sysadmin privileges to). end, local version of /media/ tweak. http://docs.djangoproject.com/en/dev/howto/static-files/ (but not http://docs.djangoproject.com/en/1.2/howto/static-files/ ) suggests running manage.py collectstatic or manage.py findstatic, , django 1.2.3 manage.py not recognize commands. adding 'django.contrib.staticfiles' installed_apps broke things (not found). i customize css, , way envision doing getting private copy of media django's admin , changing there. best options django 1.2.3 installation? just go django installation directory, browser django->contrib-> admin-> directory , copy paste media folder django projects media directory. let have media in project/media statically rendered web /media/. if copy admin media in project/media admin media web url /media/admin/ hence in settings.py file: admin_media_prefix = '/media/admin/' you may mo

ruby on rails - How do I resize high-res photos to thumbnails? -

i have site user can upload photo. have no idea how handle photos. make thumbnail out of large res photo, resize width , height? or there better way this? if point me resources or give me tips, great. i'm using ruby on rails, if matters. don't want gems because want learn how myself. for of this, "learning how yourself" going significant undertaking. resizing image, example. go ahead , find open source library (such gem) resizes images , through source code. it's not impossible on own, lot of sort of thing built on expertise that's come before, etc. there's nothing wrong making use of tool else has created, provided understand tool doing. a few points out: go white-list approach of image formats support. don't let users upload call image. each format support going have own standards (possibly multiple) meta-data. stripping out data wholesale may or may not idea. example, jpeg may contain orientation in exif data , if stri

SQL UPDATE Command - How can i tell how many records have been updated? -

if have sql statement like: update people set people_name = "rambo" people = "terminator" how can show how many records have been updated? possible? use @@rowcount: select @@rowcount 'rowschanged' http://www.brettb.com/sql_help_rowcount_rows_affected.asp

.net - does try catch clause affect performance? -

does try/catch affects performance if no exception thrown in try block? how try/catch/finally ? neither try/catch nor try/catch/finally affects performance significant degree. exceptions being created do affect performance, of course (and whether caught, or not) do try/catch blocks hurt performance when exceptions not thrown?

Is there a Java class that is a cross between a Map and a List? -

i looking java class offers both map (fast lookup) , list (determinate order) characteristics. advice? thanks! linkedhashmap preserves order elements added collection.

spell checking - Spellchecker in eclipse doesn't recognize certain strings -

spellchecker in eclipse doesn't recognize strings 'finalize', 'randomize' though correct. there setting needs enabled these don't show issues in eclipse java file editor? add strings user defined dictionary. check out general > editors > text editors > spelling page on preferences dialog (found under window > preferences).

google app engine - Send Emails From AppEngine Locally -

the subject of post says all: want able send emails appengine when running locally. far understood post: to send emails google appengine i have setup mail server. can tells me easy steps install mail server locally , use google appengine? ok, found solution question. basically, install sendmail tool, use option --enabled_sendmail when calling dev_appserver.py. here did (i use ubuntu): sudo apt-get install sendmail then whenever call dev_appserver.py, call this: ~/google_appengine/dev_appserver.py --enable_sendmail --port=8081 ./appengine/ notice --enable_sendmail option. i believe there can't easier solution :-)

javascript - How do I set a callback function parameter like 'data' in the "jQuery.ajax({ success : function(data)"? -

i wondering how set first parameter of callback function want, same way jquery in success callback or complete callback i want this: $.ajax({ success: function(data) { alert(data) } }); from understand close can want function test(text) { this.text = text this.success = function(this.text) { } } var = new test('king kong') a.success = function(k){ alert(k) } and want alert "king kong" here's example of accepting callback in constructor function , calling later in response trigger. in below, trigger calling trigger function, can want: function test(text, callback) { this.text = text; this.success = callback; } test.prototype.trigger = function() { // call success callback, passing in text this.success(this.text); }; var = new test('king kong', function(k) { alert(k); }); a.trigger(); (i've made test initially-capped there. that's convention constructor functions, of course free ignore.)

regex - c# string that has to contain quote " -

string anipattern=@"(?si:<option value=\\\"(?<year>.*?)\\)"; this breakes because " in middle. need because use in regex. i tried use string anipattern="(?si:<option value=\\\"(?<year>.*?)\\\\)"; (without @) isnot valid regex. important - isn't entirely clear want match; i've answered on premise only " being problem - see mike caron's answer assumes everything escaped incorrectly. with verbatim string literal (i.e. @"..." ), " escaped "" - string becomes: string anipattern=@"(?si:<option value=\\\""(?<year>.*?)\\)"; with regular string literal (without leading @ ), need lot worse: string anipattern="(?si:<option value=\\\\\\\"(?<year>.*?)\\\\)";

What is Oracle error ORA-01536? -

i got following error on oracle: ora-01536 what problem? the online documentation includes book explanations , resolutions error messages. of them bit cryptic place start. find out more . anyhoo, here illustrated solution ora-01536. a dba creates new user: sql> create user fox_in_socks identified tweetlebeetle 2 default tablespace users quota 1m on users 3 / user created. sql> grant create session, create table fox_in_socks 2 / grant succeeded. sql> in session our brave user creates table... sql> conn fox_in_socks/tweetlebeetle connected. sql> create table t23 (col1 varchar2(4000)) 2 / table created. sql> .. , work.... sql> begin 2 in 1..1000 loop 3 insert t23 values (rpad('a', 4000, 'a')); 4 commit; 5 end loop; 6 end; 7 / begin * error @ line 1: ora-01536: space quota exceeded tablespace 'users' ora-06512: @ line 3 sql> uh-oh! our user goe

jquery - Using prototype in javascript -

i have defined couple of functions inside javascript work perfectly, when put inside prototype doesn't seem work. wall.html: <script type="text/javascript" src="jquery/jquery-1.4.4.js"> </script> <script type="text/javascript" src="src/commentmanager.js"> </script> <script type="text/javascript" src="src/reply.js"> </script> <script type="text/javascript" src="src/comment.js"> </script> <script type="text/javascript"> $(document).ready(function(){ commentmanager(); $("form#newmessage").submit(function(){ var message = $("input#newmessagetxt").val(); var newcomment = new comment(message); }); }); </script> </head> <body> <div class="message"> <form id="newmessage"&gt;> <input ty

javascript - jQuery flying notifier -

i have long page. want show info, when user scroll page, info follow user. is plugin? http://www.phpletter.com/demo/jquery-floating-box-plugin/ http://roshanbh.com.np/examples/floating-message-jquery/ http://amirharel.com/labs/fo/float_demo.html https://d2o0t5hpnwv4c1.cloudfront.net/018_floating_menu/demo/dhtml_float_menu_final_nettut.html

CSS Help to see stars -

i have looked around , have been unable write css code based on 5 star rating system change based upon customer feedback. appreciated. you try positioned sprite-sheet: html: <div class="rating one-star"></div> css: .rating { background-image: url(stars.png); background-repeat: no-repeat; height: 20px; width: 100px; } /* assume star 20x20 */ .one-star { background-position: -80px 0; } .two-star { background-position: -60px 0; } .three-star { background-position: -40px 0; } .four-star { background-position: -20px 0; } .five-star { background-position: 0 0; } of course may want div contain 5 links star outlines, hover effects, or other such things. depends on you're looking for.

Resources to compare Java to Objective-C (syntax and basics) -

i have taught myself lot of objective-c on past year , half, , have been able publish ios apps on app store. concepts foreign me before object oriented programming second nature , understand mvc, inheritance, polymorphism etc. i'm interested in learning develop android platform, entail learning java. want find resources can match java basics regards syntax , structure same things objective-c world. the wikipedia entry objective-c has i'm looking regards how objective-c relates c++. if there document, blog post or book dedicated java in relation objective-c on bear on honey. should include things like class method declarations , implementations instance method declarations , implementations how compose method name (ie +/-(returntype)methodname:(type)argument; ) declaring properties thank of suggestions! "matching syntax" not useful thing. 2 languages not merely different syntaxes same thing. lots of people go new language mindset, , leads

Android - Ajax style auto check of username availability -

i building android app in user required choose nick name. now, 2 users cannot have same nick name. have seen forms on .net can verify availability of particular username while user types or presses tab using ajax calls. my questions - available android. can query server on fly , verify availability of nick name. thanks lot responses. if there tutorials, samples or android doc references need @ please guide me that. you could query server's database of users entered username on every keypress event specified input component( edittext , etc), might pretty network intensive , spawn lot of threads handle: add textwatcher input edittext or whatever user entering name into in ontextchanged method, spawn thread contact database sending along charsequence value. response server output json perhaps boolean property says if username available or not user hits "ok" , expects name registered themself. final check needs made before nickname, availability m

Exporting a MySQL database through PHPMyAdmin -

i'm hoping export database have access through phpmyadmin can make copy of on localhost. i've never done before , database large @ 200 tables. have experience doing this? i'm unsure if web interface of phpmyadmin reliable way export data or if i'd causing performance issues attempting export data. thanks advice. thy phpmyadmin version 2.1 if helps any. in table, select export, tick "save file" option, , keep selection "compression: none". you able download huge data tables this.

locating jar file in $PATH environment variable for java -jar command -

i want run simple executable jar this: java -jar /path/to/my/jar/myjar.jar however, have put absolute path every time want run it. there way tell os jar in $path environment variable? you can copy jar file /usr/bin folder, work $ myjar.jar make sure jar file has executable bit ( chmod +x myjar.jar ) , copy /usr/bin ( sudo cp myjar.jar /usr/bin/myjar.jar )

android - AsyncTask onPostExecute never gets called -

i not sure doing wrong onpostexecute never gets called. created base class called baseactivity.java from original activity extended class. placed posttoopenfeint class inside baseactivity called ui thread main activity doing: new posttoopenfeint.execute(); the onpreexecute(), doinbackground(..) gets triggered, reason onpostexecute never gets called. thank in advance! dave private class posttoopenfeint extends asynctask<void, void, void> { /* * (non-javadoc) * * @see android.os.asynctask#doinbackground(params[]) */ @override protected void doinbackground(void... params) { // work here return null; } /* * (non-javadoc) * * @see android.os.asynctask#onpostexecute(java.lang.object) */ @override protected void onpostexecute(void result) { // todo auto-generated method stub super.onpostexecute(result); toast.maketext(mainscreen.this, "done syncing", toast.length_long).show(); } /* * (non-ja

c# 3.0 - About casting and objects -

it's simple, want explanation this: internal class b { // base class } internal class d : b { // derived class } in other class wrote: b b3 = new object(); //compilation time error! why??? suposse classes inherit "object" b more specialized object , therefore cannot assign object instance b reference. because not every object b - opposite true. let's assume have field x in class b . when instantiate object , no memory reserved field, , if assign reference of type b , therefore try read or write unallocated memory, not allowed (or useful).

android - How to extract the content of a cursor from a SQLite DB to a class? -

i need function on mydbadapter extract users sqlite database, , then, return list<friend>. this munch hard me, testing , trying understand lot of google examples , stackoverflow posts can't it i tryed code doesn't works, c ursorindexoutofboundsexception: index -1 requested, size of 3 public list<friend> retrieveallusers() { list <friend> friends=new arraylist<friend>(); cursor result=fetchallusers(); (int i=0; i<result.getcount();i++) { //note.getstring(note.getcolumnindexorthrow(notesdbadapter.key_title))); friends.add(new friend(result.getstring(result.getcolumnindexorthrow("email")), "","","","")); } return friends; } please can me doing function ? i have user (friend) class, this: public class friend { private string email; //id de usuario private string password; private string fullname;

sql server - StreamWriter Only Works on Some Workstations -

i have page on intraweb (that didn't create) allows user specify .txt file , writes results of sql stored procedure file using streamwriter. it apparently stopped working of workstations several months ago, can't trace specific changes (however, know code didn't change). if access & use page on server (where wwwroot , applicable database located), successfully writes .txt, whether specified local file or on workstation on network. users on workstations,though, no longer able write file. (it not writing blank file. "date modified" remains unchanged.) the problem seems machine-related rather user-related, can login same user on different workstations different results. i still think may have permissions, created .txt on problem workstation every possible account having full permissions, no luck. permissions on database, stored procedure, , folder destination seem correct. any suggestions welcome, thanks. you mean tell page completes succ

profiling - How to profile a stored procedure DB2 -

i need website or application can use profile stored procedure in db2 database. does know of way this? you need ibm data studio http://www-01.ibm.com/software/data/optim/data-studio/

php - Recursive-ish query for tags? -

i have table of tags can linked other tags , want "recursively" select tags in order of arrangement. when search made, immediate (1-level) results , carry on down 5-levels have list of tags no matter if there wasn't enough exact matches on level 1. i can manage fine making multiple queries until enough results, surely there better, optimized, way via one-trip query? any tips appreciated. thanks! results: tagid, tagword, child, child tagid '513', 'slap', 'hog slapper', '1518' '513', 'slap', 'corporal punishment', '147' '513', 'slap', 'impact play', '1394' query: select t.tagid, t.tagword tag, tt.tagword child, tt.tagid childid platform.tagwords t inner join platform.tagslinks l on l.parentid = t.tagid inner join platform.tagwords tt on tt.tagid = l.tagid t.tagword = 'slap' table layouts: mysql> explain tagwords; +---------+---------------------+

php - sfValidatorFile 'mime_type' validation not working in production server -

i've built backend couple of models, 1 of them, products, supports image uploading. locally file uploading works fine. when did deploy, stopped working: form validation fails because of wrong mime type (error is: "invalid mime type (jpeg image data, exif standard).") image field, when i'm using same jpg image used test locally. i'll show form class code: class productform extends baseproductform { public function configure() { ... /* widgets */ ... $this->widgetschema['image_1'] = new sfwidgetforminputfileeditable(array( 'file_src' => '/'.basename(sfconfig::get('sf_upload_dir')).'/products/normal_'.$this->getobject()->getimage_1(), 'is_image' => true, 'edit_mode' => strlen($this->getobject()->getimage_1()) > 0, 'delete_label' => 'remover el archivo actual', 'template' => '<div>%file%

mysql - Portable SQL upsert (insert+update) solution needed -

i need perform simple operation on database - put values table key, if row exists - update it, if not - create new one. problem need in portable way - i.e. same query must work on mysql, sql server, oracle , preferably db2, postgres, etc. while use replace or insert ... on duplicate key update in mysql, i'm not sure these support such syntax. , want avoid if's database type, because unmaintainable. don't want query value before updating, because suspect slow down process (i need multiple times). so far best came doing: update table set data='data' key='key'; insert table(key, data) values ('key', 'data'); one of succeed , fail, don't care 1 of queries fails. looks kind of inelegant though. suggestions how make better? the database-agnostic solution, using modern databases, call update insert in 2 operations. databases not allow multiple statements sent in single operation , databases might not return number of row

c# syntax help, about generic programming -

tentity single(expression<func<tentity, bool>> predicate); please explain parameter. so, there lot going on here, lets start inside: func<tentity, bool> delegate takes input, type generic, call tentity . without contraints, can anything, strongly-typed anything. out 1 level expression<func<tentity, bool>> . expression tree, typed delegate takes input , return bool. in other words, expression tree (think compilers course) represents function. finally, outermost level: tentity single(expression<func<tentity, bool>> predicate) method called single takes predicate function in form of expression. returned same type passed function. essentially, single take expression, compile , execute against set of data, returning first entity in collection matches predicate expression. hope helps?

dynamic update the data using EF4 in asp.net mvc -

for example, have data table named [user], , mapping user enetity ef4: id, fullname, emailaddress, fax, tel in web page, want update "emailaddess" , "fax" 2 properties below: @using (html.beginform("edit", "user")) { <label>email address:</label> @html.textbox("emailaddress") <label>fax:</label> @html.textbox("fax") <input type="submit" value="update" /> } and controller did this: public actionresult edit(user user) { var _user = getusers().where(a => a.id == user.id).singleordefault(); _user.fax = user.fax; _user.emailaddress = user.emailaddress; context.savechanges(); } yes, updated , successful, next time want update "tel", need change code this: _user.fax = user.fax; _user.emailaddress = user.emailaddress; _user.tel = user.tel; if have 100 fields, crazy doing :( so, how can update models database related fields in we

single quote in php from java string -

i have java (android) application uses php talk ms database. problem 1 part in app. have string sql statement, , string not insert database single quotes string sql = "select * table col = 'testing' , col2 = 'tester'"; i in php script using: $script = $_request['script']; 2 things, want insert script a column datatype char , want run script well. thanks! i not having users run there own scripts on db. check checkbox stringbuilder builds script upon select. if check female or male string add select * table gender = 'female' etc. as far remember, strings in mssql represented double quotes. $var = "select ... col = \"testing\""; $var = 'select ... col = "testing"'; // more readable just use way. if receive queries, consider replacing ' " using str_replace. aware of fact may not correct cases simple ones.

json - Zend_Navigation, Zend_ACL + Roles not filtering correctly through an Ajax request -

i have been using zend_acl , zend_navigation on project , seems work correctly. how ever using lot of ajax in site , have made login jqmodal , jquery logs in users without reloading current page , have need reload navigation well. have far got working navigation being return links visible field true incorrect. example when logged in user login link should not visible. any appreciated. code below action, javascript function , json returned. ======================================================= current role = admins // controller action public function getnavigationjsonaction() { //$view->navigation($container)->setacl($this->_acl)->setrole(zend_registry::get('role')); // echo $this->navigation()->menu(); $navigation = $this->getview()->navigation()->setacl($this->_acl)->setrole(zend_registry::get('role')); //die(zend_registry::get('role')); //die($this->_acl); $this->_helper->json($navigation-&g

php 5.3 - PHP Magic faster than simply setting the class attribute? -

well, not that, here example. can explain difference between b , c? how can faster use magic function dynamically set value instead of setting value in attribute definition? here code: [root@vm-202-167-238-17 ~]# cat test.php; d in b c; echo "------"; ./test.php $d; done; #!/usr/bin/php <?php $classname = $argv[1]; class { public function __get($a) { return 5; } } class b { public $a = 5; } class c { public function __get($a) { $this->a = 5; return 5; } } $a = new $classname; $start = microtime(true); ($i=0; $i < 1000000; $i++) $b = $a->a; $end = microtime(true); echo (($end - $start) * 1000) ." msec\n"; ------ 598.90794754028 msec ------ 205.48391342163 msec ------ 189.7759437561 msec magic functions slower else in php, , should used carefully. blog subject (auto-creating attributes magic functions speed things up... anyway). el yobo stated, modified php script tests mo

hibernate - Entity bean not bound when use both EJB 2 and JPA -

i using jpa hibernate implementation , ejb 2.1 in project (a spring + hibernate project). after deployed project jboss 6.0 cr1 server log said: 15:34:20,866 info [ejbdeployer] installing bean: ejb/ejbproject.jar#ebmybean,uid27484928 15:34:20,867 info [ejbdeployer] dependencies: 15:34:20,870 info [ejbdeployer] , supplies: 15:34:20,871 info [ejbdeployer] jndi:ebmybean 15:34:20,873 info [ejbdeployer] jndi:local/ebmybean@31242541 15:34:21,038 info [persistenceunitdeployment] starting persistence unit persistence.unit:unitname=myproject.ear/ejbproject.jar#persistenceunit 15:34:21,196 info [version] hibernate commons annotations 3.2.0.final the server didn't start , @ end threw exception saying: caused by: javax.naming.namenotfoundexception: ebmybean not bound in jmx console of jboss cannot see under ejb 2.1 module section. ear file contains jar file , war file. ejbs , persistence unit in jar file. in meta-inf folder of jar file there ejb-jar.xml , persiste