Posts

Showing posts from January, 2013

asp.net mvc 3 - MVC3 Dropdown repopulates fine even on error postback, but suggestion on how to make it efficient - without introducing error -

i can't post code @ moment on road , out of office. here code simplified. don't think have syntax issue such - think need clarification or, pointer. model: [validaton attribute] class data { [required] int xx .. } viewmodel: class vm { selectitem items; int itemid; data dt = new data(); public vm { items =... load db... } } view @textbox xx (etc) @dropdownfor(vm.itemid, vm.items controller void index { vm vm = new vm(); //i default items here works - nice form loaded. return view(vm); } [post] void index(vm stuffposted) { if modelstate.ok)( { good. direct page redirect action } else { return view(stuffposted) //this problem case need efficiency } problem the form loads fine index method. on postback submit, id comes correctly in itemid. if there error - modelstate sends view...and selection list(s) in place, selections. oh joy! but, in postback method, vm stuffposted instance class invokes constructor , there (ex

winforms - Very basic? C++/CLI problem -

i'm using vc++ 2010. i'm getting error c2228. says must struct, class or unioun before .text. private: system::void textbox1_textchanged(system::object^ sender, system::eventargs^ e) { using namespace std; for(int r=0; r>(sizeof(x)/sizeof(x[0])); r++){ if (x[r][1].find(textbox1.text) != string::npos){ label1.text = (label1.text+x[r][1]); label2.text = (label1.text+x[r][2]); } } } it searches 2d array , sees if matches you've typed , displays while you're typing, main feature of application making. errors on if statement, 2 statements after twice , that's it, .text bringing errors on 5 attempts read it, identical error posted above. try instead: using namespace std; private: system::void textbox1_textchanged(system::object^ sender, system::eventargs^ e) { for(int r=0; r > (sizeof(x) / sizeof(x[0])); r++) { if (x[r][1].find(textbox1.text) != string::npos){

bitmap - Android: BitmapDrawable.Draw(Canvas) Doesn't seem to work -

i trying tile 20x20 background onto custom view reason unable too. bitmapdrawable background; background = new bitmapdrawable(bitmapfactory.decoderesource(getresources(), r.drawable.back)); background.settilemodexy(shader.tilemode.repeat, shader.tilemode.repeat); background.draw(canvas); does have idea why isn't working? you can use bitmapdrawable, have set bounds first knows how tiling do: bitmapdrawable background; background = new bitmapdrawable(bitmapfactory.decoderesource(getresources(),r.drawable.back)); //in case, want tile entire view background.setbounds(0, 0, myview.getwidth(), myview.getheight()); background.settilemodexy(shader.tilemode.repeat, shader.tilemode.repeat); background.draw(canvas);

javascript - Reading selected value of dropdown list in HTML by jQuery -

i trying read value of selectedid in drop down list in html through jquery keeps producing error. did miss something? <select style="width: 80px;" class="text ui-widget-content ui-corner-all" id="metalist"> <option value="4d5e3a8c418416ea16000000">wikipedia</option> <option value="4d5e3a8c418416ea16010000">twitter</option> <option value="4d5e3a8c418416ea16020000">dbpedia</option> <option value="4d64cd534184162629000000">test</option> </select> i tried used work before var temp = $("#metalist").val(); but produces null! your function call correct, nothing selected. reason why null returned.

c++ - Syntax error in SQLite query -

i trying insert large number of records sqlite database. above error if try use sqlite3_exec c-api. the code looks this: ret = sqlite_exec(db_p,".import file.txt table", null, null, null); i know .import command line, can there way can extremely large insert of records takes minimal time. have read through previous bulk insert code , attempted make changes these not providing desired results. is there not way directly insert string tables without having intermediate api's being called? .import not available via api. there's 1 crucial thing speed inserts: wrap them in transaction. begin; lots of insert statements here; commit; without this, sqlite need write file after each insert keep acid principle. transaction let's write file later in bulk.

.net - data transfering problem WCF -

why cant send array more 3000 elements size ~5 mb table size 2500 elements there no problem ? <binding name="testbinding" maxbuffersize="100485760" maxreceivedmessagesize="100485760" maxbufferpoolsize="100485760" closetimeout="00:10:00" opentimeout="00:10:00" receivetimeout="00:10:00" sendtimeout="00:10:00"> <readerquotas maxdepth="1000" maxstringcontentlength="100485760" maxarraylength="100485760" maxbytesperread="100485760" maxnametablecharcount="100485760" /> </binding> changing of of parameters doesnt give results i think hosting service in iis. in such case must set asp.net request limit default 4096kb. <system.web> <httpruntime maxrequestlength="4096" /> </system.web>

asp.net - Wrong firstdayofweek set in VB.NET -

hey on server working on getting wrong week day current day i.e today response.write(weekdayname(weekday(system.datetime.now))) i getting thursday, default set or can change it. , thinks day of week 4. thanks the resolution of property depends on system timer. if adjust server's system time, should adjust programs.

encoding - Writing PHP in Notepad++, and using Spanish letters? -

i don't - encoding should use? i've been using ansi, when save document, spanish letters converted illegible markings. any suggestions? in general, document, should use utf-8 without bom. (the exception documents targeting asian countries more efficiently stored in utf-16). you need make sure that: it doesn't transcoded en-route any database data stored in utf-8 aware any <meta> element in html document states encoding states correct encoding. (if document intended viewing file system instead of on http add such element) the http headers state document utf-8

c# - AOP w/ PostSharp - Classic NotifyPropertyChanged PropertyChanged Event Handler Missing? -

new postsharp 2.0 , trying out class notifypropertychanged aop provided here: http://www.sharpcrafters.com/solutions/ui#undo-redo when attempt hook propertychanged event handler compiler tells me not defined. have not directly implemented inotifypropertychanged interface on object in question, applied attribute. i assume answer implement interface defeats simplicity bit, missing or requirement? is there way postsharp modify class pre-compile introduce these members/interfaces? i suppose, trying subscribe event in same assembly. postsharp rewriting assembly after has been compiled. work, if reference assembly has been rewritten postsharp binary rewriter.

django reverse() failing -

simply put mentions of reverse() anywhere in project failing, , {% url %}. have since made progress if scroll bottom! relevant files root/urls.py from django.conf.urls.defaults import patterns, include, url django.contrib.staticfiles.views import serve servestatic # uncomment next 2 lines enable admin: django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), (r'^dbrowse/', include('dbrowse.urls')), (r'^static/', servestatic), url(r'^$', 'core.views.viewhallo',name='home'), ) root/core/views.py from django.shortcuts import render_to_response django.template.context import requestcontext site import site_store def viewhallo (request): pass return render_to_response ('core.html', {'site':site_store, 'title':'i hallo view',

javascript - Problems with jQuery UI tabs and children UL -

i'm having trouble jquery ui tabs. i'm using default tab markup: <div id="tabs"> <ul> <li><a href="#tab1">tab 1</a></li> <li><a href="#tab2">tab 2</a></li> </ul> <div id="tab1"> </div> <div id="tab2"> </div> </div> however, want display list before tabs. this: <div id="tabs"> <p>lorem ipsum dolor</p> <ul> <li>asdasdasd</li> <li>asdasdasd</li> </ul> <ul> <li><a href="#tab1">tab 1</a></li> <li><a href="#tab2">tab 2</a></li> </ul> <div id="tab1"> </div> <div id="tab2"> </div> </div> and don't want list recognized tabs. how c

Java Socket and ServerSocket Issue -

i have code snippet: serversocket serversocket=new serversocket(defaultport); serversocket.setsotimeout(1000); socket socket=serversocket.accept(); does closing serversocket object affects state of socket object? if close serversocket object can still use socket object streams? the short answers are: 1) no 2) yes the longer answer is: the serversocket waits clients connect (he waits in accept-method). when there client, accept-method returns, more returns socket-object represents server's endpoint of server-client connection. if server closes server-socket, no longer listens (he no longer accepts new clients) clients has socket-connection unaffected. your code not "wrong" per se, capable of accepting single client , if connected within 1000 milliseconds. here introduction including sample code: http://download.oracle.com/javase/tutorial/networking/sockets/clientserver.html

