Posts

Showing posts from July, 2011

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

iOS: How to get a proper Month name from a number? -

i know nsdateformatter suite of functionality boon mankind, @ same time confusing me. hope can me out. somewhere in code, there int representing month. so: 1 january, 2 february, etc. in user interface, display integer proper month name. moreover, should adhere locale of device. thank insights in mean time, have done following: int monthnumber = 11 nsstring * datestring = [nsstring stringwithformat: @"%d", monthnumber]; nsdateformatter* dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"mm"]; nsdate* mydate = [dateformatter datefromstring:datestring]; [dateformatter release]; nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"mmmm"]; nsstring *stringfromdate = [formatter stringfromdate:mydate]; [formatter release]; is way it? seems bit wordy. another option use monthsymbols method: int monthnumber = 11; //november nsdateformatter *df = [[[nsdateformatter alloc]

c++ - OpenCV: wrap image to cylindrical coordinates -

i'm trying create panoramic image using opencv library. based on this , need warp image cylindrical coordinates. got formula convert 3d cartesian (x,y,z) cylindrical coordinate(θ,v) panoramic image mosaic paper , is: θ = tan−1 (x/z) v = y/ √ (x^2 + z^2) i have read opencv mailing list thread cylindrical image warping, based on paper, don't think need use camera calibration matrix. and, in website, problem has not been solved. th question is, how can convert opencv iplimage cylindrical coordinate , display them correctly? thanks in advance. unfortunately, need camera calibration if wish warp image cartesian cylindrical coordinates. think it. if camera not calibrated, not know field of view of camera. if not field of view, can not map pixels optical rays. if not know optical ray corresponds pixel, there's no way express pixel in cylindrical coordinates.

How to reduce noise while recording sound in java? -

hi guys developing online audio recorder, need reduce noise while recording sound.how achieve this? current audio format is audioformat(8000.0f,16,1,true,false); you'll need implement digital signal filters on data. depending on kind of noise you're targeting, simple band pass filters might work, or go whole hog , implement dolby a/b

.net - Couple of VB.Net lines in C# -

i converting project vb.net, , have few lines unable convert propperly. system.runtime.caching.memorycache.default(me.name) in line, understand "me.name" has "this.name", error "non-invocable member 'system.runtime.caching.memorycache.default' cannot used method.". i have correctly added system.runtime.caching references also return new string[]; . have no idea how convert this. thanks in advance, rené it appears want call indexer (sometimes called item property). c# uses square-brackets [] purpose. system.runtime.caching.memorycache.default[this.name] i suggest 2 other changes: if there's no ambiguity, can leave out this. with appropriate using directive ( using system.runtime.caching; ), type doesn't have qualified. memorycache.default[name]

fedora - Error while connecting to sftp using shell script -

i getting following error while trying connect sftp server:- ncftpput: cannot open http://mydomain.com : unknown host. code using following:- ftpu="username" # ftp login name ftpp="password" # ftp password ftps="http://mydomain.com"# remote ftp server ftpf="/home" # remote ftp server directory $ftpu> & $ftpp locald="/localpath" ncftpput -m -u $ftpu -p $ftpp $ftps $ftpf $locald i running script on fedora 10... thanks..... ncftpput ftp client not support ssh (see faqs ). also, in script you're providing http url instead of server name. if mydomain.com runs ftp server, try ftps=mydomain.com instead.

How to send message to your follower in twitter using iPhone? -

i have iphone application in used xauth , can tweet want send message follower , don't know how send message particular follower. please give ideas stuff. in advance.. use mgtwitterengine send message particular follower.

full text search - FullText In Microsoft Sql Server - Returning exactly word -

can tell me how query fulltext table in sql server, , matches? example: i have records in table named "items": bath bathroom test testing i need query bath , 1 record, "bath", excluding word bathroom. same word "test", wich in context different "testing". have tried select column1, column2, ... [itens] ft_tbl inner join containstable([itens], *, 'bath') key_tbl on ft_tbl.unique_key_column = key_tbl.[key] http://msdn.microsoft.com/en-us/library/ms189760.aspx or select columnname [itens] contains(somecolumn, 'bath') http://msdn.microsoft.com/en-us/library/ms187787.aspx just noticed updated questions ( formatting applied ). if column holds keywords ( single word ) select column = 'keyword' . select columnname [itens] somecolumn = 'bath'

Static Web Assets over CDN and Optimal Number of Hosting Aliases -

what optimal number of host aliases (i.e. storage-1.host , storage-2.host , etc.) have content delivery network? i'm using amazon cloud front , can set 10 different cname records. understanding browsers initiate 2 parallel connections given host, i'm wondering if browsers connect unlimited number of different hosts or limit set in place? have taken through few large services (such youtube , flickr) , noticed tend use 4 different host aliases. optimal number? thanks! it sounds ideal number 10, then. :) the more hosts have, better - whole idea want many downloads running in parallel possible, , more hosts = more parallel downloads.

windows mobile - Reduce the size of a camera captured picture in c# -

i want know how reduce size of camera captured picture in windows mobile. know how can save database , show in picture box. chris tacke had great post that: http://blog.opennetcf.com/ctacke/2010/10/13/loadingpartsoflargeimagesinthecompactframework.aspx it included zooming picture, if don't want leave part of implementation out.

c - How to represent functions in flowchart? -

i define function in ansi c program (simple program). don't known how represent function in flowchart. can me? on flowchart, function can anything: state, action occurs while transitioning betwwen states, etc. depends on how have flowchart organized. recommend building flowchart normally, go , add function name description of implemented function.

gd - PHP imagettftext always drawing black -

