Posts

Showing posts from August, 2013

php - Get last record of each month in MySQL....? -

i have problem in writing query mysql. have following fields in db id created_on status 1 2011-02-15 12:47:09 1 2 2011-02-24 12:47:09 1 3 2011-02-29 12:47:09 1 4 2011-03-11 12:47:09 1 5 2011-03-15 12:47:09 1 6 2011-03-22 12:47:09 1 7 2011-04-10 12:47:09 1 8 2011-04-11 12:47:09 1 i need select last record of each month . month feb record # 3 month march record # 6 , month april record # 8 please me..... thanks in advance..... select * table created_on in (select distinct max(created_on) table group year(created_on), month(created_on))

.net - COM interop interface casting -

following this article , have translated c++ com class/interface declaration c# this: [interfacetype(cominterfacetype.interfaceisiunknown), guid(ifaceguid)] public interface ifoo { void bar(); } [comimport, guid(classguid)] public class foo { } i use this: var foo = new foo(); var ifoo = (ifoo)foo; ifoo.bar(); my question is, how can possibly work, considering foo doesn't implement ifoo (even @ runtime, typeof(foo).getinterfaces() empty) , user-defined conversions interfaces forbidden? is special handling reserved com? c# specification have this? comimport types treated differently compared "normal" .net classes, constitute runtime-callable wrapper around underlying com coclass. casting instance of 1 of these com interface type transparently mapped call object's implementation of com interface method iunknown.queryinterface . if qi requested interface succeeds @ com level, c# cast succeed.

ruby on rails - undefined method `salt=' -

i trying add password thing website. when sign account, page shows after press sign button error page showing: undefined method salt=' #<user:0x37f8168> app/models/user.rb:34:in encrypt_password' app/controllers/users_controller.rb:19:in `create' in user.rb have: def encrypt_password self.salt = make_salt if new_record? self.encrypted_password = encrypt(password) end def encrypt(string) secure_hash("#{salt}--#{string}") end in users_controller.rb have def create @user = user.new(params[:user]) if @user.save sign_in @user flash[:success] = "welcome penntwit" redirect_to @user else @title = "sign up" render 'new' end end the error lines: if @user.save self.salt = make_salt if new_record? i tried changing self.salt @salt gave me error saying salt in secure_hash("#{salt}--#{string}") not found. any ideas? thanks! ...

tfs2010 - What are the Implementation or All Links tab differences in TFS? -

what main differences between implementation tab , link tab in tfs 2010? ask, because have need requirement work items have affects/affected (or maybe predecessor/successor) link type task work items...instead of parent/child link type limited in implementation tab. essentially, want ability given task able have links multiple requirements. as extensible , free-form tfs 2010 is...i still hesitate bit go route without knowing kind of possible negative impact approach have when comes future reporting needs or else. any thoughts? thanks! the implementation tab constrained task work items children of requirement. links tab shows every link associated requirement (including tasks). form section of wit definition defines layout... , links controls. can adjust these tabs (or add new ones) there. as particular change, tread carefully. having tasks "multiple parents" can lead lot of confusion , over-engineering. i've seen many teams try approach abandon in ...

mysql - information_schema tables and update_time behaviour -

i'd have explanation information_schema , behaviours. let's want know when myisam table has been modified. write query select update_time information_schema.tables table_schema = 'my_db' , table_name = 'my_table' even though apply change table nothing happens in until run flush tables . unluckily seems me update_time stores date , time of moment run flush tables, not 1 when table changes occur. true? in advance. i prefer add last_change timestamp each of tables, define "default current_timestamp on update current_timestamp", means mysql automatically update each time row modified. with this, query table directly , know not table touched, rows touched. it doesn't work detect deleted rows though.

operator overloading - Weird characters appear in ostream in C++ -