java - How to make an arraylist remotely accessible -

i have project using java rmi make objects remotely accessible other objects. need make following class remote: public interface marketbb extends remote { public arraylist<cloudentry> getmarketbb() throws remoteexception; public void moveamp(int fromcloud, int tocloud) throws remoteexception; } the problem have because arraylist holding cloudentry objects, when getmarketbb method called object, nothing returned. is there way of making arraylist of cloudentry classes remotely accessible? here code cloudentry class: public class cloudentryimpl implements cloudentry { int cloudid; string cloudname; double speedghz; double costperghzh; double commscost; double commstime; int noamps; //constructor, , set methods fields } and cloudentry interface: public interface cloudentry extends remote { public void setnoamps(int noamps) throws remoteexception; public string getcloudname() throws remoteexception; public stri

objective c - How to play streaming audio file in iphone? -

how play streaming audio file in iphone? i trying make app can play audio file web server play pause , stop functionality.... can 1 have idea ? this lot simpler advent of avfoundation. @ avplayer class . works great streaming audio.

BASH shell process control - any other examples of controlling/scheduling work -

i've inherited medium sized project in main (batch) program fed work through large set of shell scripts lot of process control (waiting process complete, sleeping, checking conditions, etc) [ , reprocessed through perl scripts ] are there other examples of process control shell scripts ? see other people have done comparison. (as i'm not fond of 6,668 line shell script) it may lead current program works , doesn't need messed or maintenance reasons - it's cumbersome , doing way easier maintain, need other examples. to reduce "generality" of question here's example of i'm looking for: procsup inquisitor project relies on process control shell scripts extensively. might want see it's directory main function set or directory tests (i.e. slave processes) runs .

google play - In-app billing in Android - questions -