basically when draw text it's ending black this: http://i.stack.imgur.com/z675f.png instead of color i'm allocated in php , function. code: $finalimage = imagecreatefrompng($imagefile); $logo = imagecreatefrompng($logoimage); imagecopy($finalimage, $logo, $logoposition['x'], $logoposition['y'], 0, 0, imagesx($logo), imagesy($logo)); $font = "arial.ttf"; $fontsize = 10; $yoffset = 15; $white = imagecolorallocate($finalimage, 255, 255, 255); foreach($pixelarray $key => $x) { foreach($valuearray[$key] $valuetext) { imagettftext($finalimage, $fontsize, 0, $x, $yoffset, $white, $font, $valuetext); $yoffset += 15; } $yoffset = 15; } if($misctext != null) { foreach($misctext $key => $text) { imagettftext($finalimage, $fontsize, 0, $text['x'], $text['y'], $white, $font, $text['text']); } } imagepn

ios4 - Tab bar is also moving when i scroll the table view -

i have written code programmatically tab bar in table view.the problem whenever scrolling table view,the tab bar moving.the tab bar created in 1 cell,so scrolling.how keep in static.please me in this. in advance don't put tabbar in scrollview. rather, have tabbar @ bottom of main view, , have scrollview extend top of tabbar. should fix it. if put tabbar on scrollview, scroll around (that's scrollview does).

Single vs. Dual Sockets In Network Programming -

the question network programming, more precisely servers. let's suppose there server handles lot of connections, , has listening socket. there exists single instance of such socket, that's clear. i've seen designs use (a)one socket every connection, both incoming , outgoing data, , (b)two sockets, 1 incoming data, 1 outgoing data. makes 1 or other design more preferrable? possible reasons / usecases these 2 designs? programs referring instant messengers (two of them), theoretically applies multiple-connection server (any server, then.) hope question not generic, don't know lot network programming @ moment, asking this. rapid googling didn't either. tcp , udp sockets full duplex. there no reason whatsoever use separate sockets input , output same client. wastefully using kernel resources @ double rate.

android - How to install old SDK platform -

