Posts

Showing posts from January, 2013

css - How do I make a semi transparent background? -

i need make white background 50% transparent without affecting else. how do it? use rgba() : .transparent{ background:rgba(255,255,255,0.5); } this give 50% opacity while content of box continue have 100% opacity. if use opacity:0.5 , content faded background. hence not use it.

MATLAB: Merging Function Handles -

i'm coding simulation in matlab , need in regards issue i've been having. i'm working on problem have n separate anonymous function handles f_i , each of stored in cell array functions , accepts 1x1 numeric array x_i , returns 1x1 numeric array y_i . i'm trying combine each of these anonymous function handles single anonymous function handle accepts single n x 1 numeric array x , returns single n x 1 -numeric array y . here, x(i) = x_i , y(i) = y_i = f_i(x_i) as example let n = 2 , f_1 , f_2 2 function handles input , output 1x1 arrays , stored in cell array named functions f_1 = @(x_1) x_1^2 f_2 = @(x_2) x_2^3 functions = {f_1,f_2} i need code able use n , f_1 , f_2 construct function handle f inputs , outputs 2x1 numeric array. f = @(x) [f_1(x(1,1));f_2(x(2,1))] it's difficult define such function using inline @() -anonymous syntax (because of limiting requirement on function's body expression). still it's possible def...

c# - self hosting web pages? -

we trying build program sit on clients servers, user enter url in browser go our program on servers. program call data @ our servers , return image in browser possible create under wcf self hosing ? you use http call site @ clients site image or more sophisticated technology web service. there should no problem if both web servers connected internet.

RegEx to extract URL, target and link from custom markup -