i have several questions android in-app billing, cannot find need in documentation. 1: require android 1.6 or higher, , market 2.3 or higher. how can install android market 2.3 manually, if device have not rooted? 2: tried on android 2.2 , market version 2.2.11, there errors in reading bundle responses. 3: have chance running on emulator? 4: have do, test in-app purchase? downloaded sample app, , compiled it, not static responses (market app 2.2.11). 5: actually, legal install android market 2.3 on devices lower api level? google need droid 1.6 sdk, , market 2.3, far know there no (or few) devices market 2.3 running below 2.3 android. can update market app? 6: (lame) android market client auto update itself, when new 1 released ? you shouldn't have install market 2.3.0 manually, market app should update when new version released. you said requires market 2.3.0 won't work on 2.2.11. lots of people have been running market on emulator, may work: how i

.net - Building a gui with lots of controls in Visual Studio -

this new me rather broad open ended question, information welcome! i building gui lot of inputs/controls. there several pages of controls, placed on top of each other, shown @ different times. have issue controls becoming layered on top of each other. how can avoid clutter? i add controls dynamically though code, lose advantage of drag , drop gui. also, have no idea how events work. how create several pages worth of controls using gui designer , not layering controls on each other? essentially, have here, different views. suggest, create every view in own user control , add form.

iphone - Optimising UIScrollview for paging -

in continuation question asked here , want know if method update ui in viewdidscroll correct. can observe method called many times , may reason why ui become jittery , unresponsive. how can increase responsiveness of ui. code below: bool isscrollingdown = verticalscrollview.contentoffset.y > _previouscontentoffsety; _previouscontentoffsety = verticalscrollview.contentoffset.y; cgfloat pageheight = verticalscrollview.frame.size.height; int scrollingtopagenum = isscrollingdown ? (ceil((verticalscrollview.contentoffset.y - pageheight) / pageheight) + 1) : (floor((verticalscrollview.contentoffset.y - pageheight) / pageheight) + 1); int page = floor((verticalscrollview.contentoffset.y - pageheight / 2) / pageheight) + 1; [self loadpage:(page-1)]; [self loadpage:(page)]; [self loadpage:(page+1)]; /* unloading pages not seen in view done here*/ if (!(isscrollingdown) && scrollingtopagenum >1) { [self unloadpages:page-2]; }else { [self unloadpages:page+2]; }

Importing Pchar Delphi DLL to C#? -

i have procedure in delphi: procedure passworddll(month integer; password pchar); export; the procedure should output password "password" pchar passed in.. google..and reading.... ref: here , here i come with: [dllimport( "delphipassword.dll", callingconvention = callingconvention.stdcall, charset = charset.ansi, entrypoint = "passworddll")] public static extern void passworddll( int month, [marshalas(unmanagedtype.lpstr)] string password ); then when call: string pass = ""; passworddll(2, pass); so password output "pass" string. but badimageformatexception unhandled: attempt made load program incorrect format. (exception hresult: 0x8007000b) sounds function format used wrong? wonder if used incorrect unmanagedtype pchar, reading, either lpwstr , lpstr.. did missed something? thanks in advance... first off since have not stated delphi version using answer assuming delphi

python - Multi-threading different scripts -

i have aa few scripts written in python. trying multi thread them. when script starts. scripts b, c, , d start. after runs, a2 run. after b runs, b2 run, b3. c , d have no follow scripts. i have checked scripts independent of each other. planning on using "exec" launch them, , use "launcher" on linux , windows." i have other multi thread scripts procedure 5 threads. throwing me because procedures different start , run @ same time. ok i'm still not sure problem is, that's way i'd solve problem: #main.py multiprocessing import process import scripta # import other scripts def handle_script_a(*args): print("call 1 or several functions script or calculate stuff beforehand") scripta.foo(*args) if __name__ == '__main__': p = process(target=handle_script_a, args=("either so", )) p1 = process(target=scripta.foo, args=("or so", )) p.start() p1.start() p.join()

java - How do you update an existing cookie in JSP? -

i have cookie, mycookie , contains hash value. cookie set expire in 1 year , has path of '/'. need update cookie new hash value. when jsp script loaded retrieve cookie so: cookie[] cookies = request.getcookies(); cookie mycookie = null; (int = 0; < cookies.length; += 1) { if (cookies[i].getname().equals("mycookie")) { mycookie = cookies[i]; break; } } after determining value of cookie needs updated, following update it: mycookie.setvalue("my new value"); response.addcookie(mycookie); examining results, have 2 instances of mycookie : original version correct expiration date , path, , old, invalid, value; , new cookie named "mycookie" expires @ end of session, correct value, , path of jsp document. if do: mycookie.setvalue("my new value"); mycookie.setpath(mycookie.getpath()); mycookie.setmaxage(mycookie.getmaxage()); response.addcookies(mycookie); the same thing happens. 2 cookies same name , different pr

jquery - Center a div in a horizontal scrolling site -

wonder if advise on best way center div in middle of screen of horizontal scrolling site. i want header stay positioned in center of screen rest of site scrolls. i'd set left , right margins zero, width set full scroll width imagine i'll need jquery trickery find window width first of all? any advice gratefully received! can done css, no need javascript. <div class="page"> <div class="header"></div> </div> .page{ width:2000px; height:500px; } .header{ width:300px; height:100px; background-color:red; position:fixed; top:0; left:50%; margin-left:-150px; /* negative half width */ } check working example @ http://jsfiddle.net/zecax/

