Posts

Showing posts from September, 2011

javascript - Determining what jQuery .ajax() resolves a string of redirects to -

i'm aware redirects followed automatically, , have little/no control on process. fine, i'm still interested in request ends up. possible see url request ends at? i not want rely on returned html tell me am. sample code: var originalurl = '/this/will/be/redirected'; $.ajax({ url: originalurl, datatype: "html", success: function(data, statustext, jqxhr) { var endpointurl = insertmagichere(); alert("our query " + original + " ended @ " + endpointurl + "!"); } }); i'm looking around in jqxhr it, no luck far. (though, i'm new this, right under nose) so far know (and have testet) possible detect if there has been redirect , how many redirects made (but not where). you can have code: var xhr = $.ajax({ url: originalurl, datatype: "html", success: function(data, statustext, jqxhr) { console.log(data); console.log(statustext); console.log(jqxhr.

android - generate main.xml inside onCreate() -

is possible generate main.xml inside oncreate()? such as: package avm.project; import java.io.bufferedwriter; import java.io.file; import java.io.filewriter; import java.lang.reflect.field; import android.app.activity; import android.content.res.resources; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.viewflipper; public class avmordersystemactivity extends activity { viewflipper flipper; @override public void oncreate(bundle icicle) { super.oncreate(icicle); //file[] listoffiles = folder.listfiles(); /*for (int = 0; < listoffiles.length; i++) { if (listoffiles[i].isfile()) { log.i("xml generator","file " + listoffiles[i].getname()); } else if (listoffiles[i].isdirectory()) { log.i("xml generator","directory " + listoffiles[i].getname());

Unexpected end of Pattern : Python Regex -

when use following python regex perform functionality described below, error unexpected end of pattern. regex: modified=re.sub(r'^(?i)((?:(?!http://)(?!testing[0-9])(?!example[0-9]).)*?)(?-i) (code[0-9]{3})(?!</a>)',r'<a href="http://productcode/\g<1>">\g<1></a>',input) purpose of regex: input: code876 code223 matchjustcode657 code69743 code876 testing1code888 example2code098 http://replaced/code665 should match: code876 code223 code657 code697 and replace occurrences with http://productcode/code876 http://productcode/code223 matchjusthttp://productcode/code657 http://productcode/code69743 should not match: code876 testing1code888 testing2code776 example3code654 example2code098 http://replaced/code665 final output http://productcode/code876 http://productcode/code223 matchjusthttp://productcode/code657 http://productcode/code69743 code876 testing1code888 example2code098 http://replaced/code665 edit

seam - JSF: Button/Link without form submit -

in earlier projects used s:button or s:link seam 2 when caceling something, because wouldn't submit form , no model updates occured. now switched weld + seam 3 , couldn't find there anymore - blind or have use else? geziefer you can in plain jsf 2.0 setting immediate attribute true in h:commandbutton . from myfaces wiki: the immediate attribute can used achieve following effects: allow commandlink or commandbutton navigate user page without processing data in input fields of current screen. in particular, allows navigation occur when there validation errors. "cancel" button typically falls category. allow commandlink or commandbutton trigger back-end logic while ignoring validation of fields on screen. more general version of item above. make 1 or more input components "high priority" validation, if of these invalid validation not performed "low-priority" input components in same page. can

android - Problem finding/reading a file -

i'm trying develop small application, given json file, , have extract data it. understood json object takes string argument, i'm trying access file , write data string. i've placed file in "json file" folder, , when try read file, throws me file not found exception. i've tried several ways find path file, every attempt vain. might i'm extracting path wrong, or might else, please me. in advance. here code of finding path: try { path = environment.getrootdirectory().getcanonicalpath(); } catch (ioexception e) { e.printstacktrace(); //to change body of catch statement use file | settings | file templates. } file jfile = new file(path + /"json file/gallery.json"); here code reading file : string str =""; try { bufferedreader in = new bufferedreader(new filereader(jfile));

silverlight - When does a PhoneApplicationPage get disposed? -

for example, if have page this: public partial class page1 : phoneapplicationpage { dispatchertimer timer = new dispatchertimer(); public page1() { initializecomponent(); timer.interval = timespan.fromseconds(5); timer.tick += new eventhandler(timer_tick); timer.start(); } void timer_tick(object sender, eventargs e) { messagebox.show("timer tick"); } } in app, navigate page, pop message box every 5 seconds. press "back" button on phone , navigate previous page. weird thing still pops message box every 5 seconds. know can stop timer in onnavigatedfrom method, why happening? isn't page disposed after press button on it? thanks it disposed gc when nothing keeping awake. dispatchertimer keeps awake, though created page. guess in past has been dispatchertimer being referenced dispatcher itself, , can't clean up, or along lines. to demonstrate add finalize method #if de

java - Non-blocking write to a socket in Android -

i have android app has socket open. write socket without possibility of blocking thread on write noticeable amount of time. if io error occurs, write silently fail. there easy way this? yes, nio provides socketchannel class (call getchannel method on socket ), allows call configureblocking use non-blocking mode. should i/o through channel, , not through socket object.

Desaturate Images with Javascript/jQuery/CSS IN CHROME -

i can't seem find way render grayscale images colored images in chrome css or javascript. have feeling canvas solution won't work in chrome , looking another. any appreciated, i've tried pixastic , bunch of other jquery solutions, no avail. i wanted similar thing week or 2 ago , found example: http://webdesignerwall.com/tutorials/html5-grayscale-image-hover it works rendering image canvas, grayscaling , getting base64 representation. it's not ie, since specified chrome, should go. just sake of completeness, grayscaling image in ie can done the filter: gray; css option

version control - Can you undo 'git reset --hard HEAD' if never having made a commit? -

i lost code after running git reset --hard head and never committed work. there way code back? logged anywhere? can undo command? nope, git reset --hard , git checkout -f both destructive of changes haven't been committed.

Updating TimeZone from an application on windows mobile 6.1 -

i trying update timezone of windows mobile device application using opennetcf.windowsce.settimezoneinformation call. sets timezone standard timezone(ignores day light timezone) when there timezones same offset. clear, trying set timezone gmt-5 eastern (new-york zone, observes day light) gmt-7 arizona (mountain standard) , reason, sets new time zone gmt-5 indiana (which doesn't observe day light settings). to confirm if setting correctly, after setting timezone, did gettimezoneinformation see if timezone set earlier matching , does. so, dont know how setting getting messed internally. i don't find documentation setting timezone or adjusting local times/system times application on windows mobile 6.1 will have muck around registry settings working? i appreciate on this. thanks, after doing lot of research on internet, found blog posted similar issue. , issue seems in opennetcf. when populating tzdata structure each timezone, ignored standarddate(when daylig

str replace - strip all unnecessary spaces in a php string -

i want strip spaces not between 2 letters : $string = " bah bah bah bah "; $string = str_replace("/w /w", "+", $string); // goes here? this: $string = "bah+bah+bah+bah"; the idea want rid of unnecessary spaces(not @ beginning , end). not link search box on submit exploded + can = or basically $string = preg_replace('/\s+/', ' ', $string);

apache coccoon - Problem deploying Cocoon within Tomcat -

i trying deploy cocoon (2.1.11) in tomcat (7.0.12) (i know can run cocoon standalone , have done successfully, trying better understand whole web application environment) have built cocoon.war file, copied tomcat/webapps directory , started tomcat. all web pages have consulted explicitly required. can see .war file unpacked cocoon subdirectory, , cocoon shows 1 of applications. when browse url: http://localhost:8080/cocoon i java traceback: org.apache.cocoon.resourcenotfoundexception: no pipeline matched request: index.html @ org.apache.cocoon.components.treeprocessor.sitemap.pipelinenode.invoke(pipelinenode.java:149) @ org.apache.cocoon.components.treeprocessor.abstractparentprocessingnode.invokenodes(abstractparentprocessingnode.java:69) @ org.apache.cocoon.components.treeprocessor.sitemap.pipelinesnode.invoke(pipelinesnode.java:93) @ org.apache.cocoon.components.treeprocessor.concretetreeprocessor.process(concretetreeprocessor.java:235) @ org.apache.c

When debugging HTML is there a way to listen for div width change using javascript or jquery? -

when debugging html there way listen div width change using javascript or jquery? have div changing size due css , can't figure out where, stepping through. wondering if there way hook event div see causing change? if possible, i'm not sure how how pass stack information caused size change in first place, may not possible. this bad way, i'm not sure such event exists. $(function(){ var last = $("#your_div").width(); setinterval(function(){ if (last != $("#your_div").width()){ alert('div width changed'); } }, 100); });

javascript - Using OAuth with gmail's atom feed -

i attempting use oauth access gmail's atom feed in javascript in browser (yes, know security risks of building in-browser oauth app; it's personal use, , i'm not worried me stealing own consumer key). however, accessing atom feed giving me wrong user. i'm calling: oa.ajax().get("https://mail.google.com/mail/feed/atom?xoauth_requestor_id=user@domain.com", callback); where oa.ajax.get wraps proper oauth information (it works; can use access other google services). i've tried calling without xoauth_requestor_id parameter. expected result : authed user's feed actual result : atom feed of default gmail user anyone know why might happening? thanks. you need pass authentication tokens, etc. using authorization header , , i'm not sure that's possible or not using ajax. because you're logged gmail, identity being used retrieve feed , thats why see own feed , not of auth'ed user.

Pass an arbitrary number of parameters into a JavaScript function -

my javascript code barely ajax request expects xml returned back-end. back-end can return execute_callback 1 of xml tags this: <?xml version="1.0" encoding="windows-1251"?> <response> <execute_callback> <function_name>somefunction</function_name> </execute_callback> </response> and okay far know exact number of parameters callback expects. if back-end has returned <?xml version="1.0" encoding="windows-1251"?> <response> <execute_callback> <function_name>somefunction</function_name> <param>10.2</param> <param>some_text</param> </execute_callback> <execute_callback> <function_name>otherfunction</function_name> <param>{ x: 1, y: 2 }</param> </execute_callback> </response> how pass parameters 10.2 , 'some_text' somef

osx - Mac OS X Lion no longer recognizes environment.plist? -

just installed lion today , path env variable no longer being set ~/.macosx/environment.plist. did change? can't seem find info on or how fix. ideas? here's contents of plist: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>path</key> <string>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/x11/bin:/users/mdi/bin</string> </dict> </plist> use ~/.launchd.conf instead (see man launchctl ). see this answer details.

Building unit tests for asp.net mvc2 async controller actions that return data -

i've had around , can't seem specific answer above question. example, thread: building unit tests mvc2 asynccontrollers talks waiting async actions finish, great, need able retrieve data returned completed method. cheers, andrew. one way make event handler: controller.asyncmanager.finished += (sender, ev) => { var result = controller.transactioncompleted(); trigger.set(); }

xmpp - Integrating Google Talk to web app using strophe.js and punjab -

i'm trying integrate google talk (a.k.a. gtalk) web app. it's going tight integration, google talk chatback badge, , embedding google's flash based web client using iframe won't job. i'll need build client scratch if there not html based client available on web. after doing research, think solution use strophe.js front-end , punjab middleware communicate google talk server. sound right? there blog post or tutorial covers topic? for front-end, strophe.js able pull contact list; as, online status of contacts? i'm trying understand big picture first before digging further. right now, punjab complete black box me. appears there not setting once installed , running. any comments? i first make understand question. think can understand question in 2 ways, give 2 different answers. if want have same functionality google talk chatback badge visitor of website can chat gtalk account(jid) think should have @ section b) i think link strophe.js a

regex - Pseudo English to Regexp -

is there translator pseudo english regexp? is, sort of scripting language ouput regexp? thank you. tuba your best bet txt2re or similar tool.

javascript - Disable an input field if second input field is filled -

totally newbie... want know how dynamically disable input field when second input field filled eg: <td><input type="text" name="num-input1" id="dis_rm" value=""></input></td> <td><input type="text" name="num-input2" id="dis_per" value="" ></input></td> pls... links , hints do... you need give disabled property: document.getelementbyid("dis_rm").disabled = true; document.getelementbyid("dis_per").disabled = true; you can use on change event see if 1 of them filled: var dis1 = document.getelementbyid("dis_rm"); dis1.onchange = function () { if (this.value != "" || this.value.length > 0) { document.getelementbyid("dis_per").disabled = true; } } so if first 1 filled, second 1 disabled

testing - Test if a string is a Java variable identifier: (a-z,A-Z,_,$) followed by (a-z,A-Z,0-9,_,$) -

i need determine if string variable identifier. i.e. (a-z,a-z, ,$) followed (a-z,a-z,0-9, ,$) i know can manually configured reg exp, there must more compact, built in function can use. any solutions? you can use methods character.isjavaidentifierstart() , character.isjavaidentifierpart() don't think solution more compact. edit: decided search , found in codemodel: http://codemodel.java.net/nonav/apidocs/com/sun/codemodel/jjavaname.html

How to convert formatted text to XML in C++ -

i have read text file in, , need convert received input xml data. e.g.: reading text file yields: english 100 science 80 computers 77 now need output as: <head> <english>100</english> <science>80</science> <computers>77</computers> </head> how can achieve this? what can is, after reading text file append < , > subject. if fout output std::filestream , subject std::string , , score int or unsigned : fout << "<head>" << std::endl; while (/* file not finished */) { // read string , int file subject.insert(0,"<"); subject.insert(subject.size(),">"); fout << subject << score; subject.insert(1,"/"); fout << subject<< std::endl; } fout << "</head>" << std::endl;

jquery - How to initialise view again after changin the html -

i have view in backbone.js app.backbone.userview = backbone.view.extend({ tagname: 'li', classname: 'pp-entry group', template :_.template('<img src="i/pp-pic-8.png" class="pp-pic" alt="" /><a class="pp-pic-wrap show-fb" href="#pp-details-<%=username%>"></a>), templatedetails:_.template('`<div style="display:none"><div id="pp-details-<%=username%>" class="pp-details"><div class="cta clear"><input type="button" name="" value="add wallet" class="mar-right-10 addtowallet" /><input type="button" class="mar-right-10 addtogib" name="" value="add gib link" /><input type="button" name="" value="close" onclick="$.fancybox.close()" /></div></div><.d

c# - Simple Delegate (delegate) vs. Multicast delegates -

i have gone through many articles still not clear difference between normal delegates create , multicast delegates. public delegate void mymethodhandler(object sender); mymethodhandler handler = new mymethodhandler(method1); handler += method2; handler(someobject); the above delegate mymethodhandler call these 2 methods. multicast delegates come in. have read can call multiple methods afraid basic understanding delegates not correct. this article explains pretty well: delegate void del(string s); class testclass { static void hello(string s) { system.console.writeline(" hello, {0}!", s); } static void goodbye(string s) { system.console.writeline(" goodbye, {0}!", s); } static void main() { del a, b, c, d; // create delegate object references // method hello: = hello; // create delegate object b references // method goodbye: b = goodbye

javascript - jwplayer not recognized in a drupal page -

Image
i've inserted jwplayer in 1 of drupal website node can't use javascript api. work examples from here , , tried embed , setup javascript well. here sequence of module's hook_nodeapi : case 'view': // irrelevant code $node->content['body'] = array ( '#value' => "<div id='player'>loading player ...</div>", '#weight' => 9, ); drupal_add_js('sites/all/libraries/mediaplayer-5.7/jwplayer.js', 'file'); drupal_add_js('sites/all/libraries/mediaplayer-5.7/swfobject.js', 'file'); drupal_add_js("jwplayer('player').setup({ flashplayer: 'http://localhost:8088/sites/all/libraries/mediaplayer-5.7/player.swf', file: 'http://localhost:8088/" . $node->field_video[0]['filepath'] . "', height: 270, width: 480 });", 'inline'); break; the 2 javascript files appended drupal page's htm

Execution order of cruisecontrol.net blocks -

couldn't find documentation this: order of execution of different blocks of cruisecontrol.net config file (e.g. sourcecontrol , prebuild , tasks )? specifically i'd know whether sourcecontrol executed before or after prebuild block. i guess this page has answer: the <tasks> section run before <publishers> section, regardless of order in appear. however, within each of these sections, tasks run in order appear. the <prebuild> section intended tasks need run before build starts, including sourcecontrol operation. so order is: prebuild sourcecontrol tasks (in order in appear in config file) publishers (in order in appear in config file)

iphone - iOS UI - how to tell user that there are no data in table view? -

this situation: a user filters database selecting keywords list, presses "search". pushes instance of uitableviewcontroller subclass onto navigation stack. in viewwillappear: method, data fetched core data , stored in ivar, ready table view's data source , delegate methods. so far good. the ui problem arises when there no results. this simple architecture means empty result set yields empty table view no explanations. it ui tell user "your search gave no results, please try fewer keywords". my question this: what best way provide relevant feedback user, without having change architecture much? i thinking using table header, esteemed colleagues here think? using table header not bad option. can go that. can try other options showing info in simple label or perhaps alert. wouldnt recommend alert.

android - NFC on Nexus S: "TagLostException" when writing to unknown block on ISO 15693 Chip -

i wondering if out there has stumbled across issue experiencing. i writing app talk specific iso 15693 rfid chip using nexus s nfc capabilities. communication between phone , chip works fine, of time. reading , writing blocks working using transcieve() send raw byte-arrays. my chip has 8 blocks, each 4 bytes big. when trying write block other 0 - 7, android throws taglostexception: 07-21 14:07:39.390: warn/system.err(5770): android.nfc.taglostexception: tag lost. 07-21 14:07:39.394: warn/system.err(5770): @ android.nfc.tech.basictagtechnology.transceive(basictagtechnology.java:141) 07-21 14:07:39.398: warn/system.err(5770): @ android.nfc.tech.nfcv.transceive(nfcv.java:92) 07-21 14:07:39.398: warn/system.err(5770): @ de.myapp.foregrounddispatchnfcv.sendrawcommand(foregrounddispatchnfcv.java:246) 07-21 14:07:39.402: warn/system.err(5770): @ de.myapp.foregrounddispatchnfcv$3.onclick(foregrounddispatchnfcv.java:135) 07-21 14:07:39.406: warn/system.err(5770):

crash - IE9/IE10 chrashes when hiding tablerow with different cell borders -

i discovered bug in ie9 , ie10 platform preview. code contains simple table little style, cells in first column have different borders. if hide last row simple javascript, ie crashes. sample: http://jsfiddle.net/zt6wm/2/ someone idea workaround?

c# - How to retrieve group-policy settings programatically? -

microsoft deliveres nice com enabled dll named gpmgmtlib ( gpmc api ) manage gpos in active directory. library exports interface called igpmgpo , represents gpo , can sorts of stuff, settings permissions, exporting , importing. sadly, if understood reference on msdn correctly, interfaces provide no way retrive settings set gpo programatically, little uncertian if gpmgtmt way go. here goes question: how can access (read-only sufficient) policy settings of specific gpo in domain programatically? solutions using c# or .net language preferred. annotation: i need automatically compare gpos of 2 domains in forest, different. tried exporting gpo xml report , using diff-tool, way time consuming, since there ten domains in forest going have compared during next months multiple times. do know product call advanced group policy management (agpm) distributed in microsoft desktop optimisation pack (mdop) exists, , includes capavility of managing , comparing gpos. yo

android - Why is NPE thrown when finishing Activity? -

i have error has been driving me crazy days. unfortunately, can not show code 2 reason, boss not appreciate , codebase large share. error occurs whenever activity finishing. weather because call finish() or because os destroys it. the question is, (or could) cause execpendingactions() in fragmentmanagerimpl throw npe @ line 1196. here stacktrace: fragmentmanagerimpl.execpendingactions() line: 1196 fragmentmanagerimpl$1.run() line: 375 handler.handlecallback(message) line: 587 handler.dispatchmessage(message) line: 92 looper.loop() line: 126 activitythread.main(string[]) line: 3997 method.invokenative(object, object[], class, class[], class, int, boolean) line: not available [native method] method.invoke(object, object...) line: 491 zygoteinit$methodandargscaller.run() line: 841 zygoteinit.main(string[]) line: 599 nativestart.main(string[]) line: not available [native method] you try using compat library , debugging that. alternatively try

ant - Concatenate from .properties into an output file -

i tried concatenate file name , version number. the version local.properties sdk.dir=e:/android/android-sdk-windows sdk.version=1.6 my ant file build_factory.xml <?xml version="1.0" encoding="iso-8859-1"?> <project name="main release build" default="release" basedir=".."> <target name="configfactory"> <echo message="sdk.dir=f:/build/android-sdk-windows" file="build/local.properties" /> </target> <target name="release"> <ant antfile="build/build_sdk_platform.xml" target="build_prod" /> <ant antfile="build/build_sdk.xml" target="javadocs" /> <ant antfile="build/build_sample.xml" target="preparesources" /> <tar basedir="workspace" destfile="mapandroidsdk-${sdk.version}.tar" /> </t

c# - No quotef for first value in csv -

i trying make simple csv file, works except 1 tiny thing : when file opened in excel, first value of each entry isn't quoted, e.g : username,"fullname","fullname@company.com" and here code : stringbuilder sb = new stringbuilder(); // user info foreach (user u in listusers) { sb.appendformat("\"{0}\",\"{1}\",\"{2}\"\r\n", u.username, u.fullname, u.email); } // generate csv response.clear(); response.contenttype = "text/csv"; response.addheader("content-disposition", "attachment; filename=\"" + "usersexport.csv" + "\""); response.write(sb.tostring()); response.end(); any idea?

CSS3 webkitAnimationEnd event ordering -

i'm new stackoverflow , relatively new html5 programming. i'm writing (for safari, primarily) logic driven events fired out when webkit animations complete. if start number of animations of same length simultaneously, need idea of order can expect completion events fire. example: <!doctype html> <html> <head> <style> @-webkit-keyframes slideright { { left: 0; } { left: 100px; } } </style> </head> <body> <script type="text/javascript"> var square = function(ypos, color){ var mydiv = document.createelement("div"); mydiv.style.width = "20px"; mydiv.style.height = "20px"; mydiv.style.top = ypos + "px"; mydiv.style.backgroundcolor = color; mydiv.style.position = "absolute"; document.body.appendchild(mydiv); var squareinterface = { onanimend: function(ev

java - Can we use multiple message factories in Spring WS? -

i solved problem of direct streaming spring ws , arjen fast response. trick disable payload caching in axiom message factory. i suffering global decision, have either enable or disable payload caching whole system. have webservices streaming , enables validation (which not possible if payload caching disabled) so possible map specific endpoint specific message factory? it's easy webservice clients, endpoints? ideas? thank you! you're right, it's easy on client side passing specific webservicemessagefactory instance webservicetemplate constructor. anyway, guess it's possible on server side. if can use different url mappings, simplest way found out based on configuration of 2 (or more) differents messagedispatcherservlet in web.xml . have pass init parameter specific bean name of webservicemessagefactory instance prefer. this: <servlet> <servlet-name>ws1</servlet-name> <servlet-class>org.springframework.ws.tran

objective c - how to convert string value into date in iphone -

hi friend want convert string value date in project because fetching xml value web , in xml file weather condition , there value weather condition current date forecastcondition not come in date comes in string value friday saturday , sunday value come in forcast condition day string value come in day_of_week [day_of_week means shows friday,satarday,sunday ] want how can convert string value date please 1 me using please on controller class.m file - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { tweathercell *cell =(tweathercell *) [mytableview dequeuereusablecellwithidentifier:[nsstring stringwithformat:@"cell_%d", indexpath.row]]; if (cell == nil) { //cell = [[[tweathercell alloc] initwithstyle:uitableviewstylegrouped reuseidentifier:cellidentifier] autorelease]; cell = [[[tweathercell alloc] initwithframe:cgrectzero reuseidentifier:[nsstring stringwithformat:@"cell_%d", i

rspec - How to avoid Persistence of a Factory Girl object -

i have several rspec tests use factory_girl. used on mongodb mongoid in rails 3 app. somewhere along line, test against invalid values: expecting validation-errors. after that, anytime call factory(:user) , fails, because of validation errors. expect entirely new , clean object, when call factory(:user), not re-used, battered one. example code below, illustrates *user_spec.rb* adding invalid items "roles". user model marks record invalid . a little further in specs, *sidebar_helper_spec.rb* need instantiate @user , , there fails, telling me invalid role "foo" there. can see role not present in factory.rb . is expected behaviour? can toggle persistence (or caching?) config option? ## models/user_spec.rb require 'spec_helper' describe user describe 'roles' before(:each) @user = factory.build(:user) end 'should require role' @user.roles = nil @user.should_not be_valid end 'should allow

Link to automatically import a public calendar into Yahoo Calendar? -

i have created public calendar , want let users subscribe using yahoo calendar. instead of having users copy calendar's url , paste calendar, i'd prefer have link can click on , automatically subscribe public calendar within yahoo calendar account. is there way this? thank you

PHP true or false -

i trying modify plugin called "events calendar" wordpress, show past events. i have found function: /** * returns true if query set past events, false otherwise * * @return bool */ function events_displaying_past() { global $spevents; return ($spevents->displaying == "past") ? true : false; } iow can default true? /** * returns true if query set past events, false otherwise * * @return bool */ function events_displaying_past() { global $spevents; return ($spevents->displaying == "past" || !isset($spevents->displaying)) ? true : false; }

plsql - How to set cursor field name from another cursor? Oracle -

i need take cursor fields names cursor this: for rec1 in (select * table1) loop rec2 in (select * table2) loop if rec1.[rec2.field_name] <> '*' ... end if; end loop; end loop; oracle not designed kind of behavior. way can think of achieve use dynamic pl/sql produce functionality you're looking for: declare v_field_value varchar2(2000); begin rec1 in (select * table1) loop rec2 in (select * table2) loop execute immediate 'begin :value := :rec1.' || :rec2.field_name || '; end;' using out v_field_value, in rec1; if v_field_value <> '*' ... end if; end loop; end loop; end; however, because approach can work doesn't mean should use it. if field not string, instance, oracle implicitly convert value, may r

asp.net - How do you deal with the designing issues of a website? -

we created website few years ago , worked except not designers designing poor. 3 years later client asked change design of site completely. did change design many (infact pages) has few styles not available in new css file. site comparitively large. if go every single page check styles , classes applied element 15-20 days of unproductive work , miss deadline. how deal these issues? thanks in advance :) you make them pay it. then can afford pay work. if refuse pay it, tell them out of scope , either won't done or massively delay deadline.

Add timestamps in python -

how add following timestamps month wise in python 2.4 i.e, timestamps occurring in month 3 should added together. for example: result should on 2011-03 total timestamp 1:00:45 , on other months.. 2011-03-07 0:27:41 2011-03-06 0:13:41 2011-03-08 0:17:40 2011-03-04 0:55:40 2011-05-16 0:55:40 2011-05-18 0:55:40 2011-07-16 0:55:40 2011-07-17 0:55:40 how this: import datetime import re collections import defaultdict months = defaultdict(int) # months = {} # python 2.4 open("test.txt") timestamps: line in timestamps: month = line[:7] time = re.search(r"(\d+):(\d+):(\d+)", line) if time: seconds = int(time.group(1))*3600 + \ int(time.group(2))*60 + \ int(time.group(3)) months[month] += seconds # if month in months: # python 2.4 # months[month] += seconds # else: # months[month]

xml - How can i read the text inside the node of an example in C#? -

this xml want read. <server servername="sp-swd-t01"> nodes there </server> i want read servername inside server how can read it.please help. this code xmlreadersettings readersettings = new xmlreadersettings(); readersettings.ignorecomments = false; xmlreader xmlrdr = xmlreader.create(strfilepath, readersettings); // parse file while (xmlrdr.read()) { switch (xmlrdr.nodetype) { case xmlnodetype.element: // may need capture last element provide context // comments come across... copy xmlrdr.name, etc. break; case xmlnodetype.comment: messagebox.show(xmlrdr.name); break; case xmlnodetype.text: //display text in each element. //console.writeline(reader.value)

tsql - Does int in (SELECT varchar...) work? -

i'm trying modify code written bey else generating model report being built in business intelligence development studio (microsoft reporting services). i wondering if necessary? where (convert(varchar,r.kommunenr) collate database_default in (select item dbo.split('"+ @kommune+ "', ',') split_1))" $kommune text built this: "kommune1,kommune2,kommune3,..." is okay check int (r.kommunenr) in (select item dbo.split('"+ @kommune+ "', ',') split_1) reckon varchar. this where (r.kommunenr in (select item dbo.split('"+ @kommune+ "', ',') split_1)) the problem can't run code, atm have code, , not permission run it. in tsql implicit conversions, varchar cast int , not vice versa. so second query fail if r.kommunenr int , dbo.split returns varchar not castable int . if want benefit index on r.kommunenr , may try this: select * r kommunenr in (

replace variable with its value in a ruby string, string itself is stored in a variable? -

i have variable containing string , in run time replace variables stored in string. for example.. my_string = "congrats have joined groupname." groupname = "*name of group*" puts my_string output:- "congrats have joined *name of group*" issue is: my_string = " congrats have joined #{groupname}" expects groupname exists.. in case have define my_string before variable in it. solution 1: one way can be.. string replacment using gsub.. thats not one.. ps: what trying achieve. have set of 100 messages have deliver. want define @ 1 single place , replace variable when needed. want define these variables(100 ones) in application_controller, can concatenate each variable(one of 100) defined. , automatically variable(variable defined in string stored in 1 of 100 variables). this language quite confusing.. check example explained above.. you store format string: my_string = "congrats have joined %s" group

C# multithreaded windows service, private or [ThreadStatic] -

i'm in process of converting console application wrote single windows service windows service supports multithreading. however, first go around multithreads. i wondering if should make every class private static instead of public static , has remain public, attach [threadstatic] attribute. basically code lot of string work html crawling , places select data in mysql database. the answer first question no; adapting code support multiple threads not (necessarily) mean need change member or type accessibility. as second question, use threadstatic on fields (not types) if need each thread have own independent static field (otherwise threads share same static field).

android - Feed Fragment, Mark Murphy Busy Coder Helper -

is familiar mark murphy tutorial in busy coders guide advance feed fragment tutorial did? well question how make dynamic feed in tutorial meaning stays same through application. feed url in hashmaps? so tutorial how add url there each time application loaded? as replied post cw-android google group , 5 feeds built feedfragments "the same through application". while can add additional feeds, don't remember adding in ability delete feeds.

Can urls contain dots in the path part? -

is valid url? (from standard point of view) http://test.com/some/path/version/1.2/thing yes. common versioning web service interfaces. see spec: http://www.w3.org/addressing/url/url-spec.txt

android - How to change apk name by editing manifest file? -

i want change apk name in project workspace. how editing androidmanifest.xml file? in manifest file, can change application label only. if want change apk file name, should change project name. this, right click on project in navigator windows, choose refactor>rename , type new name it.

CSS reverting to default styles -

a fellow developer has set following css rule, must remain in place. * { border: medium none; list-style: none outside none; margin: 0; outline: medium none; padding: 0; } this removes border select , input fields , makes them less ideal. if remove border style in firebug fields normal again. css rules must add revert default styles set browser? edit: these styles i'm trying revert (on computer): screenshot http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single-option/icab-3-osx.png i think fellow developer attempting create own reset (similar yahoo reset, etc). since he's declaring * instead of specific elements, removes border everything. you can work around though , still browser's default border on form elements changing * common elements (sans form elements) - it's bit ugly, you're looking for: a,abbr,acronym,address,b,blockquote,body,br,caption,dd,div,dl,dt,em,fieldset,form,h1,h2,h3,h4,h5,h6

c# - IEnumerable<IDisposable>: who disposes of what and when -- Did I get it right? -

here hypotetical scenario. i have large number of user names (say 10,000,000,000,000,000,000,000. yes, in intergalactic age :)). each user has own database. need iterate through list of users , execute sql against each of databases , print results. because learned goodness of functional programming , because deal such vast number of users, decide implement using f# , pure sequences, (aka ienumerable). , here go. // gets list of user names let users() : seq<string> = ... // maps user name sqlconnection let mapuserstoconnections (users: seq<string>) : seq<sqlconnection> = ... // executes sql against given connection , returns result let mapconnectiontoresult (conn) : seq<string> = ... // print result let print (result) : unit = ... // , here main program users() |> mapuserstoconnections |> seq.map mapconnectiontoresult |> seq.iter print beautiful? elegant? absolutely. but! who , @ point disposes of sqlconnections? and don't thing

opengl es - Decoding and Rendering Video on Android -

what need decode video frames , render frames on trapezoidal surface. i'm using android 2.2 development platform i'm not using mediaplayer service since need access decoded frames. here's have far: i using stagefright framework extract decoded video frames. each frame converted yuv420 rgb format the converted frames copied texture , rendered opengl surface note using processing , not using opengl calls directly. so problems are i can decode mp4 files stagefright the rendering slow, around 100ms 320x420 frame there no audio yet, can render videos still don't know how synchronize playing of audio frames. so questions... how can support other video formats? shoud use stagefright or should switch ffmpeg? how can improve performance? should able support @ least 720p? should use opengl calls directly instead of processing? improve performance? how can sync audio frames during playback? adding other video formats , codecs stagefright

jquery - streamlining a series of javascript functions -

is there better, more concise way this: function gettweets(){ $.getjson("http://search.twitter.com/search.json?callback=?&q=superfad", function(data){ tweetsloaded = true; $.each(data.results, function(i,item){ var textplain = item.text; var textlinked = linkify(textplain); var texthashed = hashify(textlinked); var textlisted = listify(texthashed); function linkify(tweet){ return tweet.replace(/(http:\/\/[^\s]*)/g, "<a class='twtr-link' target=\"_blank\" href=\"$1\">$1</a>"); } function hashify(tweet){ return tweet.replace(/(^|\s+)#(\w+)/gi, function(m, before, hash) { return before + '&l

css - 1px vs thin, IE vs Excel issues -

i have html table rendered in ie, , excel (for reporting) if set border-width thin, shows 2px border in ie, , 1px border in excel. however, if set 1px, shows 1px border in ie, , 2px border in excel(???). how can them both show 1px border looks horrible 2px border. saving excel file html genrates css so: .xl32 {mso-style-parent:style0; border-top:.5pt solid windowtext; border-right:1.0pt solid windowtext; border-bottom:1.0pt solid windowtext; border-left:.5pt solid windowtext;} .5 displays normal line, 1.0 thick line guess setting te .5pt should work...

jmeter - How many threads/users can one Windows client simulate during my load test? -

i'm planning load test of our asp/.net web application , need simulate 600 concurrent users on our system. initially we'll running load test tools (probabaly jmeter or wcat/wast) our personal workstations windows 7/32 bit dells (dual core processors) . wondering how many users can expect able simulate 1 client. if can 200 users per client, i'll need identify 2-3 more clients test. i wanted ask community based on experience how many users should expect per client on standard windows box. any appreciated! this highly depends on test plan , cannot answered easily. if example have 500 users 1 request , have waiting timer 5 minutes, should work. if users requests without waiting, put more load on machine. it depends on samplers in use. http requests less costly soap requests example. it depends on listeners have active. for normal load test have around 100-300 threads active. suggest start such number , monitor load (cpu, network) on client see ho

keyedcollection - Keyed Collection in Python? -

is there equivalent keyedcollection in python, i.e. set elements have (or dynamically generate) own keys? i.e. goal here avoid storing key in 2 places , , therefore dictionaries less ideal (hence question). @mehrdad said: because semantically, doesn't make sense. when object knows key, doesn't make sense put in dictionary -- it's not key-value pair. it's more of semantic issue else. with constraint, there nothing in python want. suggest use dict , not worry level of detail on semantics. @gabi purcaru's answer shows how can create object interface want. why bothered how it's working internally? it c#'s keyedcollection doing same thing under covers: asking object key , storing key fast access. in fact, docs: by default, keyedcollection(of tkey, titem) includes lookup dictionary can obtain dictionary property. when item added keyedcollection(of tkey, titem), item's key extracted once , saved in lookup dictionar

osx - Reversing of _PrepareMenuWindow() subroutine -

can 1 me reversing of _preparemenuwindow() subroutine? trying find signature of method. __text:000639a7 _preparemenuwindow proc near ; code xref: drawthemenu(menuselectdata *,__cfarray **,uchar,uchar *)+274p __text:000639a7 ; popupmenuselectcore(menudata *,point,double,point,ushort,uint,rect const*,ushort,ulong,rect const*,rect const*,__cfstring const*,opaquemenuref **,ushort *)+528p __text:000639a7 __text:000639a7 var_44 = dword ptr -44h __text:000639a7 var_40 = dword ptr -40h __text:000639a7 var_3c = dword ptr -3ch __text:000639a7 var_34 = dword ptr -34h __text:000639a7 var_30 = dword ptr -30h __text:000639a7 var_2c = dword ptr -2ch __text:000639a7 var_28 = dword ptr -28h __text:000639a7 var_24 = word ptr -24h __text:000639a7 var_20 = dword ptr -20h __text:000639a7 var_1a = word ptr -1ah __text:000639a7 arg_0 = dword ptr 8 _