i have program should emulate simple filesystem, want print structure of directories, have overloaded << operator, , called function goes through structure in rectursion. works, there weird hex values before of lines in output. there wrong way manipulate iwth ostream ? (i did not include class definition, shouldnt matter) thanks all, answers! std::ostream& printtree(std::ostream& os, const cfilesystem::tdir* x, int nmbtabs) { int k; const cfilesystem::tdir * nxt = x; //cout << pocettabu<<endl; while(nxt){ os<<"--"; for(k=0;k<nmbtabs;k++){ os << '\t' ; } os<<"--"; os << nxt->m_name << endl; if(nxt->m_sub){ os << printtree(os,nxt->m_sub,nmbtabs+1); } nxt=nxt->m_next; } return os; } std::ostream& operator <<(std::ostream& os, const cfilesystem& x) ...

wpf - Strange out of order behavior for TreeView and compound data -

the follow code loads hierarchical collection of compoundobjects of strings. unfortunately inserts strings @ top of tree instead of @ bottom(which behavior i've seen. i've tried change order of enumerators, notifiers, etc , produce same results. i've pre-load list looks normal(using same code in thread). any ideas whats going on? compoundobject.cs using system; using system.collections.generic; using system.collections.objectmodel; using system.collections.specialized; using system.linq; using system.text; namespace complextreeviewlazyloadingtest { public class compoundobject : ienumerable<object>, inotifycollectionchanged { public string name { get; set; } public observablecollection<compoundobject> objects { get; private set; } public observablecollection<string> items { get; private set; } void onchanged(object sender, notifycollectionchangedeventargs e) { if (collectionchanged ...

xamarin.ios - No constructor found for ViewController::.ctor(System.IntPtr) -

i'm having issue monotouch application crashes after receiving memory warning. please see stack trace below. received memory warning. level=2 dtmobileis[2299] : _memorynotification : { osmemorynotificationlevel = 2; timestamp = "2011-04-11 14:29:09 +0000"; } toplevel exception: system.missingmethodexception: no constructor found myapp.ui.boardcontroller::.ctor(system.intptr) @ system.activator.createinstance (system.type type, bindingflags bindingattr, system.reflection.binder binder, system.object[] args, system.globalization.cultureinfo culture, system.object[] activationattributes) [0x00000] in :0 @ system.activator.createinstance (system.type type, system.object[] args, system.object[] activationattributes) [0x00000] in :0 @ system.activator.createinstance (system.type type, system.object[] args) [0x00000] in :0 @ monotouch.objcruntime.runtime.constructnsobject (intptr ptr, intptr klass) [0x00000] in :0 @ monotouch.objcrun...

python - Pynotify runs fine interactively, but crashes when run programmatically (on Fedora 13) -

i attempting use pynotify small project, having strange problem on fedora 13 machine. appears when pynotify run programmatically crashes when show() called - however if type line myself runs fine! have tested on ubuntu box, runs absolutely fine. my testing code is: import pynotify pynotify.init('somename') n = pynotify.notification("summary", "body") n.show() and results of running this: $ python -i test.py traceback (most recent call last): file "test.py", line 5, in <module> n.show() glib.gerror: unable connect server >>> n.show() true >>> so, have ideas may cause sort of behaviour? unfortunately fedora environment 1 have little control over, solutions requiring root access/etc not work. can try installing pynotify locally, however, if needed. help. since owen has not accepted offer take answer, here solution worked me. note have no idea why works (other vague guesses), , don't make so...

user - Custom usermeta fields, registration page and login widget wordpress -

here's situation: have old site, old userdatabase (mysql). i'd migrate these users wordpress without losing old data (recipe id's, custom user fields etc.). besides i'd make custom registration page (extra) user data allready had on old site. i tried find plugins (wp-members, registration widget, register plus redux, etc.), didn't fit purpose. i'm starting think need code myself, make wordpress unable update. does have solution problem? thx, rick should easy although may have assign users new password. ok users long know it's coming. take old database , simple sql query extract data, use code following create new user each user in old database: $newuser = array( 'user_pass' => wp_generate_password( 12,0 ), 'user_login' => $email, 'user_nicename' => $name['first'].' '.$name['last'], 'user_email' => $email, ...

php - What do I need to do, if anything, to ensure $mdb2->lastInsertID() returns the auto-increment value for that connection? -

i've made switch sql server mysql, , can't find solid enough answer question anywhere: i'm using php, mysql, , innodb table engine on tables need lock. standard series of 3 statements: insert table a $id = $mdb2->lastinsertid() insert table b (name, fk) values ('foo', $id) what steps need take make sure $id has value of insert step 1? fine way is? need in transaction? need add other queries lock , release tables? thanks guys. you should/could, don't need anything: information-functions , function_last-insert-id the id generated maintained in server on per-connection basis. means value returned function given client first auto_increment value generated recent statement affecting auto_increment column client. value cannot affected other clients, if generate auto_increment values of own. behavior ensures each client can retrieve own id without concern activity of other clients, , without need locks or transactions.

jQuery Div Slider With Thumbnail Nav -

i'm looking slider has thumbnail nav, thumbnail nav needs on slider accommodate large number of items. can point me site may have demo. lof jslidernews sounds fits bill perfectly: http://landofcoder.com/demo/jquery/lofslidernews/

actionscript 3 - Flex - Run Air Application In Background -

i trying provide users option have application launch automatically , complete task @ time every week. i can make application launch @ log in using nativeapplication.nativeapplication.startatlogin=true want detect if time time selected , if isn't run application in background until time match or user shuts down computer. does know of way this? on adobe's webpage comparing flex web apps , desktop apps implied me applications run in background i'm struggling find anything. you can close initial native window without killing process nativeapplication.nativeapplication.autoexit = false; nativewindow(this.stage.nativewindow).close(); or you can close initial native window , create new window acts desktop widget without appearing in taskbar either utility or lightweight window type. http://help.adobe.com/en_us/air/reference/html/flash/display/nativewindowinitoptions.html#type

java - Spring Rest JSON Binding -

i'm trying create restful service spring. a method accepts "usercontext" object via argument i.e. @requestbody. the client sends json object content-type "application/json". error "http/1.1 415 unsupported media type". ..even when client sends null "{}" json object. my controller: @controller @requestmapping(value = "/entityservice") class restfulentityservice { @resource private entityservice entityservice; @responsebody @requestmapping(value = "/getlistofentities", method = requestmethod.post) public list<entity> getlistofentities(@requestbody usercontext usercontext) { system.out.println(usercontext); return null; } } usercontext.java public class usercontext { private long userid; private string username; private useraddress useraddress; private customerinfo customerinfo; } application context: <bean id="xstreammarshaller" class=...

jquery ajax and php session -

i have simple web page has 3 tabs in main content area. once user clicks on particular tab, use jquery , ajax fetch data server , (of course) without reloading change div below 3 tabs. i use $.post data server , there 3 different php files on server call (one each tab) , data from. is possible start php session when user clicks on first tab , save $_session variables , use them when user clicks on second or third tab know user clicked on second or third tab? thanks! newman yes, sessions shared across php scripts. whatever save in first tab readable on 2nd , 3rd tab. keep in mind edit: thing keep in mind here domain should remain same scripts able see session.

c++ - Design of virtual trial room -

as part of masters project proposed build virtual trial room application intended retail clothing stores. meant used directly in store though may extended online stores well. this application show customers how selected apparel on them showing on 3d replica on screen. it involves 3 steps sizing customer building customer replica 3d humanoid model apply simulated cloth on model my question feasibility of project , choice of framework. can achieved in real time using normal desktop computer? if yes appropriate framework ( hardware, software, programming language etc ) purpose? on work have done till now, planning achieve above steps in following ways for step 1 : option a) 2 cameras front , side views or option b) 1 kinect or 2 kinect complete 3d data for step 2: either use makehuman (http://www.makehuman.org/) code build customised 3d model using above data or build scratch, unsure framework. for step 3: need few cloth samples, thought of building si...

flex - Ability to create new File Templates in Flash Builder 4 -

i have class interface have written in flex project using actionscript 3 . write flexunit test cases around each implementation of interface. process of creating new ones, thought nice create flexunit file template around interface. is there way create new flexunit file templates? seems though can modify default templates. if has idea on how or reference link, please let me know. thanks! i recommend try sourcemate 2.0 supports custom file templates or wait flash builder 4.5 supports them too.

Android XML Common Elements between pages? Frames? -

i skinning app , wondering if there way keep common elements same between xml layouts without copying same code around time. for instance, have header , footer , background same between pages. can make "common" xml containing header , footer , load individual page frame inside of it? i'm not sure how reference individual page within xml. maybe change id java side in oncreate function, although seems more work now, if changed on header , footer in future wouldn't have change every activity of app. thanks insight! i think it's inclue tag you're looking for. example: <include layout="@layout/bar_header_top" />

c++ default parameters -

possible duplicate: nonstatic member default argument of nonstatic member function ok. i'm having problems understanding how accomplish seemingly simple task... here want accomplish: #include <iostream> using namespace std; class a{ private: int _x; public: a(int x){ _x = x; } void test(int x=_x){ cout << x << endl; } }; int main(){ a(3); a.test(); } the compiler complains int x=_x part saying error: invalid use of non-static data member a::_x so how use default parameter this? thanks. you can't that. you can have overload test takes no parameters. void test(){ test(_x); }

Suddenly Visual Studio now builds and deploys EVERYTHING -

i've been using visual studio years. when press f5 or ctrl+f5, or press green arrow button, expect build , run startup project , dependencies. however, today builds (and deploys mobile device, if it's mobile device solution) every single project instead. i tried several different sln files, same thing happens each one. also, while debugger works in desktop projects, in mobile projects states "unable start debugging". anybody else had problem? i found 1 workaround, right-click single project , choose debug | start new instance. (however, there no option start without debugging.) you don't version of visual studio using. in visual studio 2010 take @ tools | options | projects , solutions | build , run | "only build startup projects , dependencies on run". item checked?

html - External Style Sheet error in the codeigniter framework php? -

i put code in search.php 1 of view pages , had external style sheet i called inside file using <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> but not working how can solve problem??? if use include('mystyle.css'); it works wanna use first code how can use correctly??? you have wrong path, try: <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/mystyle.css" />

Calibrate two Cameras OpenCV -

i'm using opencv 2.2 , i'm trying calibrate 2 cameras view along same co-ordinate system. 2 cameras placed little separate each other. understand calibrating intrinsics single camera, little confused how i'd able combine 2 cameras together. follow questions too. cheers. edit - working on problem - post , describe works me when done. possible dupe of this ? answer stereocalibrate allow solve essential matrix can use relate point in 1 camera point in other camera.

tsql - SQL Server- How to write variables and query results to Text file? -

how write using t-sql, variable values , query results text file, want keep appending. you can use sql clr write whatever want out file. can either code or can use sql# library (i author , not free -- function -- not expensive either) , use file_writefile function write out text. allows appending data. library free functions not file system functions. can found at: http://www.sqlsharp.com/ if want try coding yourself, found example basic concept think asking for: http://www.mssqltips.com/tip.asp?tip=1662

good azure storage client library? -

is there one? (for .net) i see msft samples storagedotnet , storagerest. these dont if-match right , dont appear paged queries lokad has library funky stuff spread data on columns have seen 1 supported , ships sdk? microsoft.windowsazure.storageclient.dll? supports blob, table, , queues. check windows azure training kit basic manuevers it.

Mocking Scala traits containing abstract val members -

i writing swing application following martin fowler's presentation model pattern. i create traits contain abstract declarations of methods implemented swing components: trait labelmethods { def settext(text: string) //... } trait mainview { val somelabel: labelmethods def setvisible(visible: boolean) // ... } class mainframe extends jframe mainview { val somelabel = new jlabel labelmethods // ... } class mainpresenter(mainview: mainview) { //... mainview.somelabel.settext("hello") mainview.setvisible(true) } how can mock somelabel member of mainview trait using 1 of open-source mocking frameworks ( easymock , mockito , jmockit , etc.) unit testing? there mocking framework, perhaps specific scala can this? hah! figured out on commute home :-). scala allows val in concrete class override def in trait. my traits become: trait labelmethods { def settext(text: string) //... } trait mainview { def somelabel: labelmetho...

android - Beginner help with NDK, java.lang.UnsatisfiedLinkError -

i trying create first android app uses ndk. trying use live555.com sources build app streams mp4 file phone somewhere else. i using windows 7 32 bit jdk 1.6.0_24, motodev 2.1 , latest android sdk , ndk toolkits. so far have setup new project , created jni directory. inside jni have placed source files , android.mk files. if execute ndk-build see: $ $ndk/ndk-build sharedlibrary : libtestprogs.so install : libtestprogs.so => libs/armeabi/libtestprogs.so so seems native library being built. when run app crashes lava.lang.unsatisfiedlinkerror: startstream. startstream() method trying call in libtestprogs.so library. things have checked: libtestprogs.so built , in proper place under libs/armeabi system.loadlibrary("testprogs"); called before attempt native call run javah -o jni.h com.streamtest.mainactivity , include .h .cpp file. here mainactivity.java file: package com.streamtest; import android.app.activity; import android.os.bundle; import an...

search - What is the best plugin to find a class by name using vim? -

i'm trying leave bulky ide behind , i've found 1 of best parts of intellij or visual studio + resharper ability class or symbol quickly. how average power vim user lookup class or method name (grep/regex/other?) , great plugin exist this? thank you you can generate tags using etags -r , use :tag classname or hit ^] on classname. , don't need plugins that, long tags set.