Overwriting an iPhone app from a different Xcode Project -

one of apps i've developed submitted , approved appstore. because of big changes , more generic code created new xcode project app. the problem when trying install same app (based on bundle identifier) new xcode project, quits crash. if try install again (build & run/debug) xcode, seems overwrite , run. seems first time there merge / overwrite conflicts. second install, on failed first attempt makes work. i wouldn't want happen app updates downloaded store. i've read idea not build xcode, use ad hoc build through itunes instead. simulate more natural end-user process. i've tried this, somehow won't sync / overwrite existing app appstore (no errors, app not changing). does have hint on how solve this? on matter appreciated! i run problem time. use 1 developer profile dev work (and thus, 1 bundle identifier). you have delete old app phone, , clean build. these similar problems. (1) (2)

css - Unwanted white areas on HTML page -

i've made site using css made scratch. the page the css randomly there unwanted white spaces in 2 places: above main content area (below menu bar). below main content area , sidebar , above footer. i've experimented various methods of fixed problem margins , paddings didn't seem work. what rid of these white areas? the white space comes browser's default stylesheet. add these rules: h2 { margin: 0; } h4 { margin: 0; } to solve problem, , prevent future ones, recommend using css reset. eric meyer's recommended one; option yui css reset .

java - JAXB XJC Possible to suppress comment creation in generated classes? -

our project uses xjc generate java classes xsd. i'm using java ee 6. when xsds have re-generated, generated classes include comment @ top of file: // generated on: 2011.02.23 @ 02:17:06 pm gmt is possible suppress comment? reason use svn version control, , every time regenerate our classes, every single file shows being changed in svn, though thing differs comment. i'd remove comment altogether if possible. there -no-header directive, don't want remove entire header, future generations know it's file generated tool, , modifications overwritten. want remove timestamp. (or alternatively, i'd remove inbuilt header , insert own header somehow.) if it's not possible using option can post-process generated files yourself. specific use-case had way on our project... use maven , execute specific script after java classes have been generated , before compile , package them distriuable jar.

python - multiple send on httplib.HTTPConnection, and multiple read on HTTPResponse? -

should possible send plain, single http post request (not chunk-encoded), in more 1 segment? thinking of using httplib.httpconnection , calling send method more once (and calling read on response object after each send ). (context: i'm collaborating design of server offers services analogous transactions [series of interrelated requests-responses]. i'm looking simplest, compatible http representation.) after being convinced friends should possible, found way it. override httplib.httpresponse (n.b. httplib.httpconnection nice enough let specify response_class instantiate). looking @ socket.py , httplib.py (especially _fileobject.read() ), had noticed read() allowed 2 things: read exact number of bytes (this returns immediately, if connection not closed) read bytes until connection closed i able extend behavior , allow free streaming few lines of code. had set will_close member of httpresponse 0. i'd still interested hear if considered acc

asp.net - Uploading Large files to YouTube API (.NET) -

i trying upload videos youtube api... it's working fine if video file < 4 mb.. below code.. think issue related request length?! update: error getting "cannot close stream until bytes written." upload code youtuberequestsettings settings = new youtuberequestsettings("app name", "developerkey", "username", "password"); youtuberequest request = new youtuberequest(settings); request.settings.timeout = 9999999; video newvideo = new video(); newvideo.title = "movie size 3 mb"; newvideo.tags.add(new mediacategory("autos", youtubenametable.categoryschema)); newvideo.keywords = "cars, funny"; newvideo.description = "my description"; newvideo.youtubeentry.private = false; newvideo.tags.add(new mediacategory("mydevtag, anotherdevtag", youtubenametable.developertagschema)); string videopath = &qu

Generic types in Java -

is right code list<integer> test2 = new arraylist<integer>(); test2.add(343); int x2 = test2.get(0); in compile time converted this list test = new arraylist(); test.add(343); int x = (integer)test.get(0); something similar autoboxing... let's try. take class 2 methods absolutely same thing , without generics , autoboxing: public class generictest{ // use generics , auto-boxing // java 1.5 or higher required public void generic(){ final list<integer> test2 = new arraylist<integer>(); test2.add(343); final int x2 = test2.get(0); } // use neither generics nor auto-boxing, // should java 1.4-compatible public void nongeneric(){ final list test2 = new arraylist(); test2.add(integer.valueof(343)); final int x2 = ((integer) test2.get(0)).intvalue(); } } here's byte code: // compiled generictest.java (version 1.6 : 50.0, super bit) public class genericte

java - How do I set the text in it at the beginning when the dialog opens? -

i have following code displays jdialog , shows text field, assume it's jtextfield . how set text in @ beginning when dialog opens? joptionpane pane = new joptionpane("", joptionpane.question_message); pane.setwantsinput(true); jdialog dialog = pane.createdialog(null, "test"); dialog.setmodalitytype(dialog.modalitytype.application_modal); dialog.setvisible(true); use: pane.setinitialselectionvalue("foo"); to set input value displayed selected user.

c# - How to write text to an external application -

i'm developing application user write common text faster. what have in mind windows app user can configure key combinations, when he's, instance, writing email on outlook or gmail, has press keys , text configured before pasted whatever app he's using. so, instead of user having write "dear sir, order has been received succesfully" every time receives order , wants send confirmation email, press "crtl + o + r", , corresponding text written him. i think in order achieve app has 2 things: intercept key combination pressed buy user when he's focused on different app. "paste" corresponding text app. i have no real clue on how achieve this, because app doing "pasting" text on app (otlook, word, notepad or whatever thing user can type into), replacing short text user wrote long text defined. any suggestions? i've looked hot keys, i'm not sure they're way go, , have no idea on how "paste" new text

actionscript - Flex: how to change the volume of an EMBEDDED sound? -

searching how change volume of sounds, irritating snd=new sound(urlrequest) , followed snd.setvolume(val) . oh, fine, sound not urlrequest, it's embed. i've made lot of random attempts (1) no avail. how supposed instead? (1) including casting class sound, creating sound embed class argument, creating soundtransform , setting channel , etc. instantiate embedded class this: [embed(source="mysound.mp3")] public var soundclass:class; protected function application1_creationcompletehandler(event:flexevent):void { var smallsound:sound = new soundclass() sound; var trans:soundtransform = new soundtransform(.01); smallsound.play(0,0,trans); } update: in case wanted know how change volume if sound playing: [embed(source="mysound.mp3")] public var soundclass:class; public var smallsound : sound; public var vol : number = 0.01; public var trans : soundtransform; public var chan : soundchannel = new soundchannel(); protected func

Run multiple bat files within bat and passing arguments -

my problem related passing arguments bat files. first argument passed correctly bat second time argument passed it's emtpy. example: set comport = com4 call bat1.bat %comport% ->comport com4 if errorlevel 1 goto end call bat2.bat %comport% ->comport empty so after first call of bat1.bat comport empty. how can make call argument on "main" bat level stay in memory after call of bat1.bat? @echo off set comport=com4 setlocal&(call bat1.bat %comport%)&endlocal if errorlevel 1 goto end call bat2.bat %comport% :end setlocal works on winnt4+, not dos or win9x, if need support have save %comport% other variable before calling bat1.bat , restore value

.net - How to get data from 2 tables without joining them? -

i need write on linq2sql analogue of following query: select a.field1, b.field2 tablea a, tableb b how can that? i start this from in dbcontext.tablea, ... select new {field1=a.field1, field2=b.field2}; but should write instead of "..."? how mention 2nd table linked? thanks. p.s. hope clear to cross join, try from in dbcontext.tablea b in dbcontext.tableb select new {field1=a.field1, field2=b.field2};

Simplest Ajax upload jQuery plugin? -

i'm looking add ajax uploading application progress bar, solutions i've found seem entirely vertically , overly complex. i'll need own styling everything, , need custom functionality, i'm looking simple. my desired behavior this: 1.) user can select number of files. 2.) user hits "upload" , ajax upload sends each file 1 @ time, independent progress bars. i need add files button essentially, , i'm restricted no flash. need support latest firefox , chrome, ie8 isn't issue. what plugins should looking at? non-gpl licenses preferred. without having ever tried —  http://valums.com/ajax-upload/ seems want: features listed on site: multiple file select progress-bar in ff, chrome, safari doesn't use flash

