Posts

Showing posts from August, 2013

c# - How to get the max timestamp and groupby another field in LINQ to Entities -

i have entity following fields guid taskid, guid subtaskid, datetime timestamp the taskid may one-to-many subtaskid. it's composite key almost. i write expression or expressions resulting in newest among each taskid i.e. taskid subtaskid timestamp 1 2010-11-22 15:48:49.727 1 b 2010-11-22 16:24:51.117 2 c 2010-11-15 11:49:05.717 2 d 2010-11-15 14:02:11.467 would result in sequence containing only: taskid subtaskid timestamp 1 b 2010-11-22 16:24:51.117 2 d 2010-11-15 14:02:11.467 this expression works fine showing taskid's , timestamps var q1 = req in myentity orderby req.taskid select new { req.taskid, req.subtaskid, req.timestamp }; but show latest timestamp each taskid. attempts @ adding max expression fail. posting (http://stackoverflow.com/questions/2034800/how-do-you-find-the-group-wise-max-in-linq) seemed close, couldn't translate working. perhaps foreach needed.

android - Can a service get a reference to the activity during onBind? -

i have service manages mediaplayer instance playing podcasts. once activity binds service can things play, pause, stop, etc. used service because want podcast continue playing after activity destroyed. i'd service able send messages activity in case of error or normal status updates. possible service reference activity that's trying bind it? doesn't intent makes available. the sdk samples api demos app has example of service messages activity

jquery - SlickGrid enableAddRow -

i want use enable addrow option want new row displayed @ top of grird...any suggestions; beloiw doco in slickgrid.js. enableaddrow - (default false) if true, blank row displayed @ bottom - typing values in row add new one. thank you! function addrowtothetop(){ grid.getdata().splice(0, 0, {}); grid.invalidateallrows(); grid.updaterowcount(); grid.render(); } call function add empty row @ top of grid. not effective works.

sockets - TOR Control Protocol from Perl -

i trying make signal newnym call via tor control protocol bound internal port. testing trying without auth field @ moment. in telnet, if call authenticate authenticated , can proceed signal calls. in perl using both io::socket , , socket send methods end error: 551 invalid quoted string. need put password in double quotes. a sample call using in io::socket approximately this: print "sig-tor:connecting..."; $torsock = new io::socket::inet( peeraddr => $torcont, peerport => $torconp, proto => 'tcp' ); $torsock or die "no socket :$!"; print "ok!\n"; print "sig-tor:authenticating..."; print $torsock $torauth; while (<$torsock>) { print $_; } print "ok!\n"; sleep(1); from 551 invalid quoted string. need put password in double quotes. i infer need for print $torsock '"', $torauth, '"'; but need certain in $torauth.

matlab - How can the output of a Simulink block be fed back as an input? -

Image
i have 2 embedded matlab functions using create simulink model. both functions use output of second function input. getting error @ moment indicating invalid loop. does know how implement type of behaviour? you've created algebraic loop, means compute inputs of embedded matlab block directly dependent on outputs of block. not allowed when loop "self-loop", i.e. there 1 block in loop. one way fix put unit delay block(s) somewhere on signal feeding embedded matlab block. see documentation on algebraic loops more information.

Using "seen" on a trail in KRL -

Image
i want have trail helps keep track of values want persist users. if user has not entered name, want display form them enter name use lookups. i want able check if name on trail. if name on trail display data user. if name not on trail want display form them enter name. i looking on how accomplish this. suggested encode struct json , pushing on trail , search it. direction on how done helpful. use following? if seen ent:user_data <regexp> { <get , show data> } else { <show form user> } if want save simple string later can following using entity variable in pre block retrieve saved name entity variable: savedname = ent:username || ""; in postlude save or clear entity variable: set ent:username username; clear ent:username; example app => https://gist.github.com/722849 example bookmarklet => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-persistant-trail-bookmarklet.html example run on http://exam

AspNetCompatibilityRequirement error when hosting a WCF service with AppFabric Endpoint in SharePoint 2010 -

i trying host wcf service within sharepoint 2010 appfabric endpoint. using basichttprelaybinding. when host service standard endpoint using basichttpbinding (not service bus endpoint), service works fine. however, add endpoint using basichttprelaybinding, receive following error in event log , service not register service bus. webhost failed process request. sender information: system.servicemodel.activation.hostedhttprequestasyncresult/58154627 exception: system.servicemodel.serviceactivationexception: service '/_vti_bin/firstservicefarmsolution/listaccessservice.svc' cannot activated due exception during compilation. exception message is: channeldispatcher @ 'sb://cliffwahl-trial.servicebus.windows.net/listaccessservice' contract(s) '"ilistaccessservice"' unable open ichannellistener.. ---> system.invalidoperationexception: channeldispatcher @ 'sb://cliffwahl-trial.servicebus.windows.net/listaccessservice' contract(s) '&quo

Understanding Python Classes or Customising the Django UserAdmin model -

i'm attempting override of behaviour of django useradmin model. particularly, i'd hide 'superuser' field non-superusers. so, approach this: class modeladmin(basemodeladmin): "encapsulates admin options , functionality given model." # ... def has_change_permission(self, request, obj=none): """ returns true if given request has permission change given django model instance. if `obj` none, should return true if given request has permission change *any* object of given type. """ opts = self.opts return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()) #... based on i've found in modeladmin class useradmin(useradmin): """ ... customised useradmin """ # adding new method def is_superuser(self, request): "returns true if given user superuser.&

matlab - What's wrong with my Hopfield Neural Network solution to the Traveling Salesman Problem? -

first off, homework. think it's clear i've made effort , i'm looking hints, not code. the problem following. equation of operation has 4 components altering given neuron. a) 1 part ensure each city visited @ once. b) 1 ensure each position (first, second, third, etc) has @ 1 city. c) 1 part ensure total number of active neurons equal number of cities. d) 1 part minimize distance. if weight d heavily enough has effect, network settles on invalid tour (for example, visit a, d, nowhere, e, c). can, however, deweight d , code find solutions, not minimal distance. i'd extremely grateful advice, i've been banging head against keyboard while. code should understandable familiar solving tsp hopfield network. das code: %parameters n=5; theta = .5; u0 = 0.02; h = .1; limit = 2000; %init u u=zeros(n,n); uinit = -u0/2*log(n-1); %p94 uinit = - u0/2 * ln(n-1) i=1:n j=1:n u(i,j) = uinit * (1+rand()*0.2-0.1); %add noise [-0.1*uinit 0.1*uinit]

has and belongs to many - Saving hasOne with HABTM in CakePHP -

this problem occurred when added hasone relationship 1 of habtm models. categories_posts not save in database. did before. right now, form have this: <?php echo $this->form->create('post'); echo $this->form->input('post.title'); echo $this->form->input('post.category', array('multiple' => 'checkbox')); echo $this->form->input('post.body', array('rows' => '3')); echo $this->form->input('page.title'); echo $this->form->input('page.uri'); echo $this->form->input('page.meta_keywords'); echo $this->form->input('page.meta_description'); echo $this->form->input('page.layout'); echo $this->form->end('save post'); ?> page model looks this: class page extends appmodel { var $name = 'page'; var $order = array('page.modified' => 'desc'); var $hasone = array( 'post&#

java - collections for sorting employee details by id & firstname -

i have written code sort name id , firstname. import java.io.*; import java.util.*; public class testemployeesort { /** * @param args */ public static void main(string[] args) throws ioexception { // todo auto-generated method stub string option=null; system.out.println("enter on order sorting should done \n1.id \n2.firstname \n3.lastname"); list<employee> coll = name_insert.getemployees(); bufferedreader br=new bufferedreader(new inputstreamreader(system.in)); option=br.readline(); int a=integer.parseint(option); switch(a) { case 1: collections.sort(coll); printlist(coll); break; case 2: collections.sort(coll,new empsortbyfirstname());// sort method printlist(coll); break; case 3: collections.sort(coll,new sortbylastname());// so

remove : prolog -

i trying compile csp.pl "computational intelligence book" solves constraint satisfaction problem. want use base solve crossword puzzle generator. but when try run code gives existence error in user:remove/3 ! procedure user:remove/3 not exist ! goal: user:remove([1,2,3,4],3,_127) | ?- :- i think remove not built-in predicate % select(e,l,l1) selects first element of % l matches e, l1 being remaining % elements. select(d,doms,odoms) :- remove(d,doms,odoms), !. % choose(e,l,l1) chooses element of % l matches e, l1 being remaining % elements. choose(d,doms,odoms) :- remove(d,doms,odoms). this part of code... can please me fix issue... code should execute since in textbook claimed hv run on programs.. please help i don't think remove part of prolog library -- not swi prolog. list library here . there predicate delete same thing code uses remove for. find-and-replace , should work.

javascript - MVC - pass ViewData as boolean -

sorry newbie question. when passing boolean value controller view using viewdata, how retrieve boolean value in javascript? example: controller: viewdata["login"] = true; view <script type="text/javascript"> var login = <%= (bool)viewdata["login"] %>; /// doesn't work, throw javascript error; </script> yeh surely can do <script type="text/javascript"> var login = '<%= viewdata["login"] %>'; /// login string 'true' </script> but rather keep login object boolean rather string if that's possible thanks! just remove single quotes. <script type="text/javascript"> var login = <%= (bool)viewdata["login"] ? "true" : "false" %>; </script> this result in: var login = true; which parsed boolean in browser.

c# - writing to a text file and reading that text file -

i have used code var dest1 = file.appendtext(path.combine(_logfolderpath, "log1.txt")); dest1.writeline(line.trim()); to write text file log1.txt after have read text file... i have declared in variable... know not possible..but dont know how using (var file = file.opentext(dest1)) how open text file , read file using while ((line2 = file.readline()) != null) any suggestion?? edit: sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring); sqldataadapter da = new sqldataadapter("select codesnippet edk_custombrsnippet_vw", con); datatable dt = new datatable(); da.fill(dt); string line = dt.rows[0].itemarray[0].tostring().replace("\n", environment.newline).replace("\r", environment.newline); ; //messagebox.show(line); string filepath2 = textbox1.text; int count

multiprocessing - Python 2.7 SimlpeQueue Import Error (a bug?) -

$ python2.6 -c 'from multiprocessing.queues import simplequeue' $ python2.7 -c 'from multiprocessing.queues import simplequeue' traceback (most recent call last): file "<string>", line 1, in <module> file "/usr/lib/python2.7/multiprocessing/queues.py", line 22, in <module> multiprocessing.synchronize import lock, boundedsemaphore, semaphore, condition file "/usr/lib/python2.7/multiprocessing/synchronize.py", line 33, in <module> " function, see issue 3770.") importerror: platform lacks functioning sem_open implementation, therefore, required synchronization primitives needed not function, see issue 3770. $ uname -a linux xxx-ubuntu-64 2.6.35-22-generic #35-ubuntu smp sat oct 16 20:45:36 utc 2010 x86_64 gnu/linux they fixed in ubuntu python3: https://bugs.launchpad.net/ubuntu/lucid/+source/python3.1/+bug/630511 the report 2.7 here: https://bugs.launchpad.net/ubuntu/+source/pyth

iphone - MFMailComposeViewController breaks navigationController's behavior -

ok here situation: have main viewcontroller(mainvc) navigation controller(nc) , 2 child viewcontrollers(childvc1-childvc2). the navigation bar of nc gets hidden when viewwillappear gets called on mainvc: - (void) viewwillappear:(bool)animated { [self.navigationcontroller setnavigationbarhidden:true animated:animated]; } the navigation bar shown before child view pushed on mainvc via nc: mainvc *childvc1 = [[childvcontroller1 alloc] initwithnibname:@"childvcontroller1" bundle:nil]; [self.navigationcontroller setnavigationbarhidden:false animated:true]; [self.navigationcontroller pushviewcontroller:childvc1 animated:yes]; [childvc1 release]; the navigation bar hidden again via viewwillappear of mainvc, when gets called after child view popped via standard button on navigation bar. all works smoothly until mfmailcomposeviewcontroller, standard mail viewcontroller called via presentmodalviewcontroller method child viewcontroller:

java - border not display in my images -

Image
my gallery display images image select don't know how differentiate selected image , other images.. want set border line in image...now attach screen shots me.... my screenshot: i expect type of screen in emulator: package videothumb.videothumb; import android.app.activity; import android.content.context; import android.content.intent; import android.database.cursor; import android.graphics.bitmap; import android.os.bundle; import android.provider.mediastore; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.baseadapter; import android.widget.gallery; import android.widget.imageview; import android.widget.listview; import android.widget.textview; import android.widget.toast; import android.widget.adapterview.onitemclicklistener; import android.net.uri; import android.view.window; import android.view.windowmanager; import android.graphics.color; public class videothumb extends activity{ private final static

iphone - Get battery level with higher accuracy than 5% -

our company developing iphone battery application. i use below code battery level uidevice *mydevice = [uidevice currentdevice]; [mydevice setbatterymonitoringenabled:yes]; float batterylevel = [mydevice batterylevel]; however accuracy of api 5%, example 0% 5% 10% 15%.....20% 95% 100% the requirements of application demands 1% accuracy, example 1% 2% 3%...99% 100% are there ways obtain level of accuracy? i guess try interpolating between values, wouldn't accurate.

javascript - Scaling SVG (Raphael.js) like an SWF -

i started using raphael.js few days ago , i'm enjoying it. thing haven't been able figure out how "paper" or svg/vml tag fill browser window swf. see example. note way above example resizes browser window i able "paper" resize browser window, no luck getting vector graphics adjust size. feedback appreciated. edit i tried bunch of different routes this. viewbox worked great svg only. figured out how using raphael sets , little code on window.onresize event. i'll post findings later tonight or tomorrow. i'd still see other solutions question if there any. it took me awhile came solution problem. i've wrapped solution in small js file can used raphael. can js file along simple documentation here . see in action . how works: use viewbox svg wrap vml nodes in group node wrap raphael constructor vml group node passed raphael constructor alter few css properties when paper resized deal centering, clipping , maintaining corre

java - Check for duplicates in database before inserting -

i need check in database if record exist before insert table. have 2 tables, 1 insert data , 1 log table referenced main table. in log table have id, date_import , file_import. want check if file_import exist. here scratch code: //date dateformat datef = new simpledateformat("dd.mm.yyyy"); date date = new date(); //date //db init string url = "jdbc:mysql://192.168.1.128:3306"; connection con = (connection) drivermanager.getconnection(url,user,pass); statement stmt = (statement) con.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); statement stmt1 = (statement) con.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); string mysql_log = ("create table if not exists dbtest.t_ajpes_tr_log" + "(id int unsigned primary key auto_increment, date_import varchar(45)," + "file_import varchar(75)) engi

html - JAVA - Automatic post on Facebook wall without app -

i trying simulate user behavior on facebook through org apache httpclient , able login user page (obviously having username , password). now post simple message on wall through common http call user makes when he/she clicks on "submit" button. i decoded parts of ajax call done "updatestatus.php" page wasn't able publish stream. my question is: posted on wall using kind of process? just note: don't want register app special reasons. thank c the correct way register app , use facebook's apis. "special reasons" can't that?

python - In Django's template system, how do I make it to do different things sometimes? -

{% p in posts %} <div style="width:50px;"> blah </div> {% endfor %} however, if want div 100px 75% of time? 25% of time? randomized. logic not go templates. solution: write new template tag returns random number, , use width. http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/ your template like: {% p in posts %} <div style="width:{% myrandomtag 0 100 %}px;"> blah </div> {% endfor %} or whatever. put required logic in python code tag.

Calculated Columns in the Entity Framework? -

i've not yet got experience orm's, , on last asp.net web forms site, friend created mapping file (for nhibernate) contained couple of calculated columns. these 2 columns mapped couple of properties 'photo' model. now i'm re-creating same small website, albeit using asp.net mvc , far have used entity framework, however, need accomplish same thing, map these 2 calculated columns couple of properties 'photo' model, can't see how using framework. here of content of original nhibernate mapping file photo object. <class xmlns="urn:nhibernate-mapping-2.2" name="photo" table="photos"> <id name="id" unsaved-value="0"> <column name="photoid" /> <generator class="native" /> </id> <many-to-one name="lens" not-null="true"> <column name="lensid" /> </many-to-one> <property name="title" not-null

asp.net - Regular expression for email to allow only two domain -

i have create regular expression email id this xyz@yahoo.com , xyz@gmail.com i need allow yahoo , gmail domain not other domain. have used expression \w+([-+.]\w+)*@yahoo.com . working fine yahoo. want include gmail also. how can modify except gmail also? i using asp.net 2.0 replace: yahoo\.com with: (yahoo\.com|gmail\.com) or: (yahoo|gmail)\.com)

Errorcode in MySQL procedure -

we have been facing small problem in mysql procedure. have placed exception handlers inside procedure. want retrieve errorcode of error can occur inside procedure. there way exact errorcode using kind of function (in same way, use wsagetlasterror in socket apis)? for example, suppose there select query inside procedure refers nonexisting table. in case, error generated ('table' donot exist). control transferred exception handlers without meaning information. can handle using exact error code in case (1146). if error else, havent mentioned in exception handler? want error code in case checking later. there show errors query how use in procedure processing? hope more clear. i found question here also: http://www.eggheadcafe.com/software/aspnet/35923137/show-errors-question.aspx noone has answered yet. at time, there no way examine current mysql error code or sqlstate code in store procedure. it's sql:2003 features not implemented on mysql stored program.

regex - Multi-language input validation with UTF-8 encoding -

to check user input english name valid, match input against regular expression such [a-za-z]. how can if multi-language(like chinese, japanese etc.) support required utf8 encoding? you can approximate unicode derived property \p{alphabetic} pretty succintly [\pl\pm\p{nl}] if language doensn’t support proper alphabetic property directly. don’t use java’s \p{alpha} , because that’s ascii-only . but you’ll notice you’ve failed account dashes ( \p{pd} or dashpunctuation works, not include of hyphens!), apostrophes (usually not 1 of u+27, u+2bc, u+2019, or u+ff07), comma, or full stop/period. you had better include \p{pc} connectorpunctuation , in case. if have unicode derived property \p{diacritic} , should use that, too, because includes things mid-dot needed geminated l’s in catalan , non-combining forms of diacritic marks people use. but you’ll find people use ordinal numbers in names in ways \p{nl} ( letternumber ) doesn’t accomodate, throw \p{nd} ( d

asp.net - Linq queries in UI code: do you regard this as a no-no? -

ah, i'm getting warning saying question 'appears subjective , closed'. think it's pertinent , important question architectural design. all programming years have been told sql statements being created , executed directly within ui code (for example asp.net page codebehind) massive code smell , data access , presentation concerns should @ opposite ends of application's layers. nowadays have shiny data access layer using nhibernate entities via repository pattern. , i'm finding myself writing linq queries directly in ui code! part of me thinks same writing sql queries in ui code, dressed in smarter clothes. the other part of me says linq queries tip of sophisticated abstraction layer separating ui code internals of database, , if didn't use linq queries in page have add one-off 'report' methods repository getallfooswithrednosesandsleighbells() , think of anti-pattern. what think? i'll give answer whoever makes strongest argument (in s

How to Handle Button Click Events in jQuery? -

i need have button , handle event in jquery. , writing code it'snot working. did miss something? <!-- begin button --> <div class="demo"> <br> <br> <br> <input id = "btnsubmit" type="submit" value="release"/> <br> <br> <br> </div> <!-- end button --> and in javascript file function btnclick() { // button click $("#btnsubmit").button().click(function(){ alert("button"); }); } you have put event handler in $(document).ready() event: $(document).ready(function() { $("#btnsubmit").click(function(){ alert("button"); }); });

qt - How to detect doubleClick in QTableView -

i'm using pyqt create gui application. in view inherited qtableview, need detect row user has selected when double click row. table has sorting, no editing. how do it? note - tried doubleclicked(int) signal. emitted mouse buttons, not data cells, never fired. :( ian i dont understand. doubleclicked signal of qtableview has signature void doubleclicked ( const qmodelindex & index ) if connect signal should obtain correct qmodelindex.

java - Configure Tomcat so that I can connect a JSP page to MySQL -

i need connect mysql database jsp page using drivermanager.getconnection() method. have placed mysql connector-j jar file in tomcat lib. have run same code normal java application , works, makes me think there issue tomcat. getting many exceptions, first 1 being classnotfoundexception , followd many jasperexception . could tell me steps need follow in configuring servlet interact mysql jsp page? update : have tried putting in lib folder of tomcat install root /web-inf/lib , problem persists. jar file name mysql-connector-java-5.1.13-bin.jar . right one? here exception getting java.lang.classnotfoundexception: com.mysql.jdbc.driver @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1645) @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1491) @ org.apache.jasper.servlet.jasperloader.loadclass(jasperloader.java:128) @ org.apache.jasper.servlet.jasperloader.loadclass(jasperloader.java:66) @ java.

objective c - How to handle the 404 error in libxmlparser in iphone sdk? -

can suggest me how handle 404 error in libxmlparser when there no network connection available. thanks all, monish. display error message & tell user try again later? what else 1 if there's no connection? offer user crying towel? call desk or isp? plug/unplug ethernet cable?

readonly - ActiveRecord::ReadOnlyRecord (ActiveRecord::ReadOnlyRecord): during update -

i think i'm still newbie, need again. while i'm working habtm association have problem. have form enter information computer. association habtm between machine , operatingsystem. class machine < activerecord::base .... has_and_belongs_to_many :operatingsystems, :join_table => "machines_operatingsystems", :readonly => false .... end class operatingsystem < activerecord::base .... has_and_belongs_to_many :machines, :join_table => "machines_operatingsystems", :readonly => false .... end i display operating systems check box. i modified update of machines controller def update params[:machine][:operatingsystem_ids] ||= [] @machine = machine.find(params[:id], :readonly => false) respond_to |format| if @machine.update_attributes(params[:machine]) flash[:notice] = 'machine updated.' format.html { redirect_to(@machine) } format.xml { head :ok } else format.html { render :

Problem with inserting into android sqlite3 table that has composite primary key -

i have table composite primary key , having trouble inserting. code used create table is: create table classevent ( eventname varchar(10) not null, courseid varchar(10) not null, eventtype varchar(20), eventweight number(3), duedate date not null, foreign key (courseid) references courses(courseid), primary key (courseid, eventname)); the problem having when want insert records have values may not unique columns courseid or eventname, unique combination of 2. example, if try run following 2 inserts: insert classevent values('assignment 1','60-415','assignment',10,'12/10/2010'); insert classevent values('project 1','60-415','project',15,'5/12/2010'); i following error: error: columns courseid, eventname not unique. and second insert not make db. why error out? thought composite primary key requires combination of both values unique. in above inserts, values eventname column

im need know how i used pop3 with smtp sender VB.NET 2008 -

im need know how used pop3 smtp sender vb.net 2008 i have problem when put smtp yahoo , account user , password tell me failure sending mail. so plz im need here 1 way send smtp mail vb.net. axmsmapi.axmapi.session , axmsmapi.axmapi.messages vb6 compatibility controls, believe. requires mapi email client on user's system, such outlook. try mapisession1.signon() mapimessages1.sessionid = mapisession1.sessionid mapimessages1.compose() mapimessages1.msgnotetext = "message text" mapimessages1.attachmentpathname = currentpicpath mapimessages1.attachmentname = path.getfilename(currentpicpath) mapimessages1.attachmenttype = 0 mapimessages1.send(true) mapisession1.signoff() catch ex exception msgbox("warning: email not sent. " & ex.message, msgboxstyle.okonly) end try

sql - Relational Database Design (MySQL) -

Image
i starting new project website based on "talents" - example: models actors singers dancers musicians the way propose each of these talents have own table , include user_id field map record specific user. any user signs on website can create profile 1 or more of these talents. talent can have sub-talents, example actor can tv actor or theatre actor or voiceover actor. so example have user - model (catwalk model) , actor (tv actor, theatre actor, voiceover actor). my questions are: do need create separate tables store sub-talents of user? how should perform lookups of top-level talents user? i.e. in user table should there fields id of each talent? or should perform lookup in each top-level talent table see if user_id exists in there? anything else should aware of? ok sorry incorrect answer.. different approach. the way see it, user can have multiple occupations (actor, model, musician, etc.) think in objects first translate tables. in p.o.o

c# - How to Stop VS Designer from messing up my already present code -

everytime move designer view whole designer.cs code messed : vs designer reorganizes code blocks , puts irritant verbose prefixes " this.whatever " , qualifies objects using " system.windows.forms.whatever " know "designer.cs" not intended edited need gui code customization time time , these stay changed them. how avoid ? (guess funky vs handle) (actually avoiding use of designer , hand, old way) update : i surprised see herd-like reaction towards question. sorry if disturbing, interesting see that, before hitting me on hand saying "don't that, it's bad", no 1 asked why wanted it. imho question relevant , that's why : many of "auto-generated" code rubbish , of absolutely no use, need enhancement. 1 example (among soooo many others) : why generate size/location property when control's dock mode set fill ? wanted take advantage of benefits whithout drawdowns. anyway, i'll keep short answer : take (with rubb

wpf - Binding mode for item in listbox -

when using datatemplate listbox item, app freezes , throws exception in output window. details follow. edit template: <datatemplate x:key="editonlytemplate"> <border borderbrush="blue" margin="3" padding="3" borderthickness="2" cornerradius="5" background="beige"> <stackpanel orientation="horizontal"> <stackpanel orientation="vertical" verticalalignment="center"> <textbox width="300" fontsize="25" foreground="goldenrod" text="{binding xpath=/doc/dob/text, mode=onewaytosource, updatesourcetrigger=propertychanged, diag:presentationtracesources.tracelevel=high}" /> <textbox width="300" fontsize="25" foreground="blue" text="{binding xpath=/doc/dob/group, updatesourcetrigger=propertychanged}" /> <

use of mvvm pattern in wpf application -

i new wpf , designing client-server application using wpf ui have 1 view - view model, datalist , communication model view , view model form 1 user control following doubts: if keep datalist inside viewmodel, how other view model can access it if keep datalist in application view can access , whether view model able update through binding it design if view model calls communication model directly or should keep wraper class in between. thanx sarika you should think using repository pattern access list of items. viewmodels should work against abstraction of repository (e.g. ipeoplerepository), , should pass concrete implementation of repository viewmodel via injection (e.g. through constructor injection). concrete implementation can call communication model retrieve list of items. typically, repository return collection type not specific wpf. you'll want wrap in observablecollection on viewmodel, ui notified of changes collection. whether each viewmodel

import - Programmatically adding a library to an Eclipse project -

how can create new build path entry *.jar file , add classpath entry build path of eclipse project. i have plugin should automatically setup target project. project needs have library imports , want add imports automatically using wizard. user selects location of sdk , libraries have linked target project. however, found references: importing libraries in eclipse programmatically how add folder java build path library, having multiple jars or entries in it? unfortunately, failed implement second solution cannot find classes iclasspathcontainer, javacore , ijavaproject. i'm using eclipse helios , jdk. need additional libraries make changes build path or there simpler solution import jar library programmatically? regards, florian i'm assuming creating plugin , need plugin manage jars added classpath. as mention, need create custom classpath container. first, create classpath container extension exending extension point: org.eclipse.jdt.core.classpa

google app engine - How to use services in the way I expose here? in pyamf -

my app sets array of strings available services. when app call "getservicerequest" calls on custom class, must load class match target in available services array. then problem here; class this. , run render_output everytime run service this. how extend originals classes, , ones? thanks class get_current_account2(object): def render_output(self, input): self.output = object() data = self.execute(input) self.output.data = data || nil if self.message: self.output.message = self.message return self.output def execute(self, input): app.models.user import user gaesessions import get_current_session google.appengine.ext import db session = get_current_session() if not session: self.message = 'session not found' return if not session.has_key('account.logged'): self.message = 'account not logged'

.net - How best to implement a Per-View Life-Cycle for IoC Injected Components -

i working on wpf application using mvc architecture , ioc container. presently, wrestling design issue involving scope , lifetime of container provided components. here situation. i generalize saying incorrectly ioc containers support 2 component life cycles, singleton , transient. need middle ground sets of components. consider view displays list of records in grid. when user clicks on record, new view opens display record details , allow editing. user can have many such views open, each displaying different record. each view gets own model , controller well. within context of given model-view-controller set, there components such dialogs both transient , lazily injected. want new instance each time need display 1 , since of these transients needed if user takes action, inject factory delegate. delegate invoked needed perform actual dependency resolution. beyond model, view , controller, there host of other components want 1 instance per m-v-c set. example, im

c# - How can I call the constructor? -

i dynamically create instances of objects in custom linq provider building using call: object result = activator.createinstance(typeof(t)); my t type implements abstract class has constructor take instance of object (t wrapper). question - there way can explicitly call non-default constructor can rid of this: myentity entity = result myentity; if(entity != null) entity.underlyingentity = e; //where e wrapping yes, supply constructor arguments after type object, so: object result = activator.createinstance(typeof(t), arg1, arg2, ...);

wpf - How do I set a Multibinding and Image in Expander Header -

perhaps can me solve problem. want display text-multibinding , image in header of expander. this simplified coding of expander: <expander x:name="_myexpander"> <expander.header> <multibinding converter="{staticresource expanderheaderconverter}"> <binding path="property1" /> <binding path="property2" /> <binding path="property3" /> </multibinding> </expander.header> <local:content/> </expander> how can set image in there? thanks in advance! try this: <expander.header> <stackpanel orientation="horizontal"> <image source="{binding ...}"/> <textblock> <textblock.text> <m

sql - Check if record does NOT exist in Rails (from array of ids)? -

i can check if record(s) exists (say id "1" exists, "2" , "3" don't): model.exists?(:id => [1, 2, 3]) #=> true how do opposite, so: model.not_exists?(:id => [1, 2, 3]) #=> true if need search records through id can try this class model def self.not_exists?(ids) self.find(ids) false rescue true end end if of ids not exist find method raise activerecord::recordnotfound exception catch , return true. excuse english :)

PHP: Help with if OR issue -

had twice now, don't know problem is, have normal if statement, or attribute if((checkblock($showu['id'], $user, 'wall') != 1) || (checkblock($showu['id'], $user, 'wall', 1) == 1)) { i want check whether first checkblock != 1, or if checkblock == 1 first if checkblock should true, if have blocked user , user tries visit me. second should true if have blocked user , try visit him. the first ifstatement works code above, not if statement (the if have blocked , visits him).. but second works if remove first statement.. want check both. how can make them both check work? have tried or, didnt affect issue. php skipping second check when first true because of short-circuit boolean evaluation. is, if have (a || b) , true, there's no need check b because conditional has passed. if want check both conditions need use , not or.

asp.net - Abstracting HttpContext Request and Session - thread safety -

i have following assemblies in asp.net app: website - asp.net website classlib - class lib contains business logic class lib needs interact httpcontext session , request objects. code upgrade old asp app, i've hoovered vbscript contained logic , put vb.net. didn't have time rewrite. instead of classlib interacting directly httpcontext, thought bad , prevented unit testing, introduced following abstraction layer: public class request private shared _requestwrapper irequestwrapper public shared readonly property requestwrapper() if _requestwrapper nothing throw new exception("_requestwrapper null. make sure initrequest() called valid parameters") end if return _requestwrapper end end property public shared sub initrequest(byref requestwrapper irequestwrapper) _requestwrapper = requestwrapper end sub public shared function getval(byval key string) object

apache - Just installed nginx and now having bind error - address already in use -

i running vps apache. installed nginx. got address in use error @ port 80 because apache using it. new linux/apache stuff possible change port of nginx , how ? if yes work want serve static files automaticaly or should hosting company instead since don't know these. and yes used tutorial install http://library.linode.com/web-servers/nginx/installation/centos-5 help appreciated :) thanks in advance look either into your nginx.conf file or of sites in sites-enabled (usually under nginx directory) and search server part, listen server { listen 80; here can change port 81 instance instead of 80. notes: you may have server { listen } part within nginx.conf directly if under linux, configuration in /etc/nginx (nginx.conf) , sites-enabled below directory. regarding apache (linux), using either service apache stop or service httpd stop or /etc/init.d/apache stop (or httpd) should work stop process, or try killall httpd or killall ap

c++ - Extensible parser design -

i have class target "filetype" enum holds kinds of files parser needs know (currently source, header, resource). i'd parsing function able generic like: if( token == some_known_filetype ) put_nexttoken_in_the_list_for_that_filetype(); else return an_error(); but there's catch: i'd able extend known filetypes subclasses of target , extend enum in correct way, see base enum class inheritance how did this. don't want modify above code, generically extend target half. c++0x may required , welcome. thanks! update: upon trying explain here , posting reduced class declarations, realised design broken, , tried push specialization of filetype deep in class structure. wanted 1 place store full list of known types, in trying so, accidentally forced design have access list in 2 places @ time. realise list of filetypes should keywords source, header, etc. read, , handled *generically thereon. store full list in 1 place, , access list through "

android - It is possible to remove the Shadow of the Icons (items) on a googlemap? -

i have google map these kind of items on it: drawable3 = this.getresources().getdrawable(r.drawable.trazeicon); but automatically, android draws shadow of image trazeicon on map, , don't want have shadow. how can remove it? edit: i got error: syntax error, insert "}" complete classbody here full code: package com.gpsloc; import java.util.arraylist; import android.app.alertdialog; import android.content.context; import android.graphics.canvas; import android.graphics.rect; import android.graphics.drawable.drawable; import com.google.android.maps.itemizedoverlay; import com.google.android.maps.mapview; import com.google.android.maps.overlayitem; public class myitemizedoverlay extends itemizedoverlay { private arraylist<overlayitem> moverlays = new arraylist<overlayitem>(); private context mcontext; public myitemizedoverlay(drawable defaultmarker) { super(boundcenterbottom(defaultmarker)); } protected overlay