Posts

Showing posts from June, 2011

How to convert decimal to hex in JavaScript? -

how convert decimal values hex equivalent in javascript? convert number hexadecimal string with: hexstring = yournumber.tostring(16); and reverse process with: yournumber = parseint(hexstring, 16);

.net - Open a URL from Windows Forms -

i'm trying provide link company's website windows form. want behaved , launch using user's preferred browser. what best way open url in user's default browser windows forms application? this article walk through it. short answer: processstartinfo sinfo = new processstartinfo("http://mysite.com/"); process.start(sinfo);

iphone - Upgrading to a universal app and sdk problem -

i have iphone app. i decided upgrade ipad , installed xcode_3.2.3_and_iphone_sdk_4__final.dmg i upgraded app universal app. before installation of new sdk, compile iphone app 3.0 sdk. however, after installation, can see iphone device 3.2 adn 4.0 sdks on xcode. i wonder, if compiled universal app 3.2 sdk can iphones 3.0-1-2 os versions run new universal app? if can not, there way that? you can set in project iphone os deployment target fit app. you find in project > edit project settings > build tab > deployment according apple ipad programming guide : when running on ios 3.1.3 or earlier, application must not use symbols introduced in ios 3.2. example, application trying use uisplitviewcontroller class while running in ios 3.1 crash because symbol not available. avoid problem, code must perform runtime checks see if particular symbol available before using it. information how perform needed runtime checks, see “adding runtime checks newer symb...

How to make audio sound better? (C + FFMpeg audio generation example) -

so found great c ffmpeg official example simplified: #include <stdlib.h> #include <stdio.h> #include <string.h> #ifdef have_av_config_h #undef have_av_config_h #endif #include "libavcodec/avcodec.h" #include "libavutil/mathematics.h" #define inbuf_size 4096 #define audio_inbuf_size 20480 #define audio_refill_thresh 4096 /* * audio encoding example */ static void audio_encode_example(const char *filename) { avcodec *codec; avcodeccontext *c= null; int frame_size, i, j, out_size, outbuf_size; file *f; short *samples; float t, tincr; uint8_t *outbuf; printf("audio encoding\n"); /* find mp2 encoder */ codec = avcodec_find_encoder(codec_id_mp2); if (!codec) { fprintf(stderr, "codec not found\n"); exit(1); } c= avcodec_alloc_context(); /* put sample parameters */ c->bit_rate = 64000; c->sample_rate = 44100; c->channels = 2; ...

c# - Telerik RadGrid - How do I set the MaxLength for the Insert Textbox -