iphone - how to split strings in objective c -

how split string in objective-c? working on short application contains date picker. display date date picker , display through label. my main question how can split the date in 3 separate strings? 1 has idea it? thanks you use -[nsstring componentsseparatedbystring:] or nsscanner split string, or use nscalendar extract pieces of date you're interested in.

iphone - Get User's Country -

i wanted know how find out current user's country using xcode (iphone dev sdk). if want users country can 2 things. easiest deciper localization settings. nslocale *locale = [nslocale currentlocale]; nsstring *country = [locale displaynameforkey:nslocaleidentifier value:[locale localeidentifier]]; this can unreliable (e.g. user abroad). if depend on information should use corelocation find users current location , use reverse geo-tagging country co-ordinates. take @ corelocation framework reference . should you.

java - JSF-API 2.0 is not in Maven central repo? -

i'm trying add jsf-api , jsf-impl dependencies project, , can't find them in maven central repo. there? i'm interested in 2.0+. mojarra site suggests add link repository: <repository> <id>java.net</id> <name>java.net</name> <url>http://download.java.net/maven/2</url> </repository> but against maven convention not use third-party repositories, maven central.. if don't want add repository reference directly in pom, can add in maven's settings file . alternatively, consider repository manager such nexus .

javascript - De-Anonymizing an Anonymous Function in jQuery -

