Posts

Showing posts from June, 2010

android - Accessing the contact Content Provider -

i tring access contact content provider. wrote following code cursor cur= getcontentresolver().query(contactscontract.contacts.content_uri, null,null,null,null); startmanagingcursor(cur); string[] result=new string[cur.getcount()]; if(cur.movetofirst()) { int nameidx=cur.getcolumnindexorthrow(contactscontract.contacts.display_name); int ididx=cur.getcolumnindexorthrow(contactscontract.contacts._id); string strname=cur.getstring(nameidx); string strid=cur.getstring(ididx); result[cur.getposition()]=strname+"("+strid+")"; }while(cur.movetonext()); stopmanagingcursor(cur); } but showing 1 contact name want show contact available please tell me how that. try instead cursor cur= getcontentresolver().query(contactscontract.contacts.content_uri, null,null,null,null); startmanagingcursor(cur); string[] result=new string[cur.getcount()]; (boolean hasdata = cursor.movetofirst(); hasdata;

tcpdf - Best way to convert pdf to greyscale with php? -

if want convert pdf greyscale whats best way go it. im using tcpdf convert html pdf need option can convert greyscale. whats best way go doing this. if have imagick (imagemagick) installed, can take generated pdf , save gray-scaled one. $image = new imagick('generatedpdf.pdf'); $image->setcolorspace(imagick::colorspace_gray); $image->writeimage('newpic.pdf'); $image->clear(); $image->destroy();

java me - how to check first value in rms is null in j2me? -

recordstore rs = recordstore.openrecordstore("storydatabase1",true); string data_to_write_in_file = slug.getstring()+"^"+title.getstring()+"^"+body.getstring()+"^"+com.editorial.main.mainimagepath+"^"+com.editorial.main.mainvideopath+"^"+com.editorial.main.mainvoicepath+"$"; byte b[] = rs.getrecord(1); string str = new string(b,0,b.length); if(str.equals("")) { byte bytes[] = data_to_write_in_file.getbytes(); rs.addrecord(bytes,0,bytes.length); } else { str=str+data_to_write_in_file; byte[] data = str.getbytes(); rs.setrecord(1, data, 0, data.length); } rs.closerecordstore(); in want check whether rms contains first value or not, otherwise enter new value in it??? still little bit confused whether information going stay permanent in mobile or not... an information permanently stored in rms , discussed regards this. see sample code , try this, byte[] recdata = null; int len

design - How to ensure easy maintainablilty while developing Struts application? -

i've worked on few projects on struts 1.3 application becomes difficult modify in future. follow dao objects , business delegator classes ensure separation of concern still having problems them. can tell practices follow don't have problems in fututre !! use dependency injection framework decouple classes ( spring + struts , guice + struts ) employ behavior driven design functional tests ( jbehave.org ) employ test driven design have code tested ( strutstestcase junit ) making code testable having maintainable. more resources use google/stack overflow search.

javascript - Jquery .click issue -

i facing strange , difficult problem. developing web app, have created few widgets. if click on icon widget editor appear in modular pop-up , user can enter data , data presented on dashboard label. hae "edit" button above label placed on dashboard, wanna add delete button, suppose user add widget on dashboard , later finds doesnt require dashboard clicks on delete button widget should deleted,if user feels wants widget again after deleting, when clicks on icon of particular widget deleted previously, widget should appear again. tried once click on delete button able delete widget when click on icon of widget not able in back. please me solve issue just taking guess @ you're looking do, here's example of adding div can close again: setup: var widget_markup = "<div class='widget'>i'm widget. " + "<span class='close'>close</span>" + "</div>"; // opens widget, return

WCF: Passing Kerboros token via HTTP call instead of HTTPS -

i want pass kerberos token via http call server using wcf. i have piece of code this. works if make request https uri. var httpbinding = new webhttpbinding(webhttpsecuritymode.transport) { maxreceivedmessagesize = int32.maxvalue }; httpbinding.security.transport.clientcredentialtype = httpclientcredentialtype.windows; httpbinding.security.transport.realm = "mycompany.com"; var endpoint = new endpointaddress("https:xxxxxxxx.com/my/service); // works var endpoint = new endpointaddress("http:xxxxxxxx.com/my/service); // not work var channelfactory = new channelfactory<imyservicecontract>(httpbinding, endpoint); channelfactory.endpoint.behaviors.add(new webhttpbehavior()); _channel = channelfactory.createchannel(); _channel.consumeservice(); if make request via channel, , if end point https. works , can verify kerberos token in http requst. if service end point http, gives error: system.argumentexception : provided uri scheme 'http' inv

Localization in a web app using JavaScript and JSON -

i'm trying set script automatically localize web application. web application intended use html5's offline caching ability, needs able work offline. such, javascript seems me best option. i'd prefer put strings localizations in single json file so: { "en": { "application_description": "this application's description in english.", "application_name": "this application's name in english." }, "ja": { "application_description": "this application's description in japanese.", "application_name": "this application's name in japanese." } } i thinking maybe of giving elements localized custom attribute linking intended message (eg: i18n="application_name"). i can retrieve browser's language using navigator.language , though think results have split first section (eg: "en-us" "en-gb

visual c++ - how to get hard disk used space ,free space ,not partition free space -

i know each hard disk's free space ,used space ,not partition free space thanks use getdiskfreespaceex function. see article: http://msdn.microsoft.com/en-us/library/aa364937%28v=vs.85%29.aspx

javascript - traverse array list in java script file -

in struts 2 based application, have arraylist. how can send arraylist java script file can compare list item element of jsp , show msg based on validation? how can use array list data in java script file. not want use json. json comes mind - not sure of this example here one more

php - Mysql PK and FK char(36) vs int(10) -

i have read mysql can handle indexes , searches better if tables keys integers rather char(36) uuid's. is worth converting int(10)? note: use 1 server , have have plans use multiple databases concurrently therefore removing 1 of big reasons using uuid. our tables innodb if makes difference. thanks in advance. usually rdbms can handle integer keys pk more efficient, other datatypes. reason how build index column, yes: long dont require string (or other typed) keys, should use integers. however: char(36) , int(10) far away being equal, because int(10) much smaller, char(36). dont know, if require many different keys, should keep in mind. update, complete last paragraph: int(10) 32-bit, char(36) 36 - ^byte^ (= 288-bit). not mean, int consumes less space, means, char(36) has 4 times more different keys.

java - FileNotFoundException while running Spring and Ibatis based application on Tomcat -

i using spring, ibatis orm. app-config.xml <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="jdbc:mysql://192.168.10.50/lmexdb_v1" /> <property name="username" value="lmexdba" /> <property name="password" value="lmexdba123#" /> </bean> <bean id="sqlmapclient" class="org.springframework.orm.ibatis.sqlmapclientfactorybean"> <property name="configlocation" value="classpath:com/platysgroup/lmex/server/mobile/dao/ibatis/sqlmapconfig.xml" /> </bean> <bean id="mobilecontroller" class="com.platysgroup.lmex.server.controller.mobilecontroller"> <property name="announcementservice&q

seo - Does Google crawl content loaded through jQuery's load function? -

if have test1.html file containing info , test2.html , when use .load("test1.html") will search engines read content loaded test1.html ? you should include tag page within body of page, google follow , index. hide, or replace tag if javascript present , use jquery loading approach.

Commercial in front of video, HTML5 -

is possible force user view commercial before actual video begins when using video embedding in html5? any links relevant info appriciated! this called pre-roll . the html5 specification doesn’t. can write javascript , logic around video in order create pre-roll system. ad servers , ad networks starting support html5 video. to load first video , onfinish trigger method load actual video. thanks!

python - send form values to mysql database -

i have installed mysqldb in python2.7(64bit), want know how can send form values mysql database. start reading. http://docs.djangoproject.com/en/1.2/intro/tutorial01/ http://docs.djangoproject.com/en/1.2/intro/tutorial02/ http://docs.djangoproject.com/en/1.2/intro/tutorial03/ http://docs.djangoproject.com/en/1.2/intro/tutorial04/ once you've understood can @ forms documentation (http://docs.djangoproject.com/en/1.2/topics/forms/) , models documentation (http://docs.djangoproject.com/en/1.2/topics/db/models/)

java - Hibernate with JPA annotation problem - lazy object -

i have user table associated many other tables, in general, star topology. like this: @entity @table(name = "user") public class user implements serializable { private static final long serialversionuid = 1l; @id @sequencegenerator(name = "user_userid_generator", sequencename = "user_seq") @generatedvalue(strategy = generationtype.sequence, generator = "userr_userid_generator") @column(name = "user_id") private long userid; @basic @column(name = "password_hex") private string password; @basic @column(name = "language") private string language; @temporal(temporaltype.date) private date created; @temporal(temporaltype.date) private date modyfied; @basic @column(name = "first_name") private string firstname; @basic @column(name = "last_name") private string lastname; @basic @column(name = &

mysql - How to count and group items by day of the week? -

i have following (mysql) table called "tweets": tweet_id created_at --------------------- 1 1298027046 2 1298027100 5 1298477008 i want mysql returning number of tweets per day of week; taking above data should return: wednesday 1 friday 2 i have following query (which should return day of week index, not full name): select count(`tweet_id`), weekday(from_unixtime(`created_at`)) tweets2 order weekday(from_unixtime(`created_at`)) this returns: count(`tweet_id`) weekday(from_unixtime(`created_at`)) 7377 4 (there total of 7377 tweets in database). doing wrong? select count(`tweet_id`), dayname(from_unixtime(created_at)) day_name1 tweets2 group day_name1 order day_name1;

debugging - Could Emacs Speaks Statistics loop through a R for loop like a real debugger? -

i happy user of ess coding , debugging r code. have found elusive bug inside several loops , ifs structures. is there way of having ess selectively travel if/else structures or loop values in loop?. does r or ess have debugger mode can skip else clauses, loop values , step into, step through, return etc? [update] thanks @jubba link other question debugging tools r-language . @ end real question. other thread give links kind of things wanted know way of doing debugging in current r. r-debug-tools.pdf debuggingr and 1 debugging ess, ess-tracebug there has been more general question debugging in r on stackoverflow : debugging tools r language one answer davor cubranic points ess-tracebug is, according website, "an emacs package interactive debugging , error tracing in ess" . i've never used myself, may useful : http://code.google.com/p/ess-tracebug/

jquery - ASP.Net MVC 3 JQGrid -

after reading on jqgrid control, decided use in 1 of asp.net mvc 3 web applications. firstly followed phil haacks tutorial http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx good. tried implement similar app, difference being, use linq entities. my view page has css , jquery classes imported, have javascript function , table holds data <script type="text/javascript"> jquery(document).ready(function () { jquery("#list").jqgrid({ url: '/home/linqgriddata/', datatype: 'json', mtype: 'get', colnames: ['equipmentid', 'categorytitle', 'title'], colmodel: [ { name: 'equipmentid', index: 'equipmentid', width: 40, align: 'left' }, { name: 'categorytitle', index: 'categorytitle', width: 40, align: 'left' }, { name: 'title', index: 'title', width: 200, align: 

C# Linq Query - Groupby -

i have datatable holds data such: date operationa operationb operationc today 5 today 6 today 7 now, want like: date operationa operationb operationc today 5 6 7 i've had @ linq group clause, seems seperate data being grouped , doesn't keep within collection - althought linq novice, may missing something. could please advise. thanks. class operation { public datetime date { get; set; } public int operationa { get; set; } public int operationb { get; set; } public int operationc { get; set; } } var operations = loaddata(); var result = operations.groupby(o => o.date) .select(g => new operation { date = g.key, operationa = g.sum(o => o.operationa), operationb = g.sum(o => o.operationb), operationc = g.sum(o => o.operationc)

.net - Testing WCF Chat application in different machines -

i have solution containing service 2 clients. can communicate each other, send message, , fire events. work fine when test 1 machine, install them on different machines, internet connected , not find each other. since self-hosting service reason? use duallhttpbinding binding configuration. situation chat application 2 client instances , 1 service, each of running on different machines without having network connection other internet connections. dualhttpbinding requires 2 clients able open connections , send messages each other. either 1 of clients behind firewall can't accept incoming connections, nat router isn't port forwarded, or other client doesn't have correct address find it. this kind of direct two-way communication on http difficult right once onto internet. debug it, i'd suggest taking @ fiddler excellent http debugging tool. you'll have watch connections , see if clients can connect, , if not, why it's failing. you'll have fix con

android - Have a Database that i got from an Iphone project (.sqlite) -

what change need implement iphone database (.sqlite) android project? thanks help android comes sqlite3, can either create database ground or can ship application pre-populated database. the following might prove useful: 1. sqlite basics 2. ship android application database 3. using own sqlite database in android applications

Not sure how to do ajax functions inside of javascript to get to mysql -

im not quite sure how go putting ajax function inside of javascript timer everytime restarts itll add 1 of item database. ive been looking , found this: http://www.tizag.com/ajaxtutorial/ajax-mysql-database.php im not quite sure how implement code, if me itd appreciated. heres code far: <head> <script type="text/javascript"> var c=10; var minecount = 0; var t; var timer_is_on=0; function timedcount() { document.getelementbyid('txt').value = c; c = c - 1; if (c <= -1) { minecount++; var _message = "you have mined " + minecount + " iron ore" + (((minecount > 1) ? "s" : "") + "!"); document.getelementbyid('message').innerhtml = _message; startover(); } } function startover() { c = 10; cleartimeout(t); timer_is_on=0; domining(); } function domining() { if (!timer_is_on) { timer_is_on = true; t = setinterval(function () { timedcount(); }, 1000); } }

performance - five minutes rules - the price of one access of disc I/O -

this interesting topic , use following formula compute access interval time: breakevenintervalinseconds = (pagespermbofram / accessespersecondperdisk) × (priceperdiskdrive / pricepermbofram). it derived using formulas cost of ram hold page in buffer pool , the cost of (fractional) disk perform i/o every time page needed , equating these 2 costs, , solving equation interval between accesses. so cost of disc i/o per access priceperdiskdrive / accessespersecondperdisk , question why disc i/o cost per access computed this? the underlying assumption limit life of disk how many disk seeks there are, while ram has fixed cost size, , fixed lifetime regardless of how accessed. reasonable because seeking disk causes physical wear , tear, , when disk goes, lose whole disk. contrast ram has no physical moving parts, , not wear out use. with assumption, cost of keeping data on disk depends on frequency of access , cost of disk. cost of keeping data in ram depends on how ram

java - Initialize a static final field in the constructor -

public class { private static final int x; public a() { x = 5; } } final means variable can assigned once (in constructor). static means it's class instance. i can't see why prohibited. keywords interfere each other? a constructor called each time instance of class created. thus, above code means value of x re-initialized each time instance created. because variable declared final (and static), can this class { private static final int x; static { x = 5; } } but, if remove static, allowed this: class { private final int x; public a() { x = 5; } } or this: class { private final int x; { x = 5; } }

c# - .NET - WindowStyle = hidden vs. CreateNoWindow = true? -

when start new process, difference make if use windowstyle = hidden or createnowindow = true property of processstartinfo class? as hans said, windowstyle recommendation passed process, application can choose ignore it. createnowindow controls how console works child process, doesn't work alone. createnowindow works in conjunction useshellexecute follows: to run process without window: processstartinfo info = new processstartinfo(filename, arg); info.createnowindow = true; info.useshellexecute = false; process processchild = process.start(info); to run child process in it's own window (new console) processstartinfo info = new processstartinfo(filename, arg); info.useshellexecute = true; // default value. process processchild = process.start(info); // separate window to run child process in parent's console window processstartinfo info = new processstartinfo(filename, arg); info.useshellexecute = false; // causes consoles share wind

c# - Adding new entry to DataContext db Cause null reference -

i'm bit new datacontext should still simple. i developing bidding site there many "products" each products many "bids". have 2 tables (persisted in .net datacontext model): bidproduct (with auctionid primary key) bidentry (with auctionid foreign key) relationship: bidproduct --> bidentry i trying add 1 product 1 linked bidentry db such: ( list<products> , list<bidentries> pre-populated) dbdatacontext db = new dbdatacontext(); bidproduct p = products.first(); bidentry b = bids.where(bi => bi.auctionid == p.auctionid).first(); p.bidentries.add(b); db.bidproducts.insertonsubmit(p); db.submitchanges(); when p.bidentries.add(b) called null reference on bidentries !? if try a = new on bidentries still null reference. what this!? have initialized p.bidentries list<bidentries> ? the error suggests isn't. you need ensure after point in code: bidproduc

javascript - Internet Explorer: How to modify CSS at runtime for printing? -

imagine webpage enables users show hidden element, using javascript modify css css style @ runtime. after decision (which includes modification of stlyesheet) user uses printing functionality of browser. it seems internet explorer not respect changes made in stylesheet before during printing if original css definition located in external file. in other browsers works expected. please have @ example below, changes style class initial definition display:none display:inline @ runtime hence element displayed. when printing page, element remains hidden in internet explorer (tested ie 6,7,8). do have solution or workaround? minimalistic example (html file): <html><head> <link rel="stylesheet" type="text/css" href="minimal.css"> </head><body onload="displaycol();"> <script> function displaycol() { var myrules; if( document.stylesheets[0].cssrules ) { myrules = document.sty

scala - How to replace a given item in a list? -

this describes problem pretty well: scala> var l2 = list(1,2,3) l2: list[int] = list(1, 2, 3) scala> l2(2) = 55 <console>:10: error: value update not member of list[int] l2(2) = 55 ^ scala.list immutable , meaning cannot update in place. if want create copy of list contains updated mapping, can following: val updated = l2.updated( 2, 55 ) there mutable ordered sequence types well, in scala.collection.mutable , such buffer types seem more want. if try following should have more success: scala> import scala.collection._ import scala.collection._ scala> val b = mutable.buffer(1,2,3) b: scala.collection.mutable.buffer[int] = arraybuffer(1, 2, 3) scala> b(2) = 55 scala> b res1: scala.collection.mutable.buffer[int] = arraybuffer(1, 2, 55) edit: note other answers have mentioned should use "mutable list type" - true, "list" in scala refers single-linked list, whereas in java it's used ordere

Incorporating bash scripts into an R package? -

background i writing r package support reproducible research. @ point, workflow held bash scripts, , can run analysis sending single command ./runscript.sh . use bash following: file manipulation tar , rsync , 'rename' running bash files locally , via ssh running r scripts using r --vanilla in turn call r functions find , replace text within files using sed submitting jobs via qsub it seems me more efficient (cleaner , easier) execute entire workflow r function or r script. partial r since more familiar , work within emacs ess. questions would worthwhile encapsulate of these uses of bash within r using system , files functions? are there other r packages have not yet found helpful doing this? notes following al3xa's answer, realize important note speed penalty of using eg. r vs bash versions of tar , gsub on 1000-2000 files less current rate limiting steps in workflow: computations jags (~10-20min) , fortran (>4hrs) i'm big fan

drupal view displaying different output in different pages -

i have panel displaying drupal view. context type set node id. same setting 2 pages. however, displaying different output 2 pages. have refresh multiple times see same output on both pages. how can fixed? try using #drupal or #drupal-support channels in irc client. there's ton of helpful drupalers there , easier troubleshoot if chat through additional details needed...

php - Magento how to configure cron -

i have configured custom cron in 1 of modules, want executed every 1 week, @ 11:00 am, i've wrote in config.xml <cron_expr>0 0 * * 1</cron_expr> this execute function every 1 week @ midnight, or @ least understand, don't know how write expresion execute @ 11:00 am, don't know means * * * * *, in magento's wiki everytime cron execute. how can make cron execute every 1 week @ 11:00 am thanks you need configure hour item (the second item): <cron_expr>0 11 * * 1</cron_expr>

Ruby convert array to nested hash -

i have following: value = 42 array = ["this","is","a","test"] how can convert this { "this" => { "is" => { "a" => { "test" => 42 } } } } the array flat. thank you! try this: h = array.reverse.inject(value) { |a, n| { n => } }

uiviewcontroller - Crash when Adding a WebView to a Multiview Tab Bar App -

i new , working thru "teach book". have 2 questions. how trouble-shoot in future , how darn thing work now. i have simple 3 tab bar app points 3 uiviewcontroller. 3 views work fine until add webview 1 of xibs. bring view webview included in simulator, kicked out of app. the debugger console says"'nsunknownkeyexception', reason: '[ setvalue:forundefinedkey:]: class not key value coding-compliant key bannerview.'" don't know means. .h file code.... @interface convnavcontroller : uiviewcontroller { iboutlet uiwebview *bannerview; } -(ibaction)loadbannerview:(id)sender; @property (nonatomic, retain)iboutlet uiwebview *bannerview; ========= .m file code -(ibaction)loadbannerview:(id)sender{ nsurl *bannerurl; nsstring *bannerurlstring; bannerurlstring=[[nsstring alloc] initwithstring:@"http://www.tak2000.com/banner_test.html"]; bannerurl =[[nsurl alloc] initwithstring:bannerurlstring]; [bannerview loadrequest:[ns

virtual machine - How many VM are started on Android after boot? -

android dev guide says "every android application runs in own process, own instance of dalvik virtual machine.". how many vms (on 2.3/3.0) started after boot (if default apps initiated)? so how many vms (on 2.3/3.0) started after boot some number greater or equal 1. the exact number depend on: what software came preinstalled on device what software user installed what version of android is possibly other hardware-specific or user-specific characteristics (e.g., selected input method) you welcome use ddms examine emulator , count configuration, of listed processes have dalvik vms. (if default apps initiated) there no concept in android of "default apps".

How to get root access on Android emulator? -

i have android sdk versions(from 1.5 2.3.3), , tried many methods getting root in android emulator. don't use android device , test on emulator(avd). i need root access in 1 of android emulator use 'iptables' , 'busybox' functionality. , use iptables must have root access. atleast 'su' command should execute in terminal emulator. i installed z4root application, but takes long time , doesn't finish rooting, , gets stuck. if downgrade system below rc30, way can root access. if true, how this? use both linux , windows os. please tell me method root emulator. i think can use "root.apk" stored on filecrop ( visionary in android system ) root emulator because, @ each reboot, root system. z4root can't work because needs rebooting make root access working.sorry bad english, i'm french.

jQuery JSON response always triggers a ParseError -

i trying preform basic operations jquery , json. presently having difficulty jquery accepting json response play framework application. below simplified version of code still produces error. $.ajax({ type: 'post', url: "@{frontend.isusernameavailable()}", data: "name=thisnameisavailable", cache: false, success: function(data) { console.log("success... "); }, error: function(jqxhr, textstatus, errorthrown) { console.log("error... " + textstatus + " " + errorthrown); }, datatype: 'json' }); the error callback triggered. displays error... parsererror jquery15001997238997904205_1298484897373 not called inspecting returned json through firebug shows no errors , various json lint tools validate. changing datatype "text" makes success called. trying use isusernameavailable call part of jquery validation plugin need return valid json.

ado - Strange problem in VB6 in generation of executable -

i there i have scenario: a) notebook :windows server 2008 r1, visual basic 6 service pack. b) desktop : windows server 2008 r1 (recently update sp1, dunno if guilty), visual basic 6 service pack. c) client machine (windows xp) i created executable in a) , installed in c) . uses ado (msado15.dll) , works fine in a) , in c) then, using same code, tried same in b) (compiling in b) ) , work in b) fail in c) . verified same code in a) , in b) in resume: a machine executable_compiled_in_a.exe works executable_compiled_in_b.exe works b machine executable_compiled_in_a.exe works executable_compiled_in_b.exe works c machine (customer machine) executable_compiled_in_a.exe works executable_compiled_in_b.exe fail! the error message is class not support automation or not support expected interface and trigged line set data = new adodb.connection so, don't trouble, both uses same reference b) generated different executable.

iphone - iOS detachNewThreadSelector leaking -

i have uiscrollview loading images in. apply effect image , takes bit pre-loading decided on different thread using detachnewthreadselector. using ktphotobrowser on github this. so basically, have function so. - (void)setcurrentindex:(nsnumber *)newindex { nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; currentindex_ = [newindex integervalue]; [self loadphoto:currentindex_]; [self loadphoto:currentindex_ + 1]; [self loadphoto:currentindex_ - 1]; [self unloadphoto:currentindex_ + 2]; [self unloadphoto:currentindex_ - 2]; [self settitlewithcurrentphotoindex]; [self togglenavbuttons]; [pool release]; } i call using [nsthread detachnewthreadselector:@selector(setcurrentindex:) totarget:self withobject:[nsnumber numberwithint:5]]; when run this, appears throwing leak. beginning wonder if should putting autorelease pool around code in loadphoto method. if curious code, have included below. - (void)loadphoto:(nsinteger)index {

javascript - Importing JS file with AJAX does not work -

i had javascript code working when tried put own file, stopped working :) here url use: http://www.comehike.com/hikes/javascript_library.js any idea why doesn't work? test working, try hitting url see if google map shows if js on page. http://www.comehike.com/hikes/hike_carpool.php?hike_id=125 thanks, alex <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> </script> <script language="javascript" src="javascript_library.js"> </script> place google map api before javascript_library.js (aka map scripts) and remove script tag javascript_library.js

Mercurial set up ACL -

i'm trying set acl. i've got working. however, i've got couple of specific questions. basically, i'm trying set group @group allowed access bunch of branches of form xxxx-integration-xxxx. want is: [acl.allow.branches] *integration* = @group however, doesn't seem work. there easy way this? thanks try hooking on pretxnchangegroup , writing python script gets branch , user , figure out in there. there no acl premade stuff named branches know of.

c# - Custom Excel Export Action -

public class excelresult<model> : actionresult { string _filename; string _viewpath; model _model; controllercontext _context; public excelresult(controllercontext context, string viewpath, string filename, model model) { this._context = context; this._filename = filename; this._viewpath = viewpath; this._model = model; } protected string renderviewtostring() { using (var writer = new stringwriter()) { var view = new webformview(_viewpath); var vdd = new viewdatadictionary<model>(_model); var viewcxt = new viewcontext(_context, view, vdd, new tempdatadictionary(), writer); viewcxt.view.render(viewcxt, writer); return writer.tostring(); } } void writefile(string content) { httpcontext context = htt

c# time format weirdness -

i have following string thetimeformat custom time format: "{0:h:mm tt}" i have following datetime thetime: {1/14/2011 2:19:00 am} i have following statement thistime = thetime.tostring(thetimeformat); why thistime equal " {0:2:19 am} " . should 2:19 , i'm not seeing why. not in gridview, use following statement , works charm: ((boundfield)(mygrid.columns[0])).dataformatstring = theuserpreferences.usertimeformat ; theuserpreferences.usertimeformat same format string. any suggestions? when put time format datetime 's tostring method, don't need placeholder; is, have this: thetimeformat = "h:mm tt"; and thistime = thetime.tostring(thetimeformat) would give desired output. edit: per extended question in comment, allow put format in requires placeholder (and store aforementioned version of thetimeformat in db): string formatwithplaceholder = "{0:" + thetimeformat + "}"; i brief

linux - PHP, crontab, DateInterval: Convert human-readable interval to crontab format -

i'm having little confusion crontab interval format. point want intervals human-readable strings "20 minutes", "16 hours , 30 minutes". done php datetime already . need passing crontab-valid string exec(sprintf('echo "%s %s %s * * %s" | crontab', $minute, $hour, $day, $command)); . anyhow, here sample php script <?php function getcrontabinterval($timestring) { $interval = dateinterval::createfromdatestring($timestring); $minute = $interval->i > 0 ? "*/{$interval->i}" : '*'; $hour = $interval->h > 0 ? "*/{$interval->h}" : '*'; $day = $interval->d > 0 ? "*/{$interval->d}" : '*'; $crontab = sprintf('echo "%s %s %s * * %s" | crontab', $minute, $hour, $day, '%command%'); echo "days:\t\t", $interval->d, "\n", "hours:\t\t", $interval->h, "\n", "m

c# - security dll reference in Silverlight? -

i want to aes encryption , have in silverlight project. the problem need system.security.dll cannot add reference c:\ windows\ microsoft.net\ framework\ v2.0.50727dll\ system.security.dll because silverlight not accept it. do see workaround issue? thanks in advance. you don't need system.security.dll. system.security.dll exposes managed wrapper around dpapi, not you're looking for, , not available in silverlight. you need use aesmanaged class in system.core.dll.

Comparing DateTimes in C# -

private void validateeffectivedate() { bool icadvanced = sessionmanager.displayuser.isinrole(permissions.hasicadvanced); if (!icadvanced && model.effectivedate < datetime.now) { this.checkandaddvalidation("effectivedate", "you not have advanced permission, " + "are unable value historical indications."); } } if not icadvanced, should not able have date in past, 1 day before today or earlier. however, can have today or in future. why code not reflecting correctly? well, you're going now , rather today 1 thing. if "now" 5pm, effectivedate midnight today, that's going add validation error. so might want: if (!icadvanced && model.effectivedate < datetime.today) however, need work out how model.effectivedate represented. datetime unfortunate of handling of time zones, value can utc, local or unspecified. i'm not clear on how affects compariso

php - APC caching files vs caching variables -

say have file a.php contains large array: $client = array( "a" => 123, "b" => 124, ... ); apc caches file a.php mean exactly? caches opcode assignment only? cache mapping itself? or need explicitly put in apc cache? thanks! apc caches php file in byte code. faster intermediary between human readable code , interpreter ends executing. analogous compiling c/c++ file binary. array compiled in fashion load quicker if read form file. accessing element in associative array in php constant time o(1) in big-o . adding element o(1). , large best store such arrays in database because uses less memory , more flexible. keep in mind every browser visits application going have own copy of array, if use database there 1 copy. instance if want key based on value you'll have iterate on o(n) (which slow), use of database faster.

Android menu will not appear when the menu button is pressed in AVD -

i have defined menu laid out http://developer.android.com/guide/topics/ui/menus.html here menu.xml <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_home" android:icon="@drawable/ic_menu_home" android:title="main menu" /> <item android:id="@+id/menu_signout" android:icon="@drawable/ic_menu_signout" android:title="sign out" /> </menu> and code, placed in activity @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle item selection switch (item.getitemid()) { case r.id.menu_home: startactivity(new intent(manageusersactivity.this, mainmenuactivity.class)); finish(); return tru

c# - Windows Service, Memory increases everytime it gets data from Active Directory -

i have windows service. service gets user data active directory , saves xml file on local system. service uses timer, work after every (lets say) 10 minutes. when runs first time, consumes 85 mb of memory, after 10 minutes, consumes 118 mb, , on. everytime runs, consumes memory. can me in understanding, missing here. protected override void onstart(string[] args) { startprocess(); } private void startprocess() { sevent = "ad xml generator started @ " + system.datetime.now.tostring(); if (!eventlog.sourceexists(ssource)) eventlog.createeventsource(ssource, slog); eventlog.writeentry(ssource, sevent); activedirectorygenericfunctions obj = new activedirectorygenericfunctions(); obj.generatexmlfileforallusers(domaina, domainb, xmlfilename); runservice(); //this.stop(); } protected override void onstop() { //write event log - stop of service written evenbt automatically sevent = "ad xml generator stopped @ " +

weird syntax error in django template -

{% item in items %} hiii {% endfor %) i using template , while rendering getting in template /home/user/code/templates/temp_name, error @ line 1 theres paren @ end of endfor instead of curly brace. {% endfor %) should be {% endfor %}

regex - Handle Unicode characters with Python regexes -

i'm writing simple application want replace words other words. i'm running problems words use single quotes such aren't , ain't , isn't . i have text file following aren’t=ain’t hello=hey i parse text file , create dictionary out of it u'aren\u2019t' = u'ain\u2019t' u'hello' = u'hey' then try replace characters in given text text = u"aren't" def replace_all(text, dict): i, k in dict.iteritems(): #replace whole words of k in lower cased text, regex = \bstring\b text = re.sub(r"\b" + + r"\b", k , text.lower()) return text the problem re.sub() doesnt match u'aren\u2019t' u"aren't" . what can replace_all() function match both "hello" , `"aren't" , replace them appropriate text? can in python dictionary doesn't contain unicode? convert text use unicode character, or modify regex match unicode character other

Why Do I Get SQL Syntax Errors In My Query? -

i trying retrieve data in following format: story | story type | creation date | company role | tag 1 | tag 2 | tag 3 negative iii | negative | 21/02/2011 | business analyst | project duration | team size | process negative ccc | negative | 22/02/2011 | admin | workspace layout | organisational | process instead of: story | storycategoryid | creationdate | companyrole | name negative iii | 1 | 21/02/2011 | business analyst | project duration negative iii | 1 | 21/02/2011 | business analyst | team size negative iii | 1 | 21/02/2011 | business analyst | process negative ccc | 1 | 22/02/2011 | admin | workspace layout negative ccc | 1 | 22/02/2011 | admin | organisational , reporting structure negative ccc | 1 | 22/02/2011 | admin | process but getting following errors: 1) incorrect syntax near keyword as, 2) incorrect syntax near z here's sql, please help! select story, case storycategoryid when 1 'negative' when 0 &

php - Weather for date and lat/lng -

i browsing through bunch of weather-forecast apis , none of them seem think pretty necessary. is there way me send address, or lat/lng coordinates, , date forecast want (in future)? thank you, alex ps - if matters, use php. it looks yahoo weather api this, have geocode location woeid first. can't specify date, appears return list of forecasts upcoming dates.

jquery - Using an If condition inside a template -

how use if statement inside of jquery template? here's template: <script type="text/html" id="attachmentlisttemplate"> {{if $item.current_cmt_id == id }} <li> <a href="${link}" class="fancyiframe clearfix">${title}</a> </li> {{/if}} </script> where id ${id} , being passed data binding (via knockoutjs). without if statement outputs fine, so: ${$item.current_cmt_id} here data-binding (powered knockoutjs): <ul data-bind='template: { name: "attachmentlisttemplate", foreach: attachmentsmodel.convattachments, templateoptions: {current_cmt_id: <%=comment.id%>} }'> </ul> any suggestions why if sttatement not working? comparing 2 conditions correctly? assuming id observable, need invoke function rather treat property. try following: {{if $item.current_cmt_id == id()}}

Domain Driven Design - where does data parsing belong -

in application i'm developing, domain revolves around, say, electrical appliances . there several specialized versions of entity. appliances can submitted application, , happens web services using data transfer objects. while working great, looking @ importing appliances several text-based file formats well. consider workflow: directory watcher service sees new appliance file has been added the service uses application service application submit appliances described file now, application service have method following name , signature: applianceservice.register(string filecontents) . i'm thinking directory watcher service use service method , pass entire contents of file. application service coordinate parsing. parsing contents of file , transforming complete appliances entities involves several steps. now, question is: question: correct, or should parsing logic live within directory watcher service? each type of file format kind of part of domain, again, it

iphone - One line label/input field using jquery mobile CSS -

i'm trying display list of labels , inputs using jquery mobile results settings on iphone, e.g label left aligned, , input right aligned on same row. way i've managed using tables, believe bad practice? what equaling css without tables? <ul data-role="listview" data-dividertheme="e"> <li data-role="list-divider">seamless list (margin-less)</li> <li> <table style="width:100% "> <tr> <td style="width: 50%"> foo1 </td> <td style="width: 50%"> <input type="number" value="20000" style="text-align: right" id="foo1input" /> </td>

parsing - Detect/Parse Mailing Addresses in Text -

are there open source/commercial libraries out there can detect mailing addresses in text, how apple's mail app underlines addresses on mac/iphone. i've been doing little online research , ideas seem either use google, regex or full on nlp package such stanford's nlp, pretty massive. doubt iphone has 500mb nlp package in there, or connects google every time read email. makes me believe there should easier way. bad uidatadetectors not open source. i know question has been asked before, there no conclusive answers, here's try. you can extremely high accuracy drew mentioned extracting addresses , comparing them against usps data. getting dvd usps yearly work doesn't factor in addresses change. that, want more up-to-date version. usps publishes it's updated address data (in proprietary format) monthly source of authoritative addresses. on top of that, using address validation service (after extract address data) standardize addresses , check th

Can we span the SQL server to multiple machines -

when database becoming huge, how divide , span multiple servers? how huge? single instance sql server deployments capable of handling peta-byte databases . for scale-out 1 option @ peer-to-peer transactional replication , can in-place scale-out of application not explicitly designed such. applications designed scale-out ahead of time have more options, instance consider how myspace spans on individual 1000 databases using message buss . for more specific answers, have provide more specific details real case.

iphone - Difference among native android app and phonegap app -

recently, came across one stone kills multiple birds framework - http://phonegap.com/ . i see comes limitation when trying access native features of phone - http://www.phonegap.com/features . doesn't matter me in current moment don't need native features right now. (a 2d tile game) i wondering, of has developed app using above framework? differences had found, in term of : user experience on end product. product easy install , execute? product running smoothly? ui flashy? ... developer experience during development work. can technically achieve want can through native app? ... making 2d game phonegap possible, difficult make user experience smooth want. i'd recommend don't go route. i'd suggest forget supporting windows phone 7 now, use unity3d assuming have $1,900 lying around, use cocos2d assuming don't have kind of money, or investigate other cross-platform game engine (there many game engines android, it's hard me keep track of o

javascript - Determine if Link is valid upon user clicking on it -

i offer widget user can store links have created. so in other words they: click add link modal pops , enter information: link title, link url, order saves db via ajax , refreshes widget display of users links have created. what when user clicks on link, determine if link exists(could not on domain can see foreseeable issue w/ ajax) if proceed normal open new window , send them on merry way. however if not generate growl message says like. i'm sorry link not exist, please verify link. i need method validating links existence on client side basis. possible ? you use jquery attach click() event handler on links, in turn try load url in hidden iframe, if succeeds open link in new window. note expensive way of link checking. maybe smarter done http head request. edit: found solution (for plain javascript though) here: http head request in javascript/ajax? function urlexists(url) { var http = new xmlhttprequest(); http.open('head', ur

c# - How do I import .tmx (Tile Map Editor) file into my XNA Project -

i tried load .tmx (tile map editor) file project i'm getting error: cannot autodetect importer use "level1.tmx" there no importers handle file type. specify importer handles file type in project. xna not load file default. there full tmx map loader xna projects located here http://windowsphonedevelopments.com/tmx-map-loader-xna-1-0/ tmx map loader xna full xna content pipeline library allows load , process data tmx source asset file , output data intermediate format @ design time (output .xnb file).

inverted image in C# -

this piece of code gathered here . private unsafe byte[] bmptobytes_unsafe(bitmap bmp) { bitmapdata bdata = bmp.lockbits(new rectangle(0,0,1000,1000), imagelockmode.readonly, pixelformat.format24bpprgb); // number of bytes in bitmap int bytecount = bdata.stride * bmp.height; byte[] bmpbytes = new byte[bytecount]; // copy locked bytes memory marshal.copy(bdata.scan0, bmpbytes, 0, bytecount); marshal. // don't forget unlock bitmap!! bmp.unlockbits(bdata); return bmpbytes; } i have function gets byte above mentioned function , displays without further processing. inverted image @ output. can explain? when "inverted", suppose mean upside down? you can't rely on "l33t hax0r skillz" of person posting code. lacks vital information how bitmaps handled in mem

iphone - What does the access_token in the following facebook graph request means? and how to get it? -

i want show list photo's or album's of facebook user in iphone app, in should able save photo's photo galleray. found examples foe php unable reproduce same in iphone asirequest. want use following graph request how access_token in session object. https://graph.facebook.com/me/albums?access_token= //graphrequest // delegate end after user login, i'm querying fql, - (void)session:(fbsession*)session didlogin:(fbuid)uid { _label.text = @""; nsstring* fql = [nsstring stringwithformat: @"select uid,name user uid == %lld", session.uid]; nsdictionary* params = [nsdictionary dictionarywithobject:fql forkey:@"query"]; [[fbrequest requestwithdelegate:self] call:@"facebook.fql.query" params:params]; } or there work around meet requirement? in advance. you need first authenticate access code. use access code subsequent communication. http://developers.facebook.com/docs/authentica

Dump all PHP variables -

is possible dump global variables in php script? code: <?php $foo = 1; $bar = "2"; include("blah.php"); dumpall(); // displays $foo, $bar , variables created blah.php also, possible dump defined constants in php script. use get_defined_vars and/or get_defined_constants $arr = get_defined_vars(); print_r($arr);

php - How to set ${var_name} -

we developing mail system, , allow user add custom greeting while creating message.. example, check following... we set variable(var_name) in php. hello ${var_name}, test message. we not using framework. what str_replace ? $text = str_replace('${var_name}', $var_name, $text);

iphone - Auto import for Xcode -

is possible xcode auto import frameworks , class headers automatically? what happens every time build, encounter errors due missing import. know how fix, felt xcode can more intelligent perhaps giving me option "auto fix imports". at moment it's not possible that. suppose want eclipse's auto-import, i.e. when first use class in code, auto-imports package. you should open bug report here let apple people know it.