i have radgrid on page "add new record" button. when click "add new record" button, textbox appears above each column allows me enter values. want limit number of characters can entered in textbox. how set maxlength of textboxes? you're not telling me problem don't think. very-well try use maxlength property (if it's not multiline textbox). problem? or know how can accomplish this, you're having trouble getting control via server-side or client-side code can set maxlength property?? if provide code snippet or 2 , more details regarding problem, i'd better-able you.

java - Hibernate - maxElementsOnDisk from EHCache to TreeCache -

i'm migrating hibernate application's cache ehcache jboss treecache. i'm trying find how configure equivalent maxelementsondisk limit cache size on disk, couldn't find similar configure in filecacheloader passivation activated. thanks this page seems imply correct configuration element is: <attribute name="maxcapacity">20000</attribute> however, i've ever used ehcache myself.

c - Confused by gdb print ptr vs print "%s" -

1167 ptr = (void*)getcwd(cwd, max_path_length-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/mmc-sd/partition1/aaaaaaaaaaa" (gdb) print &cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/mmc-sd/partition1/aaaaaaaaaaa", '\0' <repeats 912 times>, "��o�001\000\000\000\000��027\000\000\000�3����el鷠3�000��027\000\000\000\000\000\000\000\027\000\000\000\000��/�027\000\000\000�3����n����\230���鷠3�000��027\000\000\000\000\000\000\000��000\000\000\000\001\000\000\000��m鷠3����\000\000\000\000.\231�027��w\005\b\001\000"... (gdb) print "%s", ptr $5 = 0xbff2d96c "/media/mmc-sd/partition1/aaaaaaaaaaa" (gdb) quit why ptr printing string correctly cwd not; affects program , crashes if try use cwd... [edit: turns out crash caused stupid buffer overflow on var... grr...not gdb, print question still valid] the reason cwd print...

python - mod_wsgi, mod_python, or just cgi? -

i've been playing around own webserver (apache+ubuntu) , python. i've seen there 3(?) main ways of doing this: apache configured handle .py cgi apache configured use mod_python outdated(?) apache configured use mod_wsgi i recall reading django prefers mod_wsgi, , i'm kinda interested in learning django (i've heard official tutorial rather excellent). what 'recommended' setup? presume there's no reason use mod_python anymore, differences between handling .py cgi, , mod_wsgi? possible run them in tandem (and want to?), or ridiculous idea , should stop thinking such crazy things? i guess i'm looking primer on apache+python (links good) - nothing i've come across far has been terribly informative - how-to's. mod_python dead, using mod_python isn't idea new projects. personally, prefer use mod_wsgi on cgi (or fastcgi). it's dead-simple set up, , more efficient.

vb6 - Risks around relying on Visual Basic 6.0 applications -

given visual basic 6.0 runtime ships windows 7 , continue supported lifetime of os ( until january 2020 ) , visual basic 6.0 ide, though no longer supported , stable, risks around keeping mission-critical applications in visual basic 6.0 next several years? the official advice owners of vb6 apps microsoft uk is: [do not upgrade or replace vb6 application if] application working great, has not required changes many years, there no plans extend functionality, nor need integrate newer applications that tells factors increase risk vb6 application: a need change application (bug fixes or new features). a need integrate application newer applications. but integration doesn't require migration . interop allows mix .net code vb6 (pdf whitepaper) . edit forgot mention main risk. migrating vb6 code .net can big task. in opinion it's easier in days: there excellent commercial tools ; , more recent vb.net language features make easier . r...

Ruby on Rails Sometimes Nested Resource -

in ruby on rails app i'm working on (2.3.8), have model user can have workouts class workout < activerecord::base belongs_to :user end i have trainer->client relationships (all tied user model through join table) user can add workouts himself, trainer can add workouts clients. i've set routes follows: map.resources :workouts map.resources :clients, :has_many => 'workouts' both sets of routes working (ie. /workouts , /clients/1/workouts). i've updated workouts_controller depending on if there client_id show different set of workouts def index if(params[:client_id]) @workouts = workout.find_all_by_user_id(params[:client_id]) else @workouts = workout.find_all_by_user_id(@current_user.id) end my question is, how set views work correctly. depending on how got index want link differently add or edit screen. should conditionally... <% if (@client.nil?) %> <%= link_to 'new workout', new_workout...

Where is the Git Repository Path created? -

when 1 creates new repository git, path .git subdir added have same 1 path project files (i.e. files managed git)? way of asking same question is: if want create new git repository, repository path have coincide respective project path, or can create repository directory in location , have git point project path? instance, if project in "f:\my projects\mother goose\gerber\", create git repository in "f:\my repositories\pointer path\gerber\"? , tell git in "\my projects\mother goose\gerber\" files added repository? is there reason want this? sure, git supports different directory layouts, using git_dir , git_work_tree environment variables (or corresponding switches). useful in server(-like) scenarios, users don’t interact such repositories other pulling , pushing – f.ex. in git-based deployment systems . but default layout repository in .git directory @ project root. can try work against that, have tell tools using it. it’s not conven...

jquery response back -

i sending ajax call page. want value of variable, lets call x, page on success. how can that. here ajax code $.ajax({ type: 'post', url: 'myotherpage.php', data: 'loginname=' + loginname , success: function(success) { if(success == 1) { //get variable value here } else { //do nothing } } }); your other page should return json, contains status variable (1 success, 0 fail), , variable or whatever data need. here's example file have here. won't run of course, should give idea. req = $.ajax({ type: 'post', data: this.data.filter, url: this.data.dataurl+"listids", datatype: 'json', timeout: 5000, cache: false, error: function(){ usernotify({class:'notify_a...

ASP.NET - Is it possible to trigger a postback from server code? -

is possible to programmatically trigger postback server code in asp.net? know possible response.redirect or server.transfer redirect page, there way trigger postback same page in server code ( i.e. without using javascript trickery submit form)? asp.net postbacks initiated client (typically form submission). not sure trying achieve. of server side page lifecyle events executed , trying raise previous event handlers again.

sql - how to make a db schema such that its use is supported by all db management systems -

is there windows xp utility make database such support sql server, oracle, , other db management systems. the database schema huge know use make protable sql server oracle if future demands change? i recommend building database using orm hibernate java (or nhibernate .net). allow seamlessly transition one database type other little no issues. allow logically create database schema without specific database in mind, move 1 database other. i have created applications change sql server mysql oracle ms access sqlite (clients love flexibility). however, need know way around programming...

methodology - Real life examples of methodologies and lifecycles -

choosing correct lifecycle , methodology isn't easy before when there weren't many methodologies, days new 1 emerges every day. i've found projects require level of evolution , each project different rest. way, extreme programming works project given company 15 employees doesn't quite work 100 employee company or doesn't work given project type (for example real time application, scientific application, etc). i'd have list of experiences, stating project type, project size (number of people working on it), project time (real or planned), project lifecycle , methodology , if project succeded or failed. other data appreciated, think might find patterns if there's enough data. of course, comments welcomed. ps: large, pt: long, lc: incremental-cmmi, pr: success ps: large, pt: long, lc: waterfall-cmmi, pr: success edit: i'll constructing "summary" stats of answers. my personal experience: project size: large (150+ persons...

html - When did browsers start supporting multiple classes per tag? -

you can use more 1 css class in html tag in current web browsers, e.g.: <div class="style1 style2 style3">foo bar</div> this hasn't worked; versions did major browsers begin correctly supporting feature? @wayne kao - ie6 has no problem reading more 1 class name on element, , applying styles belong each class. article referring creating new styles based on combination of class names. <div class="bold italic">content</div> .bold { font-weight: 800; } .italic { font-style: italic; { ie6 apply both bold , italic styles div. however, wanted elements have bold , italic classes purple. in firefox (or possibly ie7, not sure), write this: .bold.italic { color: purple; } that not work in ie6.

C++ Exception code lookup -

knowing exception code, there way find out more actual exception thrown means? my exception in question: 0x64487347 exception address: 0x1 the call stack shows no information. i'm reviewing .dmp of crash , not debugging in visual studio. because you're reviewing crash dump i'll assume came in customer , cannot reproduce fault more instrumentation. i don't have offer save note exception code 0x64487347 ascii "dshg", , developers use initials of routine or fault condition when making magic numbers this. a little googling turned 1 hit dhsg in proper context, name of function in google book search "using visual c++ 6" kate gregory. unfortunately alone not helpful.

c# - When creating a WSE service, do all objects appear in the service proxy "properly"? -

i using asp.net wse web service in web application. for reason, collections in form of array. i.e. doing: myservice.someobject = new myservice.someobject(); so.somecollection = new somecollection[0]; yet developer of service says defined list, not array. is common types don't match between actual service , client proxy? what enumerations, serialize/deserialize properly? in metadata (be soap or mex), repeated elements. proxy-generation tool can choose interpret in variety of ways, , provide options control (in advanced page in vs, iirc - or @ command line). serialization should still fine.

multilingual - How do I get both arabic and english text to show in a wordpress blog post? -

i trying make blog has both arabic , english primary languages. i'm using unicode (utf-8) character encoding when paste chunk of arabic text editor, comes out "?". shows fine in editor when first paste it, after clicking update, changes arabic text junk. can keep arabic text displaying correctly? looks database charset problem. here few things can try: easiest check in settings > reading you've got encoding set utf-8. easy open wp-config.php , find line: define('db_charset', 'utf8'); change to: define('db_charset', ''); pita convert database charset utf-8, explained in this article .

spring - Rendering a GSP from a Quartz job in Grails -

i have quartz job needs render gsp, when tried: def g = new org.codehaus.groovy.grails.plugins.web.taglib.applicationtaglib() def text = g.render(template: "/templates/mytemplate", model: [language: language, product: product]) i received following exception: org.quartz.jobexecutionexception: no thread-bound request found: referring request attributes outside of actual web request, or processing request outside of receiving thread? if operating within web request , still receive message, code running outside of dispatcherservlet/dispatcherportlet: in case, use requestcontextlistener or requestcontextfilter expose current request. [see nested exception: java.lang.illegalstateexception: no thread-bound request found: referring request attributes outside of actual web request, or processing request outside of receiving thread? if operating within web request , still receive message, code running outside of dispatcherservlet/dispatcherportlet...

c# - How does DI actually do the injection to a property? -

i searched brains out , wasn't able find suitable answer, here go! have following property in each of forms or objects: private rootworkitem m_rootworkitem; [rootworkitem(inject = true)] public rootworkitem rootworkitem { { if (m_rootworkitem == null) { m_rootworkitem = new rootworkitem(); } return m_rootworkitem; } } note rootworkitem class have designed contains collection of services (collection). basically, services loaded external dll files using reflection , activator.createinstance, , put rootworkitem.services. but how on earth can "inject" first rootworkitem created every other rootworkitem marked attribute in program? how these di patterns "do" injection "into" property? know concepts of di trying write own, extremely basic di 1 single object. i've been messing reflection tons try , find suitable way , i'm not closed coming right way it. ...

Response.Clear in ASP.NET 3.5 -

i have upgraded of web applications asp.net 3.5 installing framework on server , setting web applications acrodingly , well, however. on pages, want clear current contents of response buffer code this: response.clear(); // output stuff response.end(); but isn't working in 3.5 when did in 2.0. have tried setting response buffer false didn't work either. can let me know why isn't working or if there work around? try setting buffer="true" in page directive of page , not in codebehind. i tried in vs2008 on web site project: create new item choose "web page" leave html-tags in there, fun fill page_load this protected void page_load(object sender, eventargs e) { response.write("test1"); response.clear(); response.write("test2"); response.end(); } it output "test2" without html-tags.

mysql - Which locking scheme and isolation level should one use for sequence number generation? -

i know general practice used in industry generating sequence numbers. i.e. max table. increment , store back. in order work, isolation level and/or locking scheme should used. i thought serializable should work fine. prevents updates table. selection can still done. so, value updated same. how can avoid this? thanks! anything within transaction scope subject race conditions. so sql query last used value, increment it, , store in new row means 2 concurrent clients fetch same value , try use it, resulting in duplicate key. there few solutions this: locking. each client sets exclusive lock on rows read if use select ... update (as @daniel vassallo describes) use auto-increment. mechanism guarantees no race conditions, because allocation of new values happens without regard transaction scope. benefit, no 2 concurrent clients same value. means, though, rollback doesn't undo allocation of value. last_insert_id() function returns last auto-increment v...

Anyone know what tumblr is written in -

does know tumblr written in? have been trying figure out. it's php... http://www.marco.org/55384019 spiteshow : i wonder if tumblr guys using framework or if home brew. both: it’s homebrew framework add mvc structure , useful secondary function library php 5 started in 2006 , have evolved finely tuned framework our needs. same framework runs of davidville’s former consulting-client sites of personal sites , projects. it’s not available publicly anywhere, may release in future.

c# - BaseClass method which returns an arbitrary subclass of BaseClass -

in game have base class of loot has methods universal can picked player , stored in inventory. include potions, equipment, ammo, etc. can equip arrows, not potions. arrow subclass of ammo, derive loot. can drink potion not arrow. potion subclass loot implement iconsumeable. , on. loot objects have quantity property (10 arrows; 2 potions). in loot class have method called split allows player take "stack" of items (like arrows) , split 2 separate stacks. decreases arrow instance's quantity amount, returns new arrow instance quantity value = taken original instance. my idea i'd write method in loot since loot can stacked long int stacklimit property greater 1. after decrementing calling loot quantity specified, i'd return new object of same type. problem is, don't know type of loot subclass object be. public abstract class loot { public int quantity { get; set; } public loot split(int quantitytotake) { loot clone = (loot)this.memberw...

javascript - Is there a onselect event for non-form elements? -

say want hide span when user highlights bit of text containing span, intention of copying text on clipboard. for example: <p>the dragon <span class="tooltip">a large, mythical beast</span> belched fire @ st. george.</p> i have found in firefox mac, span.tooltip disappear view (in accordance css declarations) show in clipboard when it's copied there. figured (wrongly?) if said "onhighlight, hide tooltip," maybe wouldn't happen. though may more complicated, why not have onmousedown event on <p> element, , thet event attach onmousemove event , onmouseout event, if there mouse movement, while button down, remove class on span elements, , once user exits, element can put them back. it may bit tricky, , may want key presses, or determine other times want know when put css classes, 1 option, believe.

configuration - IIS configurable http-headers for caching -

how 1 configurably set http-headers cache files in iis >= 6? example: *.cache.* => cache forever *.nocache.* => never cache an example framework using naming gwt framework. i think you're referring setting cache-control header. see here http://support.microsoft.com/kb/247404

c# - In WPF, what is the equivalent of Suspend/ResumeLayout() and BackgroundWorker() from Windows Forms -

if in function in code behind, , want implement displaying "loading..." in status bar following makes sense, know winforms nono: statusbarmessagetext.text = "loading configuration settings..."; loadsettingsgriddata(); statusbarmessagetext.text = "done"; what winforms chapter 1 class 101, form won't display changes user until after entire function completes... meaning "loading" message never displayed user. following code needed. form1.suspendlayout(); statusbarmessagetext.text = "loading configuration settings..."; form1.resumelayout(); loadsettingsgriddata(); form1.suspendlayout(); statusbarmessagetext.text = "done"; form1.resumelayout(); what best practice dealing fundamental issue in wpf? best , simplest: using(var d = dispatcher.disableprocessing()) { /* work... use dispacher.begininvoke... */ } or idisposable d; try { d = dispatcher.disableproc...

jquery + css: enlighten buttons? -

how can implement "enlightening" effect, can see in "tags" section in website ? http://dribbble.com/shots/37765-walken-on-water-halfsies?list=index i not change color (gray white) of background, progressively make button lighter , lighter. thanks basically, have use animate() , css() change background property. i point well-written tutorial explains how can achieve this. they have demo page , think you're looking last example.

Creating a Vertical menu using jquery -

Image
how can create page this? when click link in left side menu page must loaded in content area, whole page must not load. how using jquery there plugin that? i thing need load on page , selected content [who want show] show using jquery.show() , other content [unselect] hide using jqury.hide(); if use link hyperlink must need first disable him using preventdefault() or need make event on div click.

Where can I find a complete reference of the ncurses C API? -

where can find complete reference of ncurses c api? i found question while back, none of answers far answer original question. complete freely available api reference available through . . . ncurses man pages

security - How do you protect your software from illegal distribution? -

i curious how protect software against cracking, hacking etc. do employ kind of serial number check? hardware keys? do use third-party solutions? how go solving licensing issues? (e.g. managing floating licenses) edit: i'm not talking open source, strictly commercial software distribution... there many, many, many protections available. key is: assessing target audience, , they're willing put with understanding audience's desire play no pay assessing amount willing put forth break protection applying enough protection prevent people avoiding payment, while not annoying use software. nothing unbreakable, it's more important gauge these things , pick protection slap on best (worst) protection able afford. simple registration codes (verified online once). simple registration revokable keys, verified online frequently. encrypted key holds portion of program algorithm (can't skip on check - has run program work) hardware key (public/p...

python - Report generation -

i writing web app using turbogears, , in app users must able generate different reports. data reports need stored in database (mysql). reports must returned either printable html document, or pdf file. i have used jasper , ireport creating documents, if can avoid having fire java create report happy. ideally specify reports in readable markup language , feed template data kind of library produces report. i gladly accept kind of hints on how should go generating these reports! you can build fancy pdfs python reportlab toolkit.

pthreads in C - pthread_exit -

for reason thought calling pthread_exit(null) @ end of main function guarantee running threads (at least created in main function) finish running before main exit. when run code below without calling 2 pthread_join functions (at end of main ) explicitly segmentation fault, seems happen because main function has been exited before 2 threads finish job, , therefore char buffer not available anymore. when include these 2 pthread_join function calls @ end of main runs should. guarantee main not exit before running threads have finished, necessary call pthread_join explicitly threads initialized directly in main ? #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <assert.h> #include <semaphore.h> #define num_char 1024 #define buffer_size 8 typedef struct { pthread_mutex_t mutex; sem_t full; sem_t empty; char* buffer; } context; void *reader(void* arg) { context* context = (contex...

c# - How to get the file size from http headers -

i want size of http:/.../file before download it. file can webpage, image, or media file. can done http headers? how download file http header? yes, assuming http server you're talking supports/allows this: system.net.webrequest req = system.net.httpwebrequest.create("http://stackoverflow.com/robots.txt"); req.method = "head"; using (system.net.webresponse resp = req.getresponse()) { int contentlength; if(int.tryparse(resp.headers.get("content-length"), out contentlength)) { //do useful contentlength here } } if using head method not allowed, or content-length header not present in server reply, way determine size of content on server download it. since not particularly reliable, servers include information.

.net - Is it worth investing time in learning Visual Studio Macro System (usage-creation)? -

i have used visual studio long time, 1 feature have never used macro system. saw post mentioned used macros (no elaboration) wondering worth time investing in learning how create macros? if so, kind of stuff make? there similar post(s), trying lean question more towards: worth learning? tend rather know how works using if it's possible and/or worth it. macros not difficult learn, , can make life easier! for interesting appllication of macros see question

assembly - `testl` eax against eax? -

i trying understand assembly. the assembly follows, interested in testl line: 000319df 8b4508 movl 0x08(%ebp), %eax 000319e2 8b4004 movl 0x04(%eax), %eax 000319e5 85c0 testl %eax, %eax 000319e7 7407 je 0x000319f0 i trying understand point of testl between %eax , %eax ? think specifics of code isn't important, trying understand test - wouldn't value true? it tests whether eax 0, or above, or below. in case, jump taken if eax 0.

objective c - Why retain count is bigger, than I expect (using addSubview) -

why counter variable equals 3, not 2? @interface scoreview : uiimageview ... - (id)initwithframe:(cgrect)frame { if (!(self = [super initwithframe:frame])) return self; _scorelabel = [[uilabel alloc] initwithframe:cgrectmake(0,0, 10, 10)]; [self addsubview:_scorelabel]; int counter = [[[self subviews] objectatindex:0] retaincount]; // why 3? return self; } -retaincount not reliable . important: method typically of no value in debugging memory management issues. because number of framework objects may have retained object in order hold references it, while @ same time autorelease pools may holding number of deferred releases on object, unlikely can useful information method. in case, particular reason because -subview causes subviews retained once, copying value of .layer.sublayers new array*: uilabel* label = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 10, 10)]; nslog(@"%d", [label retaincount]); // 1 [so...

javascript - How to disable browser default password pop-up? -

i developing google chrome plugin. under options page running ajax request server requires password i want catch error if password incorrect, browser giving popup window. alt text http://img834.imageshack.us/img834/2905/browserproblem.png can disable , how? the problem you’re not base64-encoding username (i.e., authentication token) , (dummy) password you’re sending (which requirement of http basic authentication scheme). here’s code ought like: var xhr = new xmlhttprequest(); xhr.open('get', 'http://onsip.highrisehq.com/account.xml'); xhr.setrequestheader('authorization', 'basic ' + btoa(token + ':')); xhr.onreadystatechange = function() { console.log(xhr.responsetext); }; xhr.send(); (i swapped in 'onsip' subdomain you, still need replace token authentication token.)

c# - Taking action for all controls with an 'ImageUrl' property -

i've got below piece of code, iterates through controls on webpage , imagebutton, modifies imageurl property. i'd like do, go through each control and, if control happens have imageurl property, change. eg normal images etc included in process. feeling generics or might key here, not versed in area least. thoughts? thanks! public static void addthemepathtoimages(control parent) { foreach (control c in parent.controls) { imagebutton = c imagebutton; if (i != null) { // see if theme specific version of file exists. if not, point normal images dir. if (file.exists(system.web.httpcontext.current.server.mappath("~/app_variants/" + getusertheme().tostring() + "/images/" + i.imageurl))) { i.imageurl = "~/app_variants/" + getusertheme().tostring() + "/images/" + i.imageurl; } ...

Can I pass parameter from different page in JavaScript? -

in php easy pass parameter using $_get[] , $_post[] . there in javascript? hope can pass parameters addresses or forms. window.location.href contains current page's url. can append parameters page's url after "?" (i.e., querystring), , have javascript on page parse them. lots more information , examples on googlable pages this one.

PHP: How to get a Date when a person reach to a specific age? -

i working on task in dates involved. have person's age in months+days . want date when person reach specific age in months. for example: a person 250 months , 15 days old on 2010-1-25. on date person become 300 months old? function signature may be: function getreqdate( $startdate, $curragemonths, $curragedays, $reqagemonths ) { //return date } since calculate current age birthdate, suggest use birthdate instead of current age calculate when user gets 300 months old. following equivalent of datetime solution given above (does not require 5.3): echo date('r', strtotime('+300 months', strtotime('1990-10-13'))); with second param being birthdate timestamp above give tue, 13 oct 2015 00:00:00 +0200 further reading: http://us2.php.net/manual/en/function.strtotime.php http://www.rafaeldohms.com.br/2006/09/15/strtotime-is-it-useful/en/

linux - What's the best way to find a string/regex match in files recursively? (UNIX) -

i have had several times, when trying find in files variable or function used. i remember using xargs grep in past this, wondering if there easier ways. grep -r regex . replace . whatever directory want search from.

java - JPA and Hibernate - Criteria vs. JPQL or HQL -

what pros , cons of using criteria or hql ? criteria api nice object-oriented way express queries in hibernate, criteria queries more difficult understand/build hql. when use criteria , when hql? prefer in use cases? or matter of taste? i prefer criteria queries dynamic queries. example easier add ordering dynamically or leave parts (e.g. restrictions) out depending on parameter. on other hand i'm using hql static , complex queries, because it's easier understand/read hql. also, hql bit more powerful, think, e.g. different join types.

iphone - How to use CTTypesetterSuggestClusterBreak in Core Text -

i having trouble in using cttypesettersuggestclusterbreak function of cttypesetterref class. want use method closest word boundry near index. having difficult in implementationof method, i.e how , method must used. have been banging head on no success yet. if can me in using method greatful. thanx in advance i'm not sure coretext appropriate task; sounds should investigate cfstringtokenizer instead.

c# - Using .NET is it possible to assign a custom property to a built in object such as FileSystemWatcher? -

is possible add custom property object part of .net framework? i know how if giving class i'd wrote property, adding custom property filesystemwatcher class? i'm loading in path want watch xml file, want add property store more information, in case location of config file. can add property filesystemwatcher class itself? so want inherit functionalities of filesystemwatcher , while adding properties? try inheriting class: public class myfilesystemwatcher : filesystemwatcher { public string xmlconfigpath { get; set; } } and after can use new class on every place use system.io.filesystemwatcher , this: myfilesystemwatcher fsw = new myfilesystemwatcher(); fsw.xmlconfigpath = @"c:\config.xml"; fsw.path = @"c:\watch\path\*.*"; another approach make class both have config file location , , filesystemwatcher object property, along these lines: public class myfilesystemwatchermanager { public string xmlconfigpath { get; set; } ...

c++ - requiring msvcr80.dll and msvcr80d.dll in the same dll? -

how can dll build here (in debug mode) tries load msvcr80.dll , msvcr80d.dll ... assume leads conflict can resolve same symbols twice ... i have no idea why dependency msvcr80.dll comes in. according dependency walker ouput dependency comes directly dll , not via dll ... could problem of build settings of debug build? it may caused 1 of dlls liked linked in release mode load msvcr80.dll while loading msvcr80d.dll. and yes, may cause problem could problem of build settings of debug build? yes

java - Open-source improvements or replacements for Swing components -

i develop number of desktop java applications using swing, , while swing quite powerful (once hang of it), there still lot of cases wish advanced component available right out of box. for example, i'd see easy-to-use components (without writing them myself, given enough time) like: multi-line label windows file explorer-like icons or thumbnails view drop-down button (like firefox's old button) 5-star rating widget combo box automatic history (like text field on google) an outlook-style accordion-style bar and on i know of couple of sources of free swing components, swinglabs , home of jxtable, jxdatepicker, , few others. where go swing components beyond included java itself? the following worth look: swingx glazed lists substance look'n'feel flamingo components ken orr's mac widgets jide's open source components

sorting - How can I sort class members by name in NetBeans, or another Java IDE? -

Image
i want sort members name in source code. there easy way it? i'm using netbeans, if there editor can that, tell me name of it. in netbeans 8.0.1: tools -> options -> editor -> formatting -> category: ordering then: source -> organize members

Why might ProcessMessages throw a C++ Exception? -

while maintaining old product, came across error results in screen being filled hundreds of message boxes saying 'c++ exception' , nothing else. traced problem following line: application->processmessages(); i understand purpose of line, process messages in message queue, i'm not sure what's causing error. i'm not looking specific solution, i'm wondering if else has had problem or might know sort of situations may cause happen. closing message boxes causes application return normal, expected behavior. update - after more searching, found errors not fault of processmessages. errors occur because program doing intensive calculations , runs out of memory. seems commenting out processmessages reduces memory consumption enough through calculations without errors. hence, processmessages looks culprit, in fact, not. it looks have refactoring do. update 2 - 3 days later, have come conclusion error happens when processmessages called. if comme...

datagrid - How to add a row hyperlink for an extJS Grid? -

can please throw light on how go rendering hyperlink in cells of particular column in extjs? have tried binding column render function in js, send html: <a href="controllername/viewname">select</a> however, this, problem that, once hit controller through link, navigation successful, subsequent navigations data-grid show empty records. the records fetched db through spring mvc controller, have checked. please note happens once use row hyperlink in extjs grid navigate away grid. if come grid, , navigate elsewhere , again come grid, data displayed fine. problem occurs in case of navigating away grid, using hyperlink rendered in one/any of cells. thanks help! i created renderer looked clicking on it. arenderer: function (val, metadata, record, rowindex, colindex, store){ // using cellclick invoke return "<a>view</a>"; }, but used cell event manage click. cellclick: { fn: function (o, idx, column, e) { if (...

android:drawableLeft margin and/or padding -

is possible set margin or padding image added android:drawableleft ? as cephus mentioned android:drawablepadding force padding between text , drawable if button small enough. when laying out larger buttons can use android:drawablepadding in conjunction android:paddingleft , android:paddingright force text , drawable inward towards center of button. adjusting left , right padding separately can make detailed adjustments layout. here's example button uses padding push text , icon closer default: <button android:text="@string/button_label" android:id="@+id/buttonid" android:layout_width="160dip" android:layout_height="60dip" android:layout_gravity="center" android:textsize="13dip" android:drawableleft="@drawable/button_icon" android:drawablepadding="2dip" android:paddingleft="30dip" android:paddingright="26dip" android:s...

python - Personal archive tool, looking for suggestions on improving the code -

i've written tool in python enter title, content, tags, , entry saved in pickle file. designed copy-paste functionality (you spot piece of code on net, copy it, , paste program), not handwritten content, though no problem. i did because i'm scanning through pdf files, books, or net coding example of solution i'd seen before, , seemed logical have put content in, give title , tags, , whenever needed to. i realize there sites online handle ex. http://snippets.dzone.com , i'm not online when code. admit didn't see if had written desktop app, project seemed fun thing here am. it wasn't designed millions of entries in mind, use pickle file serialize data instead of 1 of database apis. query basic, title , tags , no ranking based on query. there issue can't figure out, when @ list of entries there's try, except clause tries catch valid index (integer). if enter inavlid integer, ask enter valid one, doesn't seem able assign variable. if enter va...

php - Why doesn't lint tell me the line number and nature of the parse error? -

i'm calling php lint windows batch file, so: @echo off %%f in (*.php) php -l %%f when file contains syntax error, outputs errors parsing xxx.php . there way tell me nature of error is, , line it's on? maybe switch? if came here because of "errors parsing foo.php" without details , missed charles comment, might looking this: php -d display_errors=1 -l foo.php thanks charles! example: [somewhere]# php -l submit.php errors parsing submit.php [somewhere]# php -d display_errors=1 -l submit.php parse error: syntax error, unexpected t_variable in submit.php on line 226 errors parsing submit.php

Get current TFS connection in a Visual Studio addin -

i'm working on visual studio 2010 add-in, , i'm trying figure out how determine connected tfs server. i'm guessing need use dte, i'm having brain cramp figuring out info. i suggest check out microsoft.teamfoundation.versioncontrol.client.workstation.getlocalworkspaceinfo method, in result have object , access serveruri property see this documentation on msdn more details .

c++ - CRTP to avoid dynamic polymorphism -

how can use crtp in c++ avoid overhead of virtual member functions? there 2 ways. the first 1 specifying interface statically structure of types: template <class derived> struct base { void foo() { static_cast<derived *>(this)->foo(); }; }; struct my_type : base<my_type> { void foo(); // required compile. }; struct your_type : base<your_type> { void foo(); // required compile. }; the second 1 avoiding use of reference-to-base or pointer-to-base idiom , wiring @ compile-time. using above definition, can have template functions these: template <class t> // t deduced @ compile-time void bar(base<t> & obj) { obj.foo(); // static dispatch } struct not_derived_from_base { }; // notice, not derived base // ... my_type my_instance; your_type your_instance; not_derived_from_base invalid_instance; bar(my_instance); // call my_instance.foo() bar(your_instance); // call your_instance.foo() bar(invalid_instance); // c...

bash - find results piped to zcat and then to head -

i'm trying search string in lot of gziped csv files, string located @ first row , thought first row of each file combining find, zcat , head. can't them work together. $find . -name "*.gz" -print | xargs zcat -f | head -1 20051114083300,1070074.00,0.00000000 xargs: zcat: terminated signal 13 example file: $zcat 113.gz | head 20050629171845,1069335.50,-1.00000000 20050629171930,1069315.00,-1.00000000 20050629172015,1069382.50,-1.00000000 .. , 2 milion rows these ... though solved problem writing bash script, iterating on files , writing temp file, great know did wrong, how it, , if there might other ways go it. you should find work: find . -name "*.gz" | while read -r file; zcat -f "$file" | head -n 1; done

c# - How to get a screen capture of a .Net WinForms control programmatically? -

how programmatically obtain picture of .net control? there's method on every control called drawtobitmap . don't need p/invoke this. control c = new textbox(); system.drawing.bitmap bmp = new system.drawing.bitmap(c.width, c.height); c.drawtobitmap(bmp, c.clientrectangle);

java - Developing a tool to know who connected to remote machine? -

scenario: team of 22 members daily log on local machines unique ids , connect remote machines set of logins. here logins used connect remote machines not unique..i mean more 1 machine can connected same user name.. in 1 line 22 remote machines have 5- 6 logins used 22 members.. problem: remote machines not dedicated each employee..everyday need send mail group asking connected specific remote machine..and if 1 replies yes..we ask them disconnect.. i want develop small tool using java, runs on every machine , displays machine used one.. the code mentioned in site useful not specify used login? link : http://lazynetworkadmin.com/content/view/34/6/ i hope made point clear :) please guide me how can proceed?..do think possible? note: forgot mentioning operating system, is: windows xp on remote machine can run netstat program, outputs this: c:\> netstat -n | find ":80" tcp 192.168.1.33:1930 209.85.129.190:80 established tcp ...

flex3 - How to apply String functions in Advancedatagrid itemRenderer -

is possible right of "~" char in advance datagrid column ? i've tried itemrenderer property no success. example, want remove repeated occurrence of "102.dangerous flora" , keep right of "~". arraycollection set data provide grid. alt text http://4.bp.blogspot.com/_t_-j3zlqfnq/te6c_dgi6mi/aaaaaaaabqu/lfnf_bok3zq/s1600/3.png use this..... for sign use these without space & # 126 ;

Double-Escaped Unicode Javascript Issue -

i having problem displaying javascript string embedded unicode character escape sequences (\uxxxx) initial "\" character escaped "&#92;" need transform string evaluates escape sequences , produces output correct unicode character? for example, dealing input such as: "this &#92;u201ctest&#92;u201d"; attempting decode "&#92;" using regex expression, e.g.: var out = text.replace('/&#92;/g','\'); results in output text: "this \u201ctest\u201d"; that is, unicode escape sequences displayed actual escape sequences, not double quote characters like. as turns out, it's unescape() want, '%uxxxx' rather '\uxxxx': unescape(yourteststringhere.replace(/&#92;/g,'%'))

Last iteration of enhanced for loop in java -

is there way determine if loop iterating last time. code looks this: int[] array = {1, 2, 3...}; stringbuilder builder = new stringbuilder(); for(int : array) { builder.append("" + i); if(!lastiteration) builder.append(","); } now thing don't want append comma in last iteration. there way determine if last iteration or stuck loop or using external counter keep track. another alternative append comma before append i, not on first iteration. (please don't use "" + i , way - don't want concatenation here, , stringbuilder has append(int) overload.) int[] array = {1, 2, 3...}; stringbuilder builder = new stringbuilder(); (int : array) { if (builder.length() != 0) { builder.append(","); } builder.append(i); } the nice thing work iterable - can't index things. (the "add comma , remove @ end" nice suggestion when you're using stringbuilder - doesn't work things...

tsql - How do I use T-SQL's Case/When? -

i have huge query uses case/when often. have sql here, not work. (select case when xyz.something = 1 'sometext' else (select case when xyz.somethingelse = 1) 'someothertext' end) (select case when xyz.somethingelseagain = 2) 'someothertextgoeshere' end) end) [columnname], whats causing trouble xyz.somethingelseagain = 2 , says not bind expression. xyz alias table joined further down in query. whats wrong here? removing 1 of 2 case/whens corrects that, need both of them, more cases. select case when xyz.something = 1 'sometext' when xyz.somethingelse = 1 'someothertext' when xyz.somethingelseagain = 2 'someothertextgoeshere' else 'something unknown' end columnname;

javascript - Using jquery from local file work only if work connection to internet -

i have local library jquery <script src="/js/jquery.js" type="text/javascript"></script> i have ajax request .post('/default/ajaxasinc/addnew',{'new':$("#name").val()},function(data){ for(var i;i< data.length.i++) { } },'json'); but work if connection internet active if connection down i see next exception data null [break on error] for(var i=0;i<data.length;i++) any idea solve problem ? ps browser firefox not fetch data site data responce local from looking @ code, place data referenced in callback function "the response of $.post(). i check data valid , contains data before trying for() loop through it. $.post('/default/ajaxasinc/addnew', {'new':$("#name").val()}, function(data) { if(data !== undefined && data.length > 0) { for(var i=0;i< data.length.i++) { } } },'json');

email - MS Entourage 2008 and quoted-printable encoding -

i need send html email. email clients (outlook, thunderbird ..) entourage can receive , read email without major problems. entourage, though breaking content , displays few lines beginning. my guess has way how entourage handles quoted-printable encoding. important headers of email set: content-type: text/html; charset=iso-8859-1 content-transfer-encoding: quoted-printable the same behaviour in entourage occurs when email sent multipart/alternative alternative plain text. content of email displayd until character =00 occurs (encoded nul?). is entourage bug behaviour? or doing wrong? the problem indeed *=00* characters. before sending email, need prepare quoted-printable encoding , remove null characters. $str = preg_replace('/\x00+/', '', $str);

security - Do you HtmlEncode during input or output? -

when call microsoft.security.application.antixss.htmlencode ? do when user submits information or do when you're displaying information? how basic stuff first name, last name, city, state, zip? you when displaying information. preserve original entered, convert display on web page. let's displaying in other way, exporting excel. in case, you'd want export preserved original. encode every single string.

xml - Need assistance with diagnosing SOAP packet problem with Amazon S3 -

we building application stores data in s3 bucket. however, having problems putobject method. here xml packet sending out: <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <putobject xmlns="http://doc.s3.amazonaws.com/2006-03-01"> <bucket>lills</bucket> <key>lills123</key> <metadata> <name>content-type</name> <value>text/plain</value> </metadata> <metadata> <name>title</name> <value>lills</value> </metadata> <data>agetage=</data> <contentlength>5</contentlength> <awsacce...

reporting services - How can I customise error messages in SSRS? -

i have ssrs report being accessed report server. there way can give error message of own, if report fails open there? i can't think of way capture rs errors if using ssrs report manager. on other hand, if using report viewer control, may have higher chance of capturing errors. same goes if use custom dataset extension report rendering.

Include row number in query result (SQL Server) -

i think each row in sql server given unique number. how can include in sql query results? if referring row number provided management studio when run query, there no way because not exist. management studio generates on fly. can however, recreate sequential number using row_number ranking function if using sql server 2005 or later. note should never assume database return rows in specified order unless include order statement. query might like: select .... , row_number() on ( order t.somecolumn ) num table t order t.somecolumn the order in on clause used determine order creating sequential numbers. order clause @ end of query used determine order of rows in output (i.e. order sequence number , order of rows can different).

html - How to mark an entire section as relevant to a link in html5 -

i have index page, consists of content name, url actual content. , in element under longer description. there way associate longer description link (for seo) or may not needed, search engines know due content itself? html example <dl> <dt><a href="fdsfsdf">the title</a></dt> <dd> longer description of content..............</dd> </dl> the fact using definition list associate stuff in dt dd , more important seo purposes content on page linked has relevance "the title" in link.

symfony1 - symfony: sfDoctrineGuardPlugin: doesn't redirect to the referer page -

i have crate new sf 1.3 project, installed sfdgp , activated security on web app when write url authentication form appears. the problem: after logging web app not redirected referrer url root url. these steps: i call url " http://rs3.localhost/frontend_dev.php/usuario " the auth form appears. if write var_dump($user->getreferer($request->getreferer())); inside signin action showed: " http://rs3.localhost/frontend_dev.php/ " any idea? regards javi

c# - Requesting memory for your application -

i having similar issue this person . primary difference being application not meant developer environment, , therefore need know how optimize space used sql server (possibly per machine based on specs). i intrigued ricardo c's answer, particularly following: extracted fromt sql server documentation: maximum server memory (in mb) specifies maximum amount of memory sql server can allocate when starts , while runs. configuration option can set specific value if know there multiple applications running @ same time sql server , want guarantee these applications have sufficient memory run. if these other applications, such web or e-mail servers, request memory needed, not set option, because sql server release memory them needed. however, applications use whatever memory available when start , not request more if needed . if application behaves in manner runs on same computer @ same time sql server, set option value guarant...