Image
i want test against android 1.3 platform instead of latest 2.2. here how android sdk , avd manager likes. however, expecting (screen http://developer.android.com/sdk/installing.html#components ), can select old platform. is there had missed out? run > check updates first, update eclipse plug-in, can access repository. why want test against 1.3? if still on old version of android (was there 1.3? it's not listed here ), it's insignificant portion of market. earliest should worry 1.5.

collections - Dictionary in python with order I set at start -

i'm making dictionary: d = {"server":"mpilgrim", "database":"master"} d['mynewkey'] = 'mynewvalue' but when display saw dict reversed. print(d) {'mynewkey': 'mynewvalue', 'database': 'master', 'server': 'mpilgrim'} how reverse back? or if true dictionary not sortable must use have collection order of informations matters? dictionary unordered (the order deterministic, depends on handful of factors don't think of , shouldn't care - hash of keys, order of insertion, collisions, etc). in python 2.7+, use collections.ordereddict . if must use older version, there various implementations google can point to.

autocomplete - Best way to perform an ajax auto complete search box in WPF? -

i have been trying autocompletebox tool in wpf tool kit. event best used if wanted display information database based on user enters? try handling populating event per following: wpf: autocomplete textbox, ...again

hibernate table does not exist error -

in configuration hibernate.cfg.xml, add <property name="hibernate.hbm2ddl.auto">create</property> hibernate create table automatically when run application. however, remove table database manually running drop table sql. run hibernate application again. exception appear caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: table 'test.person' doesn't exist only way fix problem restart mysql database. explain issue me? this hibernate.cfg.xml <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class"> com.mysql.jdbc.driver </property> <property name="hibernate.connection.url"> jdbc:mysql://localhost/test </property> <property name="connection.username">root</property> <property name="connection.password">root</property> <p

c# - Best way to dynamically get column names from oracle tables -

we using extractor application export data database csv files. based on condition variable extracts data different tables, , conditions have use union data has extracted more 1 table. satisfy union condition using nulls match number of columns. right queries in system pre-built based on condition variable. problem whenever there change in table projection (i.e new column added, existing column modified, column dropped) have manually change code in application. can please give suggestions how extract column names dynamically changes in table structure not require change in code? my concern condition decides table query. variable condition if condition a, load tablex if condition b load tablea , tabley. we must know table need data. once know table straightforward query column names data dictionary. there 1 more condition, columns need excluded, , these columns different each table. i trying solve problem dynamically generating list columns. manager told me make

c# - Transactions in Typed DataSets -

have typed dataset several related tables, , relations defined between tables. process datafeed, i'm adding, modifying, , removing records, calling update on each table. requests reapprovals userrole requestid ----- requestid ----- roleid reason roleid ----/ userid the reason using typed dataset have check existing data determine whether i'm adding, modifying, or removing records... need full dump of i'm working (the alternative 10,000 queries against database process records 1 one). i want transactional support, i'm not seeing way typed datasets. example, i'm creating new request when create new reapproval. if reapproval fails update, don't want keep request. putting update calls under transactionscope mean if record fails, fail. not want. how commit or roll related rows in typed dataset? you can use regular transactions , achieve transaction feature tableadaptermanager in below examples. first a

Java Keystore: Command "openssl" not found -

i'm using windows 7 64 bit , i'm trying export base64 encoded sha-hash of key command: keytool -exportcert -alias [alias] -keystore [keystore] | openssl sha1 -binary | openssl base64 unfortunatly error command "openssl" not found i tried use other commands, shown on website: http://www.startux.de/index.php/java/44-dealing-with-java-keystores error, openssl cannot found. missing? solution i missing openssl. , downloaded here: deanlee.cn/programming/openssl-for-windows it works me on windows, conclusion can draw missing openssl, or not on path. either add it, or use full path executable.

WYSIHAT and rails 3 -

does have advice on how go installing wysihat in rails 3 app? there's lot of information getting work rails 2, there's engine , , decent blog posts they're dated also, prefer use jquery (or mootools) on prototype. better off sticking jquery wysiwig? need able add simple text formatting , hotlink images there wysihat jquery fork: https://github.com/swilliams/jq-wysihat

Executing PHP via command line -

i want able execute php via command line $_get variable . understand can exec , i'd understand more of security risk , things should out for. parameter want pass mysql auto_incremented id returned mysql, i'm not concerned user input. merely allowing happen things should considered in regards security? the script accept order id , send customer email invoice. allows me perform function multiple sections of site maintaining code in 1 location. i don't think need execute command line. create php function , include in multiple sections instead: faster. per example: function sendinvoice($orderid) { // } then call it: include_once('send_invoice.inc.php'); sendinvoice(42); this still allows code reuse , single place maintain code.

junit - Turn on gzip compression for grizzly under JerseyTest -

i have jersey implementation of web service. response per requirements must gzip-ed. client side contains following bootstrap code switch gzip on: client retval = client.create(); retval.addfilter( new com.sun.jersey.api.client.filter.gzipcontentencodingfilter()); for tomcat web.xml gzip configured follow <servlet> <display-name>jax-rs rest servlet</display-name> <servlet-name>jax-rs rest servlet</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.servletcontainer </servlet-class> <load-on-startup>1</load-on-startup> <init-param> <param-name>com.sun.jersey.spi.container.containerrequestfilters</param-name> <param-value>com.sun.jersey.api.container.filter.gzipcontentencodingfilter</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.containerresponsefilters</param-name>

registry - Configure Windows Explorer Folder Options through Powershell -

i'm looking way configure few options in folder option dialog of windows explorer through powershell. the options are: choose "show hidden files, folders, , drives" uncheck "hide extensions known file types" uncheck "hide protected operating system files (recommended)" keith's answer didn't work me out of box. thing took registry value modification showsuperhidden. both hidden (show hidden files...) , hidefileext (hide file extension) reverted previous values opened view tab in folder settings. here's solution, found after trial , error (explorer.exe automatically restarted): $key = 'hkcu:\software\microsoft\windows\currentversion\explorer\advanced' set-itemproperty $key hidden 1 set-itemproperty $key hidefileext 0 set-itemproperty $key showsuperhidden 1 stop-process -processname explorer i tested on windows server 2008 r2 , windows 7.

Is there a built-in function to sort and filter a python list in one step? -

given directory of files numeric names, sort , filter directory list in 2 steps. #files = os.listdir(path) files = ["0", "1", "10", "5", "2", "11", "4", "15", "18", "14", "7", "8", "9"] firstfile = 5 lastfile = 15 #filter out files not in desired range files = filter(lambda f: int(f) >= firstfile , int(f) < lastfile, files) #sort remaining files timestamp files.sort(lambda a,b: cmp(int(a), int(b))) is there python function combines filter , sort operations list needs iterated on once? those orthogonal tasks, don't think should mixed. besides, it's easy filter , sort separately in 1 line generator expressions files = sorted( (f f in files if firstfile <= int(f) < lastfile), key=int)

c# - Import DataSet into SQL Server 2008 Express -

i have large dataset containing 160.000 records. if loop trough dataset , import every record, can take 20 minutes before complete dataset imported sql server. isn't there faster way importing dataset @ once in database? the dataset created file process user provides, have 1 table called lets "importtable" containing 14 columns. columns correspond columns in dataset. i use visual studio 2010 professional c#. thanks in advance! you should take close @ sqlbulkcopy class. it's c# component (no external app), takes dataset or datatable input, , copies sql server in bulk fashion. should faster doing row-by-agonizing-row (rbar) insert operation... better yet: don't need import entire data set memory - can define sqldatareader on base data, , pass sqlbulkcopy read sqldatareader , bulk insert sql server.

php - Undefinded $_GET[' ...'] index -

after making javascript variable accesable php file $_get['something'] keeps saying undefined index. although proper result gets displayed , being written xml. if try initialise score no longer shows reason. how can initalise without showing @ al on screen? regards. if javascript: window.location.href="index.php?scoreresult="+score you have access variable in php using $_get['scoreresult'] instead of $_get['score'] if make use of xsl transform xml, xslt::setparameter may interesting you. allows register (php)-variables use inside xsl-stylesheet.

Add CSS gradient with javascript - bug in IE7 -

i trying add gradient on .link.box.gradient in ie7 add on .link.box.gradient , .style.box.gradient <!doctype html> <html lang="sv"> <head> <title></title> <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js"></script> <script> jquery(function ($) { $('head').append("<style>.link.box{height:100px;width:100px;}.link.box.gradient{filter:progid:dximagetransform.microsoft.gradient(startcolorstr='#000000',endcolorstr='#ffffff');}</style>"); }); </script> </head> <body> <div class="style box gradient">gradient (style-tag)</div> <div class="link box gradient">gradient (link-tag)</div> </body> </html> you can see here too, http://jsfiddle.net/zhvpy/ 1 strange thing when move out .li

Android Voice Actions: set-alarm intent -

what intent handle "set alarm" voice action? (for "listen to" android.media.action.media_play_from_search) can not use standard android.intent.action.set_alarm android.provider.alarmclock class?

How can I reference a variable in a variable? (powershell) -

my subject not worded correctly. i working on scripts , using "send-mailmessage" command. need have variables in body of message.... how can this? these variables directories, log file locations, ip addresses, etc script. when script finishes or fails need send email pertinent info job.. $bod = "this message please see log file @ $logfilelocation" send-mailmessage -to user@user.com -subject subject -from user@user.com -body $bod -smtpserver server you've got right idea. need build $bod string using variables. 'here' string work well. like: $bod=@" directory: $directory log file location: $logfilelocation ip address: $ipaddress "@ or asking how values variables?

Drawing atop a scrollable, zoomable image in Qt -

i'm sorry if question vague. it's been few years since did qt, , never did fancy image stuff. i'm asking below general suggestions on classes consider using. i'm trying avoid barking wrong tree start. the situation: i'm writing qt-based program in need display large (let's 5000x5000) raster image. user should able zoom (quickly) in , out, , pan around image in way similar example google maps. far, not different the qt imageviewer example , except perhaps requirement zooming happens quickly. however, need draw on order of 50k simple geometric shapes (let's circles) on top of image, , able add , remove of these in simple way. circles should have same size no matter zoom level, , should either redrawn whenever user zooms, or should drawn vector graphics. think of circles map annotations. these should same @ zoom level, , behave nicely respect panning. i guess question twofold: can qt draw vector graphics on top of raster image? in general, classes

Ninject + ASP.NET MVC + InRequestScope -

i have problem ninject. my binding rules: this.bind<isphinxqlserver>().to<sqlserver>(); this.bind<imysqlserver>().to<sqlserver>(); this.bind<isqllogger>().to<standardsqllogger>() .inrequestscope(); this.bind<databaseconnections>() .tomethod(x => connectionfactory.getconnections()) .inrequestscope(); this.bind<sqlserver>().toself() .inrequestscope() .withconstructorargument("connections", kernel.get<databaseconnections>()) .withconstructorargument("logger", kernel.get<isqllogger>()); where sqlserver, isphinxqlserver , imysqlserver are: public class sqlserver: isphinxqlserver, imysqlserver { public databaseconnections connections { get; internal set; } public isqllogger logger { get; internal set; } public sqlserver(databaseconnections connections) { this.connections = connections; } public sqlserver(databaseconnections connections,

namespaces - ASP.NET MVC - Controller names in nested applications -

i have mvc web app, , nested admin application areas same name: /localhost/videos /localhost/admin/videos these separate projects in vs solution. admin project deployed folder off of root app both videos areas have controller called videoscontroller . appears mvc calling root application's videoscontroller.index instead of admin site's videoscontroller.index, (correctly) trying return admin/areas/videos/views/videos/index view. i'd rather not have go in , rename of admin controllers. suggestions? what might specifying default namespace. typically this: controllerbuilder.current.defaultnamespaces.add("myproduct.controllers"); so now, if mvc has 2 of something, have default fall on. see lot of same issues if start using areas.

Is there a C compiler that targets the 8086? -

i have 8086 cpu emulator. emulates 8086 instructions. searching c compiler target emulator with. there c compiler out there can this? also, having usable libc , such not important me. emulator uses custom(ie, non-pc) hardware , therefor libc or ctr0 have rewritten anyway bcc - bruce's c compiler from bcc(1) - linux man page : description bcc simple c compiler produces 8086 assembler, in addition compiler compile time options allow 80386 or 6809 versions. compiler understands traditional k&r c restriction bit fields mapped 1 of other integer types. the default operation produce 8086 executable called a.out source file. open watcom from description of compiler option / 80x86 run-time convention 0 in open watcom c/c++ user’s guide (pdf link): (16-bit only) compiler make use of 8086 instructions in generated object code. default. resulting code run on 8086 , upward compatible processors. macro __sw_0 predefined if "0" s

python - Directing script output to a file using subprocess? -

from within python script ("main.py"), using subprocess module run script ("sub_script.py"). here's code in "main.py" script 'runs' "sub_script.py": subprocess.popen([sys.executable, "sub_script.py"]) this works fine long "sub_script.py" not have "print" statements in it. i want channel output of "sub_script.py" external file ("log.txt"). how do it? subprocess.popen([sys.executable, "sub_script.py"], stdout=open("log.txt", "a"))

javascript - Quit jQuery $.each loop -

possible duplicate: how break out of $.each in jquery? how quit jquery $.each loop? use return false inside .each() loop break out entirely. returning that's not false continue : stops current iteration , jumps right next. var myarr = [1,2,3,4,5,6,7]; $.each( myarr, function(){ // skip on 3 if( === 3 ) return true; // abort on 5 if( === 5 ) return false; dostuff( ); // never 3, 5, 6 or 7 });

arrays - Prolog print out 2 dimension table -

i have square start , finish points, places can't go. , program must find way reach finish: ar_galima([], _, _):-!. ar_galima([prad|galas],kelias, x) :- not(prad == x), not(member(x, kelias)), ar_galima(galas, kelias, x). gener(stac_m, stac_k, k(a,b), k(y,b)) :- y + 1, y > 0, y =< stac_m, b =< stac_k. gener(stac_m, stac_k, k(a,b), k(y,b)) :- y - 1, y > 0, y =< stac_m, b =< stac_k. gener(stac_m, stac_k, k(a,b), k(a,y)) :- y b + 1, y > 0, y =< stac_k, =< stac_m. gener(stac_m, stac_k, k(a,b), k(a,y)) :- y b - 1, y > 0, y =< stac_k, =< stac_m. paieska(_, _,_,tikslas,tikslas,[], _):-!. paieska(stac_m, stac_k, draudziama, prad, tikslas, [k|kelias], kelias2) :- gener(stac_m, stac_k, prad, k), ar_galima(draudziama, kelias2, k), paieska(stac_m, stac_k, draudziama, k, tikslas, kelias, [k|kelias2]). trasa(ilgis, aukstis, draudziama, k(x,y), tikslas, kelias) :- paieska(ilgis,aukstis, draudziama, k(x,y), tikslas,kelias, []).

Cron Job PHP script execution time report -

my question simple: want know how long php script taking execute. on top of this, executing via cron. now, via php code execution time start/end, wondered if there via cron command add emailed me, in milliseconds? currently using: /usr/bin/php -q httpsdocs/folder/script.php > /dev/null 2>&1 which runs script , stops errors/output getting emailed me. can change above execution time emailed me somehow? thanks you can use time command this: /usr/bin/time /usr/bin/php -q httpsdocs/folder/script.php > /var/log/crontiming

cron - Python OpenWRT crontab -

im trying run python script on openwrt box: #!/root/system/usr/bin/python import subprocess p = subprocess.popen([r"snmpget","-v","1","-c","public","-oqv","-ln", "192.168.1.1","1.3.6.1.2.1.2.2.1.10.7"], stdout=subprocess.pipe).communicate()[0] data = [r"curl","-d","iface_id=1&content="+ str(p).rstrip() ,"http://192.168.1.5:8080/stat/add_istat/"] = subprocess.popen(data, stdout=subprocess.pipe).communicate()[0] it's geting data on snmp, post data curl local server. working ok shell: root@openwrt:~/python# ./w.py % total % received % xferd average speed time time time current dload upload total spent left speed 0 34 0 6 0 28 31 146 --:--:-- --:--:-- --:--:-- 0 i can see data in db. cron: 0-55/5 * * * * /root/python/w.py i see in logread: dec 20 2

Python OpenCV: Detecting a general direction of movement? -

i'm still hacking book scanning script, , now, need able automagically detect page turn. book fills 90% of screen (i'm using cruddy webcam motion detection), when turn page, direction of motion in same direction. i have modified motion-tracking script, derivatives getting me nowhere: #!/usr/bin/env python import cv, numpy class target: def __init__(self): self.capture = cv.capturefromcam(0) cv.namedwindow("target", 1) def run(self): # capture first frame size frame = cv.queryframe(self.capture) frame_size = cv.getsize(frame) grey_image = cv.createimage(cv.getsize(frame), cv.ipl_depth_8u, 1) moving_average = cv.createimage(cv.getsize(frame), cv.ipl_depth_32f, 3) difference = none movement = [] while true: # capture frame webcam color_image = cv.queryframe(self.capture) # smooth rid of false positives cv.smooth(color_image,

python - Why does this code return a list index error? -

basically it's supposed take set of coordinates , return list of coordinates of it's neighbors. however, when hits here: if result[i][0] < 0 or result[i][0] >= board.dimensions: result.pop(i) when i 2, gives me out of index error. can manage have print result[2][0] @ if statement throws errors. why happening? def neighborgen(row,col,board): """ returns lists of coords of neighbors, in order of up, down, left, right """ result = [] result.append([row-1 , col]) result.append([row+1 , col]) result.append([row , col-1]) result.append([row , col+1]) #prune off invalid neighbors (such (0,-1), etc etc) in range(len(result)): if result[i][0] < 0 or result[i][0] >= board.dimensions: result.pop(i) if result[i][1] < 0 or result[i][1] >= board.dimensions: result.pop(i) return result you indexes iterate on list, , proceed remove e

android - How to animate Bitmap on Surface view onDraw()? -

i trying make game. try use gridview wonder how can drag item ontouchevent(). found example http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html it great example. cropped image in 12 small image bitmap. display them on screen randomly on specific position. overriding ontouchevent() got requirement. want animate image "swap" other image animating. have both images x,y location. wondring if can done animation class.so should not put effort doing manually. know not hard job. animation class can more smoothly. have arrayofimages(bitmap) , want swap 2images animation. using thread update "canvas" in background. please me. . more thing. how can add scroll view surface holder?? possible? because think when try drag image , not drag , active scrollbar response? finally using loop specific x,y specific x,y while updating canvas. although not efficient way.

objective c - Handling 404 error problems in the WebView Delegate in iPhone sdk -

i working webview based application, in had problem http 404 errors when tried load url. want show alert when happens. can guys please suggest me how trigger , there delegate methods fired when happens?. please suggest. thanks in adv, s. you can not check status code uiwebview requests. use webviews requests , when don't care status codes are. use nsurlconnection or asihttprequest requests. if have know status of http request, using nsurlrequest object , set delegate receive response status code.

php - what is the role of ob_start() in here -

session_start(); ob_start(); $hasdb = false; $server = 'localhost'; $user = 'user'; $pass = 'pass'; $db = 'acl_test'; $link = mysql_connect($server,$user,$pass); if (!is_resource($link)) { $hasdb = false; die("could not connect mysql server @ localhost."); } else { $hasdb = true; mysql_select_db($db); } a) ob_start() do.? got understand turn output buffering on. reference above code benefit if use ob_start() while trying establish connection database. output data buffer? thank you.. normally php sends text not included in <?php ... ?> , echos, prints output. send err... output: http server (which sends client), console etc. after ob_start output saved in output buffer, can later decide it. it doesn't affect db connection. deals text (mostly) produced php.

regex - Regular Expressions and JavaScript: Find digits in last part of string -

i need extract id number string. results given me in following format: "something kind of title (id: 300)" "1, 3, 4 - starts numbers (id: 400)" etc.. these values passed javascript, needs extract id number only, i.e. 300, or 400 in above example. i still struggling regex, appreciated. can string operations, feet wet regex on actual examples can use. online tutorials i've read far have proven fruitless. thank you if number in form (id: ###) \(id: ([0-9]+)\) should regex. brackets around id , number escaped, otherwise considered matching group (as brackets around [0-9]+ are. [0-9] means check character between 0 , 9 , + means 'one or more of'. var regex = new regexp(/\(id: ([0-9]+)\)/); var test = "some kind of title (id: 3456)"; var match = regex.exec(test); alert('found: ' + match[1]); example: http://jsfiddle.net/jonathon/fumhr/ http://www.regular-expressions.info/javascript.html useful resource

python - django-admin.py makemessages issues (1) Duplicated message (2) .pot not .po? -

hi i'm working on localization of website frontend, , met 2 issues django-admin.py makemessages -l zh_cn. 1) it's generating .pot files instead of .po files? why that? how change this? 2) when i'm editing translation got kind of error message "duplicate message definition". makes sense because have same string in different html pages, example, "login", it's duplicated. i'm not sure how avoid these duplicated messages? there no other ways remove duplicated ones 1 one manually? (i can't delete strings in poedit) what i've done renamed .pot file .po, , manually deleted duplicated strings, don't think it's proper way do? plus in future if need make changes, if "django-admin.py makemessages -l zh_cn" again, .pot file show again , i'll have manually change on again, , translation i've done .po file no longer there... how avoid this?? many in advance time , patience!! all solved. it's because th