c# - Is there a performance or encapsulation reason to create a private variable to use in place of a public property? -

let's have class public property used property injection, this: public partial class managefoo : pagebase { [inject] public ifoo foo { get; set; } public void somemethod() { this.foo.bar(); } } our ioc container handles injecting instance of ifoo property. can see property foo uses short hand { get; set; } define property. have heard bad practice use public property throughout class , should have accompanying private variable this: public partial class managefoo : pagebase { [inject] public ifoo foo { { return _foo; } set { _foo = value; } } private ifoo _foo; public void somemethod() { _foo.bar(); } } i've heard differing opinions i've yet hear concrete reasons why 1 better another. shorter syntax preferred or private variable preferred, , why? there's no significant difference between using automatically-implemented property , using explicit form. yes, class...

jquery - Check if mouse is hovering on any object -

i have jquery animation example here : http://jsfiddle.net/p7eta/ i all titles pop out if mouse not within container div @ all. have tried like: $("#container").mouseout( function() { //slides spans $('.popup').stop().animate({ bottom: 0 + 'px' }); }); but not work prior animations. correct way achieve effect? edit: i'd similar this: http://jsfiddle.net/re3xk/ on mouseover i'd individual span titles pop in first example instead of having them dissapear finally, jsfiddle cooperated... i'm doing hacky, it's way work. had add .hover class hovered element, code doesn't work without it. don't @ code, , it'll nice! here's working example: http://jsfiddle.net/p7eta/41/ and code: // javascript document //when div.popup moused on moused on $("#slider div.block").hover( function() { //slides spans $(this).addclass('hovered'); $(this).find('spa...

