Posts

Showing posts from March, 2014

Should I use event design when handling no-idempotent invocation? -

Image
i'm working on air booking project. the image below shows domain model develop far. we define domain service (airbookservice) encapsulates booking, ticketing , other operations. our suppliers provides remote-procedure-call api handle these requests, implement domain service adding anti-corruption-layer(we have multiple suppliers). this solution works fine when dealing imdenpotent rpc calls such getting price. however, there risks when dealing non-imdenpotent rpc calls. for example public class transactionalreservationhandlingserviceimpl .... { @transactional @override public void modifytraveler(string resid, string tktid, airtravler traveler) { airreservation res = reservationrepository.findby(resid); res.modify(tktid, traveler); airbookservice.modify(res, traveler); reservationrepository.store(res); } } i place airbookservice.modify() behind res.modify(), rpc call avoided if local domain logic broken. if rpc ca...

c++ - Overload resolution between object, rvalue reference, const reference -

given 3 functions, call ambiguous. int f( int ); int f( int && ); int f( int const & ); int q = f( 3 ); removing f( int ) causes both clang , gcc prefer rvalue reference on lvalue reference. instead removing either reference overload results in ambiguity f( int ) . overload resolution done in terms of strict partial ordering, int seems equivalent 2 things not equivalent each other. rules here? seem recall defect report this. is there chance int && may preferred on int in future standard? reference must bind initializer, whereas object type not constrained. overloading between t , t && mean "use existing object if i've been given ownership, otherwise make copy." (this similar pure pass-by-value, saves overhead of moving.) these compilers work, must done overloading t const & , t && , , explicitly copying. i'm not sure strictly standard. what rules here? as there 1 parameter, rule 1 of 3 viable p...

ibm mobilefirst - Populate List based on json data in Worklight Application -

i developing worklight application using dojo shows list data based on webservice response.for getting webservice response have created adapter,i tested adapter , working fine.my problem show json data on view ,also in new view taught of showing data in list(list should populate based on json data array length) if click on list show details. how .any appreciated. code. .js function dispdata() { var invocationdata = { adapter : 'getsampleadapter', procedure : 'sample' }; wl.client.invokeprocedure(invocationdata,{ onsuccess : success, onfailure : failure, }); } function success(result) { var httpstatuscode = result.status; if (200 == httpstatuscode) { dijit.registry.byid("view0").performtransition("view1", 1, "slide"); } } html file <div data-dojo-type="dojox.mobile.scrollableview" id="view0" data-dojo-props=...

ruby on rails - Can I set Mongoid query timeout? Mongoid don't kill long time query -

mongoid don't have timeout option. http://mongoid.org/en/mongoid/docs/installation.html i want mongoid kill long time queries. how can set mongoid query timeout? if nothing, mongoid wait long time below. mongo > db.currentop() { "opid" : 34973, "active" : true, "secs_running" : 1317, // <- long! "op" : "query", "ns" : "db_name.collection_name", "query" : { "$msg" : "query not recording (too large)" }, "client" : "123.456.789.123:46529", "desc" : "conn42", "threadid" : "0x7ff5fb95c700", "connectionid" : 42, "locks" : { "^db_name" : "r" }, "waitingforlock" : true, "numyields" : 431282, "lockstats" : { "timelockedmicros" : { "r" : numberlong(5143...

php - "Map to existing tables" in Extension builder showing weird issues in TYPO3 -

Image
in extension myext , mapped model page pages table in typo3. firstly shows me type mismatch error, anyhow went ahead , saved it. the following things happen: my page tree becomes this: my new record form shows uids , not titles: my page edit becomes this: in myext/configuration/typoscript/setup.txt have this: config.tx_extbase.persistence.classes { tx_myext_domain_model_page { mapping { tablename = pages } } } is bug ? or i'm doing wrong ? this /domain/model/page.php , glimpse of it. class page extends \typo3\cms\extbase\domainobject\abstractentity { /** * uid * @var int * @validate notempty */ protected $uid; /** * title * @var string * @validate notempty */ protected $title; /** * __construct * * @return page */ public function __construct() { //do not remove next line: break functionality $this->initsto...

Allow only numbers using JavaScript for textboxes -