Entity Framework Inheritance -

i have looked @ several possible solutions issue did not find right one. i need full set, is, need fetch types of base type. i.e. actionhistory type, others, inherit actionhistory base class. problem was getting entities of actionupdate type did not have actionupdatedetails collection filled. my problem unable retrieve actionupdatedetails data within derived actionupdate class. there 3 classes in model: public class actionhistory { public int id {get;set;} } public class actionupdate : actionhistory { public icollection<actionupdatedetail> actionupdatedetails{get;set;} } public class actionupdatedetail { int id{get;set;} public string field{get;set;} public string value{get;set;} } i tried implementing solution suggestion: entity framework: inheritance , include like this: var result = actionhistory in actionhistories select new { actionhistory, actionupdatedetails = actionhistory actionupdate ? (actionhistory actionupdate).actionupdatedetails : null }; a

Programmatically creating Excel VBA validation list -

i have array of data coming in vba code external source. want able assign data use validation in dropdown box in cell in 1 of sheets in workbook. however, not want copy data sheet , use named range - there may quite lot of data, , not feel efficient! i'm sure there must way - haven't found 1 yet. ideas? place data in text file delimiting comma eg(a,b,c). read data using vba string variable eg validationlist. use thing this with range("a1").validation .add type:=xlvalidatelist, alertstyle:=xlvalidalertstop, operator:= _ xlbetween, formula1:=validationlist .ignoreblank = true .incelldropdown = true .inputtitle = "" .errortitle = "" .inputmessage = "" .errormessage = "" .showinput = true .showerror = true end with