rewriting url in asp.net -

hey guys, using asp.net 2.0 , dotnetnuke 5.6, , using crossarticle module, want user can create multiple alias article. say below. article/stackoverflow stackexchange/article etc.. say first article linked article id 1, , second linked articleid 2 should jump respective pages.. article/1 or article/2 i can web.config file... problem there lacs of alias'es, maintaining in web.config file totally flop idea. want global.asax file.. i tried below code: in string variable saved: request.rawurl.tostring() , comparing url user entered , redirecting him appropriate page... but having below issues: dont want user redirect want rewrite url, i.e, if user enters article/stackoverflow... should redirected article/1 page url should retain. please suggest issue.. to rewrite url (as opposed redirecting) can this: private static void rewriteurl(httpapplication application, tabinfo tabinfo, string additionalquerystring) { application.context.items["urlrewrite:or...

plsql - Check cursor closed in java -

how check if plsql cursor closed java i using following code stmt.registeroutparameter(25,oracletypes.cursor); if use following code if(stmt.getobject(25)!=null) i getting cursor closed error please help. you should able check instance of statement object: if(!stmt.isclosed()&&stmt.getobject(25)!=null) ...

What's the git command to pull in all changes from a remote repo? -

i have repo that's forked remote repository. made changes, remote repository updated , want pull in changes remote repository, , not care in local repository. i've been deleting local repository, doing simple fork , clone. there's got better way this. what's magic command? if understand correctly, want throw away commits on local branch (if you've made any). if that's case, want: # fetch updated branch(es) origin git fetch origin # reset, including work tree, origin's master branch # make sure have master branch checked out first! # , don't mind throwing away local commits or # uncommitted modifications git reset --hard origin/master

grails - How to build from my checkout directory ... with a twist -

we're using maven 3 git our scm system. using latest version of scm plugin (1.5). our project in grails 1.2.1 (java 1.5). question is, how run single command generate war file after doing checkout our repo? this question seems complicated fact we're using grails project (and hence maven-grails plugin, version 1.3.4). grateful info have, - dave i'm assuming command line below below wont work because of requirement use maven. grails <environment> war you can generate pom.xml existing grails project following command. can useful starting point. mvn grails:create-pom more documentation grails's maven integration can found here: http://grails.org/doc/latest/guide/4.%20the%20command%20line.html#4.5%20ant%20and%20maven

jquery - Check if one of two elements are clicked -

i checking if 1 button clicked this $j('#button1').click( function () { and performing function want perform same function when either button1 or button2 clicked. what jquery syntax that? you can this: $j('#button1, #button2').click( function () {

iphone - UIInterfaceOrientation within UINavigationController -

i control device reorientation effect on 2 different uiviewcontrollers pushed onto uinavigationcontroller. on first view, setting app rotate portait only, seems doing on views. this code: - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return uiinterfaceorientationisportrait(interfaceorientation); } and, on view using following code: - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // overriden allow orientation. return yes; } on second view rotate orientations, on first want rotation restricted portrait only. thanks!

iphone - Dynamically set UIScrollView height and UITableView Height depending on content -

i'm bit of iphone noob here, please bare me. setup : have scrollview label, uiimage, , tableview (grouped) nested within. label, uiimage, , tableveiw populated webservice. last section in grouped table view contains text never same , long 5 characters 250+. also, view pushed basic tableview (so has navigation bar. if matters @ all). expected : tableview should extend in height depending on length of content received web service. set scrollview height accommodate height of tableview problem : i'm not quite sure how approach issue. know how change height fixed values, not work in many scenarios. any appreciated. thank you. the width , height of cell ignored; cell cell re-sized according value return -tableview:heightforrowatindexpath: or (failing that) tableview.rowheight . might appear if cell big enough if label in cell sized big enough, because label allowed bigger (and render outside) cell. one way override -tableview:heightforrowatindexpath: return ...

scala - Splitting scalac plugin into multiple files -

i'd split scalac plugin multiple files. sounds easy haven't managed pull off due path-dependent type issues stemming import global._ line. here's lex spoon's sample plugin: package localhost import scala.tools.nsc import nsc.global import nsc.phase import nsc.plugins.plugin import nsc.plugins.plugincomponent class divbyzero(val global: global) extends plugin { import global._ val name = "divbyzero" val description = "checks division zero" val components = list[plugincomponent](component) private object component extends plugincomponent { val global: divbyzero.this.global.type = divbyzero.this.global val runsafter = "refchecks" // using scala compiler 2.8.x runsafter should written below // val runsafter = list[string]("refchecks"); val phasename = divbyzero.this.name def newphase(_prev: phase) = new divbyzerophase(_prev) class divbyzerophase(prev: phase) extends stdphase(pre...

php - I need to reorder my results some how -

so wrote little script. problem want newest message @ bottom not @ top how need take results mysql query , reorder them before echoing them out.. help... edit: desc correct order while loop problem.. since php runs line line p.s. please not worry security features add in later. <?php mysql_connect('localhost', '', ''); mysql_select_db(''); if(isset($_post['submit'])) { date_default_timezone_set('america/new_york'); $_post['username'] = 'guest'; //$_post['message'] = "hello name guest!"; mysql_query("insert chat (username,message,date,time) values ('".$_post['username']."','".$_post['message']."','".date('n.j.o g:i:s a')."','".time()."')"); } $result = mysql_query("select * chat order time desc limit 10"); while ($row = mysql_fetch_assoc($result)) { $u...

Javascript this object inside intervals/timeouts -

i have method big setinterval statement, , needs access this object of object owns method inside interval. implemented simple closure, doesn't seem elegant: connect: function(to, rate, callback){ var cthis = this, //set cthis this, connectintervalid = setinterval(function(){ if(cthis.attemptconnect(to)){ //reference here, clearinterval(connectintervalid) cthis.startlistening(10) //here, callback && callback.apply(cthis, []) //and here } }, rate) } you apply or call , if wanted use this instead of cthis connect: function(to, rate, callback){ var cthis = this, tempfunc = function(){ if(this.attemptconnect(to)){ clearinterval(connectintervalid) this.startlistening(10) callback && callback.apply(this, []) } }� connectintervalid = seti...

java - How to force Apache Tomcat not to reuse a thread from the thread pool? -

we've got normal-ish server stack including blazeds, tomcat , hibernate. we'd arrange things such if errors (especially assertionerror) thrown, current thread considered in unknown state , won't used further http requests. (partly because we're storing things, such hibernate transaction session, in thread-local storage. now, can catch throwables , make sure roll transactions , rethrow, there's no guarantee other code may have left knows in thread-local storage.) tomcat default thread pool behavior reuses threads. tried specifying our own executor, seems specific method of changing thread pool behavior, doesn't call executor.execute() new task each request. (most reuses same execution context requests in same http connection.) one option disable keepalive, there's 1 request per http connection, that's ugly. anyway, i'd know. there way tell tomcat not reuse thread, or kill or exit thread tomcat forced create new one? (from tomcat source, ...

objective c - Can cocoa framework hide an ivar declaration in their public header file? -

is possible ? my colleague told me naming ivar prefix underscore apple may cause problem. said apple can declare ivar in class , doesn't let in public header file. if accidentally name ivar collide "secret ivar" not in header file , cause problem. i don't know how frameworks works i'm not sure explanation. know apple reserve use of prefix underscore method name in there code guideline , many people use prefix underscore when name ivar , said it's safe because if name collide compiler generate error. know true if name of ivar in header file. kind of "secret ivar" not in public header file? my colleague's evidence if dump apple's application framework's header file , compare apple's public header file, find don't match many declaration of both methods , ivars. i'm confused question , hope can provide professional answer , if can provide reliable reference question , great help. (i don't know whether have expl...

jquery - How to open search/find dialog in jqGrid from an external button? -

i have jqgrid has "find" button - brings jqgrid's filter dialog can filter stuff - cool. how can trigger dialog open button not part of jqgrid control? i've found can this: $("#id").trigger('reloadgrid'); tell grid go data again , rebuild jqgrid ui. there similar, $("#id").trigger('openfinddialog'); ? jqgrid has searchgrid method need use. open searching dialog should call method , use parameters or events knows previous usage of navgrid : $("#id").jqgrid ('searchgrid', {multiplesearch:true, overlay: false}); how can see here code running on click on "search" button of navigator not more this.

search - Linked List, searching through -

my teacher gave practice assignment deals linked lists got code search , searchhelper, having trouble initializing search. how might go that? have tried prompting user variable , throwing through search method error "the method search(t) in type list_3 not applicable arguments (integer)" the program has to: create linked list, prompt user value search for, use method search recursively searches linked-list object specified value. method should return reference value if it’s found; otherwise, should return null. import java.util.scanner; class listnode< t > { t data; listnode< t > nextnode; listnode( t object ) { this( object, null ); } listnode( t object, listnode< t > node ) { data = object; nextnode = node; } t getdata() { return data; } listnode< t > getnext() { return nextnode; } } public class list_3< t > { private listnode<...

html - Javascript string/integer comparisons -

i store parameters client-side in html , need compare them integers. unfortunately have come across serious bug cannot explain. bug seems js reads parameters strings rather integers, causing integer comparisons fail. i have generated small example of error, can't explain. following returns 'true' when run: javascript:alert("2">"10") parse string integer using parseint : javascript:alert(parseint("2", 10)>parseint("10", 10))

c# - Correct way to handle locking of classes shared across threads -

i have cleaned , shortened snippet of code multiuser game show accomplish. here is: public class subject { public list<iobject> objects = new list<iobject>(); } public interface iopenable { void open(subject by, params string[] p); void close(subject by, params string[] p); bool isopen { get; } } public interface iobject { void pickup(subject by, params string[] p); void drop(subject by, params string[] p); } public class box : iobject, iopenable { bool opened = false; subject owner = null; public void pickup(subject subject, params string[] p) { subject.objects.add(this); this.owner = subject; } public void drop(subject subject, params string[] p) { subject.objects.remove(this); this.owner = null; } public void open(subject by, params string[] p) { ...

asp.net - connect to different sql servers -

i want connect many sql server data bases of them located in same server , others located in different servers. these servers may locate in same building or other buildings around city or country. best way connecting them , create queries?? own idea linked servers. idea caching? connecting them directly , creating query idea? speed if connect them directly?

activerecord - How to turn a self-table subquery SQL to a Rails named_scope? -

i'm using rails 2.3.10 , new named_scope . i'm dealing sql retrieves list of last invitations of particular event. came sql subquery , looks can want. i'm thinking of possible use named_scope same thing can make use of find() . i have following questions: is possible implement sql named_scope ? can in elegant way sub-select not included in :condition ?more 1 named_scope needed? how named_scope (s) like? how find() when includes name_scope(s)? sql: select * invitation inv1 join ( select event_id, user_id, max(invite_time) last_invite_time invitation group event_id, user_id ) last_invite on inv1.event_id = last_invite.event_id , inv1.user_id = last_invite.user_id , inv1.invite_time = last_invite.last_invite_time invitation data: event_id user_id invite_time invite_reply_code 1 78 2011-02-01 15:21 1 2 78 2011-02-02 11:45 1 2 79...

centering - Is it possible to center a div with an unspecified width that contains two floating div also with unspecified widths -

i trying 2 elements sit side side inside div or other element, both 2 elements centered in page. here's catch... cannot use fixed widths, dynamically generated javascript. seem reading other posts not possible without fixed widths, wanted see if 1 had other ideas achieve same result. html: <body> <div class="centerdiv"> <div class = float1></div> <div class = float2></div> </div> </body> css: body {text-align: center; width: 100%;} .centerdiv {margin: 0 auto;width: 100%} div.float1 {float:left; display:inline;} div.float2 {float:left; display:inline;} you can use follwing code center div side side. <html> <head> <style type="text/css"> body {text-align: center; width: 100%;} .centerdiv {margin: 0 auto;width: 100%;margin-left:40%;} .float1{border:1px solid black;width:10%;float:left;} </style> </head> <body...

sql server - working of charindex,cross apply and substring in single query of sql -

i have query follows display @prodid= ''1,2,10,4,5,6,7,8,13,16,17,3'' string 'dbo.proudction @prodid= ''1,2,10,4,5,6,7,8,13,16,17,3'' ,@stock= 0' : declare @t table(col1 varchar(100)) insert @t values ('dbo.proudction @prodid= ''1,2,10,4,5,6,7,8,13,16,17,3'' ,@stock= 0') select substring(col1, start, stop-start) @t cross apply (select charindex('''', col1)+1) c1(start) cross apply (select charindex('''', col1, start)) c2(stop) can me understand working of query, please ? the first cross apply use charindex locate first quote in string. second cross apply locates second quote in string. substring extract text between first quote , second quote. result 1,2,10,4,5,6,7,8,13,16,17,3

iphone - How to solve the error of "[_NSCFTimer login:]:unrecognised selector sent to instance -

i have created application.when run application following error: -[__nscftimer login:]: unrecognized selector sent instance 0x4b37380 2011-04-12 10:57:36.441 journey[6190:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscftimer login:]: unrecognized selector sent instance 0x4b37380'. i totally confused how solve above mentioned error,please me in solving problem. thanks are calling login method on instance of nstimer ? if yes, can't, call methods on instance of nstimer declared in nstimer class see apple documentation nstimer . http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/classes/nstimer_class/reference/nstimer.html

php - Handle time from different timezone and store into mysql -

i making website facebook, bad thing is.. there many timezone , hard convert utc. server using utc default setting, may know how manage in more generic way, convert difference time zone utc time, , display preset timezone setting ? additionally, may know how store mysql database php ? 2011-04-10t08:13:30+0000 use gmdate() function, formats time in utc.

mysql - Retrieve records based on Date -

i have date column in table. there way in mysql retrieve record based on date excluding time part? i have tried appending * not seems work. select * mytable filterdate="2010-08-01 *" is there way rather filtering using between ? thanks. select * mytable filterdate "%2010-08-01 %"

entity framework - Autofac registration with multiple assembies and differing EntityConnections -

we have 2 assemblies contain own entity-framework edmx & repositoriy objects. these registered using autofac in asp.net webapplication. these assemblies similar of architecture (but differing edmx) have found last entityconnection being registered entityconnection being used in both assemblies. need limit usage of entityconnection used types of assembly or namespace. var assembly = typeof(activity).assembly; builder.registerassemblytypes(assembly).asimplementedinterfaces(); builder.register(reg => new entityconnection(connectionstring)); var assembly = typeof(user).assembly; builder.registerassemblytypes(assembly).asimplementedinterfaces(); builder.register(reg => new entityconnection(connectionstring)); is there way register entityconnection , limit depth of entityconnection? limit each entityconnection assembly belong to? here's pseudocode example of how want register entityconnection use in assembly or namespace. builder.register(reg => new entityconn...

php - What other get method characters can be used? aside from question mark? -

the normal get: http://localhost/get.php?id=2&get=row can done this? http://localhost/get.php&id=2&get=row or in other way. when user make parameter site like http://test.com/ ?url=http://localhost/sample/ or if contains "?id=234" so new url http://test.com/?url=http://localhost/smaple?id=1234 it creates 2 question mark. when user make parameter site, has urlencode such data, so, it's going be http://test.com/?url=http%3a%2f%2flocalhost%2fsmaple%3fid%3d1234

SQL Viewstate in Delphi ASP.Net - How to override PageStatePersister -

i following example of storing view state in database. however, have come end of page , asking me override property .. have no idea how achieve in delphi. can point me in right direction? i using masterpage setup , .net 2.0 view state in db edit: more information, have tried: tdefault = class(system.web.ui.page) //code excluded public function getpagestatepersister: pagestatepersister; property pagestatepersister: pagestatepersister read getpagestatepersister; end; but code inside getpagestatepersister isn't called. thanks. ok, managed sort out. using .net reflecter dug through system.web.ui.page assembly , found function called get_pagestatepersiter have done: function get_pagestatepersister: pagestatepersister; override;

cuda - Allocating more memory to an existing Global memory array -

is possible add memory allocated array in global memory? what need this: //cudamalloc memory d_a int n=0;int n=100; { kernel<<< , >>> (d_a,n++); //add n memory d_a while(n!=5)} does doing cudamalloc removes values of allocated array? in case values of previous allocated array should kept... first, cudamalloc behaves malloc, not realloc. means cudamalloc allocate totally new device memory @ new location. there no realloc function in cuda api. secondly, workaround, can use cudamalloc again allocate more more memory. remember free device pointer cudafree before assign new address d_a . following code functionally want. int n=0;int n=100; //set initial memory size size = <something>; { //allocate enough memory cudamalloc((void**) &d_a, size); kernel<<< ... >>> (d_a,n++); //free memory allocated d_a cudafree(d_a); //increase memory size size+=n; while(n!=5)} thirdly, cudamalloc c...

mysql Using INNER JOIN to select multiple tables? -

i want select fields of several table , fetch result separate mysql return rows together: select prod_product.* ,pub_comment.* prod_product inner join pub_comment on (prod_product.id = pub_comment.itemid) prod_product.id=7744 is there way fetch each table rows separately? i try @prod:=prod_product.* , @comment:=pub_comment.* mysql didn't allow me store more 1 row. select @prod:= concat_ws(',',prod_product.field1,prod_product.field2,...) ,@comment:= concat_ws(' ',pub_comment.field1,pub_comment.field2,....) prod_product inner join pub_comment on (prod_product.id = pub_comment.itemid) prod_product.id = 7744 note concat_ws separate fields , concat smash together.

jQuery, get ID of a textarea -

i've got form text field defined follow: <textarea style="height: 60px; width: 100%;" name="f3414" id="f3414" rows="6" cols="80" wrap="virtual" class="frmtxa fckeditor"></textarea> i need, using jquery, textarea id (in case, f3414 ). i've tried: $('textarea .fckeditor').attr('id'); $('.fckeditor').attr('id'); / ... no luck. any idea? thanks lot alert($('textarea.fckeditor').attr('id')); you have space between textarea .fckeditor in original question, removing make difference working example : here

Iphone dev : how can I get a result from google currency converter? -

sorry english ^^ know how can have result google converter tool currency, available on http://www.google.com/finance/converter?a=1&from=usd&to=gbp example. i have tried : -(ibaction)getresponse:(id) sender{ nsstring *myurlstring = @"http://www.google.com/finance/converter?a=1&from=usd&to=gbp"; nsurl *myurl = [nsurl urlwithstring: myurlstring]; nsdata *data = [nsdata alloc]; data=[nsdata datawithcontentsofurl:myurl]; if(data!=nil && data != ""){ nsstring *response = [[[nsstring alloc] initwithdata:data]] [label settext: response]; } else [label settext:@"not working"]; } but when click on button, label not have text (it empty). doing wrong ? possible want ? thank futures answers ! olivier. yeah.. possible... see data getting html file or can treated xml. parse xml file , result. there ia lot of things in file have extract <div id=currency_c...

tsql - what is the procedure in SQL server to not execute anything(T SQL commands) but outputs the commands it would execute -

what procedure in sql server not execute anything(t sql commands) outputs commands execute there isn't 1 unless using dynamic sql you'd use print you can see stored proc definition won't show actual parameter values etc

unicode - Calculating the length of a Japanese multibyte string with half-width kana in PHP -

so have utf-8 encoded string can contain full-width kanji, full-width kana, half-width kana, romaji, numbers or kawaii japanese symbols ★ or ♥. if want length use mb_strlen() , counts each of these 1 in length. fine purposes. but, i've been asked (by japanese client) count half-width kana 0.5 (for purpose of maxlength of text field) because apparently thats how japanese websites it. using mb_strwidth() counts full-width 2, , half-width 1, divide 2. however method counts romaji characters 1 chocアイス count 7 .. i'd divide 2 account kanji , i'd 3.5. want 5.5 (4 romaji + 1.5 3 half-width kana). // edit: more info: character (even non-kana) has both full , half should 1 full-width , 0.5 half-width. example, characters ¥、3@( should 1, characters ¥,3@( should 0.5 // edit: symbols ☆ , ♥ should 1, mb_strwidth/2 method return them 0.5 is there standard way japanese systems count string length? or loop thru strings , count characters don't match standard width...

Memset In C Using Sizeof Operator : -

here struct : typedef struct tag_device_sys { char device[string_size]; int id; char category; } device_sys; for memset, 1 should used below ? memset(dev_sys, 0, (size_t)num_devices * sizeof(device_sys)); or memset(dev_sys, 0, (size_t)num_devices * sizeof(dev_sys)); what differences ? i use objects arguments sizeof struct whatever *ptr; /* ... */ ptr = malloc(nelems * sizeof *ptr); memset(ptr, 0, nelems * sizeof *ptr); the advantage on using parenthesized type code needs changed @ 1 place should type of data change struct before_change *ptr; /* ... */ ptr = malloc(nelems * sizeof (struct before_change)); memset(ptr, 0, nelems * sizeof (struct before_change));

Attaching databases results in error "The server principal is not able to access the database" -

i have 2 databases want attach them sql server express. when try user account, recieve login failed error. this code sets owner of databases current user use [databasename] create user[domainname\\username] login [domainname\\username] exec sp_addrolemember 'db_owner','domainname\\username' this works first database second 1 receive error: the server principal not able access database how can done programmatically? you should change database owner exec sp_changedbowner 'yourlogin',null and alter database [your_db] set trustworthy on

sql - Will TOP always return the same rows -

i have written code move data archive table, 1000 rows @ time (sql server 2008 r2): -- archive data while (@quitloop = 0) begin begin transaction insert mytransactiontable (...) select top 1000 * mytransactiontable dateofsale < @archivecutoffdate delete top 1000 mytransactiontable dateofsale < @archivecutoffdate if (@@rowcount = 0) select @quitloop = 1 commit transaction end will top returns same 1000 rows? so rows being inserted archive table same rows being deleted form transaction table. as using them no, not guaranteed return same rows. why? because don't specify order by clause. it'll whatever 1000 records engine decides 'top' ones time around. also note it's possible if specify order by still wouldn't same 1000 rows... if order not selective enough on border of 1000th item specific, definable order. for example; if there 1002 items same sorted value @ top, don't know 2 not included. ...

Can I define a Clojure protocol with methods starting with ":"? -

i provide methods clojure protocol starting : character. there way override in clojure? don't think so. clojure keywords implemented in reader , don't think there's way of overriding behavior. when use keyword function, equivalent (get arg :keyword). can extend implementing ilookup in protocol. joost.

email - how to send mail from .net? -

i want send email .net application. please tell me steps sending email. start exploring system.net.mail.smtpclient type in .net. type offers overload method send. look here public static void createtestmessage1(string server, int port) { string = "jane@contoso.com"; string = "ben@contoso.com"; string subject = "using new smtp client."; string body = @"using new feature, can send e-mail message application easily."; mailmessage message = new mailmessage(from, to, subject, body); smtpclient client = new smtpclient(server, port); // credentials necessary if server requires client // authenticate before send e-mail on client's behalf. client.credentials = credentialcache.defaultnetworkcredentials; try { client.send(message); } catch (exception ex) { console.writeline("exception...