Posts

Showing posts from June, 2013

c# - How do you resolve a Ninject dependency in the global file in ASP.NET? -

i using ninject , ninject.web assemblies web forms application. in global.asax file specify bindings so: public class global : ninjecthttpapplication { protected override ikernel createkernel() { ikernel kernel = new standardkernel(); // vendor briefs. kernel.bind<ivendorbriefrepository>().to<vendorbriefrepository>().inrequestscope(); kernel.bind<ivendorbriefcontroller>().to<vendorbriefcontroller>().inrequestscope(); // search services. kernel.bind<isearchservicescontroller>().to<searchservicescontroller>().inrequestscope(); kernel.bind<isearchservicesrepository>().to<searchservicesrepository>().inrequestscope(); // error logging kernel.bind<ierrorlogentrycontroller>().to<errorlogentrycontroller>().inrequestscope(); kernel.bind<ierrorlogentryrepository>().to<errorlogentryrepository>().inrequestscope(); retur

Java: Why is this code not working? -

can tell me what's wrong java code? array : static string [][] data = new string[6][2]; in case, data[0][1]="abcd" , data[1][1]="efgh" , remaining data[2-5][1] should null . trying print out non- null ones. @ (j=2,k=3) , code doesn't executed after that. eg, "i here3" doesn't printed. int k=1; system.out.println("data[2][0]="+data[2][0]); for(int j=0; j<data.length; j++,k++) { system.out.println("j="+j+" k="+k); if (!(data[j][0].equals("null"))) { system.out.println("i here2"); sbissues = sbissues.append("\n"); sbissues = sbissues.append(k); sbissues = sbissues.append(". "); sbissues = sbissues.append(data[j][1]); } system.out.println("sbissues="+sbissues.tostring()); system.out.println("i here1"); } system.out.println("i here3"); the output looks like: data[2]

c# - For-each loop variable -

what ob means in following code - same item? foreach (var item in allitems) { if (excludeitems.exists(ob => ob.equals(item))) { console.writeline("item {0} excluded",item); } } ob parameter lambda expression . if you're familiar anonymous methods, it's like: foreach (var item in allitems) { if (excludeitems.exists(delegate (string ob) { return ob.equals(item); }) { console.writeline("item {0} excluded",item); } } that's assuming type of ob should string - may not be. depend of excludeitems , due generic type inference. lambda expressions can more explicit, could written as: if (excludeitems.exists((string ob) => { return ob.equals(item); }) or if (excludeitems.exists((string ob) => ob.equals(item)) basically there several little shortcuts in lambda expressions common case of single parameter type can inferred, , return value single expression. now in particular case, dele

R: How to change the text of strips in R's lattice xyplot -

i trying use function histogram plot density of data. sample format of data follows: library(lattice) index<-c(1,1,1,2,2,2,2) freq<-c(3,4,6,3,6,2,2) d<-data.frame(index,freq) histogram(~d$freq|d$index) i want have index number printed strip text each histogram (i.e. in example, 1 , 2 on top of histograms respectively instead of printed d$index ), don't know of easy way (i know have use strip.custom() possibly, , change var.name properly, don't know how iterate on according index) if change index variable factor supposed default behavior, i.e. printing shingle levels in strip: library(lattice) index<-factor(c(1,1,1,2,2,2,2)) freq<-c(3,4,6,3,6,2,2) d<-data.frame(index,freq) histogram(~d$freq|d$index) just fun can play style variable in strip.default: histogram(~freq|index, data=d, strip = function(..., style){ strip.default(..., style = 4)} )

android - Long press list item to open pop up menu -

hello im trying make small menu pop once item long pressed in list view can 1 point me in right direction accomplish this? these posts contain possible solutions problem: long click on list activity item show context menu long-clicks in android listview click & long-press event listeners in listactivity contextmenu not popping on long click i hope helps.

ruby - Rails - PostGIS + postgis_adapter Geometry Problem -

i use postgis_adapter alongside postgresql 9.0.4, postgis 1.5.2 , rails 3.1.0 on ruby 1.9.2. described in the postgis_adapter readme, tried perform model.create(:geom => point.from_x_y(10,20)) postgres responds with error: parse error - invalid geometry hint: must specify valid ogc wkt geometry type such point, linestring or polygon the created georuby object looks this: #<georuby::simplefeatures::point:0x0000010420a620 @srid=4326, @with_z=false, @with_m=false, @y=20, @x=10, @z=0.0, @m=0.0> hopefully got idea. executive summary: may work if change to: model.create(:the_name_of_your_geo_column => point.from_x_y(10,20)) longer version, high probability of ruby howlers: i've barely written word of rb saw 1 many great projects week continue in state of ignorance. working through error messages in irb (starting 0 in language familiar postgis): activerecord::base.establish_connection(:adapter=>'postgresql',:database=>'moveabl

XCode 4 - using GCC 4.0 to compile? -

code coverage xcode 4 works on gcc 4.0. how can set compiler use gcc 4.0 instead of gcc 4.2. need download 4.0 ? gcc 4.0 not installed xcode 4. can following directions in this question adding support 10.4 , 10.5 sdks xcode 4.

iphone - Method didn't work in UIScrollView -

hello put uitextfield in uiscrollview,and connect them in interface builder event "touch down" method,the problem when uitexttfield inside uiscrollview method doesn't called , when textfield not in uiscroll view method doesn't called. uiscrollview special because of touch events needs process itself. try sub-classing uiscrollview , add: -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event { nslog(@"you should see touch events on scroll view"); } set class name in ib uiscrollview subclass.

Checking file permissions for a specified user account in Java -

i'm running java application windows service , using java application, executed user, set directory used windows service application. is there way in java determine file permissions of directory user? in case, want know file permissions of windows service application while running separate java application executed user. this kind of filesystem support not available in standard java, because java cross-platform , filesystem security differs across platforms (or may not exist @ all). however, there plans add support java 7 (which have been waiting years get!) if using on windows , know c/c++, can use jni (java native interface) jna tap windows dlls , information. otherwise, can trial or paid version of jniwrapper works out-of-the-box. i'm not sure if provides support file security, provide other filesystem support - you'll need review feature list.

c# - Appending filename of savedialog to the file wich is going to be saved -

i trying append name of file in first line of text file going saved. how can it? here code. couldnt find method stringbuilder append @ beggining of instance. stringbuilder sb = new stringbuilder(); sb.appendline("blah blah"); if (savefile.showdialog() == dialogresult.ok) { //how append file name @ beggining of file saved? file.writealltext(savefile.filename, sb.tostring()); } thanks. add line before call writealltext: sb.insert(0, savefile.filename + environment.newline); -- or -- string outstring = savefile.filename + environment.newline + sb.tostring(); file.writealltext(savefile.filename, outstring);

Linux Driver for Roland GR-55 -

currently roland not make drivers linux, starting project write driver roland gr-55 guitar synthesizer, after looking around, find have several options , not sure best or current method, thought i'd ask before waisting lot of time on this. this device uses usb, controls midi , audio devices in gr-55. alsa or libusb api 2 choices; both new me; been years since wrote device driver , unix in 80's, know can figure out how, once know tools use, i'm guessing both use c still; have looked @ libusb api; nice; have no idea alsa project; seems geared getting modules kernel achieve this. i find programmers have worked roland device drivers dealing midi , audio might able point me in right direction; have asked roland help; waiting reply, not wanting hold breath, think getting started best option; if help, suppling technical specs, great. i hope gave enough details; not else when asking question device drivers.

post - Cannot force an update in save() with no primary key. Horror ! -

i don't know do, i'm 'blank'... i have function querys database using request.get , fills form, can change contents , save updating information. problem id isn't passed function , django opts insert instead of update, here's code: look @ mess: def meet_save(request): if request.method == 'post': form = meetingform(request.post) if form.is_valid(): creator = get_object_or_404(submitter, name=request.user) meeting = meeting(creator=creator) meeting.ave = form.cleaned_data['ave'] meeting.st = form.cleaned_data['st'] meeting.date = form.cleaned_data['date'] #it supposed work save() #i tryed meeting.save(force_update=true) #and figured out id missing meeting.save() people in form.cleaned_data['people']: meeting.people.add(people) return httpresponseredirect('/meeting/register/') elif request.get.ha

drupal - Can't create custom handler for Views2 -

basically want create custom handler unserialize db field called birthday. i've managed correctly output field serialized using default views_handler_field. unfortunately when try create custom handler, message: error: handler drappsprofiles > birthday doesn't exist! here's file structure: all/modules/drapps/drappsprofile/ |->drappsprofiles.views.inc |->drappsprofiles.module |->drappsprofiles.install |->drappsprofiles.info |->drappsprofiles.inc |->drappsprofiles_handler_field_birthday.inc here's drappsprofiles.module /** * views2 module * implementation hook_views_api **/ function drappsprofiles_views_api() { $info['api'] = 2; return $info; } /***************************************************************************** * includes **/ // loads google apps profile integration module_load_include('inc', 'drappsprofiles'); (...) here's drappsprofil

rubygems - Using RVM, how to ensure gems and non-gems see the same version of ruby? -

i'm trying install bdb on ubuntu gem follows, gem install bdb i'm not using sudo, since installing rvm. ruby version on system 1.9.1 version i'm using installation 1.8.7 (i'm installing rbot, see). problem i've encountered is: checking db_version() in -ldb-4.something... no i assume means rubygems not finding ldb4.something in places looking. because installed libdb-4.something (7, actually) using sudo, , system's ruby version different ruby version i'm using bdb? using rvm, how should manage sort of situation? maybe i'm doing things wrong, seems me problem not i'm using gem, , stuff isn't gems seeing wrong version of ruby. (if turns out problem unrelated: still interested in question. how things i've installed on system particular version of ruby along gems installed using rvm under different versions of ruby?) "how things i've installed on system particular version of ruby along gems installed using rvm under

javascript - Move validation message to a new place -

<p class="section requiredtext">some text<br /> <textarea class="title required" id="foo" name="foo"></textarea> </p> how jquery validate show "required field" error message on same line "some text" title. tried few things, cant right. lot. $('form').validate({ errorplacement: function(error, element) { error.prependto(element.parent()); } });

newline - What is the easiest way convert line endings to unix style when creating tar file in Gradle? -

at work use mixture of windows , linux workstations during development. deployment deploy unix machines. i'd ensure line endings in unix format. easiest way in gradle achieve this? thinking might possible use filterreader didn't manage find ready made one. best option? editing entry use copy task instead. initial version of using tar task noticed while stripping crlf when run in linux on windows failing work correctly. since they're both copyspecs afaik have expected tar tasks work same sadly not case (gradle 1.0-milestone-3). looks i've figured out myself. filterreader required fixcrlffilter. following snippet shows how might use it: import org.apache.tools.ant.filters.*; task archiveit(type: copy) { "conf" "targetdir" filter(fixcrlffilter.class, eol:fixcrlffilter.crlf.newinstance("lf")) }

c# - how to write client side events functions for the combobox items -

<dx:aspxcombobox id="aspxcombobox2" runat="server" clientidmode="autoid" selectedindex="-1" onselectedindexchanged="aspxcombobox1_selectedindexchanged1" > <clientsideevents selectedindexchanged="function(s, e) { grid.selectrows();}" /> <items> <dx:listedititem text="selecte rows" /> <dx:listedititem text="unselectall" /> </items> </dx:aspxcombobox> i want write event "unselect all" item in combobox. how can this? you'll need write javascript function iterates thru combo-box , marks selected items false. see select/unselect checkbox fields using pure javascript , html sample code msdn:

firefox - counting jquery script tags with xpath -

i want use document.evaluate expression in userscript able detect presence (or absence) of existing jquery library in document head, part of developing jquery wrapper userscripts work in firefox , chrome, , not conflict other libraries (what i'm hoping insert library , jquery code, if necessary, before other script tags , have them run in no conflict mode.) long story short, statement not appear work: jqueryscript = document.evaluate("//*script[contains(@src, 'jquery')]", document.head, null, xpathresult.ordered_node_snapshot_type, null); when try test if jqueryscript.snapshotlength > 0, script fails. incredibly new @ xpath please me understand this. jqueryscript = document.evaluate ("//script[contains (@src, 'jquery')]", document.head, null, xpathresult.ordered_node_snapshot_type, null); should work. but note on sites (like so) yield false hits. eg: <script ... src="http://engine2.adzerk.net/z/8277/adzerk2_2

Critical tunnel failure error blackberry -

i have developed app blackberry ,its approved appworld gives following error on 4.6 critical tunnel failure and on 5.0 , 6.0 ava.io apn not specified please why error coming , how solve it i think problem didn't add appropriate connection suffix url. follow link can solve problem:http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/what_is_-_different_ways_to_make_an_http_or_socket_connection.html?nodeid=826935&vernum=0 and ou can use following sample code: private static string getconnectionstring(){ string connectionstring=""; if(wlaninfo.getwlanstate()==wlaninfo.wlan_state_connected){ connectionstring=";interface=wifi"; } else if((coverageinfo.getcoveragestatus() & coverageinfo.coverage_mds) == coverageinfo.coverage_mds){ connectionstring = ";deviceside=false"; } else if((coverageinfo.getcoveragestatus() & coverageinfo.co

Problems in executing a query in mongodb -

i have exception being thrown mongodb connection wed may 11 10:39:33 assertion: 10057:unauthorized db [inbox] lock type: -1 where inbox database. using php driver connection. problem using admin username , password connection still throwing unauthorized. can please provide insights. authenticating admin requires run authenticate command in admin database before changing regular database. authenticating admin user say, test not work. for case, connect admin , run authenticate admin user, , handle on inbox . alternately should create user specific inbox database safety. connecting superuser application isn't best idea.

Displaying HTML Content in Blackberry Browser Field? -

i not able display html content in browser field. used utf-8 encoding method. html content <!doctype html public '-//w3c//dtd html 4.01 transitional//en'><html><head><title></title></head><body><p><strong>welcome &hellip; </strong></p> <p style="text-align: center;"><span style="color: #003366;">warning! - life may never same after downloading cool &#039;know yourself&#039; tool&hellip; , it&#039;s fun!</span></p> <p><span style="color: #003366;"><strong><em>understand relationships friends &amp; family!</em></strong></span><br /><br /><span style="color: #003366;">why can&#039;t relate parents?</span><br /><span style="color: #003366;">why argue best friend?</span><br /><br /><span style="color: #003366;

oop - Differences in function declarations in a Javascript constructor function -

i'm confused different ways declare functions inside constructor function. function classname() { this.one = function() {}; var 2 = function() {}; 3 = function() {}; } i know one public , can called outside , two private. semantics three ? the example have provided syntax error, need use = assignment in context. three if used correct assignment operator global function exist outside of scope. when omit var keyword, variable assigned property of global object, window in browser. jsfiddle . when using var , become properties of variableobject in execution context. use them normal variables. further reading .

javascript - What would be php equivalent of this code? -

var oktags = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i; var oklinks = /^(<a\shref="(\#\d+|(https?|ftp):\/\/[-a-za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i; var okimg = /^(<img\ssrc="https?:(\/\/[-a-za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i; text = text.replace(/<[^<>]*>?/gi, function (tag) { return (tag.match(oktags) || tag.match(oklinks) || tag.match(okimg)) ? tag : "" }) replace() can replaced preg_replace() and match() preg_match() powerful check manual see how work code, not different, , can use call function too.

iphone - compilation error for navigation controller -

i new in objective c. don't know more things this. practicing on navigation controller. problem whatever methods putting in action: @selector in shows sigabrt error. clarify me types of methods can put in action: @selector section. though know it's silly question think these clear concept on navigationviewcontroller . thank you. - (void)viewdidload { uisearchbar *search=[[uisearchbar alloc] init]; self.navigationitem.rightbarbuttonitem=[[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemsearch target:self action:@selector(searchbarshouldbeginediting:)]; [super viewdidload]; } - (bool)searchbarshouldbeginediting:(uisearchbar *)searchbar{ uisearchbar *search=[[uisearchbar alloc] init]; [search resignfirstresponder]; return yes; } try moving '[super viewdidload]' beginning of viewdidload method, not end. need make sure controls exist before add right bar button item.

objective c - How to save comment entered in textview to the map current location in iphone -

i have map application in there 3 buttons picture,video , comment.when user clicks on picture button opens camera taking pictures , same video ,he can take video .this 2 buttons done.when user clicks on third comment button comment page opens can enter comment title , enter comment , when clicks on submit button comment user has entered posted current location.please can me in solving problem on how save comment current location on map.thanks annotation view small showing entire comment. such things done like: 1) user touch pin 2) annotation view showing text (for you, exmaple, part of comment) , detail disclosure button 3) when user click on detail disclosure button new view controller entire comment pushed.

java - How to prevent ant build changing national characters when replacing characters in xml -

the problem facing whenever try build app ant need change values in strings.xml. value parsing through replacefilter swedish national characters. getting changed after buid done. in build.xml write : <replace file="res\values\strings.xml"> <replacefilter token="@app_name@" value="${application.name}" /> in properties file: ånimal in strings.xml value <string name="app_name">@app_name@</string> getting changed <string name="app_name">ånimal</string> i've tried using utf-8 , iso-8859-1 in both build.xml , strings.xml got answers? please help. the problem not in <replace> task, in <property file="..."/> . value first incorrectly translated. use following instead: <loadproperties srcfile="application.properties" encoding="utf-8"/>

Creating lists do not include duplicates in Prolog -

**facts** player(milan,[seedorf,zambrotta,gattuso]). player(inter,[seedorf,ronaldo,zambrotta]). player(realmadrid,[seedorf,zidane,ronaldo]). i wanna create predicate such : find (team, players) and if goal find(x,y) returns list of teams,x, , list of players,y, without duplicates... below: x=[milan], y=[seedorf,zambrotta,gattuso]; x=[inter], y=[seedorf,ronaldo,zambrotta]; x=[realmadrid], y=[seedorf,zidane,ronaldo]; x=[milan,inter] y=[seedorf,zambrotta]; x=[milan,realmadri] y=[seedorf]; ... x=[milan,inter,realmadrid] y=[seedorf]; ... i try gives "error: out of local stack", if not use remove_dups predicate, list of teams,"x", have duplicates , program not stop... keep going x=[milan,milan,milan,milan,inter] .... how can correct code. ?: find([x], y) :- player(x1, y),remove_dups(x1,x). find([x|xs], y) :- player(x1, y0),find(xs, y3), intersection(y0, y3, y),remove_dups(x1,x). remove_dups([],[]). remove_dups([first|rest],newrest):-member(first, re

python - What is the best pythonic way of wrapping an object? -

i able wrap object in python. following not seem possible, know why? class wrapper: def wrap(self, obj): self = obj = list() b = wrapper().wrap(a) # can't b.append thank you! try getattr python magic : class wrapper: def wrap(self, obj): self.obj = obj def __getattr__(self, name): return getattr(self.obj, name) = list() b = wrapper() b.wrap(a) b.append(10)

java - JAXB, how to skip class tag when included -

i'm trying xml: <person> <foo>thing</foo> <bar>other</bar> </person> from code public class person { private innerthing in; } public class innerthing { private string foo; private string bar; } with jaxb java annotations. by default, get <person> <innerthing> <foo>thing</foo> <bar>other</bar> </innerthing> </person> how can skip innerthing tag annotations? you use eclipselink jaxb (moxy) 's @xmlpath annotation solve problem (i'm moxy tech lead): import javax.xml.bind.annotation.xmlaccesstype; import javax.xml.bind.annotation.xmlaccessortype; import javax.xml.bind.annotation.xmlrootelement; import org.eclipse.persistence.oxm.annotations.xmlpath; @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class person { @xmlpath(".") private innerthing in; } for more information: http://bdough

Empty strings in sql -

m having 2 tables 1) hr_pay_employee_payslip_history_details 2)hr_pay_employee_payslip_history table 1 has pay_head_id,payslip_history_id , value columns table 2 has employee_id,payslip_history_id columns i map table 1 , table 2 on payslip_history_id retrieve employee_id,pay_head_id,value the problem is, employees not have pay_head_ids , values how can retrieve pay_head_ids of employees , values(0.00 incase value not stored) ?? this may vary depending on dialect of sql you're using, you'll need use left outer join, this: select employee_id, pay_head_id, isnull(value, 0.00) value hr_pay_employee_payslip_history history left outer join hr_pay_employee_payslip_history_details details on history.payslip_history_id = details.payslip_history_id

fortran - Progress bar. [gfortran vs ifort] -

i have wrote genetic algorithm in fortran able compute long double precision generic fitness function. first version (double precision) wrote gfortran have implemented progress bar. have compile ifort because gfortran not capable of perform real*16 calculations. works fine in case (ifort) progress bar not works properly. namely when whole cycle completed progress bar printed std output. here piece of code progress bar: if (rate(i).gt.ratemax) ratemax=rate(i) write(*,"(1x,a57,d12.4,a27,f6.2,a1)",advance="no") & '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ff: ', & ratemax,' progress:',100.*real(nmix)/real(nmixing),'%' end if i use intel xeon of 64bit , options ifort are: ifort -o2 -assume bscc ffevalld.f90 func.o -o ffevalld while when use gfortran compile in way: gfortran -ffree-form -o2 -fbackslash ffeval.f func.o -o ffeval in gfortran

Android Device specific Camera Path -

the project working on requires me store images/ videos same folder device native camera stores them. per research have found each device stores images/videos different name. nexus-one stores camera files in folder named "camera" (/sdcard/dcim/camera). htc incredible stores camera files folder named "100media" (/sdcard/dcim/100media). sony xperia x10 stores camera files folder named "100andro" (/sdcard/dcim/100andro). want know if programatically possible path can store images/videos taken app same location.??? there api may or work around required. if can u pls suggest me same. please guys pretty urgent , important. appreciate , glad response soon. looking forward replies. ton in advancce... afaik, base directory videos , photos accessible in standard way through environment class. think you'll have let user configure target directory themselves. nothing prevents making intelligent suggestions user, though.

d - How to install two versions of Qt and tell the application which to use? -

i developing application in qt, using d language (with qtd binding). i've noticed app crashes qt 4.7.x, need use qt 4.6.2 instead. in system qt 4.7.2 installed. unfortunately neither make qtd work latest qt versions nor (i'm afraid) count on qtd developers... the thing need make application install in system qt 4.6.2 libs , use it, let other applications still use qt 4.7.2. possible? if is, how then? the answer question version of qt determined qmake use generate makefile. /opt/qtsdk/qt-4.6.2/bin/qmake /opt/qtsdk/qt-4.7.3/bin/qmake each use library in directory.

Accessing Unknown 'ID' class method-Objective C -

rs232msggeteventdescriptions.h: #define declare_rs232_newmsg(classid)\ enum \ { \ id = classid \ }; \ @interface rs232msggeteventdescriptions : rs232msg { } @end rs232msggeteventdescriptions.m @implementation rs232msggeteventdescriptions declare_rs232_newmsg(rm_get_event_descriptions); @end eventlogs.m -(void)event { service = [cserviceappdlg alloc]; if ([service:(remote_message_id)rs232msggeteventdescriptions.id withevent:pevent]) { nslog(@"get event descriptions!!"); } } i'm getting error "accessing unknown 'id' class method" should not modify definition here.how pass id.i going call different descriptions id in same way declaration of id. the reason why getting accessing unknown 'id' class method error message because have not declared method called id in class rs232msggeteventdescrip

Syntax errors can be caught in JavaScript? -

mdn states : a syntaxerror thrown when javascript engine encounters tokens or token order not conform syntax of language when parsing code. but if there's syntax error, how program run in first place? how can javascript syntax errors caught? it's runtime errors can caught try-catch, not syntax errors ( if eval code can handle syntax errors in evaled code that's weird). i'd recommend read these: https://developer.mozilla.org/en/core_javascript_1.5_guide/statements#try...catch_statement https://developer.mozilla.org/en/core_javascript_1.5_guide/statements#exception_handling_statements

javascript - When I print my webpage I lose all the css colouring. Is there an option or script to print a webpage exactly how it looks? -

Image
my webpage has table mainly. tables columns have different background. when print lose background colours though printing in colour. the colours not gray, don't come up you can specify background gets printed in browser options, @ least in firefox can anyway.

java - Listing Windows file types -

how can java program list of file types in windows (those listed in control panel/folder options/file types)? the list of registered file types present in registry under hkey_classes_root key. if key begins . registered file extension. take @ msdn > file types more information how stored in registry. you can query registry using reg command. example, in command prompt type following command list out file extensions. reg query hkey_classes_root | find "hkey_classes_root\." to execute java program, use processbuilder .

python - Got an error while connecting to database -

i unable connected database in linux using psycopg2. have postgresql installed in linux , code is: import psycopg2 def testegg(): conn = psycopg2.connect("dbname = mydatabase user = postgres port = 5432") cur = conn.cursor() cur.execute("create table egg ( num integer, data varchar);") cur.execute("insert egg values ( 1, 'a');") conn.commit() cur.execute("select num egg;") row = cur.fetchone() print row cur.close() conn.close() testegg() and got error: psycopg2.operationalerror: fatal: ident authentication failed user "postgres" this code runs in windows7 got above mentioned error in linux . there need more in linux? suggestion appreciated. thank you. it's not problem due code, due permission of postgres user. you should create new user access database , replace : conn = psycopg2.connect("dbname = mydatabase user = postgres port = 5432")

python - How to get twitter followers using Twython? -

i want list of twitter followers/following of particular user, when screenname or user.id specified. can please give code snippet it? thanks. i'm author of twython. there's 2 different methods can use this; 1 returns follower ids (get_followers_ids), , 1 returns statuses/etc of follower set (get_followers_list). some example code 1 following: from twython import twython twitter = twython() followers = twitter.get_followers_ids(screen_name = "ryanmcgrath") follower_id in followers: print "user id %d following ryanmcgrath" % follower_id if have ids, you'd need further lookups yourself, latter method (get_followers_list) may want. keep in mind twython functions mirror api key parameters official twitter api docs, methods can pass argument same you'll find on docs. good luck!

ruby on rails - link helpers, current_pages and navigation -

i'm trying keep tab on page selected checking controller. i.e., page displays products controller should keep product tab selected. can't seem find right approach. considering of making helper method, seems bit tricky put helper link_to helper. here guess of how can make work: <%= link_to "products", products_path, current_controller?('products') ? :class => 'selected' %> anyone has better idea? and problem wont in 1 place, you'll have many tabs , each tabs have rules on controllers+action combinations active/selected for. it's common problems , people have written "plugins" same too. i suggest write helpers. make own mini dsl. decide easy , nice at: <%= link_to_tab_for("products", products_path, :controller => "sss", :action => "", :other_html_options => {}) next step, implement method in helpers/application.rb def link_to_tab_for(name, path, options)

java - Is there possibility of sum of ArrayList without looping -

is there possibility of sum of arraylist without looping? php provides sum(array) give sum of array. the php code like $a = array(2, 4, 6, 8); echo "sum(a) = " . array_sum($a) . "\n"; i wanted same in java: list tt = new arraylist(); tt.add(1); tt.add(2); tt.add(3); once java-8 out (march 2014) you'll able use streams: if have list<integer> int sum = list.stream().maptoint(integer::intvalue).sum(); if it's int[] int sum = intstream.of(a).sum();

android - Out of memory, showing AlertDialog and making changes in orientation -

i have activity containing 2 imagebuttons. if user clicks alertdialog shown. while alert shown, if orientation changed , forth few times application crashes message: error/dalvikvm-heap(10988): 3363556-byte external allocation large process. error/dalvikvm(10988): out of memory: heap size=4935kb, allocated=2594kb, bitmap size=19579kb error/graphicsjni(10988): vm won't let allocate 3363556 bytes if alertdialog not there, application doesn't crash. public class startpageview extends activity implements onclicklistener, android.content.dialoginterface.onclicklistener { private static final string tag = "startpageview"; private imagebutton vacbutton; private imagebutton sickbutton; private alertdialog alert; private static boolean alertdismissedbylifecycle = false; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.startpage); vacbutton = (imagebutton)findvie

java - How can I make my xml safe for parsing (when it has & character in it)? -

i've been given xml string need put through parser. complaining because of illegal xml character. simplified example: <somexml>this & that</somexml> i know solution replace & &amp; , i'm not generating xml , therefore have no control on values. a simple string replace not right way to since '&' has special meaning in xml , global replace of '&' '&amp;' ruin special meaning intended. there solution take full xml document , 'fix' '&' become '&amp;', intended? safe globally replace ' & ' ' &amp; ' (note spaces on either side)? i think interesting question, because it's situation may happen in real-life. although believe right thing asking xml provider fix xml , make valid, thought 1 option trying lenient parser. did search , found blog post talking same problem, , suggesting same solution think of. may try jsoup . let me repeat think not

java - GWT: Could not locate RequestContext method -

i have public interface myrequestfactory extends requestfactory { @service(client.class) public interface clientrequest extends requestcontext { request<list<clientproxy>> getclients(); request<clientproxy> findclient(int id); instancerequest<clientproxy, void> persist(); instancerequest<clientproxy, void> remove(); } } i calling method with myrequestfactory.clientrequest request = requests.clientrequest(); request<clientproxy> getreq = request.findclient(clientid); getreq.fire( new receiver<clientproxy>() { @override public void onsuccess(clientproxy response) { display.getbreadcrumptextbox().settext( response.getbreadcrump() ); display.getintroductiontextarea().settext( response.getintroduction() ); } @override public void onfailure(serverfailure err

architecture - 64bit Applications and Memory Limits -

can explain me how 64 bit applications, 64bit os, , 64 bit cpu fit establish how memory addressable application? for example, how addressable memory application affected if run 64bit application on 64bit cpu, 32bit os? or 64bit cpu 64bit os , 32bit application? what happens when run 64bit application on 32bit cpu? you can't run 64-bit application on 32-bit cpu/os. a 64-bit os running on 64-bit processor has unlimited memory. address space 0 2^64, or 18.4 exabytes. a 32-bit application running on 64-bit os/processor gets 32-bit address space, 4gb. more detail: http://cnx.org/content/m13082/latest/

Cross platform makefiles for small Haskell project? -

i built small, one-file haskell utility included in 'tools' section of otherwise pure php (raised eyebrows, know) project. initially checked in both .hs source file binary generated on linux development machine version control system use (git). think more it, i'd create cross platform makefiles go along other developers can compile on systems. are there best practices / guidelines, or better, makefile templates available can download? nothing fancy, allows developers specify details ghc setup , run simple script started. the recommended way of distributing haskell projects use cabal . cabal both build system , package manager haskell code, , makes easy build haskell code on different platforms while handling dependencies you. here's example cabal file: name: mypackage version: 0.0 cabal-version: >= 1.2 license: bsd3 author: angela author synopsis: small package utility program build-type: simple executa

SQL Concatenation filling up tempDB -

we attempting concatenate possibly thousands of rows of text in sql single query. query have looks this: declare @concattext nvarchar(max) set @concattext = '' update top (select max(pagenumber) + 1 #orderedpages) [#orderedpages] set @concattext = @concattext + [columntext] + ' ' (rtrim(ltrim([columntext])) != '') this working fine functional standpoint. issue we're having columntext can few kilobytes in length. result, we're filling tempdb when have thousands of these rows. the best reason have come we're doing these updates @concattext, sql using implicit transactions strings immutable. we trying figure out way of solving problem , far have 2 possible solutions: 1) concatenation in .net. ok option, that's lot of data may go across wire. 2) use .write operates in similar fashion .net's string.join method. can't figure out syntax bol doesn't cover level of sql shenanigans. this leads me question: .write work? i

vim - How to get the autocomplete to fill in full_methods instead of just full -

i write lot of methods "like_this". when press "l< tab >" autocomplete offered "like". there way configure vim give me "like_this" option? kindest of regards, -- jack @randy morris's comment worth exploring, type set completeopt? see have :help completeopt explore choices. but think that's because vim considers _ word delimiter default. check out typing :set iskeyword? , mine says iskeyword=@,48-57,_,192-255 . type :help iskeyword more information.

Php server response to android when executing a batch file -

i have application in java & have created batch file(.bat) of application & running in php this <?php system ("cmd.exe /c final.bat"); ?> the output this c:\wamp\www\php>java -jar closely reseambling this...c:\wamp\www\php>pause press key continue . . . i invoking through android application & want out response...can tell me how .... great if able eliminate prompts response. check out exec function . instead of automatically printing output, return output string, or in optional array of lines in second argument. can parse string or array , print need. example print first line of output: exec('cmd.exe /c final.bat',$output); for($i = 1; $i < count($output); ++$i) echo $output[$i],'<br />';

html - Form inside a table -

i'm including forms inside html table add new rows , update current rows. problem i'm getting when inspect forms in dev tools, see form elements closed after opening (inputs, etc not included within form). as such, submitting form fails include fields. the table row , inputs follows: <tr> <form method="post" action=""> <td> <input type="text" name="job_num"> </td> <td> <input type="text" name="desc"> </td> </form> </tr> any great, thank you. a form not allowed child element of table , tbody or tr . attempting put 1 there tend cause browser move form appears after table (while leaving contents — table rows, table cells, inputs, etc — behind). you can have entire table inside form. can have form inside table cell. cannot have part of table inside form. use 1 form around

Is there a way to post a message to a Facebook group's feed? -

i'm working on facebook app uses facebook groups, , i'd open feed dialog let user post notice group's feed. have user in group , i've got relevant permissions well. i've tried passing group's facebook id in https://developers.facebook.com/docs/reference/dialogs/feed/ feed dialog, facebook error. there doesn't appear programmatic way either: group's feed (described @ https://developers.facebook.com/docs/reference/api/group/ ) isn't documented accept posts either. there way post message group using graph api or 1 of other api methods? i made test , it's working other wall. i made post 'group_id/feed' message variable value , worked. logged app group owner. using facebook php-sdk : $facebook->api('group_id/feed', 'post', array( 'message' => 'testing...' )));

community server - Eval inside an ASP.net repeater doesn't work inside another control -

i have reapter control custom server side control inside of it. when place code: <%# eval("dateadded") %> inside item template of repeater works fine, when place inside custom server control inside repeater, doesn't work. possible parent.eval() or container.eval() context of reapeter rather custom control? the repeater databound, control placing eval statement in isn't. you'll need pass value control using property. for example: <uc1:mycontrol myproperty='<%# eval("dateadded") %>' /> you can access myproperty property inside control access value.

jquery - Trouble with a script for logging amount of facebook likes with mysql + php -

i trying write script log how many likes(facebook) page has in mysql using facebook api, ajax , mysql. @ moment isn't working. variables defined, connected mysql, , jquery embedded , i'm not getting , sql or php errors. can see i'm going wrong? source code: index.php: <?php $sql=mysql_query("select * likes order id desc limit 9"); while($row=mysql_fetch_array($sql)) { ?> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_us/all.js"></script> <script > fb.init({ status: true, cookie: true, xfbml: true }); fb.event.subscribe('edge.create', function(response) { alert(response); if (response == "http://fbquote.me/like.php?id=<?php print $row['id']; ?>") { $.ajax({ type: "post", url: "popular/ajax_pop.php", data: "id=<?php print $row['id']; ?>" cache: false, }); } }); </script>

tsql - Where/How to Create Reference Number -

i'm using entity framework , mssql... i need insert custom reference number when record inserted. format yyyy-01 , yyyy-02 , etc sequential number needs reset when new year begins. for example 2011-01 , 2011-02 , 2012-01 i'm curious if should go trigger or manage ef or ? having sequential numbering reset each year has me little confused... thanks advice! update: sorry, couldn't code tag work markup --variables declare @year    int ,         @seqnum  int ; --try to find if the [complaintcount] table already contains the current year set @year = (select [count_year]              from   [complaintcount]              where  [count_year] =  year ( getdate ())) --if the current year cannot be found in the [complaintcount] table, a new record for the current year needs to be made if @year is null   begin        --get the current year and set the initial sequence number to start counting for the new year       set @year =  year ( getdate ());       set @

How to escape double quotes in a WCAT scenario file? -

using wcat 6.3, i'd set http header including double quotes around etag: if-none-match: "a52391cbf838cd1:0" how escape double quotes in scenario file? snippet scenario file not working: request { url = "/css/navigation.css"; setheader { name = "if-none-match"; value = ""a52391cbf838cd1:0""; } statuscode = 304; } wcat based in c , scenario file uses of c syntax including escape character. correct syntax is: setheader { name = "if-none-match"; value = "\"a52391cbf838cd1:0\""; }

Question on Java Servlet to open a PDF file using iText -

the code below grabs pdf file , displays in browser. import java.io.bytearrayoutputstream; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.outputstream; import java.io.printwriter; import javax.servlet.servletconfig; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import com.lowagie.text.document; import com.lowagie.text.documentexception; import com.lowagie.text.pdf.pdfreader; import com.lowagie.text.pdf.pdfstamper; import com.lowagie.text.pdf.pdfstream; import com.lowagie.text.pdf.pdfwriter; public class welcomeservlet extends httpservlet { private static final string document_location = "h:\\testpdf.pdf"; // test pdf on pc @override public void init(servletconfig config) throws servletexception { super

iis 7 - What services are required for AppFabric to run properly and monitor WCF Services -

i'm running appfabric on iis7 windows 7 development. appfabric works fine period of time, stop updating. can send service requests through, , appfabric doesn't show them in dashboard when refresh it. i think service stopping, or there's permission issue. know services required appfabric run properly? sql server , appfabric event collection service, off top of head (for event collection; there other services, since appfabric runs requests, presume they're ok). there's event tracing windows, it's not, strictly speaking, service. i presume you've checked tracking profile set correctly , have looked in application event log?

iphone - How to read Xcode console output? -

as java , php developer new xcode, having trouble dealing memory errors. have sample program book, crashes on startup "program received signal 'sigabrt'." don't know console output below. realize it's kind of stack trace, name on left name of application, not class or file. don't know "main + 121" or "start + 53" means or look. guidance appreciated. 2011-05-11 10:43:23.071 flowerinfonavigator[22537:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[nscfdictionary objectforkey:]: method sent uninitialized mutable dictionary object' *** call stack @ first throw: ( 0 corefoundation 0x00dc25a9 __exceptionpreprocess + 185 1 libobjc.a.dylib 0x00f16313 objc_exception_throw + 44 2 corefoundation 0x00dbf542 -[__nsplaceholderdictionary objectforkey:] + 194 3 flowerinfonavigator 0x000

Asp.Net MVC2 Unit Test Controller: Request["Choice"] -

i new unit testing , trying learn tdd, cannot figure out how test this. spent 2 days on (don't worry not employer, please no smart answers). i wrote controller want test, need assign value "choice". simplified, looks this: public actionresult index() { string s = request["choice"]; return view(new mylist.getlist(s)); } how assign value "choice" in test or can i? in application, value of "choice" assigned radiobutton in form in page view. test in psuedocode: [testmethod()] public void indextest() { categorycontroller target = new categorycontroller(); var result = target.index() viewresult; mylist actual = result.viewdata.model mylist; // etc ... assert.areequal(expected.list, actual.list); } thanks, mario i'm pretty sure can accept choice parameter action method. no shenanigans necessary: public actionresult ind

iphone - Consequences of Singletons -

so delved singleton classes , yes, find them quite helpful. use singletons data storage multiple targets (views, tables etc.). being said, can see myself going implement lot of singletons in project. but can lot of singletons have negative impact? i've read singletons create 1 instance each of them in proces. other class instances released (assuming released properly) memory, should singletons released too? so narrow down 1 question: harmful have lot of singletons? singletons don't scale. no matter think should singleton, when system gets bigger, turns out needed more one. if never need more one, singleton fine. however, systems scale, typically need more 1 of anything within own context. singletons merely way "global". it's not bad, generally, it's not idea systems evolve , grow in complexity.