this quite simple problem, it's causing me scratch head, i'm posting here. i have jquery in following form: if (jquery('.searchregions:checked').length == 0) { jquery('.searchregions').each(function(){ //code }); } else { jquery('.searchregions:checked').each(function(){ //the same code }); } obviously seems ridiculous repeat big block of code inside each of these functions. when tried name , move function, seemed break down - perhaps because of issues scope and/or jquery(this) inside function no longer referring same object? can me posting general idea of code should like? (or other optimisings or recastings make work appreciated!) you can define function , use name: function somehandler(event) { // code code code } jquery('.searchregions').each(somehandler); note when refer function name, don't include "()".

Pretty Print Formatting Issue in Python -

str = "" in range(1,91): str = str + '-' print "+", '{:^90}'.format(str), "+" elem in cursor: print "|", '{:^8}'.format(elem['classid']), \ "|", '{:^8}'.format(elem['dept']), \ "|", '{:^8}'.format(elem['coursenum']), \ "|", '{:^8}'.format(elem['area']), \ "|", '{:<46}'.format(elem['title']), \ "|" print "+", '{:^90}'.format(str), "+" i have following code in place try , print out results of db query. in standalone file, prints following output: + ------------------------------------------------------------------------------------------ + | centered | centered | centered | centered | 12 | | centered | centered | centered | centered | 12

c++ - gTest and multiple main() -

i have eclipse project. testcases in 1 *.cpp file. problem way end 2 main() functions. 1 app , 1 testcases. , eclipse, of course, refuses build... keep under 1 project (and avoid having multiple configurations, svn repositories etc). ideally, want force eclipse build 2 executables (one app , 1 testcases). had quick @ eclipse makefile, honest, don't quite understand how works. possible exclude main.cpp/testcases.cpp , build 1 executable, not elegant... anybody similar experience? are linking libgtest_main in addition libgtest? if don't link in libgtest_main should good. if want create 2 executables eclipse cdt easiest way have each executable have separate project. can have 1 project reference if have common code.

.net - Resize WPF UserControl without all children "jumping around" -

is there way resize wpf usercontrol in such way child controls don't flop around? i've got storyboard: <storyboard> <doubleanimation storyboard.targetproperty="height" storyboard.targetname="myusercontrol" to="145" from="0" duration="0:0:1" /> </storyboard> this works great; takes control height 0 height 145 -- problem height property changes, of child controls inside start jumping around, suspect, due horizontalalignment , verticalalighment properties. there way can disable until animation finished? i'm trying create illusion of usercontrol "sliding" view -- i'm open other approaches if i'm going wrong. everything "jumping around" because every time height of control changed containing controls reposition according new available space. to achieve desired effect should use rendertransform instead of changing actual height of control. here how can t

css - what should be width of web site? -

what ideal (fixed) width of general portal website? noticed many websites have width 960px 1000px. maybe check out browsersize.googlelabs.com , determine audience want cater to.

flash - How to I add button-like behavior to a video player button component? -

background i'm trying create simple "universal" media player presents same user interface (or similar possible) video , audio playback. unfortunately, flvplayback seems not able handle audio files far can tell, i'm using sound , soundchannel. my video playback handled using flvplayback component "wired" standard controls on-the-fly when needed. want wire them sound / soundchannel when i'm playing sound same ui widgets work in both cases. i'd avoid building components scratch because flvplayback component lot of nice stuff "for free" it's starting tricky. gorey stuff the standard playpausebutton movieclip 2 layers, 1 containing play button (and instance name play_mc) , containing pause button (pause_mc). inside 1 of these movie code this: stop(); this.uplinkageid = "pausebuttonnormal"; this.overlinkageid = "pausebuttonover"; this.downlinkageid = "pausebuttondown"; this.disabledlinkageid = "

XAMPP with apache and mysql already installed -

is there problem install xampp apache , mysql installed? there shouldn't problem. know won't able start both apache servers or mysql servers @ same time without modifying them use non-standard ports. (you use xampp mysql server existing apache or existing mysql server xampp apache.) you may have problems registering xampp apache , mysql windows services using xampp controls if have other apache , mysql servers configured services (i'm expecting service name conflicts). if have apache , mysql installed on machine, i'm not sure why want install xampp.

debugging - How is gdb used to debug Java programs? -

when gdb used debugging purposes in java: what's practical use? limitations? how compared other debuggers? i gdb used debugging java when programmer coming different language , familiar gdb. otherwise, seems strange choice given there more popular alternatives java: jdb , jswat , eclipse , netbeans , etc. here tutorial debugging java gdb.

c# 4.0 - Audio Conversion using C#.Net -

i want build simple audio converter (between major file formats) using c#.net, need know basic steps so. thanks. step 1: find third-party component(s) do(es) conversion between file formats. step 2: use component in app. if intent write raw conversion code yourself, ready pain. wav file format (aka linear pcm) easy enough deal with, long file header plus sample data. often, however, wav files lot more complicated , require more elaborate code locate various riff chunks , parse file. and that's straightforward file format (usually) not encoding of sort. mp3 format vastly more complex, , requires knowledge of fft (fast fourier transform) , like. update: alvas.audio 1 third-party c# component may need. naudio another.

PowerShell: Comparing dates -

i querying data source dates. depending on item searching for, may have more date associated it. get-date ($output | select-object -expandproperty "date") an example of output looks like: monday, april 08, 2013 12:00:00 friday, april 08, 2011 12:00:00 i compare these dates , return 1 set further out future. as get-date returns datetime object able compare them directly. example: (get-date 2010-01-02) -lt (get-date 2010-01-01) will return false.

c# - What's the best approach for developing a BlackBerry web application (WebWorks Application) -

i'm junior asp.net/c# developer , know java pretty similar c#. i've considered using 2 methods: the java toolkit (which native language of bb's os thought more powerful) the visual studio (asp.net) toolkit (which language , platform know , practiced before) so 1 of best approach? advantages/disadvantages every approach? suggest other solutions developing blackberry version of asp.net website? i'm facing same choice, , see, doesn't matter. you're developing web pages additional api's interfaces allow webkit browser take advantage of blackberry api's. it doesn't webworks applications run either java or .net code. instead, webworks apps made of html, css, , javascript. however, if you're planning on doing standard blackberry apps, you'll want go java. prepare developing on android platform. java isn't going away time soon, , rise in popularity of android platform, think demand java development going on rise, comp

c# - How to get Custom Attribute values for enums? -

i have enum each member has custom attribute applied it. how can retrieve value stored in each attribute? right this: var attributes = typeof ( effecttype ).getcustomattributes ( false ); foreach ( object attribute in attributes ) { gpushaderattribute attr = ( gpushaderattribute ) attribute; if ( attr != null ) return attr.gpushader; } return 0; another issue is, if it's not found, should return? 0 implcity convertible enum, right? that's why returned that. forgot mention, above code returns 0 every enum member. it bit messy trying have use reflection: public gpushaderattribute getgpushader(effecttype effecttype) { memberinfo memberinfo = typeof(effecttype).getmember(effecttype.tostring()) .firstordefault(); if (memberinfo != null) { gpushaderattribute attribute = (gpushaderattribute) memberinfo.getcustomattributes(typeof(gpushaderattribute), false)

debugging - How to debug crashed android native library? -

i runing junit test native library(c++), native library process crashed , logcat shows: i/activitymanager( 161): force stopping package xxxxx uid=10043 i/activitymanager( 161): start proc xxxxx added application xxxx: pid=1656 uid=10043 gids={1015} i/testrunner( 1656): started: testaddressbook(xxxxx.addressbooktest) f//system/bin/app_process( 1656): stack corruption detected: aborted i/activitymanager( 161): process xxxxx (pid 1656) has died. where xxxxx process name. i try follow instruction on http://source.android.com/porting/debugging_native.html , instruction confusing: if crashes, connect aproto , run logcat on device what aproto? can't find it. nor "stack" tool. any suggestion appreciated! -henry f//system/bin/app_process( 1656): stack corruption detected: aborted that sounds you're trashing local variable. here's popular way that: char localvar[16]; sprintf(localvar, "and why sprintf devil"); that's not as

java - Grails: JAVA_HOME is not defined correctly -

i have tried install grails framework , command "grails" in terminal every time crashes. using debian squeeze , set in /etc/profile , ~/.profile this : export java_home=/usr/lib/jvm/java-6-sun-1.6.0.22 export grails_home="/home/snitch/grails" export path=${path}:${grails_home}/bin what wrong? make sure java_home points jdk, not jvm. see: http://www.grails.org/installation . you may need add ${java_home}/bin path also.

vb.net - .NET COM assembly interacting with Excel via BackgroundWorker -

i writing (and teaching myself how write) experimental assembly in vb.net 3.5 exposed via com , called excel vba code initiate instance of class traps excel events , perform functions on active workbook in excel. to initiate class, reference excel application passed vba (i using pia excel in assembly). i needed perform time-consuming operation on active workbook assembly decided use backgroundworker in winform can display progress dialog operation whilst operation completes in background. i know if there problems interacting excel via com using background worker in way? reason asking main class in assembly holds reference excel application object, , passed backgroundworker can determine active workbook , perform operations on it. accessing workbook (not other objects) through 1 procedure. for reason have in head excel might not - right? if refering this: getting method call vba vb.net code spin off new thread (or worker thread) , handing on reference workbook

If I have 2 million rows in a db4o database, would you recommend a large flat table, or a hierarchy? -

i have 2 million rows in flat db4o table. lot of information repeated - example, first column has 3 possible strings. i break table 4-tier hierarchy (i.e. navigate root >> symbol >> date >> final table) - worth speed , software maintenance point of view? if turns out cleaner break table hierarchy, recommendations on method achieve within current db4o framework? answers questions to answer question, need more information. kind of information store? i'm storing objects containing strings , doubles. hierarchy exactly, in concept, file system directories, sub-directories, , sub-sub-directories: single root node contains array of subclasses, , each sub-class in turn contains further arrays of sub-sub-classes, etc. here example of code: // rootnode---| // sub-node 1----| // |-----sub-sub-node 1 // |-----sub-sub-node 2 // |-----sub-sub-node 3 //

nhibernate - iBatis / MyBatis opinion -

what opinion on ibatis / mybatis? respect performance , flexibility. how think stacks against other c# orms? is c# version pretty stable , usable? caching work well? i mybatis, so, there few bugs i've seen. for instance, when implemented paging solution, had write interceptor told mybatis stop caching stuff because saw record, , rowcount, , reason created "cache key" used presence of record (not doing "equals" call on it) , rowcount matched next record , rowcount (though different record , if equals invoked, wouldn't have matched). later included rownum around similar issue. interceptor had introspect (yuck!) via breaking access reflection in order see if handler our own handler, because there no getter field , private. secondly, i've seen mybatis construct object return, null, returned null instead of record constructed - serious bug. got around because thing returning versioned, version wasn't null, returned , hence record

Method and variable scoping of private and instance variables in JavaScript -

i have tried figure out or search on google, can find how create objects, not how functions work. if explain me how encapsulation works. function myobject() { this.variable1 = "tst"; this.function1 = function() { //now function works. 'this' function private function ok _privatefunction1(); //here error one, cannot seem call methods within object //from. this.function2(); } this.function2 = function() { alert("look! function2!"); } function _privatefunction1() { //this work though. confused. _privatefunction2(); } function _privatefunction2() { alert("look! privatefunction1"); //this not work. alert(this.variable1); } } i think can explain better if go in reverse order. first, define functions: function _privatefunction1() { //this work though. confused. _privatefunction2(); } function _p

php - Auto - Check Username -

how go auto checking username user enters on html form? project i'm working on , need finished. not have code i'm working now, haven't found useful on this. you have construct validation routine first before can anything. imagine take in string , returns boolean depending on if finds given string in table of usernames. next, have attach javascript event fire off on keypress when field in focus. javascript event pass string in field validation check. then, have catch reply , react accordingly (display success/error div or whatnot.) i can try , churn out code if want php know using codeigniter , javascript know using jquery code put out using frameworks.

asp.net - Show progress img while loading a page -

i want show loading gif while page loading. opening popup window javascript using window.open. want display image when mozilla or ie progress bar being shown gmail when login. there way can achieve this? i know how show loading img after page loaded want progressbar of browser you need add pre-loading progress bar script. please see links http://davidwalsh.name/mootools-image-preloading-progress-bar http://davidwalsh.name/dw-content/image-preloader.php

math - Finding angle between two unit vectors in three dimensions -

i trying basic 3d simulation has been 20 years since learned stuff in high school... if have 2 vectors in 3 dimensions, how find angle between them. example have 1 vector of (3,2,1) , of (4,-5,6) how find angle (in degrees or radians) between them. if recall there formula this. thanks. here go

php - How can I let my visitors compare (and rate) two images displayed from a mysql database? -

so have set mysql database holds image (more path image) , images rank (starting @ 0). created web page displays 2 images @ random @ time. [up till here works fine] want users able click on 1 of images better , images rank increase +1 in database. how set up? please detailed possible in explanation. new php , mysql. you need this. a table images: id,name,path,ranking have 1 vote button ( update images set ranking = ranking + 1 id = $id; ) have 1 down vote button ( update images set ranking = ranking - 1 id = $id , ranking > 0; ) hopefully solves problem.

javascript - How to watch for array changes? -

in javascript, there way notified when array modified using push, pop, shift or index-based assignment? want fire event handle. i know watch() functionality in spidermonkey, works when entire variable set else. there few options... 1. override push method going quick , dirty route, override push() method array 1 : object.defineproperty(myarray, "push", { configurable: false, enumerable: false, // hide for...in writable: false, value: function () { (var = 0, n = this.length, l = arguments.length; < l; i++, n++) { raisemyevent(this, n, this[n] = arguments[i]); // assign/raise event } return n; } }); 1 alternatively, override array.prototype.push() ... though, messing array.prototype ill-advised. still, if you'd rather that, replace myarray array.prototype . now, that's 1 method , there lots of ways change array content. need more comprehensive... 2. create custom observable array rather overriding

objective c - NSArray (and other Cocoa types) @property values -

while in process of debugging code written co-worker, stumbled across following has me mystified: nsmutablearray *array = [nsmutablearray array]; nsuinteger arraycount = array.count; why work? works nsdictionary , other types, in documentation nor cocoa headers can @property definitions found. googling "nsarray property" doesn't yield many useful results, i'm reaching out surely embarrassing question. it works because dot syntax has nothing properties. syntactic sugar (though don't it, perhaps it's "syntactic salt"). when use dot syntax rvalue expression (or expression right of equal sign), simple turns: bar = myobject.thing; into bar = [myobject thing]; when dot left of equal sign (as lvalue), turns setter. so: myobject.thing = 42; becomes [myobject setthing:42]; so yes, can things myobject.retain . you should never ever that . should ever use dot syntax accessors declared properties (ie, things have been e

directx - Find out which display belongs to which adapter? -

i'm working on slimdx apps works multiple display. apps occupy selected display, , it's selection input via commandline, int. use system.windows.forms.screen.allscreens[selection] find out bound, , display apps "fullscreen" on display. now, optimize performance, need select gpu adapter initialize direct3d's device. how find out gpu adapter powering selected display? since each gpu adapter might have 1 2 display connected, can't use display number. i'm utilizing direct3d10. don't mind solution in direct3d9. worse case let user select display , adapter via commandline, prefer fool prove method. thanks both d3d10 , d3d11 use dxgi managing details this. factory interface create lets list of adapters installed on system. each adapter can have 1 or more outputs, can enumerate adapter interface. this list of output interfaces, have description property contains, among other things, rectangle of output's bounds intptr handle monit