Posts

Showing posts from April, 2011

asp.net mvc - How to use Linq objects to validate a view in MVC 2 -

i use linq , typed views in right way. @ moment following: make model verify agianst: public class menu { public int id { get; private set; } public string text { get; private set; } public string action { get; private set; } public string controller { get; private set; } public string parameter { get; private set; } public string langue { get; private set; } public menu(int id, string controller, string action, string parameter, string text) { id = id; controller = controller; action = action; text = text; parameter = parameter; } use linq data database model: public static list<menu> gettablistformenu(string langue) { page_dbentities entity = new page_dbentities(); var tablist = (from ml in entity.wpmenulangue ml.langue == langue m in entity.wpmenu ml.menu == m.id ...

c - How to use getaddrinfo_a to do async resolve with glibc -

an overlooked function requires no external library, has no documentation whatsoever. update (2010-10-11) : linux man-pages have documentation of getaddrinfo_a, can find here: http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo_a.3.html as disclaimer should add i'm quite new c not newbie, there might bugs, or bad coding practices, please correct me (and grammar sucks too). i didn't know until came upon this post adam langley, shall give few code snippets illustrate usage of , clarify things might not clear on first use. benefits of using data readily usable in socket() , listen() , other functions, , if done right won't have worry ipv4/v6 either. start off basics, taken link above (you need link against libanl (-lanl)) : here function prototype: int getaddrinfo_a(int mode, struct gaicb *list[], int ent, struct sigevent *); the mode either gai_wait (which not want) , gai_nowait async lookups the gaicb argument a...

Excel like server side control for ASP.NET -

we have requirement increase functionality of grid using edit on our webapp, , our manager keeps citing excel perfect example data grid :/ still doesn't spreadsheet control doesn't exist out of box, thought i'd bit of searching nonetheless. i've found couple of products on google, wondering if else has feedback around such controls (obviously cheaper or ahem freer better) edit have telerik controls, 'current' requirement is, control can copy , paste (e.g) 3 cells 1 row , paste them on another, row row editing of telerik doesn't cut it. in competition 'excel' based solution, nightmare in winning users around, prefer flexibility structure update: silverlight fast approaching, maybe can use real excel control. devexpress has powerful grid control both web , windows. not free , guess nothing matches excel. once users started using it, wanted every app it. check these videos data grouping one.

math - Algorithm to find a common multiplier to convert decimal numbers to whole numbers -

i have array of numbers potentially have 8 decimal places , need find smallest common number can multiply them whole numbers. need original numbers can multiplied out same scale , processed sealed system deal whole numbers, can retrieve results , divide them common multiplier relative results. currently few checks on numbers , multiply 100 or 1,000,000, processing done *sealed system can quite expensive when dealing large numbers multiplying million sake of isn’t great option. approximation lets sealed algorithm gets 10 times more expensive every time multiply factor of 10. what efficient algorithm, give best possible result, accomplish need , there mathematical name and/or formula i’m need? *the sealed system isn’t sealed. own/maintain source code 100,000 odd lines of proprietary magic , has been thoroughly bug , performance tested, altering deal floats not option many reasons. system creates grid of x y cells, rects x y dropped grid, “proprietary magic” occurs , results spa...

java - Static factory method with generics -

i have class enumconverter<t extends enum<?>> converts strings correct enum constant enum t (i can't use enum.valueof ). construct instances of class in factory method this: public static <t extends enum<?>> enumconverter<t> getinstance(class<t> enumclass) { return new enumconverter<t>(enumclass.getenumconstants()); } this works, want cache enumconverter instances make sure there 1 per enum, i.e. map , , problem how declare map . closest have come this: private static final map<class<?>, enumconverter<? extends enum<?>>> but error if try return value map factory method: type mismatch: cannot convert enumconverter<capture#1-of ? extends enum<?>> enumconverter<t> any ideas? as want store different sub types in map, compiler can't know actual subtype receiving. think have add cast: public static <t extends enum<?>> enumconverter<t> getinstanc...

javascript - Microsoft JScript runtime error: 'RequestCompleted' is undefined -

anyone got ideas? the above error occurs when following code run: sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted); within block: <script language="javascript" type="text/javascript"> var postbackelement; sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted); sys.webforms.pagerequestmanager.getinstance().add_initializerequest(initializerequesthandler); function initializerequesthandler(sender, args) { //set postbackelement postbackelement = args.get_postbackelement(); } you need handle requestcompleted event if you're going use it: function requestcompleted(sender, args) { // need here } if don't need handle event, remove line markup: sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted);

sql server - How to check which locale is a .NET application running under, without having access to its sourcecode? -

context: i'm in charge of running service written in .net. proprietary application. uses sql server database. ran user member of administrators group in local machine. worked alright before added machine domain. so, added machine domain (win 2003) , changed user member of power users group , now, the problem: of sql sentences tries execute "magically" in spanish localization (where , separates floating point numbers instead of .), leading errors. there fewer columns in insert statement values specified in values clause. number of values in values clause must match number of columns specified in insert statement. @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection) operating system , regional settings in machine in english. asked provider of application , said: looks have combination of code running under spanish locale, , sql server under english locale. sql expects '15.28' , no...

java - Hibernate with Annotations and MySQL: Creation Date -

i try save date of creation of entity. have found that approach. tried implement date doesn't reach db-table. import java.io.serializable; import java.util.date; import javax.persistence.entity; import javax.persistence.id; import javax.persistence.prepersist; @entity public class project implements serializable { private static final long serialversionuid = 7620757776698607619l; @id int id; string title; date created; public int getid() { return id; } public void setid(int id) { this.id = id; } public void settitle(string title) { this.title = title; } public string gettitle() { return title; } @prepersist protected void oncreate() { created = new date(); } public date getcreated() { return created; } } only title being saved. field data empty :-( where mistake? thank helping me. update i tried add annotation of pascal didn't help. possible should use sql.date istead of utils.date. try can't find how today's d...

windows - a problem with creating a site in IIS 7.5 which is using PHP -

i trying run web application scripted in php on windows server 2008. have configured php (as fastcgi) , iis. goes fine except following scenario. in php.ini document "doc_root" edited correct root path php projects "c:\inetpub\wwwroot\". created new site on iis , mapped it's path "c:\inetpub\wwwroot\application1". when try open site, see somehow (iis or php no idea ) nt run new application on path "c:\inetpub\wwwroot\application1". tries run on "c:\inetpub\wwwroot\", returns 404 of course. missing here ? check see whether changing , loading correct php.ini file using phpinfo()

A design pattern question regarding multiple database with slightly different structures -

i working on rewrite of old perl project. project employee performance evaluation. every year employee evaluated supervisor(s). the project first put use in 1994 using mysql. in 1995, new mysql database created 1995 evaluation , source code modified. 1996, 1997, .....2003. in 2004, different. developers use oracle....til now. see there more 10 databases. a bad thing each year evaluation form (evaluation standard) different. database structure different year year. now need rewrite project using jsp/servlet has universal user interface years. have keep database structure, boss said, data very sensitive keep there. this situation. tell me how design this? design patter should used? i assume evaluation reports used view data, not change them anymore. if case, decide data/tables needed databases evaluation reports (this possibly subset of data/tables). on each database, define view contains data evaluation report. of course, view definition different every database...

sql - Do I really need to use transactions in stored procedures? [MSSQL 2005] -

i'm writing pretty straightforward e-commerce app in asp.net , need use transactions in stored procedures? read/write ratio 9:1 many people ask - need transactions? why need them? when use them? the answer simple: use them time, unless have reason not (for instance, don't use atomic transactions "long running activities" between businesses). default should yes. in doubt? - use transactions. why transactions beneficial? deal crashes, failures, data consistency, error handling, write simpler code etc. , list of benefits continue grow time. here more info http://blogs.msdn.com/florinlazar/

asp.net - help styling the asp:button control using the Sliding Door technique -

due problem encountering asp.net (see: asp.net 4.0 random posting behavior ) need style asp:button controls (that of course resolve <input type=submit> tags) using sliding door technique. we had <button><span>text</span></button> sets because of above issue need move asp:button controls. you cannot put <span> tag inside of asp:button control, working above not work. i got work in ie8 wrapping button div using "display: inline-block". fails in ie7, not solution us. needs work in both ie7 & ie8 (firefox great, in not required) to fix display: inline-block; ie6-7 can try <div class="button"><input type="submit" /></div> .button { display: inline; display: inline-block; zoom: 1; } (these styles correct time want simulate inline-block in browsers)

Class for representing a card in Java? -

i'm making blackjack program in java, , starting write class declaration object card. sufficient, or there methods should have i'm glossing over? public class card { public int suit; //value 1-4 represent suit public int value; //value 1-13 represent value (i.e. 2, j) public card(int suit, int value) { //not yet implemented } } also, there way have c++'s enum data structure in java, because nice card names , suits? public enum suite { heart, diamond, club, spade } public enum value { two, three, ... , jack, queen, king, ace } and rest can figure out.

iphone - What devices does Apple test your app on during app review? -

we have app ready submission app store. app built 4.0 , targeted run on 3.1 , above. have tested on iphone 3gs 3.x , 4.0, on ipod touch 3.1.3 , iphone 3g 3.x , works fine. on iphone 3g 4.0, app becomes slow after half hour , starts giving low memory warning. crashes. not observed on other device or 3g 3.x os. os update has made 3g device terribly slow , inbuilt apps settings slow now. i wanted know if has idea devices , os apple tests app with. 3g no longer on sale. there has got lots of users still have it. apple reject app if 3g ios4 combination kills app? apple typically tests iphone 3gs , iphone 4, @ least 2 they've ever listed in rejection notices i've run across. either way, i'm whole-heartedly against releasing app doesn't run on device stating support. shouldn't sell/give away doesn't work, not 99 cents, not free, not @ all. take time make quality apps, not crapps. that's customer service, , more notably personal pride in produc...

How do I determine the permission settings for PHP scripts? -

what best file permission settings php scripts? suggestions on ways figure out minimum required permissions? wallowizard correct should use minimum permissions necessary script function. however, let me more specific, assuming you're running on unix-based system such linux or bsd or mac osx. web server runs unprivileged user such "nobody" , scripts need readable user, best permissions 644, meaning can read , write script, , else can read it. in uncommon case script owned same user running web server, can set permissions 600, can read , write script , no 1 else can read it.

asp classic - Checkbox list in columns via JQuery -

how can create layout set of checkboxes evenly distributed columns @ top of page? i'm using jquery , classic asp. use css , html: #checks_container { width:600px; overflow:auto; } .check{ float:left; width:100px; } html: <div id="checks_container"> <div class="check"><input type="checkbox" name="myname" value="1" />one</div> <div class="check"><input type="checkbox" name="myname1" value="2" />two</div> <div class="check"><input type="checkbox" name="myname2" value="3" />three</div> </div>

ggplot2 - R + ggplot: plotting irregular time series -

i have data @ number of days since event. data sampled irregularly - time points 0, 5, 6, 10, 104 days. don't have specific date-time information - i.e. have no idea when in real life event i'm studying occurred. i'd plot, using ggplot, time series. can use, say p <- ggplot(data,aes(x=time,y=expression)) p <- p + geom_point() but of course x-axis variables plotted next each other, distance between t=10 , t=104 same t=5 , t=6. can make like start <- isodate(2001, 1, 1, tz = "") data$time <- start + data$time*60*60*12 which works, ticks on x-axis horribly inaccurate date times. re-format them maybe? can't see anyway make format "days start". , i've been googling around quite while, nagging feeling i'm missing obvious. i? sounds time variable factor or maybe character vector, not numeric value! if data$time <- as.numeric(data$time) may solve problem. ggplot pretty @ using right sort of scale right sort o...

What are the pros and cons of the SVN plugins for Eclipse, Subclipse and Subversive? -

svn in eclipse spread 2 camps. svn people have developed plugin called subclipse . eclipse people have plugin called subversive . broadly speaking both same things. advantages , disadvantages of each? both similar subversive "eclipse svn provider". use subversive because of few convenient features: grouping of history when i'm browsing history of branch instead of seeing bunch of rows every commit can group commits today, week, etc. mapping of trunk, branches, , tags subversive assumes default svn layout: trunk, branches, tags (which can change), whenever want tag or branch 1 click , provide name of tag or branch. like said these minor differences find convenient. both work great mylyn, overall there isn't whole lot of differences these 2 extensions. merging subversive pain though (haven't tried subclipse), i've never been able merge. preview of merge great never complete merge or take way long. of time complete merging through command...

open source - What are some viable alternatives to BizTalk Server? -

in evaluating different systems integration strategies, i've come across words of encouragement, words of frustration on biztalk server. what pros , cons using biztalk server (both developer standpoint , business user), , should companies consider open source alternatives? viable alternatives out there? edit: jitterbit seems interesting choice. open source , seems nicely engineered. on here have experience working it? biztalk server's key benefit provides lot of 'plumbing' around deployment, management, performance, , scalability. through visual studio, provides comprehensive framework developing solutions, relatively little code. the frustration , steep learning curve others mention comes using biztalk wrong purpose , misunderstanding how work biztalk , message-oriented systems in general. learning curve not steep people suggest - essential part of underlying learning focuses on changing thinking procedural approach stateless message-based approach...

security - NHibernate and shared web hosting -

has been able nhibernate-based project , running on shared web host? nhibernate whole lot of fancy stuff reflection behind scenes host i'm using @ moment allows applications run in medium trust, limits can reflection, , it's throwing sorts of security permission errors. case though i'm using public properties in mapping files, though have classes defined proxies. which companies offer decent (and reasonably priced) web hosting allows nhibernate run without complaining? update: seems these answers (and experimentation -- sorry ayende, still can't work on web host after going through article linked to) choose hosting provider wisely , shop around. seems webhost4life pretty in respect. however, has tried nhibernate windows shared hosting 1and1? have linux account them , i'm satisfied on front, , if nhibernate work seamlessly windows i'd stick them. i have had no issues running nhibernate based apps on webhost4life, although don't them. get...

clojure - How do I multiply all elements in one collection with all the elements in another collection? -

say have: (def s1 [1 2 3 4 5]) (def s2 [1 2 3 4 5]) for every x in s1 , want multiply every y in s2 . to clarify, want cartesian product, don't think map works here. (for [x1 s1 x2 s2] (* x1 x2))

VS2008 Command Prompt + Cygwin -

i use vs2008 command prompt builds, tfs access etc. , cygwin prompt grep, vi , unix-like tools. there way can 'import' vcvars32.bat functionality cygwin environment can call "tfs checkout" cygwin itself? according this page need to: "depending on preference, can either add variables required compilation direct environment, or use vcvars32.bat script set them you. note have compile cygwin bash shell, use vcvars32, first run dos shell, run vcvars32.bat, run cygwin.bat directory installed cygwin. can speed adding directory containgin vcvars32 (somewhere under \microsoft visual studio\vc98\bin) , directory containing cygwin.bat path."

php - Algorithm to stop flickering (clear box and re-populate) when adding text -

i wondering if there's algorithm or resource @ changes made ajax request , not update whole box (causing flicker) add/remove changes made. this used keypress command. a example stack overflows "preview" doesn't flicker when add more text parses text adds (though i'm not sure uses ajax in stackoverflow's case). i'm using jquery so: $('#content').html(response); thanks! matt mueller the best (most flexible way) accomplish break target , response chunks. returning json object {object-id: 'html source', ...} , checking if each object has changes associated before updating. i'm guessing want catch-all parsing-solution, text-difference scanner update changed portions - creates more inflexible problems. because done through ajax call, it's hard determine returned (if it's valid request or not), , how of has changed. for reference, preview on uses attacklab's showdown , pure-javascript parse.

windows - Is there any better MFC 2008 Feature Pack Documentation -

i'm trying figure out how use cdockablepane. but few total overloaded demo samples (look marketing samples not intended programmers) can't find tutorial kind. , reference heavy medium skilled mfc hacker me. edit: documentation have @ moment: msdn vs2010 mfc as microsoft bought feature pack classes bcgsoft, there more information on homepage http://www.bcgsoft.com/ in support area.

Is there any way to create multiple insert statements in a ms-access query? -

i using ms access 2003. want run lot of insert sql statements in called 'query' in ms access. there easy(or indeed way) it? yes , no. you can't do: insert foo (c1, c2, c3) values ("v1a", "v2a", "v3a"), ("v1b", "v2b", "v3b"), ("v1c", "v2c", "v3c") but can do insert foo (c1, c2, c3) select (v1, v2, v3) bar what if don't have data in table? well, craft select statement composed of lot of unions of selects hard coded results. insert foo (f1, f2, f3) select * (select top 1 "b1a" f1, "b2a" f2, "b3a" f3 onerow union select top 1 "b1b" f1, "b2b" f2, "b3b" f3 onerow union select top 1 "b1c" f1, "b2c" f2, "b3c" f3 onerow) note: have include form of dummy table (e.g., onerow) fool access allowing union (it must have @ least 1 row in it...

REST type API for non web based applications, Is It a good idea? -

we developing middleware sdk, both in c++ , java used library/dll by, example, game developers, animation software developers, avatar developers enhance products. having created typical api using specific calls specific functions considering simplifying api using rest type api (get, put, post, delete) or crud type (create, read, update, delete) interface. this work in similar way client-server type rest api there 4 possible api calls these can take flexible parameters. this seems have benefit of making api stable in new calls not being added , old calls not being removed. consumer of api need not worry having recompile , change code suit updates our middleware. the overhead there layer of redirection in middleware controller route api calls , developer needs know parameters available each rest call (supplied of course). i have not far seen system used outside of web type client server applications question this: feasible idea? i thinking in terms of efficiency if exampl...

Ignore case in Python strings -

this question has answer here: how do case-insensitive string comparison? 10 answers what easiest way compare strings in python, ignoring case? of course 1 can (str1.lower() <= str2.lower()), etc., created 2 additional temporary strings (with obvious alloc/g-c overheads). i guess i'm looking equivalent c's stricmp(). [some more context requested, i'll demonstrate trivial example:] suppose want sort looong list of strings. thelist.sort(). o(n * log(n)) string comparisons , no memory management (since strings , list elements sort of smart pointers). happy. now, want same, ignore case (let's simplify , strings ascii, locale issues can ignored). can thelist.sort(key=lambda s: s.lower()), cause 2 new allocations per comparison, plus burden garbage-collector duplicated (lowered) strings. each such memory-management noise orders-of-magnitude s...

objective c - Creating a plist using Java -

is there easy way create plist java? result should same serializing dictionary in objective c. the plist class code.google.com/xmlwise looks more promising me.

Trying to use regex matches between words using PHP -

i trying match html tags might occur between words on web page, using regex's. for example, if sentence want match "this word", need develop pattern match "this <b>word</b> ". i've tried using code below prepare regex pattern: $pattern = "/".str_replace(" ", .{0,100}, $sentence)."/si"; this replaces spaces .{0,100} , uses s modifier match character. however, getting undesired results this. thanks in advance this! try use ereg_replace() or preg_replace() function when trying perform regular expression search , replace.

html - Redirecting to another PHP page, then going back with filled fields -

i have been needing way to, once redirect php page review data, have ability go original page fields filled before redirecting. can think of several messy ways of doing nothing willing do. there standard way of doing this? depending on sensitivity of data, store in session variable , check presence of post or variables prior falling session variables when form being displayed. you wrap above nicely, don't suspect there's easier way around if you're trying keep query string clean.

sockets - java.net.SocketException: Connection reset -

i getting following error trying read socket. i'm doing readint() on inputstream , , getting error. perusing documentation suggests client part of connection closed connection. in scenario, server. i have access client log files , not closing connection, , in fact log files suggest closing connection. have idea why happening? else check for? arise when there local resources perhaps reaching thresholds? i note have following line: socket.setsotimeout(10000); just prior readint() . there reason (long story), curious, there circumstances under might lead indicated error? have server running in ide, , happened leave ide stuck on breakpoint, , noticed exact same errors begin appearing in own logs in ide. anyway, mentioning it, not red herring. :-( there several possible causes. the other end has deliberately reset connection, in way not document here. rare, , incorrect, application software this, not unknown commercial software. more commonly, caused writin...

python - GAE - Sharing Authentication Across Apps -

let's had root app , multiple sub-apps. possible share authenticated sessions across them? i'm using google app engine (python). if use tipfy , wonderful lightweight almost-not-a-framework @moraes developed app engine use, many excellent choices authentication approaches (see here ) several of let achieve you're after.

php - What is the difference between “=” and “=&” when assigning variables? -

i trying figure out difference between $a=&$b , $a=$b . know & make variable reference variable. following test gave me same result. can explain difference? thanks. $a=5; $b=6; $a=&$b; echo $a; //6 $a=5; $b=6; $a=$b; echo $a; //6 first of all: you'll hardly ever need references, avoid confusion of using them if can. $a=5; //assign value $b=&$a; //make $b reference $a $b=6; //assigning value $b assigns same value $a (as point same location echo $a; //6 $a=5; //assign value $b=$a; //set $b value of $a $b=6; //set $b value leaves $a @ it's original value echo $a; //5

iphone - objective c arrays of floats and booleans possible? -

nsarray chemconstantarray = [[nsarray alloc] initwithobjects:0.0021400, 0.0012840, 0.0010700, nil]; gives me 4 errors: incompatible type argument 1 of 'initwithobjects:' invalid initializer statically allocated instance of objective-c class 'nsarray' x 2 which makes sense, floats not objects, how can make array of floats. need 1 bools too. if need array purely within own code, can use regular c array: float chemconstantarray[] = {0.0021400, 0.0012840, 0.0010700}; if need nsarray* something, need wrap each value nsnumber . nsarray *chemconstantarray = [[nsarray alloc] initwithobjects: [nsnumber numberwithfloat: 0.0021400], [nsnumber numberwithfloat: 0.0012840], [nsnumber numberwithfloat: 0.0010700], nil]; you can use numberwithbool bools.

javascript - How to implement "DOM Ready" event in a GreaseMonkey script? -

i'm trying modify greasemonkey script firing on window.onload window.domcontentloaded, event never fires. i'm using firefox 2.0.0.16 / greasemonkey 0.8.20080609 this full script i'm trying modify, changing: window.addeventlistener ("load", dostuff, false); to window.addeventlistener ("domcontentloaded", dostuff, false); so googled greasemonkey dom ready , first result seemed greasemonkey script running @ "dom ready" need remove onload call , run script straight away. i removed window.addeventlistener ("load", function() { , }, false); wrapping , worked perfectly. it's much more responsive way, page appears straight away script applied , unseen questions highlighted, no flicker @ all. , there rejoicing.... yea.

html - How do I programmatically set the value of a select box element using JavaScript? -

i have following html <select> element: <select id="leavecode" name="leavecode"> <option value="10">annual leave</option> <option value="11">medical leave</option> <option value="14">long service</option> <option value="17">leave without pay</option> </select> using javascript function leavecode number parameter, how select appropriate option in list? function selectelement(valuetoselect) { var element = document.getelementbyid('leavecode'); element.value = valuetoselect; }

oracle - Best practices for holding passwords in shell / Perl scripts? -

i've had dust off perl , shell script skills out colleagues. colleagues in question have been tasked providing reports internal application large oracle database backend, , don't have skills this. while might question whether have skills either (grin), apparently enough people think mean can't weasel out of it. so question - in order extract reports database, script having connect , run queries. haven't far managed come solution store username , password database being stored plaintext in script. is there solution else has written, perhaps cpan module? or there else that's better - keep user / password combo in separate file that's hidden away somewhere else on filesystem? or should keeping them trivially encrypted avoid them being pulled out of scripts system-wide grep? edit: oracle database sits on hp-ux server. application server (running shell scripts) solaris. setting scripts owned me no-go, have owned service account multiple support personnel ...

language agnostic - What's your favorite "programmer" cartoon? -

Image
personally one: alt text http://www.jeffpalm.com/fox/fox.jpg p.s. not hotlink cartoon without site's permission please. another 1 xkcd

cocoa touch - iPhone - How to select and show a single record in Grouped Table View Format -

im making iphone app includes list of sports teams. rootviewcontroller lists teams in table view. when click row want load teamviewcontroller, shows record single team. the catch im wanting display single teams details in grouped table view style. this causing me endless issues. i can't seem work out draw on objects need from. eg need use nsfetchedresultscontroller. ive implemented core data , can see example of appdelegate , rootviewcontroller bits replicate , parts call in in new teamviewcontroller have me stumped. to setup cellforrowatindexpath in teamviewcontroller main steps need go through can pull in single selected record , able manipulate , how go laying out grouped table view record. more broadly im not seeming bits carried forward in each new viewcontroller can make navigation app have many pages, each record drilling in give next pages view. if bit confused ask me more questions , i'll clarify. it sounds using master-detail pattern wherei...

python - Need some ideas on how to code my log parser -

i have vps that's hosting multiple virtual hosts. each host has it's own access.log , error.log. currently, there's no log rotation setup, though, may change. basically, want parse these logs monitor bandwidth , collect stats. my idea write parser , save information small sqlite database. script run every 5 minutes , use python's seek , tell methods open log files last parsed locations. prevents me parsing 10gb log file every 5 minutes when need new information sitting @ end of (no log rotation, remember?). after thought, realised i'm doing taking information log files , putting them database... moving data 1 location :/ so how else can this? want able like: python logparse.py --show=bandwidth --between-dates=25,05|30,05 --vhost=test.com this open log file test.com , show me bandwidth used specified 5 days. now, question is, how prevent myself parsing 10gb worth of data when want 5 days worth of data? if use idea of saving log data database eve...

How to start in Windows development? -

i've been unix-based web programmer years (perl , php). i'm competent c , c++ (and bash , sort of sysadmin sort of stuff) in terms of language itself. i've never had problem learning new language (i mucked around java few years ago , whilst write didn't language). what don't have experience vast array of frameworks exist writing graphical windows applications. i have few ideas windows-based applications want work through. perl/tcl/tk want more "native" variety of reasons. through current company have access microsoft tools (and licences use them "development") i've decided teach myself new. so, i've got visual studio 2008 installed. fired up, cliked "new project" , got absolutely confused variety of types of new project start. can please me understand not fundemental differences advice on sort of things each type lends to? assuming i'm going down c++ route (i know language hence not choosing c# - unless m...

c++ - Container that doesn't require its elements to be default and copy constructible -

i'm looking c++ container-like class wraps typed array of objects not initialized , don't have default-constructible or copy-constructible. interesting raii objects have no well-defined copy semantics. such container-like class seems easy write (using allocator allocate uninitialized memory , placement new). there in boost have overlooked? i'm not looking std::vector (which requires elements copy-constructible) or pointer container, this: #include <cstddef> #include <memory> #include <vector> #include <algorithm> #include <iostream> template< typename t, typename alloc = std::allocator<t> > class fixedvector { public: typedef typename alloc::value_type value_type; typedef typename alloc::pointer pointer; typedef typename alloc::reference reference; typedef typename alloc::const_pointer const_pointer; typedef typename alloc::const_reference const_reference; typedef typename alloc::size_type size_type; typedef t...

c++ - Why use static_cast<int>(x) instead of (int)x? -

i've heard static_cast function should preferred c-style or simple function-style casting. true? why? the main reason classic c casts make no distinction between call static_cast<>() , reinterpret_cast<>() , const_cast<>() , , dynamic_cast<>() . these 4 things different. a static_cast<>() safe. there valid conversion in language, or appropriate constructor makes possible. time it's bit risky when cast down inherited class; must make sure object descendant claim is, means external language (like flag in object). dynamic_cast<>() safe long result checked (pointer) or possible exception taken account (reference). a reinterpret_cast<>() (or const_cast<>() ) on other hand dangerous. tell compiler: "trust me: know doesn't foo (this looks if isn't mutable), is". the first problem it's impossible tell 1 occur in c-style cast without looking @ large , disperse pieces of code , knowing rules. ...

iphone - Are plists the best way to store multiple in-app preferences for my iOS app? -

i'm diving ios development , building game has multiple game types. when user selects game type want play, presented game configuration screen can adjust options how game play. since there 2 different game types, there 2 different configuration screens. limited knowledge on ios programming, planning use 2 separate plists present options , store settings. suggest better way this? thanks in advance help! if it's actual application preference, can use nsuserdefaults save information standard defaults. way don't have mess files.

performance - How can Google be so fast? -

what technologies , programming decisions make google able serve query fast? every time search (one of several times per day) amazes me how serve results in near or less 1 second time. sort of configuration , algorithms have in place accomplishes this? side note: kind of overwhelming thinking if put desktop application , use on machine not half fast google. keep on learning say. here of great answers , pointers provided: google platform map reduce algorithms crafted hardware - cluster farms , massive number of cheap computers caching , load balancing google file system latency killed disk accesses. hence it's reasonable believe data used answer queries kept in memory. implies thousands of servers, each replicating 1 of many shards. therefore critical path search unlikely hit of flagship distributed systems technologies gfs, mapreduce or bigtable. these used process crawler results, crudely. the handy thing search there's no need have either cons...

c# - Programmatically delete emails and SMSs on a Window Mobile device -

i'm looking code snippet can delete emails , text messages on windows mobile device. preferably code delete items in sent , draft folders inbox. my platform windows mobile (5.0 sdk) , .net 2.0 compact framework (c# / vb.net) unfortunately microsoft has not made easy managed developers. why windowsmobile.pocketoutlook class wrappers don't provide functionality 1 can guess. have write own com interop object mapi. sorry, don't have 1 give sample, can @ least give pointers methods you'll interested in: imapi::getmsgstorestable imapisession::openmessagestore imsgstore::openentry imapifolder::deletemessages inthehand has wrapper has additional methods poom, i've never used , don't know if has need. might worth look, though, before embarking on rolling yourself.

linux - Copy to restricted folder with Ant (using Eclipse in Ubuntu) -

using eclipse in ubuntu linux. i'm creating ant task delete directory in apache localhost directory (/var/www) , copy in files eclipse project. i have: <project> <target name="deploy"> <delete dir="/var/www/gds"/> <copy todir="/var/www/gds/src"> <fileset dir="src"> </fileset> </copy> <copy todir="/var/www/gds/"> <fileset dir="web"> </fileset> </copy> </target> </project> however ant doesn't appear have root user privileges copy directory. works if open eclipse using 'sudo eclipse' don't want running eclipse in root. is there way can ant copy directory? you create entry user run eclipse in /etc/sudoers file (using visudo or sudo permissions editor of choice) allow ant run root without password. need eclipse invoke "sudo ant" instead of "ant" - i'm not familia...

regex - Efficiently match multiple regexes in Python -

lexical analyzers quite easy write when have regexes. today wanted write simple general analyzer in python, , came with: import re import sys class token(object): """ simple token structure. contains token type, value , position. """ def __init__(self, type, val, pos): self.type = type self.val = val self.pos = pos def __str__(self): return '%s(%s) @ %s' % (self.type, self.val, self.pos) class lexererror(exception): """ lexer error exception. pos: position in input line error occurred. """ def __init__(self, pos): self.pos = pos class lexer(object): """ simple regex-based lexer/tokenizer. see below example of usage. """ def __init__(self, rules, skip_whitespace=true): """ create lexer. rules: list of rules. ea...

SQL Server 2005: Getting error when setting auto increment on one of two primary keys -

i getting error "cannot insert explicit value identity column in table 'table' when identity_insert set off." the table has 2 primary key, 1 set auto-increment, 1 set value passed into. is possible in sql server 2005? or missing something? thanks alot in advance. you trying insert value identity column can set identity_insert tablename on insert tablename() values () set identity_insert tablename off http://msdn.microsoft.com/en-us/library/ms188059.aspx

ruby on rails - Inject data members to an object -

this question based on another question of mine (thankfully answered). so if in model have this: def self.find_extended person = person.find(:first) complete_name = person.firstname + ', ' + person.lastname return person end how can inject complete name in person object in controller/view can access person.complete_name? thank time, silviu i think best way creation of complete_name attribute in person class: def complete_name firstname + ', ' + lastname end

javascript - Issue With Python Sockets: How To Get Reliably POSTed data whatever the browser? -

i wrote small python+ajax programs (listed @ end) socket module study comet concept of asynchronous communications. the idea allow browsers send messages real time each others via python program. the trick let "get messages/..." connection opened waiting message answer back. my problem on reliability of have via socket.recv... when post firefox, working well. when post chrome or ie, "data" in python empty. does know problem between browsers? are browsers injecting eof or else characters killing receiving of "recv"? is there solution known problem? the server.py in python: import socket connected={} def inrequest(text): content='' if text[0:3]=='get': method='get' else: method='post' k=len(text)-1 while k>0 , text[k]!='\n' , text[k]!='\r': k=k-1 content=text[k+1:] text=text[text.index(' ')+1:] url=text[:text.index(' ...

debugging - In GDB, how to find out who malloc'ed an address on the heap? -

i have pointer in gdb, how can find out first allocated on heap? in windbg, can done !heap -p -a <0x12345678> after turning on gflags /i <*exe> +ust since valgrind can tell me memory allocated (when detects leaks), guess possible? (this not watchpoint. given situation randomly break in gdb, application, @ pointer , want know "who created piece of memory"?) using reverse debugging in gdb novel way , correct way solve problem. encountered problem approach gdb 7.1 -- latest stable version. reverse debugging rather new feature in gdb needed check out head (7.2) fix it. it says matureness of gdb approach think should used when it's more mature. (awesome feature!) valgrind hijacks memory management calls, that's how heap checkers work. there's no facility in gdb tell given address returned malloc(3) . suggest looking mtrace , glibc allocation debugging .

security - Unlock Windows workstation programmatically -

i write small application unlocks workstation. put specs of need simple: have exe runs , @ defined time (let's midnight) unlocks workstation. of course application knows user , password of logged on account. i know of logonuser api , have tried using failed. have solution, code excerpt works issue? i targeting nt5 oses. well, since people started asking reason: working on desktop sharing application , want add feature of unlocking workstation. having small , simple app unlock station @ defined time in order separate problem , avoid integration details. just have answer instead of people leaving answers might better off comments. this possible, though many people have said it's not wise, happens if walking computer unlocks, how long have play around, etc? anway, apart suggesting have service work want on hte computer, or remotely connecting computer work might able make user of following information. (as 'code excerts' can make yourself) http:/...

git - How to modify existing, unpushed commits? -

Image
i wrote wrong thing in commit message. alternatively, i've forgotten include files. how can change commit message/files? commit has not been pushed yet. amending recent commit message git commit --amend will open editor, allowing change commit message of recent commit. additionally, can set commit message directly in command line with: git commit --amend -m "new commit message" …however, can make multi-line commit messages or small corrections more cumbersome enter. make sure don't have working copy changes staged before doing or committed too. ( unstaged changes not committed.) changing message of commit you've pushed remote branch if you've pushed commit remote branch, you'll need force push commit with: git push <remote> <branch> --force # or git push <remote> <branch> -f warning: force-pushing overwrite remote branch state of local one . if there commits on remote branch don't have in loca...

c++ - Is there a fix or a workaround for the memory leak in getpwnam? -

is there fix or workaround memory leak in getpwnam? getpwnam() does not suffer of memory leak. subsequent calls, indeed, overwrite static internal buffer. such kind of functions instead non-reentrant , therefore non-thread safe . paul suggested use of getpwnam_r() reentrant version, safe used in multithread context. that said, memory leaks caused system calls allocate memory means of malloc() , leave application responsability free() memory once returned data has used. in these cases raii idiom advisable in order not forget free allocated memory -- see exception safety. std::tr1::shared_ptr<> viable way: shared_ptr custom deleter must provided free() raw pointer when shared_ptr goes out of scope. under perspective dangerous functions scandir() , asprintf() , vasprintf() etc.

redirect - Apache - Reverse Proxy and HTTP 302 status message -

my team trying setup apache reverse proxy customer's site 1 of our web applications. http://www.example.com/app1/some-path maps http://internal1.example.com/some-path inside our application use struts , have redirect = true set on actions in order provide functionality. 302 status messages these re-directs cause user break out of proxy resulting in error page end user. http/1.1 302 found location: http://internal.example.com/some-path/redirect is there way setup reverse proxy in apache redirects work correctly? http://www.example.com/app1/some-path/redirect there article titled running reverse proxy in apache seems address problem. uses same example.com , /app1 have in example. go "configuring proxy" section examples on how use proxypassreverse .

asp.net - Does Lucene.Net manage multiple threads accessing the same index, one indexing while the other is searching? -

when using lucene.net asp.net, can imagine 1 web request can trigger update index while web request performing search. lucene.net have built in ability manage concurrent access, or have manage it, avoid "being used process" errors? edit: after reading docs , experimentation, think i've learned: there 2 issues, thread safety , concurrency. multithreading "safe" in can't bad index. but, it's safe @ cost of 1 object having lock on index @ 1 time. second object come along , throw exception. so, can't leave search open , expect writer in thread able update index. , if thread busy updating index, trying create searcher fail. also, searchers see index @ time open it, if keep them around, , update index, won't see updates. i wanted searchers see latest updates. my design, , seems working far, writers , searchers share lock, don't fail - wait - until current write or search done. according this page , indexing ,...

c# - DBML: s letter added to my table names -

i'm using visual studio 2008 each time modify dbml through designer of table names in designer.cs file changed tablename tablenames leading reference errors in rest of project. names appear on dbml not changed. where come ? setting ? edit: happens tables have added through designer , tables have foreign key linking theme these tables. it setting: tools > options > database tools > o/r designer and have pluralization of names option can switched : enabled false