i'm sure simple, can't figure out. i want extract url, target , link this example: [http://www.testdomain.com/blog/122_blog post.aspx _blank]click here![/] i have tried this: \[(.*) (.*)\](.+?)\[\/\] it works long have _blank or _self following url, if remove together, post.aspx target (of course). i tried things (_blank)? , didn't work @ all. please help, regex isn't thing, , feel free suggest other improvements. doesn't have foolproof, want keep simple. thanks! try this: \[(.*?)(?: (_blank|_self))?\](.+?)\[\/\]

iphone - ABPersonRemoveImageData leaks even when released? -

hi using code set contact image. getting leaks in instruments , points " abpersonsetimagedata(ref, cfdata, &error);" line. dont see problem , love here. thanks shani if(person.state!=0){ //set default image; nsstring *n=[nsstring stringwithformat:@"%@%@", person.category_en,@"_b"]; uiimage *img = [uiimage imagenamed:n]; nsdata *dataref = uiimagepngrepresentation(img); cfdataref cfdata = cfdatacreate(null, [dataref bytes], [dataref length]); abpersonremoveimagedata(ref, &error); abaddressbooksave(addressbook, &error); abpersonsetimagedata(ref, cfdata, &error); cfrelease(cfdata); //set default category name; abrecordsetvalue(ref, kabpersonjobtitleproperty, nslocalizedstring(person.category,@""), &error); //set notes person abrecordsetvalue(ref, kabpersonnoteproperty,person.note, &error); } ...

zend framework - Structuring Zend_Acl and CRUD with Parent/Child Relationships -

i wondering how should structure acl crud parent/child relations. eg. projects have todolists. todolists have todos there various controller actions project /projects/add /projects/edit/{projid} /projects/delete/{projid} /todo-lists/add/{projid} /todo-lists/edit/{todolistid} ... as can see going down hierarchy, actions have ids refer not (eg. todo-lists controller -> todo-list resource) parent so with have setup (generally), looks this acl controller plugin (predispatch) set role loggedin user or 'unauthenticated' set resource controller name set privilege action name if request param 'id' set, actual entity (i using doctrine orm) implements zend_acl_resource_interface . here complication arises. resource controller name, eg. /todo-lists/add must know parent entity instead (project). setup, have chage privilege to 'addtodolist'. way, project acl assertion class have todolists stuff. there disconnect between controller actions ...

mocking window.location.href in Javascript -

i have unit tests function makes use of window.location.href -- not ideal far rather have passed in not possible in implementation. i'm wondering if possible mock value without causing test runner page go url. window.location.href = "http://www.website.com?varname=foo"; expect(actions.paramtovar(test_data)).toequal("bar"); i'm using jasmine unit testing framework. you need simulate local context , create own version of window , window.location objects var localcontext = { "window":{ location:{ href: "http://www.website.com?varname=foo" } } } // simulated context with(localcontext){ console.log(window.location.href); // http://www.website.com?varname=foo } //actual context console.log(window.location.href); // http://www.actual.page.url/... if use with variables (including window !) firstly looked context object , if not present actual context.

php - Encoding problem when using htmlentities method -

i've problem of character encoding in php, this's php code: n_event=$_get['ndlann']; $nom_complet=htmlentities(stripslashes($_post['nom'])); $email_comment=htmlentities(stripslashes($_post['email'])); $titre_comment=htmlentities(stripslashes($_post['titre'])); $texte_comment=htmlentities(stripslashes(nl2br($_post['commentaire']))); $pays_comment=$_post['pays']; $date_ajout=date('y/m/d'); data added in database table , see data comes comments form, when user enters comments orient languages carachters (arabic,hebrew...etc), input data change : Ø´Ù�را عÙ�Ù� اÙ�Ù�Ù�ضÙ�Ø i tried delete htmlentities method , works fine , start problem of comments form security (js scripts executed) what can situation? and thanks do not use htmlentities() ever. this function has been obsoleted long time ago. use htmlspecialchars() instead. you have bunch of nonsense in code doing htmlentities(nl2br(*)) ...

sharepoint - SPItemEvent: abort the event from the EventHandler -

how can abort item (in case, itemdeleting) doesn'r executed? want deletion not take place if conditions matched , silently use (no messages, no exceptions). thanks edit: sp 2010 public override void itemdeleting(spitemeventproperties properties) { properties.cancel = true; properties.errormessage = "something went wrong!"; } if cancel though, reported user, nothing can that. update for use status property http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventpropertiesbase.status.aspx public override void itemdeleting(spitemeventproperties properties) { properties.status = speventreceiverstatus.cancelnoerror; }

captcha - PHP client PIN security -

i'm developing system has functionality clients can view details of purchases/renewals/etc supplying pin "number". a pin being used instead of login information because of type of clients we're targeting. pin printed on documents sent them. the view shown when supply pin not reveal highly sensitive information such credit card etc, less sensitive 1 such product name, type, price, barcode, repairs etc. the issue in question pin. opted using random 5 character pin (0-9, a-z a-z) - case sensitive. i'll removing homoglyphs ('i','1','l','0','o','rn','vv'), actual number of combinations lower. i've got couple of questions this: is practice acceptable? should write lockout mechanism "ban" traffic ips large amount of failed attempts?* should write error checking system (similar luhn's algo in credit card numbers)? *should make use of captcha system? as captcha , lockout ...

android - how to resolve "WARNING: Application does not specify an API level requirement"? -

hello writing android application, run application, following application generates , application doesn't appear on windows, please .. !!!! appreciate if right solution ,,,,,, to resolve warning add <uses-sdk android:minsdkversion="4" /> to manifest tag in androidmanifest.xml . replace 4 lowest number of sdk version want support.

CodeIgniter routes and pagination adding “/page/” to all links -

i’ve implemented pagination following: $this->load->library('pagination'); $perpage=10; $config['base_url'] = site_url().'news/page'; $config['total_rows'] = $this->news_model->getnews(array('count' => true)); $config['per_page'] = $perpage; $config['uri_segment'] = 3; $config['num_links'] = 8; $news = $this->news_model->getnews(array('limit' => $perpage,'offset'=>$offset)); $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $data['news'] = $news; $data['page'] = "news"; $this->load->view('index', $data); i’m using following routes: $route["news"] = "news/news_list"; $route["news/page"] = "news/news_list"; $route["news/page/(:num)"] = "news/news_list/$1"; $route["news/detail/(:any)"] = "n...

algorithm - sorting int array with only 3 elements -

i have array: int [] myarray = {17, 6, 8}; what optimal way sort array, in pseudocode? thanks! i think should quite fast (ascending order): if (el1 > el2) swap(el1,el2) if (el2 > el3) swap(el2,el3) if (el1 > el2) swap(el1,el2)

windows - How can I control Internet Explorer with Perl? -

is possible control progammatically internet explorer perl , have each opened instance of ie configured use different proxy? could provide code example or point cpan module that? while entirely possible control internet explorer via perl using variety of means (using win32::ie::mechanize or accessing ibrowser2 , related interfaces via win32::ole ), doubtful requirement of running multiple instances different proxies can met.

asp.net - How to read character by character from text file? -

how read character character in line text file? use straemreader class. has read() method reads next character input stream , advances character position 1 character. (overrides textreader.read().) for example: using (streamreader sr = new streamreader(path)) { while (sr.peek() >= 0) { char c = (char)sr.read(); } }

html - Site not displaying correctly in IE -

can explain me why site not displaying correctly in internet explorer: http://shortener3.info/web/ the choice of doctype (transitional no url) triggers quirks mode , causes browsers emulate bugs appeared in earlier browsers in order cope legacy code. ie emulates lot of features of ie 5.5, very broken. use doctype triggers standards (aka strict) mode . that might not solve problems, should first step in trying resolve them.

algorithm - Working with large amounts of data in java: speed -

i want work 10k-100k data points in form of 16-tuples (x_1,...,x_16). of elements of tuple floats in [0,1], along 1 string , ints. i want able lightning fast (preferrably <10ms) math operations on selected points of data. example: compute average of x_15 points satisfy: x_3 in [0.3,0.4] , x_5 > x_2. my naive approach create class each tuple , math on classes. storage i'd write tuples text file when program finished , load them there when program starts. is feasible , approach lightning fast? it faster load tuples 2 dimensional array of floats rather 1 dimentional array of class instances, appears want doing lot of comparison between individual tuples (so have access class properties 100k times+ per query doing 1d array way)

html - Full-width CSS header not scrolling correctly with narrow browser window -

i have header 100% in width , content doesn't have minimum or maximum size. when make browser window rather small , scroll header doesn't fill 100%. size of browser window if content under bigger. image: http://i.stack.imgur.com/y5782.png i cannot use max-width or min-width. when start setting width of banners experience things don't happen want them to. suggestion set div banner area black background convert banner transparent image. way can set dimensions of image exact size needed keep links visible , appear "blend" background 1 whole image. way won't matter size window banner visible.

c# - NHibernate relationship has an issue with two-directional getting data -

i have 2 tables have many-to-many relation. code of entities public class product : baseentity { public virtual string name { get; set; } public virtual ilist<category> productcategory { get; set; } public virtual float price { get; set; } public virtual string description { get; set; } public virtual datetime dateofadd { get; set; } public virtual float discount { get; set; } public virtual int salecount { get; set; } public virtual byte[] image { get; set; } } public class category : baseentity { public virtual string name { get; set; } public virtual string description { get; set; } public virtual ilist<product> categoryproducts { get; set; } public virtual void addproduct(product product) { this.categoryproducts.add(product); } public virtual void deleteproduct(product product) { this.categoryproducts.remove(product); } } i map classes many-to-many in conform mapping. ...

ASP.Net MVC 2 Image upload -

i trying simple image upload using mvc2. in view have: <% using (html.beginform("upload","home")) { %> <input type="file" name="upload" id="imageupload" value="upload image"/> <input type="submit" value="upload" /> <% } %> in controller (home), how image uploaded , save database? new asp.net mvc , thing has got me stuck. in advance , time. edit: okay, guess question vague answer got provide more detail , have: the image model simple below -- public class imagemodel { public image image; public string imagename; public imagemodel(image image, string name) { this.image = image; imagename = name; } } the view this: <%using (html.beginform("upload","home", formmethod.post, new {enctype = "multipart/form-data"})) {%> <input type="text" id="imagename" /...

android - how to add layout on ontouch event of activity? -

here code trying add 1 layout @ runtime on ontouch event. package desingtesting.com; import android.app.activity; import android.content.context; import android.media.audiomanager; import android.os.bundle; import android.util.log; import android.view.keyevent; import android.view.layoutinflater; import android.view.motionevent; import android.view.view; import android.view.window; import android.widget.framelayout; import android.widget.imagebutton; import android.widget.imageview; import android.widget.linearlayout; import android.widget.seekbar; public class desingtesting extends activity { framelayout albumframe; linearlayout extraview; linearlayout mainchield; boolean flag = true; layoutinflater inflater; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setvolumecontrolstream(audiomanager.stream_music); setcontentview(r.layout.ma...

haskell - Storable empty data declaration -

i'm attempting create haskell wrapper c library. underlying structs complicated express explicit types, , don't use them other passing between c functions, i'm using emptydatadecls let ghc work out me. what need pointer 1 of these data types, when attempt create 1 alloca complains data not of type storable . example: {-# language foreignfunctioninterface, emptydatadecls #-} module main import foreign.marshal.alloc import foreign.ptr data struct foreign import ccall "header.h get_struct" get_struct :: ptr struct -> io () main = alloca $ \ptr -> get_struct ptr ghc won't compile this, saying there's no instance storable struct . implement myself: instance storable struct sizeof _ = ... alignment _ = ... but comes close defeating purpose - don't want have define such things if don't care what's in struct. i've noticed pointer pointer works fine, because ptr class storable . can accomplish i'm aim...

java - JMS MQ binding problem -

i have strange issue jms binding on mq queue mdb the message-driven ejb: crbeventmessageasynchronousservice unable connect jms destination: queue.contratto.crb.input.publicqueue . error was: javax.jms.jmsexception : mqjms1017 : non-local mq queue not valid receiving or browsing> i checked on queuemanager , mq queue defined local , not remote said exception. it may top-most queue application opening reading defined locally. however, queue wmq resolving not. example, if define local alias on remote clustered queue, resolved queue non-local. possible cause queue intend open output being opened input well. quite common. finally, common wmq client connected different queue manager expected. example, connection qmgra , queue object specifies fully-qualified name queue@qmgrb. though queue lives on qmgrb , jndi object specifies queue manager name, connection on qmgra resolves transmit queue , therefore sees non-local. one of best ways nail kind of err...

android - Fastest way to seek (skip) an inputstream with http protocol -

i making download service of sorts, , has ability resume previous partial download. using skip method this long skipped = 0; while (skipped < track.getcachefile().length()){ skipped += is.skip(track.getcachefile().length()-skipped); } i did test , took 57 seconds seconds skip 45 mb in inputstream. curious how native code this, instance, mediaplayer can seek part of remote stream instantaneously. realize not have access same libraries, can achieve similar. btw, test on wifi. slower on normal data networks. update: simple (thanks below) if (track.getcachefile().length() > 0){ request.setheader("range","bytes="+track.getcachefile().length()+"-"); } if using http protocol initiate inputstream, may try range header. take here : http://www.west-wind.com/weblog/posts/244.aspx

Iphone stop an ASIFormDataRequest -

i have problem in viewcontroller when have pending asiformdatarequest (started asynchronous task) still executing , user presses button (in order pop view). is there way stop asynchronous task? i have read method called "cleardelegatesandcancel" don't know if i'm looking for. thanks thing is, call cleardelegatesandcancel , have have handle asifromdatarequest object that's running asynchronously. means should set property, like... @interface myviewcontroller : uiviewcontroller <asihttprequestdelegate> { asiformdatarequest *therequest ... } @property (nonatomic, retain) asiformdatarequest *therequest; then in .m, don't declare new request object, assign formdatarequest class's ivar: @synthesize therequest; -(void)viewdidload //or whatever { self.therequest = [asiformdatarequest requestwithurl:myurl]; // configure , fire request, being sure set .delegate self } -(void)viewwilldisappear:(bool)animated //or wha...

c# - System.Reflection.MethodInfo.Invoke and multiple threads ( with return type ) -

i have been looking through other questions on site , have found post. stack overflow original post ben voigts answer useful , believe have working in system. the issue have in cases need value returned method invocation. i going leave comment on post rep isnt high enough leave comments. hopefully either ben see post or else able extend answer include how return value. please let me know if there other information require. kind regards ash you have 2 options. either call methodinfo.invoke synchronously , wait result. or set callback method called once invocation complete. extending example linked to: public void invokeonnewthread(methodinfo mi, object target, action<object> callback, params object[] parameters) { threadstart threadmain = delegate () { var res = mi.invoke(target, parameters); if(callback != null) callback(res); }; new system.threading.thread(threadmain).start(); } ...

Inno Setup StringChangeEx Failure -

i'm using inno setup script install 32- , 64-bit dlls in 64-bit install. can 64-bit path registry setting, 32-bit path missing not exist. however, know path's 'tail' constant, head needs modified. ie, 64-bit (from registry) = c:\program files\my application\bin 32-bit (derived) = c:\program files (x86)\my application\bin so swap out 64-bit program file path 32-bit one. stringchangeex: regquerystringvalue(hklm, 'software\my application', 'rootdir', spath) if iswin64() stringchangeex(spath, expandconstant('{pf}'), expandconstant('{pf32}'), false); spath returned 32-bit path. works great on systems, seems stringchangeex not swap out 'c:\program files' 'c:\program files (x86)'. have verified (using msgbox's) {pf} , {pf32} constants think are. casing same , there no leading/trailing spaces. seems on systems, function doesn't work. i'm using latest version of innosetup (10/2010). web site doesn...

java - Why I cannot debug a DatabaseMetaData? -

i've strange situation little application in java using jdbc-obdc. i'm inspecting database using databasemetadata class. when execute program, works without anyproblem. when want debug see values inside resulset containing databasemetadata java.sql.sqlexception thrown if put breakpoint within while. here's code: databasemetadata patrol = con.getmetadata(); resultset answer = patrol.gettables(null, null, null, null); while(answer.next()) { if (answer.wasnull() == false) { tablenamesasone = tablenamesasone + answer.getstring("table_name") + " "; } } answer.close(); why cannot put breakpoint in section of code?? this printstacktrace. exception in thread "main" java.sql.sqlexception: no data found @ sun.jdbc.odbc.jdbcodbc.standarderror(unknown source) @ sun.jdbc.odbc.jdbcodbc.sqlgetdatastring(unknown source) @ sun.jdbc.odbc.jdbcodbcresultset.getdatastring(unknow...

debugging - How to use strace to only show calls that take a lot of time? -

is there way grep calls on amount of time? it looks there flag shows cpu time in output ( -c ): man strace sample output: sysadm@brownie:~$ strace -c ./crypt_crack.py % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 84.38 0.000027 0 340 273 open 15.63 0.000005 0 67 rt_sigaction 0.00 0.000000 0 91 read 0.00 0.000000 0 67 close 0.00 0.000000 0 117 89 stat 0.00 0.000000 0 96 fstat 0.00 0.000000 0 1 lstat 0.00 0.000000 0 3 lseek 0.00 0.000000 0 64 mmap 0.00 0.000000 0 17 mprotect 0.00 0.000000 0 30 munmap 0.00 0.000000 0 8 br...

primefaces - problem with primerfaces gmap tag -

i tried use simple gmap example start developt webapp, doesn´t work me. i used example prime movie-collector found on web page. included code <p:gmap center="41.381542, 2.122893" zoom="15" type="hybrid" style="width:600px;height:400px" /> in template.html file. i got error: javax.servlet.servletexception: /template.xhtml @39,39 <p:gmap> tag library supports namespace: http://primefaces.prime.com.tr/ui, no tag defined name: gmap javax.faces.webapp.facesservlet.service(facesservlet.java:325) i think haven´t wrong libraries. another day, tried create own example using simple map, obtained same output. thanks! download latest primefaces jar. http://www.primefaces.org/downloads.html the following must in head section: <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" ></script> <p:gmap> must inside <f:view contenttype=...

iphone - XML Parsing Without using any delegate methods of nsxmlparser class -

i don't want use nsxmlparser delegate methods. want write own methods xml parsing. how can parse xml file? i don't understand point of not using delegate. well, have 2 options: use parser use nsstring methods separate xml on tokens , parse them.

c# - Problems with drag'n'drop from IE -

my question simple , don't know whether missing or not allowed. trying accept content has been selected in ie , dragged onto app. events fire should, , starting analyze content have received , fun begins. when ask e.data.getformats() in string array, can see text, html format , rich text format amongst other types. but when try e.data.getdatapresent("text") returns false. funny enough, when try e.data.getdata("text") null too. (was expected though) my question is, should using different handle dragged content ie? or can't access data because internet zone? i forgot add later edit: - .net 2.0 windows app , not asp.net nor website :) thank you use javascript handling such tasks, compatible standard browsers. you may want program own jquery plugin drag , drop here 1 dragging table rows

java - Servlet 3.0 async Timeouts -

is possible extend timeout of servlet 3.0 async servlet. tried in timeout method still completed async request. what best way of extending timeout such async servlet never completes tx its time haven't got reply. here breaking silence :p asynccontext cntx = request.startasync(request, response); long timeout = default_time_out; if( req.getparametermap().containskey( time_out ) ){ try { timeout = long.parselong( req.getparameter( time_out ) ); } catch (numberformatexception e) { e.printstacktrace(); } } cntx.settimeout( timeout );

apache - How do I enable mbstring extension on PHP 5, Fedora server -

i need add mbstring extension install of php 5.2.6 on apache/2.2.11 (fedora). have dynamic extensions enabled think need .so file , .ini files, correct? can drop these files in , make work or have recompile php? if it's upload , go, can files need? try yum install php-mbstring . may need restart apache, e.g. /sbin/service httpd restart . you can use yum info "php-*" find list of other php packages available.

ftp - Managed File Portal -

we portal can put file assets , control access them (or sets of them) on per customer login basis. open source/free self host ideal. any suggestions appreciated! take @ alfresco (share). there's community edition well.

python - Does pip handle extras_requires from setuptools/distribute based sources? -

i have package "a" setup.py , extras_requires line like: extras_require = { 'ssh': ['paramiko'], }, and package "b" depends on util: install_requires = ['a[ssh]'] if run python setup.py install on package b, uses setuptools.command.easy_install under hood, extras_requires correctly resolved, , paramiko installed. however, if run pip /path/to/b or pip hxxp://.../b-version.tar.gz , package installed, paramiko not. because pip "installs source", i'm not quite sure why isn't working. should invoking setup.py of b, resolving & installing dependencies of both b , a. is possible pip? this suppported since pip 1.1, released in february 2012 (one year after question asked).

maven 2 - Hudson build fails with Fatal Error (java.lang.ClassNotFoundException: hudson.util.RemotingDiagnostics$HeapDump ) -

hopefully, can point out maybe issue causing fatal error receive when doing maven build using hudson. i installed instance of hudson in tomcat on windows xp box in test environment. rather novice @ hudson. trying simple maven 'clean' on small java project know builds fine on instance of hudson on server. the stack trace hudson console below: thank you [error] fatal error [info] ------------------------------------------------------------------------ [info] null hudson.util.remotingdiagnostics$heapdump [info] ------------------------------------------------------------------------ [info] trace java.lang.reflect.undeclaredthrowableexception @ $proxy2.end(unknown source) @ hudson.maven.mavenbuildproxy2$filter.end(mavenbuildproxy2.java:67) @ hudson.maven.mavenmodulesetbuild$builder.postmodule(mavenmodulesetbuild.java:922) @ hudson.maven.mavenbuilder$adapter.fireleavemodule(mavenbuilder.java:353) @ hudson.maven.mavenbuilder$adapter.postbuild(maven...

c# - Traversing Expression tree -

is there possibility traverse expression instance in .net? i mean: have expression/expresstion> instance generated in external code. there possibility see in there ? yes. the easiest option inherit expressionvisitor class . .net 3.5 version available.

c# - dial a number in Cisco IP Communicator with .NET -

we working on custom crm , need provide functionality allow make calls our clients through .net application. our company have cisco ip communicator telephone service contact center. anybody have sample o tutorial dial number in cisco ip communicator through (c#).net application? finally did soap service webdialer provided cisco call manager https://ip:port/webdialer/services/webdialersoapservice?wsdl

Reading single character from console in java -

how read single character console in java...?? can done without bufferedreader..? using: int byte = system.in.read(); char singlechar = (char)byte; should read single byte console.

.htaccess - Can I redirect a subdomain to a particular webpage and process the subdomain value with PHP -

i familiar modifying htaccess files not sure if following possible: ultimately, want point users 'imaginary' subdomains (those not exist) subdomain can parsed correctly php , mysql find particular member's information. for example: when goes www.site.com currently, shows parent site including information on how become member. once person member, 'unique' url is: www.site.com?memberid=12345 ultimately, forcing member remember question mark agent equals can confusing along need remember proper capitalization , such. i 'like' achieve following: www.12345.site.com redirects www.site.com/index.php (and index.php reads 12345 $_get function lookup id, valid , retun response based on that. i realize achieve same using information after hash: e.g. www.site.com/12345 but issue have other pages using /xxxx modify client content don't want block anybody's ability visit: www.site.com/contact example (where site redirects index, tries...

Mercurial - use hg log to view all ancestors -

given changesets a --b ----c ------d --------e how can listing of changesets come before d. ie: how can use hg log return a-b-c? you can hg log -r :d (but display d).

multithreading - Java threaded Random.nextLong() returning the same number -

i'm using oauth library calls new random().nextlong() generate nonces, generates same nonce on asynchronous calls. i've narrowed down threading random.nextlong() returning same exact number every often. does know if known limitation of java? if so, know of thread safe operation? edit: i'm using java 1.6 edit: small program made test out going on in larger app. ran several times , more should, coming same random number when time same. please excuse quick programming. public class threadedrandom { /** * @param args */ public static void main(string[] args) { // todo auto-generated method stub new threadedrandom().run(); } private randomnumbergenerator _generator; public threadedrandom() { _generator = new randomnumbergenerator(); } public void run() { runnable r = new runnable() { @override public void run() { system.out.println(system.currenttimemillis()+"\t"+_generator.gen()); } }; thread t1, ...

python subprocess calling bash script - need to print the quotes out too -

i'm having problem subprocess , printing quotes. my python script takes user input, mashes around bit - , need send it's results bash script in manner. myscript.sh 'var1 == var2 == b; othervar == c' /path/to/other/files where i'm getting hung on single quotes. python tries rip them out. i used test. subprocess.popen([myscript.sh 'var=11; ignore all' /path/to/files], shell=true, executable="/bin/bash") which returns invalid syntax pointing @ 2nd single quote. i've tried above without brackets , using single quotes outside , double quotes inside, etc. other - would-like. as saying above 'var == var == b; othervar == c' derived python script (in string format) - , i'll need call in subprocess this. subprocess.popen([myscript.sh myvariables /path/to/files], shell=true, executable="/bin/bash") i have put single quotes around value of myvariables first example. any pointers i'm going off correct...

razor - Is it possible to display raw Html from database in ASP.NET MVC 3? -

i have table in db 1 of properties html page (without html, head , body tags), , intend put in middle of 1 of views - say, call cotroller method takes argument, , return view passing html big string model. searched (not much, admit), , found following method: <%= system.web.httputility.htmldecode(yourencodedhtmlfromyoudatabase) %> that found here in stackoverflow. when tried similar razor aproach, ended this: @system.web.httputility.htmldecode("<h1>test</h1>") that's idea, didn't work quite planned. all need is: @html.raw(yourencodedhtmlfromyoudatabase) i'm assuming html in database has been sanitized (or @ least reliable source), because if not, opening cross-site scripting attacks. the reason approach didn't work razor html-encodes output default (every time use @ display something). html.raw tells razor trust html , want display without encoding (as it's raw html).

php - Including into a variable -

you know how print_r accepts optional 2nd parameter if set true return result instead of printing it? i wish include accepted 2nd parameter work same way. it doesn't available alternatives? how can include file variable? ob_start() , ob_get_clean() you: ob_start(); include "file.php"; $result = ob_get_clean(); after ob_start() echoed captured, , ob_get_clean() used retrieve captured data. you can include2 function this: function include2($file) { ob_start(); include $file; return ob_get_clean(); } and use this: include2("file.php"); // return printed values instead of printing them as noted @ircmaxell, include2 function not behave same include since scope of include changes (from global function's scope). potentially break things if rely on global scope.

objective c - Changing UITableCellView appearance before it is highlighted (from UITableView) -

i may have taken million wrong turns question, i'm happy revise if can spot went wrong. i trying build tableview looks same contacts app. first issue entry have both bolded , unbolded string in given row "john appleseed " or "martin luther king ". figured need have 2 uilabels within uitableviewcell (possible first mistake). all want add second uilabel instead of subclassing add uilabel in uitableviewcell (possible next mistake). however when row highlighted (but not yet selected) default uilabel text switches white, ad-hoc uilabel remains black. can force uilabel text change white in uitableviewdelegate methods occur after highlighting. cause noticeable flash of white -> black. now see uitableviewcell method 'sethighlighted:animated:' override if subclassed, hoping way approach it. thoughts? i think you're going find difficult keep last name proportionally spaced other portion of name in separate view, given views may resize...

diff - How do I get a list of changed files in svn? -

i want list of files different between working directory , repository. summary seems report differences between repositories. run svn status . distinguish between modified, deleted, added, etc. svn status has bunch of information you.

java - Scanner without delimiter -

i able parse strings following: "123456abcd9876az45678". bnf this: number: ? definition of int ? word: letter { , letter } expression: number { , word , number } however class java.util.scanner doesn't allow me following: scanner s = new scanner("-123456abcd9876az45678"); system.out.println(s.nextint()); while (s.hasnext("[a-z]+")) { system.out.println(s.next("[a-z]+")); system.out.println(s.nextint()); } ideally, should yield: -123456 abcd 987 az 45678 i hoping java.util.scanner me, looks have create own scanner. there present in java api me? the question miss information. , therefore answers valid question not problem. unfortunately cannot use no delimiters scanner class afaik. if wish ignore delimiters, you'd need use methods such findinline() or findwithinhorizon() . in case, findwithinhorizion() appropriate. scanner s = new scanner("-123456abcd9876az45678"); pattern num = pattern.c...

jquery - JSONP call works local but not on server -

i'm trying data remote server using jquery , perform jsonp ajax call. problem whenever use local server response gets evaluated, when use remote server it's not. response in form jsonp12345678[{"key":"value"}] hence, using [ instead of ( json. unfortunately don't have access remote server change that. here's javascript call. $.ajax({ datatype: 'jsonp', jsonp: 'jsonp_callback', url: 'url', error: function(status) { console.log(status); }, success: function (html) { $("#content").text(html.reply); }, }); if remote server doesn't support jsonp, not able jsonp queries it. server has explicitly call jsonp callback.

xml - Extremely slow XSLT transformation in Java -

i try transform xml document using xslt. input have www.wordpress.org xhtml source code, , xslt dummy example retrieving site's title (actually nothing - doesn't change anything). every single api or library use, transformation takes 2 minutes! if take @ wordpress.org source, notice 183 lines of code. googled due dom tree building. no matter how simple xslt is, 2 minutes - confirms idea it's related dom building, anyway should not take 2 minutes in opinion. here example code (nothing special): transformerfactory tfactory = transformerfactory.newinstance(); transformer transformer = null; try { transformer = tfactory.newtransformer( new streamsource("/home/pd/xslt/transf.xslt")); } catch (transformerconfigurationexception e) { e.printstacktrace(); } bytearrayoutputstream outputstream = new bytearrayoutputstream(); system.out.println("start"); try { transformer.transform(new saxsource(new...

How can I get a character in Python similar to Pascal readkey -

in pascal can execute code character keyboard input: uses crt; var ch: char; begin ch := '.'; while ch <> '\' begin ch := readkey; writeln( ch ); end; end; is there similar 1 in python? :) import sys def prog(): char = "" while char != "/": char = sys.stdin.read(1) print char prog()

Best way to fill in gaps within multidimensional array in Ruby -

i have multi-dimensional array similar example below want group using ruby's zip method. have working fine when each inner array has same number of elements, running problems when different lengths. in example below, second set missing record @ 00:15. how fill in missing record? what considering gap? it's timestamp constitutes gap. take @ first code sample have comment gap being @ 00:15. other arrays have hash timestamp, consider "missing record" or "gap". timestamp other unique string fact 15 minutes apart irrelevant. values irrelevant. the approach comes mind involves looping on arrays twice. first time build array of uniq timestamps, , second time fill in missing record(s) timestamp not present. i'm comfortable coding approach, seems little hacky , ruby seems surprise me elegant , concise solution. i start this: values = [ [ {:timestamp => "2011-01-01 00:00", :value => 1}, {:timestamp...

javascript - jQuery .data() to store id for later access? or other method? -

i trying append div body, $('<div>').appendto(document.body); however instead of giving div id attribute association can access later, use jquery.data() access div later actions can applied it. $('<div>').data('#myid').appendto(document.body); now how access later. var later = $('<div>').appendto(document.body); // ... later.actions();

c++ - Validating against multiple xml schemas with Xerces DOM parser -

i wondering if there way validate against multiple xml schemes using xerces dom parser in c++? here use-case: want able parse multiple xml files against corresponding xsd schema. however, when @ each xml file, not know file until parse it, hence cannot link static xsd file it. there way of saying, want validate each xml file against xsd1 or xsd2 or etc... after reading around appears settings of parser 'setexternalschemalocation' able hold list of schemes when in code, doesn't validate correctly. parser->setexternalschemalocation("http://www.somelocation schema.xsd http://www.somelocation schema1.xsd"); the schema works if did parser->setexternalschemalocation("http://www.somelocation schema.xsd"); so there no error in xml or xsd file. any insights how validate against multiple xml schemas? the code not work if each xml in same namespace. each xml file must in different namespace in order code above work. parser->set...

omnicomplete - Vim omni completion: continue typing to select desired item -

consider scenerio when have typed: file.f when type ctrl-x ctrl-o omni-completion popup shown , first item selected. see: file.fileno --------- fileno() <-- highlighted flush() --------- notice text have typed ("file.f") has changed to: file.fileno i can move selection down in list 'flush', press enter , end f.flush() but continue typing desired method name instead of using arrow keys. i.e. type "file.f", "ctrl-x ctrl-o", "l" , either file.fileno --------- flush() --------- or file.fileno --------- fileno() flush() <-- highlighted --------- is possible? maybe omni-completion settings have changed, or should use different keys combination instead of ctrl-x ctrl-o ? add: set completeopt+=longest .vimrc file. this tell omnicomplete insert longest common text of matches. for more information, run command :help comple...

c# - Using LINQ to parse XML into Dictionary -

i have configuration file such as: <configurationfile> <config name="some.configuration.setting" value="some.configuration.value"/> <config name="some.configuration.setting2" value="some.configuration.value2"/> ... </configurationfile> i trying read xml , convert dictionary. tried coding liek wrong not compile. dictionary<string, string> configdictionary = (from configdatum in xmldocument.descendants("config") select new { name = configdatum.attribute("name").value, value = configdatum.attribute("value").value, }).todictionary<string, string>(something shoudl go here...?); if tell me how working helpful. always, of co...

.net - Reading binary files -

although suspect know answer, interested in people's responses. currently, have vc6 app running on w2k3 reads text file using following(simplified code): string line; ifstream infile("test.txt",ios::in); while (!infile.eof()) { getline(infile,line); } ... each record in file has fields pipe delimited , code works fine crlf, although fields , records not fixed length. issue file going binary due data being unsigned packed decimal in addition text. basically, code above still valid if opened binary file(delimiters , lf retained)? tried quick test dummy data , appeared behave same. it understanding binary files read w/the knowledge of data content bytes can retrieved , w/o lf's. i've searched around web , found various options c++ , other .net languages(an option), none seem capable of reading 1 line @ time -- if variable sized data , lf seem defeat purpose of using binary file -- , not want read entire file in 1 shot since quite large(hoping not r...