UIAlertview in iphone application -

i new iphone application.i working on first app.i have implement alertview 3 textfields , 3 labels(currentpassword,newpassword,verifypassword) , 2 uibuttons(submit,cancel).title is:changepassword.upto now,i found single textfield , 2 uibutton fields.can tell me,how can done this?give me example or detailed explanation. you've got lot of stuff there. commenters note, modal viewcontroller way go. can have slide bottom , cover setmodaltransitionstyle:uimodaltransitionstylecoververtical .

java - how to listen the change the value in textfield or textbox in j2me? -

i want store each character input user. when user presses key, key should store in variable. when user presses other key, must replace value of variable new character in textbox in j2me yes need listen event itemstatelistener , can handle in itemstatechanged(..) here full code /* * change template, choose tools | templates * , open template in editor. */ package hello; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; /** * @author jigar */ public class keyeventlistener extends midlet implements itemstatelistener{ private boolean midletpaused = false; //<editor-fold defaultstate="collapsed" desc=" generated fields "> private form form; private textfield textfield; //</editor-fold> /** * keyeventlistener constructor. */ public keyeventlistener() { } //<editor-fold defaultstate="collapsed" desc=" generated methods "> //</editor-f

javascript - Ebook in iOS using CSS multi-column (calculate range of text in different column) -

my first question here. correct me if i've done wrong. i've found source here demonstrate how paginate html using css multi-column. http://groups.google.com/group/leaves-developers/browse_thread/thread/27e4bf5ff3c53113/f137dc01b6d853b7 my question is: how calculate range / location of text in different column (page)? for example, when changing font size, text in current page jump page. solve this, program should save current text location, , move correct page (column) after reformatting web page. it useful implementing bookmark function. i think should done javascript, i'm new javascript. any suggestions , tips welcomed. this bit of general question, , hard answer, i'll try point in direction might try. i have no idea how layout of page might or function, 1 way theoretically checking text node of 'column' whenever change font-size (presuming font size change implimented button click). so, instance, have div w/ id #column_1, whenever

java - transform xml to xsl -

i'm calling web service, returning result in xml format. how convert returning xml xsl , display in web browser? xsl language specifying visual formatting of xml document. cannot extract xsl xml.

.net - compare two generic list containing class objects -

how compare 2 generic list(of csystem) in csystemcatalog class? wanna know if 1 of list contains more or fewer class objects, want compare _systemkey , _systemname public class csystemcatalog private _systems list(of csystem) public class csystem private _systemkey int32 private _systemname string if _systems1.count > _systems2.count

php - There in PDF not change the style which i have added in HTML? -

in site, using tcpdf generate pdf html ,and using image in header can't show style added in html. ljubljana,'.date("d.m.y").' '.jtext::_('buyer_name').': '.$my->name.' '.jtext::_('booking_code').': '.$ticketno.' this table in pdf not margin top given 35px. plz help....... if refer original documentation , examples of tcpdf when checking question, you'll find without valid solution. this because tcpdf hasn't full css complementation, basic formatting. gethtmldomarray() you'll able access css partial use, such font-family , others . so, if want use full css tcpdf, using wrong tool , i'd advise try other 1 make same output, many are. anyway, sure check new versions of implementation, in case want keep using it, might add more implementations on future.

android - How to display a text popup on single click and download on double click? -

i busy editing aptoide code github used users suggest apps , able browse , download suggested apps. the problem aptoide not display explaination of app is. so know firstly, possible code if single-click event , double-click event? and secondly, how go coding this? single-click show info app , double click download app. you'd click suggested app, it'll show info , click again download. i using eclipse adt plugin. i have tried thorough possible. i not eclipse , android yet, might have spoon feed me here. i long press standard action people expect not double tap, check out adapterview.onitemlongclicklistener docs maybe i'm not understanding correctly you're trying do mean want change onclicklistener once first 1 has been run.

get result of two query with one query - mysql -

$sql ="select * user limit 5"; is there way can limited number of results total results without limit. basically want result of below 2 queries in 1 single query. query 1 : select count(*) user query 2 : select * user limit 5 is possible without sub query? select *, '' total user limit 5 union select *,count(*) total user group id>0

r - ggplot and errorbars -

i'm trying create plot errorbars following data (dput of dataframe in end). i'd create errorbars "est a" , "est b" variables each "loc", cannot figure out right way melt/cast data each "loc" have 2 rows several columns. i.e. i'd convert dataframe into loc est value lb ub a 0.56 0.26 1.20 a b 0.26 0.11 0.60 b 0.13 b b 0.03 c a c b ggplot(test,aes(x=loc,y=value,color=est))+geom_point()+geom_errorbar(aes(ymax=ub,ymin=lb)) > dput(test) structure(list(loc = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s"), `est a` = c(0.563270934055709, 0.137109873453407, 0.0946514679398302, 0.185103062070327, 0.0322566231880829, 0.122509922923046, 0.1202

python - Printing without newline (print 'a',) prints a space, how to remove? -

i have code: >>> in xrange(20): ... print 'a', ... a a a a a a a a a a i want output 'a' , without ' ' this: aaaaaaaaaaaaaaaaaaaa is possible? there number of ways of achieving result. if you're wanting solution case, use string multiplication @ant mentions. going work if each of print statements prints same string. note works multiplication of length string (e.g. 'foo' * 20 works). >>> print 'a' * 20 aaaaaaaaaaaaaaaaaaaa if want in general, build string , print once. consume bit of memory string, make single call print . note string concatenation using += linear in size of string you're concatenating fast. >>> in xrange(20): ... s += 'a' ... >>> print s aaaaaaaaaaaaaaaaaaaa or can more directly using sys.stdout . write() , print wrapper around. write raw string give it, without formatting. note no newline printed @ end of 20 a s. >>> impo

.net - Attaching to w3wp using mdbg -

i trying attach w3wp process using command line managed debugger (mdbg). not able see process in list of processes "a" command. i sure problem w3wp process running in session under localsystem account , cannot find documentation on how attach types of processes using mdbg. is possible? it turns out running w3wp process in 64 bit mode , running mdbg process in 32-bit mode. had 32 bit powershell window open obscured fact running in 32-bit mode. as executed mdbg in 64-bit mode, w3wp showed up.

iphone - Adding UIImageView to UIScrollView in background Thread, wont show up until all are added -

i have scrollview add uibuttons , uiactivityindicators in main thread. perform [nsthread detachselectorinbackground:@selector(getimages) totarget:self withobject:nil]; getimages downloads images , add them uiimageviews , adds uiimageviews scrollview, wont show until method getimages done. there way scrollview redraw or refresh or that? and if scroll scrollview (with fingers..) during getimages method, uiimageviews has been added shows up. - (void) getimages { nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; int x=5; int y=0; nsdata *imgdata; uiimage *img; uiimageview *imgview; (nsdictionary *tmp in thumbs) { imgdata = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:[functions urlforfile:[tmp objectforkey:@"img"]]]]; if ([imgdata length] > 0) { img = [[uiimage alloc] initwithdata:imgdata]; imgview = [[uiimageview alloc] initwithframe:cgrectmake(x, y + (133-img.size.height)/2, 100, img.size.height)];

date problem while adding Event to iPhone calendar -

while adding event calendar of iphone, date going reseted 1.1.2001 , have no idea why. id arg1 = [args objectatindex:0]; // start id arg2 = [args objectatindex:1]; // end id arg3 = [args objectatindex:2]; // title id arg4 = [args objectatindex:3]; // location id arg5 = [args objectatindex:4]; // text nsdateformatter *df = [[nsdateformatter alloc] init]; [df setdateformat:@"yyyy-mm-dd hh:mm:ss"]; nsdate *startdate = [df datefromstring: arg1]; nsdate *enddate = [df datefromstring: arg2]; ekeventstore *eventstore = [[[ekeventstore alloc] init] autorelease]; ekevent *event = [ekevent eventwitheventstore:eventstore]; event.title = arg3; event.location = arg4; event.notes = arg5; event.startdate = startdate; event.enddate = enddate; [event setcalendar:[eventstore defaultcalendarfornewevents]]; nserror *err; [eventstore saveevent:event span:ekspanthisevent error:&err]; the input seems fine since nslog([args objectatindex:0]); writes correct da

out of memory - Solr - Faceted navigation on large index -

i have index containing 1.2 billion of documents (solr 1.4.1). want enable faceted navigation on field (int type) containg around 250 unique values. i getting java heap space java.lang.outofmemoryerror default method (facet.method=fc), while enum method slow (but works). what best approach given number of documents , unique values? updated: so if understand correctly: memory usage faceting using fc method is: maxdoc * 4bytes (the field type int, 64bit jvm), is: 1118950216 * 4bytes = 4.1gb (aprox.) memory usage faceting using enum method is: numberofuniquevalues * sizeofbitset = 250 * (1118950216 / 8) = 32gb is correct? i try again fc method (and give more ram solr). thanks! you'll have tune jvm memory allocation settings and/or add more memory server; or alternatively sharding index .

objective c - iPhone PopUp RGB colors -

i presenting uiview animation takes half of screen. i've seen in many apps not find appropriate rgb colors: ios uses example in "contacts": http://img98.imageshack.us/img98/9402/image001u.png i'm trying : bottomlayer.backgroundcolor = [[uicolor colorwithred:80.0/255.0 green:86.0/255.0 blue:97.0/255.0 alpha:1] cgcolor]; but it's whitey. if how popup designed... thanks! you'll want @ uiactionsheet . create view , have proper animations. easy use. you need implement uiactionsheetdelegate delegate method. @interface myviewcontroller : uiviewcontroller <uiactionsheetdelegate> and make action sheet: uiactionsheet *choice = [[uiactionsheet alloc] initwithtitle:@"" delegate:self cancelbuttontitle:@"annuler" destructivebuttontitle:nil

How To Get Current User in ASP.NET MVC Model -

in opinion not duplicate of how current user in asp.net mvc . i trying figure out how access current user asp.net mvc model in manner easy unit test. models linq sql entities generated sqlmetal. the reason think need know current user in model because want restrict access properties / methods based on user's privileges. i open adopting alternative design , making whatever changes necessary implement in clean, unit test friendly manner. managing permissions , restricting access properties sounds job controller. model's single responsibility store data, not know or manage users , permissions. so, in short, don't need current user in model.

javascript - Virtual pageview in place of real pageview in Google Analytics -

i'd have better error page reporting in google analytics. currently, if on site causes problem, see error page instead of content expected. url remains same. if went www.example.com/view_my_profile , there problem profile, see error page @ url. what i'd send google analytics virtual pageview of www.example.com/error/view_my_profile/ (maybe event captures parameters better?). that's easy enough. want virtal pageview happen instead of /view_my_profile real pageview. because real page wasn't viewed , registering pageview on site. is simple leaving out _trackpageview call in google analytics snippet below or asking trouble? var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-${gaaccount}-1']); _gaq.push(['_trackpageview']); way over-complicating things..just use _trackpageview normal pass value (virtual url) url want be. count page view url pass instead of current url.

mysql - What's the most scalable way to track user activity? -

i track user activity , limit activity using time constraint. example of votes per day limit enforced so. of following methods provides better solution in terms of scalability , ease of use? store activity info in database store activity info in application scope use entirely different method track information method 1: advantages : data integrity, not important in use case. disadvantages : requires database interaction, stores redundant data, requires scheduled event reset values being tracked method 2 advantages : not require database interaction, appears easier disadvantages : i'm unsure of implications on application memory given large user-base track, or how easy find , manipulate struct data hundreds of keys i'm using coldfusion mysql, if matters. assuming care data on per-person basis, , won't getting aggregates of this, i'd suggest go key/val store supports ttl. redis sounds fits requirements pretty well. though runs in me

layout - Android: Use different drawables after choosing a different theme, keeping the same references -

is possible make app use different drawables after choosing theme in android? an explanatory example: i have layout background uses reference to: "@drawable/backgroundsolid", image backgroundsolid.png in res/drawable-mdpi . i want that, if user choose "glass" theme, reference stays "@drawable/backgroundsolid" resources folder changed res/drawable-glass , contains different backgroundsolid.png image. is possible set programmatically? lot! you can set programmatically using view.setbackgroundresourceid() . not sure if other way let android pick right theme you. maybe else has better answer

multithreading - Python multiprocessing and sockets not being closed -

i'm experiencing odd behaviour when using multiprocessing , socket on python. i'm dealing piece of code similar 1 i'm posting below (i've simplified things lot trying naive). the code spawns 3 processes: 1 process nothing, process launches third one, listening on socket. if terminate "listener" process, socket still remains open (i can see there netstat). if remove (or stop) "donothing" process, works. if switch threading.thread, works, but if leave donothing process , switch server , launcher threading.thread, problem persists. does have hint why socket still opened? there problem dealing multiprocessing , sockets? i'm using python 2.6.6 running on linux. thank much, alvaro. import time multiprocessing import process, event import socket class server(process): def __init__(self, port): super(server, self).__init__() self.s = socket.socket(socket.af_inet, socket.sock_stream) self.s.bind(("1

php - quantity of data that should be stored in session -

assumption understand it's not store data , needed simple. state today use minimum needed , using simple data types (int , strings) storing user's id , tell if logged in. must of functions static or singleton has built each post/get. have trouble representing current state , changing it. , largely static site. of state representing goes javascript . target other hand if i'll create object represent entire website easier me maintain user's input , including database interaction. simple question, how data should stored there? example 1 of things want implement objects relate database tables, let's take page " car.update() ". if store object it, extends connection database methods crud. when handle post page details put them in properties needed , call update method. situation now: need create new object details , make static update another example storing previous search result , filter using new data in many cases ide