this question has answer here: how allow alpha numeric chars javascript 2 answers i new javascript. have created form submits details database. have different textboxes, need accept only letters , allow numbers. i got code while doing research, code tells me of invalid pattern. can me code allows only letters . tried modify code takes letters failed. function f_check_lett(form){ //only letters , numbers allowed var text = form.bucketname.value; alert(text); var filter = /^[a-za-z0-9]+$/; if (filter.test(text)) { form.submit(); } else { form.bucketname.select(); alert("only allow letters , numbers!"); } } use filter var filter = /^[a-za-z]+$/; in filter [a-za-z0-9] accept character of: 'a' 'z', 'a' 'z', '0' '9' sinc...

.Net Script works in windows 7 but not in XP -

i have script sorts excel file , generates text file out of sorted file. in other words, have button users can click sort file. sort button modifies file , closes it. next user clicks on generate button generate text file out of sorted sheets. the generate function checks see if excel file sorted before generating text file. however, code works in windows 7 user clicks on sort button , waits finish before clicking on generate button. however, in windows xp, user clicks on generate button , throw error stating excel file not sorted. have tried open file , file shows sorted. both framework .net 4.0 i had similar problem when opened excel files .net different cultures have different sort methods, in 1 culture sorted numbers before letters , in other letters before numbers. related this.

Can i use some tables with InnoDB engine and some with MyIsam on my MySQL database? -

i read innodb better use on table lot's of insert records simultaneously. application gets 50 records per seconds. these tables should use innodb, right? in other hand have tables used select, few updated or have few new insert. myisam faster select ? if it's case, better leave table myisam , innodb or should use tables same engine ? my application searches lot on tables want pass in innodb. should ? you can check these: reasons use myisam: tables fast select-heavy loads table level locks limit scalability write intensive multi-user environments. smallest disk space consumption fulltext index merged , compressed tables. reasons use innodb: acid transactions row level locking consistent reads – allows reach excellent read write concurrency. primary key clustering – gives excellent performance in cases. foreign key support. both index , data pages can cached. automatic crash recovery – in case my...

c++ - Merge sort not working completely -

the code have made merge sort given below. thing on giving input output 3 2 1 5 0 . going wrong? #include <iostream> #include <cmath> using namespace std; int d[100]; void merge(int a[], int b[], int c[], int n) { int n2=floor(n/2); int i=0, j=0, k=0; while(i<n2 && j<(n-n2)) { if(b[i]<c[j]) { d[k++]=b[i++]; } else if(b[i]>c[j]) { d[k++]=c[j++]; } } if(i==n2) { if(j<(n-n2)) { d[k++]=c[j++]; } } if(i<n2) { d[k++]=b[i++]; } } void mergesort(int a[], int n) { int n2=floor(n/2); int b[50],c[50]; int i,j=0,k=0; for(i=0;i<n2;i++) { b[i]=a[k++]; } while(k<n) { c[j++]=a[k++]; } merge(a,b,c,n); } int main() { int a[]={5,4,3,2,1}; int n=5; mergesort(a,n); for(int i=0;i<n;i++) { cout<<d[i]<<endl; } } the main problem arrays (b , c) passed merge not sorted. other problems algorithm not recursive , merge...

c# - How to store a Dictionary<string,object> inside a Container in Windows 8 Metro app? -

i windows phone developer.. started development windows 8 metro style apps. trying figure out basics storing user data. tried storing dictionary of type dictionary inside container. when try exception saying data of type cannot stored! doing wrong? code looks this: this storage manager class: applicationdatacontainer localsettings = applicationdata.current.localsettings; storagefolder storagefolder = applicationdata.current.localfolder; public bool savetostorage(string containername, string key, object datatostore) { try { if (!localsettings.containers.containskey(containername)) { localsettings.createcontainer(containername, applicationdatacreatedisposition.always); } localsettings.containers[containername].values.add(key, datatostore); return true; } catch (exception ex) { return false; } } this how passing dictionary dictionary<string, object> profiledict = new dictionary<string...

c# - Calling the HomePage and having it display a PartialView (ie.ResetPassword) from external link -

imagine forgotpassword sent email link recover password. ideally want recoverpassword partialview , has run inside homepage itself. the external link passes guid. questions: 1) what's right way tell home page display partial view on specific case? 2) url link like? 3) homepage index controller handle possibility of resetpassword external link request? you simple have query string. example www.yoururl.com/index?showresetpassword=true then inside view can add if statement render partial view or not. if need inside of controller suggest have parameter nullable bool. public actionresult index(bool? showresetpassword) make nullable if not inside of url not have isssues.

