Posts

Showing posts from August, 2010

How youtube load image -

i youtube load 1 part of images when page load, when scroll down , it'll load continue remain part . youtube use, load remain part image fast. i can't quite understand if you're looking for: lazyload jquery it's not youtube uses, should work similarly.

winapi - how to send key's to any application that is currently running from background program (c++) -

my question how send key's application application running in background? let's made shortcut left arrow key alt+s, , want whenever i'm in application , when press alt+s background application response shortcut , send opened program left arrow key. here code made in embarcadero c++ 2010 simulate arrow left when pressing alt+s every 200 milisecond's: void __fastcall tform1::timer1timer(tobject *sender) { bool bbothpressed = getasynckeystate(vk_menu) && getasynckeystate(0x53); if(bbothpressed){ // showmessage("control!"); keybd_event(vk_left, 0, 0, 0); } } ... , work fine application, want know how include code global scope (any application), not application. i encourage use registerhotkey instead of getasynckeystate. way won't need loop nor timer, making application more reliable , responsive. to simulate keypresses application/window, need to: a) focus specific window: bringwindowtotop(hwnd); ...

c# - How to Cache a large amount of data from database for ASP.NET Mvc -

my website uses linq-to-sql load 50k rows of data database. data static , never changes. works similar spam filter , 50k rows of patterns need loaded. what's best way program this? optimal performance? loading entire thing single static readonly data-structure (it being immutable means once constructed can safely used many threads) give greatest overall performance per lookup. however, lead long start-up time, may not acceptable. in case may consider loading each item accessed, brings concurrency issues (since mutating data-structure used multiple threads). in between option of loading indices on start-up, , adding rest of information on per-access basis, finer-grained locks reduce lock contention. or can ignore lot , load database needed. have advantages in terms of performance because memory not used rarely-used information. it'll whole lot easier if ever find have allow data change. no 1 comes out reasonable way go in general, it'll depend on speci...

How to check that an array contains a particular value in Scala 2.8? -

i've got array of d unique (int, int) tuples. i need know if array contains (x, y) value. am implement search algorithm myself or there standard function in scala 2.8? i've looked @ documentation couldn't find of such there. that seems easy (unless i'm missing something): scala> val = array((1,2),(3,4)) a: array[(int, int)] = array((1,2), (3,4)) scala> contains (1,2) res0: boolean = true scala> contains (5,6) res1: boolean = false i think api calls you're looking in arraylike .

algorithm - Ideal hashing method for wide distribution of values? -

as part of rhythm game i'm working, i'm allowing users create , upload custom songs , notecharts. i'm thinking of hashing song , notecharts uniquely identify them. of course, i'd few collisions possible, however, cryptographic strength isn't of importance here wide uniform range. in addition, since i'd performing hashes rarely, computational efficiency isn't big of issue. is easy selecting tried-and-true hashing algorithm largest digest size? or there intricacies should aware of? i'm looking @ either sha-256 or 512, currently. all cryptographic-strength algorithm should exhibit no collision @ all. of course, collisions exist (there more possible inputs possible outputs) should impossible, using existing computing technology, find one. when hash function has output of n bits, possible find collision work 2 n/2 , in practice hash function less 140 bits of output cannot cryptographically strong. moreover, hash functions have weaknesses all...

Integrating freely available Asp.Net forum with a Asp.net web app on a MySQL DB -

we have finished delivering (large-ish) asp.net 3.5 web application project uses mysql database. we have used mysql membership provider along subsonic 2.2 finish project in. however, client wants forum go along website - such when user signs our site, id created on forum. (it not necessary login session transfer forum - user have re-login when tries access forum - credentials need created forum side also) instead of building forum, looking port existing solution , bind membership creation process. however, forums (yaf.net, etc) on ms-sql database causing issue. at best (last option), sql express server installed yaf. wanted see other alternatives there , whether somehow use existing mysql database our stuff done. guys have done if in similar situation? any / pointing-in-a-direction appreciated. thanks. saurabh ps: forum can simplest forum there can be. more of discussion board. you can try nearforums . built asp.net mvc , uses mssql or mysql db (mysql...

Books for Ruby On Rails With Facebook Platform! -

hey guys! know books ruby on rails facebook platform. please suggest books ruby on rails facebook platform! there 2 screencasts using facebooker gem from peepcode from pragmaticprogrammers however, facebooker gem rails3 gives problems. , debugging facebook app not documented. there new facebook gem might worth too: koala

html - PHP DomDocument alter conditional comments -

i have html file conditional comment. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" href="css/elements.css"> <title>page</title> <!--[if lte ie 6]> <link rel="stylesheet" type="text/css" href="css/ie6.css" /> <![endif]--> </head> etc... i using domdocument library modify <link> attributes. there way of getting domdocument read , modify <link> element in conditional comments. foreach($dom->getelementsbytagname('head') $head) { foreach($head->childnodes $node) { if($node instanceof domcomment) { $node-...

Making a copy of a FeinCMS page tree using django-mptt changes child order -

i'm trying make copy of feincms page tree, managed using django-mptt. wrote function: def make_tree_copy(page, parent=none): ''' makes copy of tree starting @ "page", reparenting "parent" ''' new_page = page.objects.create_copy(page) new_page.save() page.tree.move_node(new_page, parent) # re-read django-mptt fields updated new_page = page.objects.get(id=new_page.id) child in page.get_children(): # re-read django-mptt fields updated child = page.objects.get(id=child.id) make_tree_copy(child, new_page) and call using make_tree_copy(page.tree.root_nodes()[0]) it works in general when have page tree looking this: a |- b |- c |- d it comes out this: a |- b |- d |- c from stepping through mptt code, magic seems happen in mptt/managers.py/_inter_tree_move_and_close_gap(), reason "lft" values of grandchildren changed. before move c=3, d=5, after...

.net - C# adding a character in a string -

i know can append string want able add specific character after every 5 characters within string from string alpha = abcdefghijklmnopqrstuvwxyz to string alpha = abcde-fghij-klmno-pqrst-uvwxy-z remember string immutable need create new string. strings ienumerable should able run loop on it using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication1 { class program { static void main(string[] args) { string alpha = "abcdefghijklmnopqrstuvwxyz"; var builder = new stringbuilder(); int count = 0; foreach (var c in alpha) { builder.append(c); if ((++count % 5) == 0) { builder.append('-'); } } console.writeline("before: {0}", alpha); alpha = builder.tostring(); console.writel...

javascript - Node.js on Heroku? -

i wonder if heroku addons - working rails - work node.js once support there? and eta launch of node.js support? node.js officially supported on heroku .

tabs - Primefaces wizard showing progress -

i want use primefaces display wizard pretty similar 1 shown in showcase , kind of tabview displays progress of user, combining wizard tabview . because think quite common requirement wondering if tried same , give me suggestions on how it ? checkout primefaces latest release 2.2 has new feature of wizard progress step step

iphone - Remove hyperlinks in uiwebview -

i trying load html page through uiwebview.i need disable hyperlinks in webview , make color normal text color i.e need disable webpage detection.is possible thanks in advance use uiwebview method – stringbyevaluatingjavascriptfromstring: to use javascript. then use " document.getelementsbytagname('a') " array of elements , want want (change href, change color etc.)

svn - subversion for online projects -

i've started using subversion keep track - , able reverse - of our website changes related development , maintenance. loving feeling of security provides! i know if there tool / way able automate synchronisation between "live" website , subversion repository. great able both commit bug patch repository , live version (right manually upload via ftp corrected file, commit subversion repository). i'm sure must exist somewhere, under name ? set need? thank feedback, a. you can create post-commit hook export repository @ latest revision webserver directory: #!/bin/sh # delete old site rm -r /var/www/website # export repository svn export --force file:///var/svn/website /var/www/website # make sure apache owns website chown -r www-data:www-data /var/www/website (credits this forum thread) save in file called post-commit , in hooks directory of repository, , make executable. if repository , website not on same server, you'll want export i...

ios - Set UILabel line spacing -

how can modify gap between lines in multiline uilabel ? edit: evidently nsattributedstring it, on ios 6 , later. instead of using nsstring set label's text, create nsattributedstring , set attributes on it, set .attributedtext on label. code want this: nsmutableattributedstring* attrstring = [[nsmutableattributedstring alloc] initwithstring:@"sample text"]; nsmutableparagraphstyle *style = [[nsmutableparagraphstyle alloc] init]; [style setlinespacing:24]; [attrstring addattribute:nsparagraphstyleattributename value:style range:nsmakerange(0, strlength)]; uilabel.attributedtext = attrstring; nsattributedstring's old attributedstringwithstring did same thing, that being deprecated. for historical reasons, here's original answer: short answer: can't. change spacing between lines of text, have subclass uilabel , roll own drawtextinrect , create multiple labels, or use different font (perhaps 1 edited specific line height, see p...

android - How to show a balloon above a marker in a MapActivity? Isn't there a widget? -

Image
i dont point, why have code it. like, dont want care about... the position of balloon (i want assign geopoint) the layout of basic balloon (later on might want implement xml based layout) the number of shown balloons (only display 1 @ time) the open/close behaviour of balloon (close, when other bollon tabbed) update solved it! see answer below... here "the missing widget"... balloons without icons: https://github.com/jgilfelt/android-mapviewballoons#readme balloons icons (extends jeff gilfelt's project): https://github.com/galex/android-mapviewballoons (offline, see comments answer)

c# - Dispose of AddIns created using MAF (System.AddIn) -

does know how dispose of addins created using system.addin. examples online seem show how load , use addin, none show how dispose of them once they're alive. problem create addins in new processes, , these processes never garbage collected, problem. below sample code illustrating problem. assume user never exits application, instead creates many instances of icalculator. how these addin processes ever disposed of? static void main(string[] args) { string addinroot = getexecutingdirectory(); // update cache files of pipeline segments , add-ins string[] warnings = addinstore.update(addinroot); // search add-ins of type icalculator collection<addintoken> tokens = addinstore.findaddins(typeof(icalculatorhost), addinroot); string line = console.readline(); while (true) { addintoken calctoken = choosecalculator(tokens); addinprocess addinprocess = new addinprocess(); ...

A Linux tool that will display errors as I type, Visual Studio style -

i'm looking tool display details of syntax errors in code i'm typing it, in same way visual studio does. i'm using gedit, not adverse acquiring new text editor. i'm using c++ , html/css right now, branching out more languages in future, needs have support many languages possible. i'd avoid using ide feel more productive using text editor , gnu toolchain. suggestions? you have difficulty finding simple one-file editor can this. ide virtually necessity, since integrates compiler detect errors/warnings. if use ide (and recommend eclipse or maybe kdevelop), can continue use gnu toolchain; don't need build project ide if don't want to. regularly use eclipse programming , ant or make in terminal building.

Adding dynamic property to a python object -

site = object() mydict = {'name': 'my site', 'location': 'zhengjiang'} key, value in mydict.iteritems(): setattr(site, key, value) print site.a # doesn't work the above code didn't work. suggestion? the easiest way populate 1 dict the update() method , if extend object ensure object has __dict__ try this: >>> class site(object): ... pass ... >>> site = site() >>> site.__dict__.update(dict) >>> site.a or possibly even: >>> class site(object): ... def __init__(self,dict): ... self.__dict__.update(dict) ... >>> site = site(dict) >>> site.a

fortran90 - Store a "pointer to function" in fortran 90? -

in fortran, can pass function/subroutine argument function/subroutine b, can store later retrieval , use? for example, allowed in c int foo(float, char, char) { /*whatever*/}; int (*pointertofunction)(float, char, char); pointertofunction = foo; in fortran can pass subroutine argument subroutine foo ! whatever end subroutine foo subroutine bar(func) call func end subroutine bar program x call bar(foo) end program but how can store address of foo in similar way c ? starting so-called "fortran 2003" (iso/iec 1539-2004) procedure pointers part of fortran language. it's of major new features of fortran language. usage example fortran wiki. stefano, mentioned strategy design pattern. in fortran 2003 can use pure oop way implement (without procedure pointers). offhand example: strategies.f90 module strategies implicit none private public :: strategies_transportation_strategy, & strategies_by_taxi_strategy, ...

c# 4.0 - C# HttpWebRequest ignore HTTP 500 error -

i'm trying download page using webrequest class in c#4.0. reason page returns content correctly, http 500 internal error code. request.endgetresponse(ar); when page returns http 500 or 404, method throws webexception. how can ignore this? know returns 500 still want read contents of page / response. you can try / catch block catch exception , additional processing in case of http 404 or 500 errors looking @ response object exposed webexeption class. try { response = (httpwebresponse)request.endgetresponse(ar); } catch (system.net.webexception ex) { response = (httpwebresponse)ex.response; switch (response.statuscode) { case httpstatuscode.notfound: // 404 break; case httpstatuscode.internalservererror: // 500 break; default: throw; } }

seo - Redirect old urls after url rewriting -

i need deciding how redirect old urls new ones. @ moment have urls like myhost.com/viewrecipe.php?id=2 but want them like myhost.com/recipes/pear-pie the problem website indexed in google. there way write 301 redirect search engines redirect them old type of urls new one? if it's impossible achieve without using id in new url type, other option makethis transition smooth possible search engine? p.s. dynamic urls you can use .htaccess file in root of application containing: redirect 301 viewrecipe.php?id=2 http://www.myhost.com/recipes/pear-pie yes needed urls... if not can't try write rewrite neded id on new seo-friendly url. another way able acces viewrecipie.php?id=2 , code like: <?php // new name dependeind of id $slug = posts::getbyid($id); header("http/1.1 301 moved permanently"); header("location: http://www.myhost.com/recipes/".$slug); ?> and shortest way: header("location: http://www.myhost.com/recip...

Issue with visual studio template & directory creation -

i'm trying make visual studio (2010) template (multi-project). seems good, except projects being created in sub-directory of solution. not behavior i'm looking for. the zip file contains: folder1 +-- project1 +-- project1.vstemplate +-- project2 +-- project2.vstemplate myapplication.vstemplate here's root template: <vstemplate version="3.0.0" type="projectgroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"> <templatedata> <name>my application</name> <description></description> <icon>icon.ico</icon> <projecttype>csharp</projecttype> <requiredframeworkversion>4.0</requiredframeworkversion> <defaultname>myapplication</defaultname> <createnewfolder>false</createnewfolder> </templatedata> <templatecontent> <projectcollection> <solutionfo...

java ee - Deploying an exploded WAR inside a compressed EAR == not possible? -

at moment trying deploy exploded war directory in compressed ear file on jboss-4.2.3.ga server. jboss complains can't find web-app.war file (failed find module file: web-app.war). if deploy same ear file exploded, too, deployment works without problems. so question is: possible deploy exploded war inside compressed ear? i can deploy exploded war inside compressed ear on jboss-5.1.0.ga. i suggest can check youear.ear/meta-inf/application.xml. my appliation.xml this: <module> <web> <web-uri>myapp-war-1.0.0-snapshot.war</web-uri> <context-root>/myapp</context-root> </web> </module> and myapp-war-1.0.0-snapshot.war exploded war directory.

How do I read the number of files in a folder using Python? -

how read number of files in specific folder using python? example code awesome! to count files , directories non-recursively can use os.listdir , take length. to count files , directories recursively can use os.walk iterate on files , subdirectories in directory. if want count files not directories can use os.listdir , os.path.file check if each entry file: import os.path path = '.' num_files = len([f f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]) or alternatively using generator: num_files = sum(os.path.isfile(os.path.join(path, f)) f in os.listdir(path)) or can use os.walk follows: len(os.walk(path).next()[2]) i found of these ideas this thread .

How do I use my own domain for my own openID login without having to make a myopenid domain account? -

i have own domain signed-up under myopenid follows: openid.mysite.com everything verified , seems working on myopenid site. however, want setup website have enter domain name openid login. i have read http://blog.stackoverflow.com/2009/01/using-your-own-url-as-your-openid/ , understand basic concept using header link tags. however, instead of... <link rel="openid.server" href="http://www.myopenid.com/server"> <link rel="openid.delegate" href="http://username.myopenid.com/"> i want use own site openid.delegate follows... <link rel="openid.server" href="http://www.myopenid.com/server" /> <link rel="openid.delegate" href="http://openid.example.com/username" /> and works on site no problems! however, plan have 1 user authenticated through site, me. not plan on having other users, have... <link rel="openid.server" href="http://www.myopenid.com/se...

tomcat6 - Is there a tomcat anonymous role or user for tomcat security realms? -

i want role protected username , password in environments, not require prompt in others. if have auth-constraint in tomcat web.xml, can create user role needed has 'anonymous' access? in tomcat-users.xml file (%tomcat_home%/conf) add in 'anonymous' role there. can use auth-constraint secure application. your tomcat-users.xml (this v5.5) <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="tomcat"/> <role rolename="role1"/> <role rolename="anonymous"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="role1" password="tomcat" roles="role1"/> <user username="myuser" password="mypassword" roles="anonymous"/> </tomcat-users> the user need enter myuser/mypassword access application

Weird CakePHP (1.3) Pagination component behaviour -

have users list page result can modified using gender, city , country selects (dropdowns), , it's working fine. have lot of users need put pagination well, , here comes "weird" part (i sure it's not weird cannot figure out problem comes from): when select gender, pagination works great , can navigate between of pages, if select city instance (in addition or not of gender), pagination numbers right lost city restriction when move page. tried understand happens filters displaying $this->data . , says same before: working fine gender ( $this->data['users']['gender'] go through pagination pages), other parameters got lost once try navigate away. thing there isn't difference between filter gender , other ones, either on controller side or in view (both select inputs). on more technical side, here's bit of code: //in controller function if (!empty($this->data['users']['gender'])) { $conditions[...

printf() statement makes a difference to my return value? - C Programming -

i'm experimenting 1 of functions in k&r c programming language book , using pointers write strindex function rather array notation. have strange problem if include printf() statement @ either of 2 points in code below function returns correct index (6 in case), if leave printf() statements out function returns -1. i can't see why should make difference @ , grateful clarification. here's code: #include <stdio.h> int strindex(char *a, char *b) { char *pa; char *astart = a; char *pb = b; int len; while(*pb++ != '\0') len++; while(*a != '\0') { pa = a; pb = b; for(;*pb != '\0' && *pa == *pb; pa++, pb++) ; if(len > 0 && *pb == '\0') { return - astart; } //printf("%c\n", *a); a++; } //printf("%c\n", *a); return -1; } int main() { char *a = "experiment...

sharepoint - Applying a custom webtemplate to a sitecollection works on powershell ise and not on powershell console -

i'm working on automated script deploying sharepoint projects. i'm using sandbox level webtemplate must applied when de site created. had lot of troubles doing because seems sharepoint caches list of webtemplates , get-spwebtemplate doens't find new added one. way made work this: [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint") $site= new-object microsoft.sharepoint.spsite($web_application_complete_url) $site.openweb().applywebtemplate($web_template_name) $site.dispose() as can see, i'm using .net sharepoint api instead of cmdlets. works sweet in powershell ise in powershell console throws exception regarding referenced dll: exception calling "applywebtemplate" "1" argument(s): "could not load file or assembly 'xxx.sharepoint.common, version=1.0.0.0, culture=neutral, publick eytoken=534c125b45123456' or 1 of dependencies. system cannot find th e file specified." @ c:\build\sharepointbuil...

How can I remove a gem from my Rails 3 project without getting this really strange Bundle error? -

the error is: have modified gemfile in development did not check resulting snapshot (gemfile.lock) version control what version control? why/how bundle know version control? removed line gemfile. not supposed that? do rm -rf .bundle && bundle install project root.

Equivalent of LIMIT for DB2 -

how do limit in db2 iseries? i have table more 50,000 records , want return records 0 10,000, , records 10,000 20,000. i know in sql write limit 0,10000 @ end of query 0 10,000 , limit 10000,10000 @ end of query 10000 20,000 so, how done in db2? whats code , syntax? (full query example appreciated) using fetch first [n] rows only : http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.perf/db2z_fetchfirstnrows.htm select lastname, firstname, empno, salary emp order salary desc fetch first 20 rows only; to ranges, you'd have use row_number() (since v5r4) , use within where clause: (stolen here: http://www.justskins.com/forums/db2-select-how-to-123209.html ) select code, name, address ( select row_number() on ( order code ) rid, code, name, address contacts name '%bob%' ) t t.rid between 20 , 25;

jquery - prepend after element -

is possible prepend after element? example, prepending hyperlink div there element in there represented <a id="test">test1</a> possible prepend test2 hyperlink after test1 hyperlink? $('div[id='+id+']').prepend('<a id="test">test2</a>'); you can use .after() place after other element, this: $('#test').after('<a id="test2">test2</a>');

vb.net - resize borderless form -

i able resize using code below resizes towards right side , bottom right corner i want modify code user can re size form bottom left corner. also of solution given on site based on wndproc / wm_nclbuttondown , not using because form have lots of controls flicker's badly. private shared frmlastwidth integer = 0 private shared frmlastheight integer = 0 private shared frmwidth integer private shared frmheight integer private shared frmisresizing boolean = false private frmrectangle new system.drawing.rectangle() private sub resizeme_mouseup(byval sender object, byval e system.windows.forms.mouseeventargs) handles resizeme.mouseup if frmisresizing frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) me.width = frmwidth me.height = frmheight ...

SmartGwt - Load Grid Data From JSON -

i trying started smartgwt. using xjsondatasource make cross-domain call example page @ smartclient has json data. when run code, however, popup comes says "finding records match criteria..." never goes away, , data not loaded. using free version of smartgwt (my company has said we'll use). hoping i'm missing obvious. datasource datasource = new xjsondatasource(); datasource.setdatatransport(rpctransport.scriptinclude); datasource.setdataformat(dsdataformat.json); datasource.setdataurl("http://www.smartclient.com/smartgwt/showcase/data/dataintegration/json/contactsdata.js"); datasourcetextfield namefield = new datasourcetextfield("name", "name"); namefield.setvaluexpath("name"); datasource.setfields(namefield); listgrid grid = new listgrid(); grid.setdatasource(datasource); grid.setwidth100(); grid.setheight(100); grid.setautofetchdata(true); grid.draw(); i se...

visual studio 2010 - How to delete all comments in a selected code section? -

every once in while, code gets littered many useless comments, of them obsolete lines of code, , obsolete "memos self". wondering if there's way select code section, , magic key combination or macro, delete of those. thanks. i believe search & replace in vs allows regular expressions, easy enough search "// (anything end of line" or "/* (anything) */" , replace "". since c++ (i think), 1 write regex not find 'escaped' comments.

How to configure a proxy class for an ASP.NET web service for flexible deployment to production -

i inherited web app @ visual studio 2003 level placed of code accessing sql server in asmx web service. web project had web reference web service. needed bring whole thing under source control, upgrade vstudio 2008 , make bunch of fixes , enhancements. in doing this, came across neat article code magazine emphasizing advantages of "assembly separation" . written wcf "inspired me" to: remove web reference main asp.net web application project add new project class library called proxyzipeeeservice add web reference in proxyzipeeeservice project point @ zipeeeservice project add reference in main web app project proxyzipeeeservice.dll produced building project of same name. the things work , guess there [performance?] advantages separating things out having described structure, i need question/problem : i run lots of configuration problems when deploy production require me make changes quite "awkward" , prone me screwing things up. here g...

c# - Need to run SQL script on 5000+ databases. How should I approach? -

i developing tool used run sql script on 5000+ production databases simultaneously. used run scripts on our dev , qa databases. want design in extensible way, , have no experience doing this, use advice. technology i'm using: c# .net 4.0 ado.net smo edit: suppose extensible mean able run scripts on arbitrary number of databases in efficient way possible. first recommend double-check if cannot use 1 of existing management facilities, policy based management or central management servers . specially pbm, covers many operations traditionally required 'run script on every database'. there many articles describing pbm in action, eg. policy-based management , central management servers . another thing consider use powershell instead of c#/ado/smo. ps deliverables scripts changed/maintained in production, opposed compiled executables. object pipe model of ps makes lot of tasks easier in ps in raw c#. ps can use multithreaded execution. see sql server powershell...

php - How to detect root folder in URI when using apache mod_alias and mod_rewrite? -

how detect root folder in uri when using apache mod_alias , mod_rewrite? i have website running on sub folder in of document root example /var/www/this/an/other/dir in folder have .ht_access file mod_rewrite rules redirect index.php # nothing if file (s), link (l) or (d) exists rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] # redirect else index.php rewriterule ^.*$ index.php [e=port:%{server_port},nc,l]` i have set alias easy access alias /foo /var/www/this/an/other/dir now when go address http://host.com/foo/bar/ how can detect /foo root folder of uri? easiest way set env variable directly within apache: setenv aliasroot /foo you can access through $_env superglobal: $root = $_env['aliasroot']; i don't think there reliable way in pure php.

objective c - iphone: is this a correct design: 2 views with 1 class? -

i' new iphone developer coming flash stuff. let me tell problem: i'm doing puzzle game , have tab bar controller 4 tabs. use 1 tab sign , other login, works different uses lot of same code (displaying images, playing sounds, settings stuff, audio things, animations things, , on). the point 2 views have almost same ui elements, i.e. differences them 2 labels. when using flash easy, reused elements: if in login window hid 2 additional sign labels. 1 class controlled everything. easy , fast. here have created 2 views: sign , login (one each one) 1 class: "singuploginviewcontroller.m" controls (please note: 1 class, 2 instances) question works concern if it's correct design? other way separating "singuploginviewcontroller.m" in "singupviewcontroller.m" , "loginviewcontroller.m". , other way sharing same instance. thanks help nothing wrong that. it's avoid code duplication. an alternative create base...

iphone - Unexpected results from NSUserDefaults boolForKey -

after uninstalling application device , loading in debugger, attempting in setup method load flag using boolforkey. first time app runs have expectation bool not exist, since have reinstalled app. expect documentation boolforkey therefore return no. i seeing opposite though. boolforkey returning yes, fubars initial user settings. idea why might happening or way around it? bool stopautologin = [[nsuserdefaults standarduserdefaults] boolforkey:@"stopautologin"]; _userwantsautologin = !stopautologin; so stopautologin comes out "yes", unexpected. stranger , stranger: when call objectforkey:@"stopautologin" nil object, expected. it's boolforkey returns bad value. changed code this: // nil nsobject *wrapper = [[nsuserdefaults standarduserdefaults] objectforkey:@"stopautologin"]; // yes bool stopautologin = [[nsuserdefaults standarduserdefaults] boolforkey:@"stopautologin"]; please try [userdefaults synchronize]; ...

jquery - How to check what div span is placed in -

i trying find out div span in using jquery. here eg. <div id='one'></div> <div id='two'></div> <div id='three'><span id="find_me"></span></div> thanks use .closest() find closest ancestor div ( .parent() find it if div immediate parent). $('#find_me').closest('div').attr('id')

asp.net - Force local user to change password at next login with C# -

i'm writing function web app in asp.net client logs server machine, windows authenticated against local users on server. function writing resets users password , emails them new one. so: string userpath = "winnt://" + environment.machinename + "/" + username.text; directoryentry de = new directoryentry(userpath); de.invoke("setpassword", new object[] { password }); how can check flag force user change password next time log in password emailed them? tried using pwdlastset so: de.properties["pwdlastset"].value = 0; but apparently works ldap, not winnt, , doing locally. any experts know better me? have tried looking way through command line can create process, haven't been able find way way, either. for winnt, must set value 1 rather 0, , property name "passwordexpired" rather "pwdlastset"; see http://msdn.microsoft.com/en-us/library/aa746542(vs.85).aspx in other words, winnt: de.properties[...

3D is not rendering in WPF Application -

i trying render 3d object using below code. when run application, nothing displayed. seems blank. missing anything? <page x:class="samplewpfapplication.demopage3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="demopage3" xmlns:my="clr-namespace:samplewpfapplication"> <grid> <grid.rowdefinitions> <rowdefinition height="126*" /> <rowdefinition height="126*" /> <rowdefinition height="66" /> </grid.rowdefinitions> <viewport3d x:name="theview3d"> <viewport3d.camera> <perspectivecamera position="6,6,6" lookdirection="-4,-4,-4" updirection="0,1,0" /> </viewport3d.camera> <modelvisual3d x:name="themodel"> <modelvisu...

mysql - SQL query not returning expected results -

here's sql query scrubbed (just column/table/database names). kept structure same production. query taken mysql log. select master.pk pk, master.vendor_id vendorid, master.vendor_text vendorname, master.device_id deviceid, master.device_did devicedid, master.device_text devicename, master.class_id classid, master.class_text classname, master.oem_id oemid, master.oem_did oemdid, master.oem_text oemname, master.oem_vendor_text oemvendor, master.comment comment, master.v1 v1, master.v2 v2, master.status status, dev_mod_join.mod_text module master left join dev_mod_join on master.device_did = dev_mod_join.dev_id ( master.device_text concat("%", 'search term', "%") or master.vendor_text concat("%", 'sear...

Flex/AIR: Export DataGrid to Excel with multiple sheets -

i have air application 2 datagrids export excel. i've found as3xls library, can handle 1 sheet (as per comments). ideally, i'd export both datagrids separate sheets in same workbook. the air application running entirely on user's desktop , doesn't have connection server, solution need flex/air only. suggestions? checkout air 2.0's nativeprocess class, let's call external/system commands. i'm calling python script merge 2 worksheets created as3xls. biggest issue as3xls writes lot of garbage. going try exporting datagrids csv , let python's xlrd/xlwt modules excel stuff.

iphone - How to push uiviewcontroller over tabbarcontroller -

i have tabbar app. each tab has uinavigationcontroller. navigationcontroller's shows navigation bar value no. i control navgation control active in -(void)tabbarcontroller:(uitabbarcontroller *)tabbarcontroller didselectviewcontroller:(uiviewcontroller *)viewcontroller event in appdelegate. user taps row in table in tab call same method (opendetail)in appdelegate. want push detailviewcontroller full screen, not in tabs controller. tried ways never worked. push modalview. [currentnavcontroller presentmodalviewcontroller:detailvc animated:yes]; how can come/go right side. want work normal rootviewcontroller. new controller should come on tabbarcontroller usa today app. present view controller this [tabbarcontroller presentmodalviewcontroller:detailvc animated:yes];

intellisense not properly working visual studio 2008 for Visual C++ and MFC environment -

i working in vc++ of visual studio 2008. in project (vc++), access intellisense when press ctrl+space. doesn't work automatically other project ( i.e. c#, vb .net). so should work intellisense efficiently? jim brissom correct think confusion "statement completion" isn't option, section title. if follow menu tools-->options-->text editor-->c++ on right @ top see statement completion check boxes "auto list members", "parameter information", etc hope helps.

Install Firefox extension using Windows registry -

i have developed firefox extension , installed in xpi file. it's working fine. need install extension in windows registry. how can this? you can use command line that: http://kb.mozillazine.org/installing_extensions or registry: https://developer.mozilla.org/en/adding_extensions_using_the_windows_registry

objective c - iphone JSON Parsing.. How can i parse this data -

this print screen of nsmutablearray. this 2409,2410,2412 not fix key. coming dynamically. { 2409 = ( { altselectionprice = "2.00"; }, { altselectionprice = "3.00"; } ); 2410 = ( { altselectionprice = "7.00"; }, { altselectionprice = "0.00"; } ); 2412 = ( { altselectionprice = "0.00"; }, { altselectionprice = "9.00"; }, { altselectionprice = "5.00"; } ); } thnx in advance. i on work computer runs windows cannot post exact code. need hold of dictionary in array. may following: nsdictionary* dict = [mymutablearray objectatindex:0]; and iterate on keys in dictionary: for (id key in [dict keyenumerator]) { //use key or object of key using [dict objectforkey:key] } update : assumed getting array json parser! ...

c++ - QT separator widget? -

Image
greetings all, is there widget separate 2 qwidgets , give full focus 1 widget. shown in following figure ? thanks in advance, umanga how qsplitter ? qwidget 1 , exmaple, qlistview . qwidget 2 combination of qwidget s (the left part simple qpushbutton show/hide caption, , right part widget)... have do, hide qwidget2 when user clicked on qpushbutton ... if need example, may post it. updated main.cpp #include "splitter.h" #include <qtgui/qapplication> int main(int argc, char *argv[]) { qapplication a(argc, argv); splitter w; w.show(); return a.exec(); } splitter.h #ifndef splitter_h #define splitter_h #include <qtgui/qdialog> class splitter : public qdialog { q_object; qwidget* widget1; qwidget* widget2; qpushbutton* button; public: splitter(qwidget *parent = 0, qt::wflags flags = 0); ~splitter(); private slots: void showhide(void); }; #endif // splitter_h spl...

php - How to find the time is fall between two times? -

i having 2 times in database. starting time 07:00 , ending time 07:25 and if chooses starting time application 07:10 , end time 07:35 need inform time not available booking. how can check 07:10 , 07:35 fall between 07:00 , 07:25 using php?thanks in advance? update: may give 06:50 07:15 .at time need find time falls between previous times? you can convert times number of minutes since start of day make comparison easier. 07:00 = 07 * 60 + 00 = 420 call $start and 07:25 = 07 * 60 + 25 = 445 call $end similarly convert user input hh:mm min above , call them $userstart , $userend . need is: if($userstart >= $start && $userend <= $end) { // valid }

How can D return 0 on success and non-zero on failure if main is void? -

in d, main function defined: void main(/*perhaps args not remember*/) { } i know sure function returns 0 on success , non-zero on failure , yet defined not returning anything. logic behind it? function void return type not return value. there nothing illogical when consider call stack looks this: os -> d runtime -> main the main function invoked d runtime system, recognized main function returns nothing - , in case return success os. in case main function defined return type int, d runtime return os value returned main function.

c++ - Parsing <multi_path literal="not_measured"/> in TinyXML -

how parse following in tinyxml: <multi_path literal="not_measured"/> i able parse below line: <hello>1234</hello> the problem first statement not getting parsed normal way. please suggest how go this. not 100% sure youre question asking here basic format loop through xml files using tinyxml: /*xml format typically goes this: <value atribute = 'attributename' > text </value> */ tixmldocument doc("document.xml"); bool loadokay = doc.loadfile(); // error checking in case file missing if(loadokay) { tixmlelement *proot = doc.rootelement(); tixmlelement *element = proot->firstchildelement(); while(element) { string value = firstchild->value(); //gets value string attribute = firstchild->attribute("attribute"); //gets attribute string text = firstchild->gettext(); //gets text element = element->nextsiblingelement(); } } else { //err...

java - Problem loading resources from classpath -

in web application running in local tomcat, trying load folder /folder in tomcat/webapps/myproject/web-inf/folder it: inputstream realpath = getclass().getclassloader().getresourceasstream("/folder"); which returns null . piece of code supposed load resources classpath, if not wrong in path folder in. anyway, moved folder different paths, such tomcat/webapps/myproject/web-inf/classes/folder or tomcat/webapps/myproject/web-inf/lib/folder same result. did miss something? in advance. regarding on answers (thanks), edit question have tryed, same null result. a) string realsource = getservletcontext().getrealpath("/folder"); b) inputstream realpath = getclass().getclassloader().getresourceasstream("/folder/fileinfolder"); c) servletcontext servletcontext = (servletcontext)context.getexternalcontext().getcontext(); string realsource = servletcontext.getrealpath("/folder"); i must folder path tomcat/webapps/mypro...

java - Call COM port from webpage -

i'm looking way call com port webpage. i thinking abut running java webstart (or flash?) program opens local web server allows interact com port using jsonp. are there show stopping security restrictions on way don't know of? should possible: use native libraries (java com bridge) java ws application open local port access local port javascript, using <script> tags do without scaring users "this website trying nasty, off fast can" kind of messages :) i've used java com bridge before, shouldn't problem - @ least i'm able run native code. so how jnlp file have working? alternatives java ws? better install daemon? impossible. violates sorts of basic security principles, part do without scaring users "this website trying nasty, off fast can" kind of messages this messages intended prevent.

Selenium: Dynamic clicking of radio button beside search result -

i'm month-old selenium , far use ide. haven't had luxury of reading on rc (although after critical project). anyway know how click radio button beside search result w/c not appear on same position. w/ limited knowledge in selenium , programming, best solution can think of veryfytextpresent on text of result click blindly couple of positions beside text using xpath (? doable ?). how in less primitive manner? so in scenario verify bingo! click on radio button beside o xxxxxxxx o xxxxxxxx o xxxxxxxx o bingo! o xxxxxxxx o xxxxxxxx however on different searches o bingo! o xxxxxxxx o xxxxxxxx o xxxxxxxx o xxxxxxxx o xxxxxxxx anyway hope i've explained problem clearly. in advance comments, suggestions , guides. :) try using firebug investigate additional distinguishing properties radio button. if exist, use them construct css identifier. if not, (and if possible), ask developer add properties. alternately, try posting html t...

Taking Arabic Character Input in C++ from a console application on Windows -

is there example code showing how accept arabic input user in c++ on console application, in windows? i'll try answer c++ part. cannot read arabic characters console cin . in <iostream> there's predeclared wcin object of type wistream - wide-character input stream. , should read input not string wstring . e.g #include <iostream> #include <string> int main() { std::wstring s; std::wcin >> s; } this c++ part, question remains whether or not os allows wide characters in console window. hth

path - vim travel to pathfile via shortcut, directly, always -

when travel between files using shortcut on pathfile, seems don't travel between files. i go file using >, within file change location of cursor , something, press <. instead of going previous file, first goes original location @ when entered file, need press < again previous file. that's nuisance doesn't allow me change stored location within destination file. remains same enter @ same place, plus requires 2 clicks travel when 1 necessary. , makes system behavior more confusing. this problem seems arise when enter large files. small ones location works fine. how make < button move me previous file in, directly, always? p.s. use following mapping in vimrc: noremap > gf noremap < <c-o> have tried substituting <c-o> <c-6>, doesn't work, reason. you can use :bp in mapping (previous buffer): :noremap < :bp<cr>

Access query from VB.NET - To insert data though they are NULL -

i need insert data db db. run query vb.net: for example: insert dbdestino.tabladest (campo1,campo2) select valor1,valor2 dborigen.tablaorigen field " campo1 " integer (in dbdestino) but value " valor1 " (in dborigen) null. if run previous query, returns error , not insert data. how can insert data though " valor1 " null? i doubt problem due null values in valor1, unless campo1 field rejects nulls. you need insert statement access' database engine accept. example, statement executed in access dbdestino.mdb open: insert tabladest ( campo1, campo2 ) select valor1, valor2 tablaorigen in 'c:\access\dborigen.mdb'; i'm not proficient vb.net, think can open connection dbdestino.mdb, , execute same insert statement works in access. imports system.data.oledb module module1 dim cn oledbconnection dim cmd oledbcommand dim icount integer dim strinsert string sub main() cn = new oledbconnecti...