wordpress - How to implement PayPal Adaptive payments to WooCommerce -

i'm writing extenstion woocommerce plugin , got 1 problem multiple payments. want use paypal , think best way implement paypal adaptive payments. i've read paypal's , woocommerce's documentation can't figure out. i got defined new payment gateway, documentations said: http://docs.woothemes.com/document/payment-gateway-api/ class wc_gateway_adaptive_paypal extends wc_payment_gateway { public $environment = 'sandbox'; public function __construct() { $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'wc_gateway_adaptive_paypal', home_url( '/' ) ) ); $this->id = 'adaptive_paypal'; $this->has_fields = false; $this->method_title = 'paypal'; $this->method_description = 'handle payment many receivers (up 5)'; $this->init_form_fields(); $this->init_settings(); $this->title = $this->get_option( 'title...

onclicklistener - How do android's Event Listeners work? -

how event captured view object? there 1 thread running : ui thread (when haven't implemented of our own threads). suppose if have implemented onclicklistener button , button's function "cancel". event raised button i.e., cancel whatever ui doing, must interrupt. it? work interrupts ? the api guides @ developer site beautiful explanations still don't give complete picture. http://developer.android.com/guide/topics/ui/ui-events.html internally, android running event loop handle ui events. nice diagram, see a third slide of presentation . thread being used dispatch system calls ui elements: the system not create separate thread each instance of component. components run in same process instantiated in ui thread, , system calls each component dispatched thread. (source: processes , threads ) have @ inside android application framework video google i/o 2008. has nice explanation of event loop (consisting of looper , message queue). inte...

java collection sort issue -

i use simple comperator , exception , don't know do this how call: try { collections.sort(this.closepositions, new positioncomperator()); } catch(exception e) { e.printstacktrace(); } this comperator: public class positioncomperator implements comparator<dataresponse> { @override public int compare( dataresponse pos1, dataresponse pos2) { if (pos1.opentime >= pos2.opentime) { return 1; } else { return -1; }// returning 0 merge keys } } this exception: java.lang.illegalargumentexception: comparison method violates general contract! @ java.util.timsort.mergelo(unknown source) @ java.util.timsort.mergeat(unknown source) @ java.util.timsort.mergecollapse(unknown source) @ java.util.timsort.sort(unknown source) @ java.util.timsort.sort(unknown source) @ java.util.arrays.sort(unknown source) @ java.util.collections.sort(unknown source) @ gttask.refreshidentityhistory.call(refreshi...

mobile - Is there any framework to allow P2P communication via phone? -

i want build app allow p2p communication(send message, exchange files), build app phonegap, since want app cross platform. i know webrtc allow real-time communication, browsers doesn't support well. found websocket plugin phonegap, satisfied part of requirement, can use send message, if use websocket send files b, guess traffic go through server, pressure server , don't want server carry traffic. can't make peer peer connection between , b. is there anyway make p2p communication on phone? workaround solution welcome. you can peer peer connections using flash or recent webrtc. these options can use so, websockets connect server. as flash not supported phones (only android < 4.0 has support), can use webrtc. webrtc available on chrome beta now, you'll still have cross platform app not work in platforms/devices. you have go through server (websockets or http) increase number of devices can cover.

python - how to get all the urls of a website using a crawler or a scraper? -

i have many urls website , i've copy these in excel file. i'm looking automatic way that. website structured having main page 300 links , inside of each link there 2 or 3 links interesting me. suggestions ? if want develop solution in python can recommend scrapy framework. as far inserting data excel sheet concerned, there ways directly, see example here: insert row excel spreadsheet using openpyxl in python , can write data csv file , import excel.

Multipart Rest based Java spring web service -

im new java based web service development. need create web service accepts multipart data(ex: zip file). please me out how mention in function. below current web service code accepting data in form of json. @requestmapping(value="/workitems/updatedata", method=requestmethod.post) @responsebody public object updatedata(@requestheader string devicetoken, @requestbody formfields[] formfields,httpservletresponse response) throws exception { //some code } please guide me how accept multipart data in web service method. thanks in advance. @requestmapping( value ="/workitems/updatedata",method=requestmethod.post ,headers="accept=application/xml, application/json") public @responsebody object updatedata(httpservletresponse response,@requestheader string devicetoken, @requestparam ("file") multipartfile file) throws exception { } you can support above.

css - divs button hover mouse not behaving correctly -

i have 3 main main div in main div , each these 3 div have small button @ bottom, because , feel same have same class "readmore_button" 3 of them styling them in css. button first block behave fines hover rest of 2 not (mouse has @ bottom of div button behave). cant figure out why!! many in advance. <div id="highlight_blocks_wrapper"> <div class="highlight_block" id="management_block_01"> <div class="highlight_block_label">management</div> <div class="readmore_button"><a href="/myurl">read more</a></div> </div> <div class="highlight_block" id="valuation_block_01"> <div class="highlight_block_label">valuation</div> <div class="readmore_button"><a href="/myurl2">read more</a></div> </div> <div class=...

c# - How do I serialize a system type so I can store in viewstate? -

i have property list<basevalidator> . need save property in viewstate exists on postback. error indicate list isn't serializable. i've googled ... , googled not got answer works yet. i've created own custom class still error because basevalidator isn't simple type. anyone got ideas? a list serializable if generic type serializable. should make generic object , sub objects in list serializable. add [serializable] tag these objects.

python - doing calculations in pandas dataframe based on trailing row -

is possible calculations in pandas dataframe based on trailing rows in different column? this. frame = pd.dataframe({'a' : [true, false, true, false], 'b' : [25, 22, 55, 35]}) i want output this: a b c true 25 false 22 44 true 55 55 false 35 70 where column c same column b when trailing row in column false , column c column b * 2 when trailing row in column true? you use where series method: in [11]: frame['b'].where(frame['a'], 2 * frame['b']) out[11]: 0 25 1 44 2 55 3 70 name: b, dtype: int64 in [12]: frame['c'] = frame['b'].where(frame['a'], 2 * frame['b']) alternatively use apply (but slower): in [21]: frame.apply(lambda x: 2 * x['b'] if x['a'] else x['b'], axis=1 since using "trailing row" going need use shift : in [31]: frame['a'].shift() out[31]: 0 nan 1 true 2 false 3 ...

ipad - Issue while Creating Latitudes-Lines on Globe using WhirlyGlobeComponet -

Image
i working on whirlyglobe component tester application (great framework globe app in ios mousebird team)and trying create latitudes , longitudes. have created longitudes on globe using method : - (void)addgreatcircles:(locationinfo *)locations len:(int)len stride:(int)stride offset:(int)offset , assigning values in array : locationinfo locations[numlocations] but when try create latitudes on globe giving coordinates in as: locationinfo locations[numlocations] = { {"twenty five",0, 180}, {"twenty six",0, -10} // {"three",30,180.0}, // {"four",30,0}, // {"five",60, 180}, //{"six",60, 0}, } and son on... able half latitude line on globe. not know why issue coming up.is due opengl or what.somebody please me correctly. screenshot when give starting points(0,-180) end point(0,0) comes shown in images- 1,2: image-1 image-2 and need complete latitude line drawn on globe .using start point(0,0) end point(0,360) ...

azure - SignalR SelfHost: Issue on calling Signalr server from JavaScript Client -

i have self hosted signalr server referencing " signalr owin simple example javascript client not being called " , " https://github.com/signalr/signalr/wiki/self-host " links, when try call hub javascript got following error "error: signalr: error loading hubs. ensure hubs reference correct, e.g. ." my self hosted server that: "hub class" using microsoft.aspnet.signalr; using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using microsoft.owin.hosting; using owin; namespace signalrworker { public class chat:hub { public void send() { clients.all.send("hi"); } } } "startup class" using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using microsoft.aspnet.signalr; using owin; names...

actionscript 3 - AS3 flash CC I want to set the width of the parent Movieclip of a Textfield -

i have dynamically created bunch of textfields, number of depends on xml input. textfields need button-enabled, thought easiest solution put them in movieclip , buttonmode movieclip. the hierarchy looks this: main (extends movieclip) -> klankoefening (a movieclip) -> textfieldparent (a movieclip) -> textfield i have variable maxw contains biggest textfield's width , want textfieldparents have width. i'm trying this: //generate textfields keuzes = new xmllist(lijstopties.categorie.(@cat == catname)); var nrs:int = keuzes.keuze.length(); //aantal keuzemogelijkheden var maxw:int = 0; //grootste breedte tf, nodig voor bepalen breedte knoppen (var nr:int = 0; nr < nrs; nr++) { var tf:textfield = createtextfield(werkfmt); tf.text = keuzes.keuze[nr].tostring(); tf.autosize = "center"; tf.background = true; tf.backgroundcolor = 0xffcc33; tf.border = true; tf.bordercolor = 0x000000; tf.name = "keuzetf"; t...

.net - MultipartFormDataStreamProvider vs HttpContext.Current -

i struggling understand why want use multipartformdatastreamprovider when can information using httpcontext.current. it easier this: var mydata = httpcontext.current.request.form["mydata"]; than this: string root = httpcontext.current.server.mappath("~/somedir"); var provider = new multipartformdatastreamprovider(root); this.request.content.readasmultipartasync(provider).continuewith(t => { var mydata = provider.contents.first(c => c.headers.contentdisposition.name == "\"mydata\"").readasstringasync().result; }); ps - trying build apicontroller accept file uploads. i've read article http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2 . this found on msdn . think might you. the stream provider looks @ content-disposition header field , determines output stream based on presence of filename parameter. if filename parameter present in content-disposition header field body p...

php - mysql COUNT(*) always returns 8 -

the title says all. have below code: public function getrows($table) { $result = mysql_query("select count(*) `".$table."`"); if (! $result) { throw new exception(mysql_error().". query was:\n\n".$query."\n\nerror number: ".mysql_errno() . ".table = ".$table); } return $result; } seems should easiest function ever, result returns 8. any ideas? thanks, josh your function returns mysql_query() function result, not results of sql query. you have mysql_fetch_assoc() mysql_* old php functions. ps: should use pdo now, mysql_* deprecated, it's tip ;)

ruby on rails - factory girl passing arguments to model definition on build/create -

models/message.rb class message attr_reader :bundle_id, :order_id, :order_number, :event def initialize(message) hash = message @bundle_id = hash[:payload][:bundle_id] @order_id = hash[:payload][:order_id] @order_number = hash[:payload][:order_number] @event = hash[:concern] end end spec/models/message_spec.rb require 'spec_helper' describe message 'should save payload' payload = {:payload=>{:order_id=>138251, :order_number=>"aw116554416"}, :concern=>"order_create"} message = factorygirl.build(:message, {:payload=>{:order_id=>138251, :order_number=>"aw116554416"}, :concern=>"order_create"}) message.event.should == "order_create" end end error_log failures: 1) message should save payload failure/error: message = factorygirl.build(:message, {:payload=>{:order_id=>138251, :order_number=>"aw116554416"}, :concern=>...

c# - ASP.Net web api post action param always coming null -

i getting null value post action param in asp.net web api. this action. [system.web.mvc.httppost] public httpresponsemessage add([frombody]products id) { var response = new httpresponsemessage(); try { if (id.productslist.length > 0) { response.statuscode = httpstatuscode.ok; response.ensuresuccessstatuscode(); response.content = new stringcontent(string.format("number of products {0}",id.productslist.length) ); logger.info(string.format("number of products {0}", id.productslist.length)); } response.statuscode = httpstatuscode.badrequest; } catch (exception ex) { response.statuscode = httpstatuscode.internalservererror; response.content = new stringcontent("error occured"); ...

how to edit an android animation interpolator? -

i need make scale driven animated dialog.. want bounce effect tried bounce interpolater <scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:fromxscale="0" android:fromyscale="0" android:interpolator="@android:anim/bounce_interpolator" android:toxscale="1" android:toyscale="1" /> i want modify bounce effect make slower/faster , size bounce to. didnt find anything, t tried make sets <set > <scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:fromxscale="0" android:fromyscale="0" android:toxscale="1" android:toyscale="1" /> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="100" android:fr...

php - MySQLi Fetch Array returning Null -

really don't know whats here it's not returning on page.. changing mysql new mysqli <?php include_once "php_includes/db_conx.php"; $query = "select * testimonials order id asc limit 32"; $result = mysqli_query($query) or die (mysqli_error()); while ($row = mysqli_fetch_array($result)){ $testtitle = $row['testtitle']; $testbody = $row['testbody']; $compowner = $row['compowner']; $ownertitle = $row['ownertitle']; $compname = $row['compname']; $compwebsite = $row['compwebsite']; $testslist .= '<div class="gekko_testimonial testimonial gekko_testimonial_speech"> <div class="gekko_main"><div class="gekko_headline">' . $testtitle . '</div> <p>' . $testbody . '</p> </div> <div class="speech_arrow"></div> <span class="gekko...

objective c - Accessing a file in a subproject of xcode -

i have phonegap application has added cocoa touch static library project sub project. need access xml file embedded library project. nsstring *configxmlfilepath=[[nsbundle mainbundle]pathforresource:@"configurationfile" oftype:@"xml"]; nsstring *xmlcontent=[[nsstring alloc]initwithcontentsoffile:configxmlfilepath encoding:nsutf8stringencoding error:nil]; that's how access file in project usually. since sub project, can't access path this.does know how this? you should able drag file in question subproject in project navigator "copy resources" build phase in master xcode project. let me know if you'd me explain in detail.

How to change Rails app time zone setting based on user's input? -

i have user model, allow user provide own time zone. user can choose own time zone using time_zone_select . store pacific time (us & canada) in database. my rails 3 application default setting using pacific time (us & canada) . time display in time zone. may change time time display based on user time zone? example, user see time displayed in time zone central time (us & canada) , , user b see time in london . thanks all. in controllers/application.rb before_filter :set_user_time_zone private def set_user_time_zone time.zone = current_user.time_zone if logged_in? end from railscast

java - MySQL - question marks -

when inserting app chinese characters written db '???'. needless works fine within built in command line mysql client. connection string: --user-db-uri = jdbc:mysql://localhost/tigasedb?user=tigase_user&password=tigase_passwd&useunicode=true&characterencoding=utf8&noaccesstoprocedurebodies=true code: try { conn_valid_st.setquerytimeout(query_timeout); st = conn.preparestatement("set character_set_client = utf8"); st.execute(); st.close(); st = conn.preparestatement("set character_set_connection = utf8"); st.execute(); st.close(); st = conn.preparestatement("set character_set_results = utf8"); st.execute(); st.close(); st = conn.preparestatement("set collation_connection = utf8_general_ci"); st.execute(); st.close(); st = conn.preparestatement...

css - WebKit Issue with negative top margin -

Image
i having trouble getting web-kit cooperate! can see images left column intended in ff yet web-kit browsers (safari , chrome) produces second image. lost how fix issue! firefox version webkit version code area on question <div class="container" style="margin-top: 30px; position: relative;"> <section class="row" ><!--id="content" --> <div class="content_bckgrnd span9"> <div class="item-page"> <p style="text-align: center;"><img src="http://avanti.websitewelcome.com/~ingles/images/demo/store-locations.png" width="531" height="368" alt="store-locations" /></p> </div> </div> <div class="content_bckgrnd span3 "> <div class="mod-padding"> <div class="mod_content "> <div class="custom" > ...

mysql - Count all items on which a user is the high bidder -

i working on auction system, , functionality complete. need add count user's profile shows how many items user bidding on. the system comprises of 2 key tables (extra tables feature in system of course, these tables related issue): item_sales : +-----+------------------+------------+-------------+---------+ | id | selling_format | duration | list_date | buyer | +-----+------------------+------------+-------------+---------+ item_sales_bids : +-----+-------------+-----------+---------------+-----------+--------+ | id | sale_item | user_id | current_bid | max_bid | date | +-----+-------------+-----------+---------------+-----------+--------+ item_sales_bids . date unix timestamp of bid time. i can count of bids given user has made following query: select count(distinct(`item_sales_bids`.`user_id`)) `total`, sum((`sale`.`list_date` + (`sale`.`duration` * 86400)) - unix_timestamp()) `endtime` `item_sales_bids` inner join `item_...

mysql - How to add to string a new string -

i have database products. need add name of products string. example: product name "abc1", "abc2", "abc3" new products name: "super abc1", "super abc2", "super abc3" use mysql's concat() . if want update : update tablename set column=concat('super ', column); you can add where clause .

NOT operator doesn't work in query lucene -

i use lucene version 3.0.3.0, expression search, doesn't work properly. example if search "!fiesta or astra" on field "model", "vauxhallastra" returned , "fordfocus" not returned. code below: var fordfiesta = new document(); fordfiesta.add(new field("id", "1", field.store.yes, field.index.not_analyzed)); fordfiesta.add(new field("make", "ford", field.store.yes, field.index.analyzed)); fordfiesta.add(new field("model", "fiesta", field.store.yes, field.index.analyzed)); var fordfocus = new document(); fordfocus.add(new field("id", "2", field.store.yes, field.index.not_analyzed)); fordfocus.add(new field("make", "ford", field.store.yes, field.index.analyzed)); fordfocus.add(new field("model", "focus", field.store.yes, field.index.analyzed)); var v...

Customizing data annotation attributes for ASP.NET MVC -

i customize @ runtime attributes mvc sees on view model property. far know, mvc relies internally on type descriptors enumerate attributes. there way hook type descriptor somewhere return custom list of attributes property? is there way hook type descriptor somewhere return custom list of attributes property? it depends. if want override data annotations used metadata provider write own custom modelmetadataprovider , replace default 1 ( dataannotationsmodelmetadataprovider ). allows have custom metadata provider given type , return information @ runtime. if on other hand doing validation, bit out of luck. more flexibility recommend using fluentvalidation.net instead of data annotations.

SQL UPDATE row Number -

i have table serviceclusters column identity(1590 values). have table serviceclustersnew columns id, text , comment. in table, have values text , comment, id 1. here example table: [1, dummy1, hello1; 1, dummy2, hello2; 1, dummy3, hello3; etc.] whai want values in column id continuing index of table serviceclusters plus current row number: in our case, 1591, 1592 , 1593. i tried solve problem this: first updated column id maximum value, tryed add row number, doesnt work: -- update id maximum value 1590 update serviceclustersnew set id = (select max(id) serviceclusters); -- command returns correct values 1591, 1592 , 1593 select id+row_number() on (order text_id) rownumber serviceclustersnew -- i'm not able update table command update serviceclustersnew set id = (select id+row_number() on (order text_id) rownumber serviceclustersnew) by sending last command, error "syntax error: ordered analytical functions not allowed in subqueries.". have suggestio...

android - Fragment instanceof in onItemClick -

im using array adapter fragments , on item click action should start fragment fragment f = (fragment) parent.getitematposition(position); if (f instanceof myfragment) { newcontent = new myfragment(); } if clause false , dont know why there problem? try this, object f = class.forname(applicationsession.getinstance().getapppackage() + "." +parent.getitematposition(position)).newinstance(); if (f instanceof myfragment) { newcontent = new myfragment(); }

python - 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server -

i'm having trouble python odbc code. don't following code work: temp=process_query("select fname, lname employee ssn='%s'" %i) known_hours=process_query("select distinct coalesce(hours,0) works_on essn='%s'" %i) temp.append(known_hours) where process_query takes form: def process_query(query): cursor1.execute(str(query)) (process_query continues more merely printing surposes, when i've searched web problem seems problem lies within how call execute function omitted rest of function here). the error receive when i'm trying execute program is: pyodbc.programmingerror: ('42000', "[42000] [mysql][odbc 5.1 driver][mysqld-5.1.66-0+squeeze1-log]you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'john', [decimal('32.5'), decimal('7.5')], 'yes']'' @ line 1 (1064) (sqlexecdirectw)") would grateful if me out! ps. i...

database - Button to copy paste in Excel -

ok write words in cells c3 c9. want button copies , pastes 6 blocks cells h3 h9. i did code this. sub save_click() range("c3:c9").copy range("h3:h9").pastespecial end sub but need program register if cells h3 h9 empty or not , if aren't empty should paste cells i3 i9 , if aren't empty should paste in cells j3 j9 , on , on... i found other forums i'm complete noob in , didn't had do. if knows have thankful. you need rely on simple loop; cells makes things easier range letters on it. here have sample code: sub save_click() range("c3:c9").copy dim currange range dim curcol integer: curcol = 7 dim completed boolean: completed = false curcol = curcol + 1 set currange = range(cells(3, curcol), cells(9, curcol)) if (worksheetfunction.counta(currange) = 0) exit end if loop while (not completed) currange.pastespecial end sub

node.js - Update array in mongodDB collection -

building api node/express. i'm having problem updating array inside collection mongodb. want add reference id useritems array in collection user. user looks this: [ { fbname: "name.name", email: "name.name@hotmail.com", username: "mr.name", useritems: [objectid("51e101df2914931e7f000003"), objectid("51e101df2914931e7f000005"), objectid("51cd42ba9007d30000000001")] }]; in server.js: var express = require('express'), item = require('./routes/items'); var app = express(); app.configure(function () { app.use(express.logger('dev')); app.use(express.bodyparser()); }); app.put('/users/:userid/item/:itemid/add', item.adduseritem); query: exports.adduseritem = function(req, res) { var user = req.params.userid; var item = req.params.itemid; console.log('updating useritem user: ' + user); console.log(...

python - How to trigger a write event? -

i know there 'writable' interface indicate there data written. once asyncore loop enters sleep, when no data write, there no chance wake till timeout. this means data can't sent in real time. i tried change 'writable' method return true , resulted in high cpu usage. isn't there solution trigger write event in real time? btw: i'm using python 2.4.3

.htaccess - url rewriting add prefix www with htaccess -

i created website symfony , want rewrite url. url apprears this: domain.com/web/ i removed web/ adding code .htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.*)$ web/$1 [qsa,l] </ifmodule> this worked perfectly. my target add www. prefix. solved adding code: rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] the result ok. in fact, the url domain.com becomes www.domain.com (perfect!!!) the url domain.com/something/ becomes www.domain.com/something/ (perfect!!!) the url domain.com/web/ stays same (it's url not change) is there idea redirect domain.com/web/ www.domain.com ??? thanks... this behavior caused condition existing files won't rewritten: rewritecond %{request_filename} !-f

java - Unexpected Crash Android Sensors -

whenever try run crashes. not know problem be. missing or in wrong place?in logcat says system services not avaliable activities before oncreate. import android.os.bundle; import android.app.activity; import android.hardware.sensor; import android.hardware.sensorevent; import android.hardware.sensoreventlistener; import android.hardware.sensormanager; import android.os.handler; import android.view.menu; import android.widget.*; import android.*; import java.math.*; import java.text.*; import java.util.*; public class mainactivity extends activity implements sensoreventlistener { private final sensormanager msensormanager; private final sensor mrotationvector; public float x,y,z; public mainactivity(){ msensormanager = (sensormanager)getsystemservice(sensor_service); mrotationvector = msensormanager.getdefaultsensor(sensor.type_rotation_vector); } @override protected void oncreate(bundle savedinstancestate) { super...

php - Merge multidimesional and associative arrays -

i'm trying merge 2 given arrays new one: first array: array ( [0] =>; array ( [label] => please choose [value] => default ) ) second array: array ( [label] => 14.09.2013 - 27.09.2013 - 3.299 € [value] => 14.09.2013 - 27.09.2013 ) i want generate arrays looks this: array ( [0] => array ( [label] => please choose [value] => 14.09.2013 - 27.09.2013 ), [1] => array ( [label] => 14.09.2013 - 27.09.2013 - 3.299 € [value] => 14.09.2013 - 27.09.2013 ) ) i tried merge arrays: array_merge($array1,$array2); which results in: array ( [0] => array ( [label] => please choose [value] => default ) [label] => 14.09.2013 - 27.09.2013 - 3.299 € [value] => 14.09.2013 - 27.09.2013 ) what appropriate function use-case? if pass in ...

php - Merging multiple objects -

i have mysql query goes through framework (wolfcms). $sql_query = 'select distinct country ' . $tablename . ' order country asc'; $countries = record::query($sql_query, array()); //execute query but returned array of objects this array ( [0] => stdclass object ( [country] => canada ) [1] => stdclass object ( [country] => france ) ) i wondering if there way php merge object array simple possible like array ( [0] => canada [1] => france ) i know parse array foreach loop once data , create custom array way needed wondering if there way directly data it's final form database. i want simple array use parameter autocomplete function on text field. * edit * i found better way. had avoid executing query record class. here's how //create sql statement $sql_query = 'select distinct country' . ' ' . record::tablenamefromclassname(__class__) . ' order country asc...

grails - gorm domain class shared property -

i have 4 classes class process { string status } class request { string status = "incomplete" belongsto = [parent: parent] } class response { string status = "incomplete" static belongsto = [parent: parent] } class confirmation { string status = "incomplete" static belongsto = [parent: parent] } then status of request, response or confirmation updated. how can achieve autoupdate process.status status of last updated of other 3 classes ? is there particular grails-way accomplish ? without details on how domains mapped - relationship process request, response , confirmation - i'll assume have access process other domains. with assumption, can use gorm events achieve update process.status on afterupdate event in other domains. for example, in request, response , confirmation, can define like: def afterupdate() { .. //get process how process.status = this.status }