Posts

Showing posts from February, 2010

php - Regex to extract specific urls from <img> tags in an HTML document -

i trying extract specific url pattern body of content , replace newly formed url. running problems regex patterns , wanted see if me. here code testing with: $body = '<p><img src="/file/637/view" height="540" width="640"></p>'; $pattern = '/src="/file/(0-9)+/view"/'; $pattern = '/src="/file/(.)+/view"/'; $pattern = '/"/file/[0-9]+/view"'; $pattern = '/\<img src="(.)+"(.)+"\>/'; preg_match($pattern, $body, $matches); now, last pattern down grab entire image tag, great, want extract image urls (just url) use "/file/(some number)/view" pattern can form new urls , string replace on them. of others fail find when run print_r on $matches var. obviously body string represents content body scanning this. suggestions how work , grab image url? have work situations multiple images intermingled lots of other html including anchor tags. ...

vb.net - C# equivalent of VB LINQ Query -

i have following query in vb, not know how translate c# synatax dim q = c in db.customers group join o in db.orders on c.customerid equals o.customerid orders = group select new {c.contactname, .ordercount = orders.count()} thank you it's pretty easy. have drop "group": var q = c in db.customers join o in db.orders on c.customerid equals o.customerid orders select new { c.contactname, ordercount = orders.count() }; or, if you're looking lambda syntax: var q = db.customers.groupjoin(db.orders, o => o.customerid, c => c.customerid, (c, orders) => new { c.contactname, ordercount = orders.count() });

Does .NET JIT compiler generate different code for generic parameterized with different enums? -

if write (or use) generic class, e.g. list, , parameterize 2 different enumerated types, 2 copies of code jitted? given following articles discuss how jitter generates 1 copy reference types, , 1 copy each value type, think boils down to, "is each specific enum considered different value type purpose of jitting?" clr vs jit http://msdn.microsoft.com/en-us/library/ms379564%28v=vs.80%29.aspx#csharp_generics_topic1 in c# code: using system.collections.generic; namespace z { class program { enum {a} enum b {b} class c<t> { } static void main(string[] args) { var x = new c<a>(); var y = new c<b>(); // jit new c constructor enum type b? } } } i'm interested know in general, .net cf 3.5 (windowsce) jit compiler (edit: because i'm interested in possible code bloat implications). suggestions on best way find out? thinking of writing function ...

reusability - Use a userscript as a regular javascript? -

if have userscript i've found online, , i'd incorporate website normal javascript (i.e. not userscript), how can that? this seems pretty simple new javascript , userscript, can me out. for example, found userscript: " convert ups , fedex tracking numbers links "... which parse page regular expressions matching ups/fedex/usps tracking number, , convert them links respective carriers' tracking website track number. this works great userscript, automatic on site working on (not require visitors download/install userscript). how can use userscript regular javascript? userscripts executed after page dom loaded, make sure page contents can accessed. so, need kind of mechanism achieve that. bit tricky since older versions of ie need special treatment. doing manually require 30 lines of code. libraries jquery offer ready() method so: <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(docume...

regex - Test filename with regular expression -

i trying test filename string pattern: ^[a-za-z0-9-_,\s]+[.]{1}[a-za-z]{3}$ i want ensure there 3 letter extension , allow letters, numbers , these symbols: - _ , \s precede don't want have include of letters , characters in filename. use * instead of + match 0 or more wouldn't valid filename. here examples of how rule should react: correct file name.pdf - true correct, file name.pdf - true correct_file_name.pdf - true correctfilename.pdf - true incorrect &% file name.pdf - false incorrect file name- false it great if point me in right direction. thanks you use these expressions instead: \w - same [a-za-z0-9_] \d - same [0-9] \. - same [.]{1} which make regex: ^[\w,\s-]+\.[a-za-z]{3}$ note literal dash in character class must first or last or escaped (i put last), put in middle, incorrectly becomes range . notice last [a-za-z] can not replaced \w because \w includes underscore character , digits. edited: @tomasz right! \w == [...

iphone - UIImage position -

possible duplicate: uiimage position i'm using following code place images in uiview: uiimage *image; uigraphicsbeginimagecontext(cgsizemake(480, 320)); int k=0; int posy=0; (int i=0; i<[thearray count]; i++) { image=[uiimage imagenamed:[nsstring stringwithformat:@"%@",[thearray objectatindex:i]]]; if (k>2) { k=0; posy++; } [image drawatpoint:cgpointmake(k*64, posy*23)]; k++; } uiimage *combinatedimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); obtaining result http://cl.ly/8bsp but obtain this: http://cl.ly/8c6q i can't figure out, confused. can me, please??? thanks!! [solved] this final working solution uigraphicsbeginimagecontext(cgsizemake(480, 320)); int k=0; int posy=0; int d = 0; (int i=0; i<[thearray count]; i++) { int imagesleft = min(3, [thearray count]-i); image=[uiimage imagenamed:[nsstring strin...

atk4 - Agile Toolkit, worth using? -

i'm considering using agile toolkit, atk4 upgrade number of web projects i'm working on. idea/paradigm agile toolkit presents, i'm worried documentation. the agile website's documentation sparse, in broken english, , seems 'paraphrase' symfony documentation. the agile toolkit alleges have been in development/production since 1999, yet there handful of stackoverflow.com posts regarding agile, , next nothing comes in google searches... in short worth spending time learning agile toolkit, or time better spent on framework has more of active support community? i've tried few other frameworks, atk's implementation stands out... initially atk born internal tool agile technologies (.ie) has been conceived in 1999 launched dual licensed framework. that's why lacks documentation , has not huge community nor appears googling. i amazed @ first sight working way proposal engaged it. documentation has been improved , on time keep getting be...

android - Loading data from rss feed? -

i want have rss string set variable. want content loaded inside application when list item clicked holding rss feedlable("example new feed" in list). how go doing create listview of strings of rss feeds labels feed is, , when clicked load content in activity? a example greate! there great tutorial on rss parsing @ http://www.ibm.com/developerworks/opensource/library/x-android/index.html it has lot of source code well. if want introductory tutorial, http://www.ibm.com/developerworks/xml/tutorials/x-androidrss/ might you

javascript array timed -

i'm missing little thing.. prints array doesn't wait in between lines. <script type="text/javascript"> function showlines() { arr = [ "hi!", "welcome!", "hello!" ] var duration=2000; document.getelementbyid("quotes").innerhtml=arr; settimeout('showlines()',duration); } </script> most answers here re initializing array on each iteration.it makes no sense that. should this: <script type="text/javascript"> function showlines(){ var arr = [ "hi!", "welcome!", "hello!" ], = 0; (function showlineshelper(){ document.getelementbyid("quotes").innerhtml += arr[i++]+'<br />'; if(i < arr.length) settimeout(showlineshelper, 2000); })(); } </script> this way works, , array, , initialized once. edit in response comment: <script type="t...

python - Can i do an order_by on day in month? -

i trying create list of birth days, ordered dates, query set is: birth_days = get_list_or_404(userprofile.objects.order_by('-birthdate'), birthdate__month=datetime.datetime.now().month) how can list ordered day in month birth days list ordered, right ordered date, if 2 people has birth day month , person 1 date lets 20/7/1980 , person 2 date 17/7/1970, person 2 still after person 1 in list. don't care year of birth, month , day in month.... can in order_by this: order_by('-birthdate__day') i know can't because isn't working, asking if there way (in view, not in model in case...not think matters on here, saying)? thank you, erez you can extract day "extra" field , sort on that, example: userprofile.objects.select(extra={'birth_day': 'extract(day birthdate)'}).order_by('-birth_day') this should work postgresql @ least.

java - Netbeans libraries contains different jar/class than directed to -

i have been trying follow getting started jax-ws web services . had lot of trouble because jdk 6 has jax-ws 2.1 metro has jax-ws 2.2 . lot of searching found out called " endorsed " exists. try work apache , found out jax-ws clash (see ps2 hyperlink 3). have endorsed folder 2 .jar files in it: "c:\program files\java\jdk1.6.0_21\jre\lib\endorsed" containing "jaxb-api.jar" , "jaxws-api.jar". , seemed work, unfortunately 'server-application'. after lot of searching , copying different files endorsed folder , again , again... ...i started think wrong netbeans instead of me being stupid. downloaded java decompiler (see ps2 hyperlink 4), , looked in jar-files in endorsed folder. btw, errors recievin in netbeans javax.xml.ws.service not contain following constructor: protected service(url wsdldocumentlocation, qname servicename, webservicefeature[] features) but following constructor: protected service(url wsdldocumentlocation, qname s...

asp.net mvc 2 - Multiple serializations on state server corrupt property value -

i have abnormal serialization/de-serialization behavior in asp.net mvc application. setup , architecture follows: .net 3.5, mvc 2, unity 2.0 dependency injection, iis 7. state stored in aspnet state process. application apart models, views , controllers contains number of application specific services , model mappers (for interfacing existing code). 2 of services have per session based lifetime, implemented custom persessionlifetimemanager (as unity not have 1 out of box). lifetime manager uses httpcontext.current.session store objects. there fair bit of dependencies between controllers, mappers, services , between services well. problem: one of session lifetime services contains private boolean field changes value under internal logic conditions, value changes outside of code. after investigation found problem relates object being serialized/de-serialized twice every time , values of field different during serializations. investigation done far: i have break points/...

php - How can I benchmark the XML parser of my choice? -

i handle huge xml file , go xmlreader. below 3 ways go with, need know 1 fastest. how can know this? planet.xml file located @ http://trash.chregu.tv/planet-big.xml.bz2 in case hat may need it. thank you! you might want consider php profiling extension: http://www.php.net/apd you can examine results pprofp: http://www.compago.it/php/phpckbk-chp-21-sect-3.html

iphone - navigating to a TabBar from different ViewControllers -

i trying build app has landing screen link either "signin" page or "sign up" page. meat of app tabbar. right place implement tabbarcontroller given user can have following flow: landing page - >sign in -> main app landing page - > sign -> main app straight main app if user logged in already is possible in appdelegate? then, how go appdelegate if @ "sign in"/"sign up" page? thanks help!! create modal view pop ups (the landing page) if user not signed in/up. once either sign in or sign up, dismiss view. just create view , xib, , if first view load detects not logged in (example: have tab bar twitter feed, facebook feed, , feed, first view twitter view, senses aren't signed up/logged in awesome service, calls modal view sign in/up) once users done dismiss modal view. here's official documentation: http://developer.apple.com/library/ios/#featuredarticles/viewcontrollerpgforiphoneos/modalviewcontrollers/m...

.net - Passing value from single C# dropdown selection to a query string -

i have dropdownlist , listbox functioning fine. need able insert selected value dropdownlist database when user moves selection products table productsmail table in listbox . have attempted modify sql string multiple times no success "+emailddn.selecteditem+" , "+emailddn.selectedvalue+" , etc. can selected value display in emaillabel1 label not in query. please provide solution. appreciate time. _ jt hi suryakiran, in "destinationdatasource": updatecommand="update productsmail set name = @name, email = @email, emailid = @emailid id = @id". i have attempted modifications such as: "update productsmail set name = @name, email = ' + @email + ', emailid = @emailid id = @id" , "update productsmail set name = @name, email = ' +emailddn.selecteditem+ ', emailid = @emailid id = @id" and others no success. <telerik:radscriptmanager id="scriptmanager" runat="server" /> ...

php - Using PDO to select when param columns are unknown/variable -

for simplicity's sake, let's have rather contrived table: [id] [weekday] [weather] 1 sun cloudy 2 mon sunny ... ... ... 8 sun cloudy ... ... ... 15 sun windy and i'm hitting table datasets. want data based on weekday, based on weather. create class: class weather { public static function reportbyday($weekday) { return self::weatherserver('weekday',$weekday); } public static function reportbyweather($weather) { return self::weatherserver('weather', $weather) } private static function weatherserver($reporttype, $value) { $q = "select id, weekday, weather table $reporttype = $value"; $r = mysql_query($q); etc etc. return $results; } } so wanted convert pdo, discovered morning where :field = :thing structure doesn't work... @ least can't make work. ...

oracle - SQL For Update Skip Locked Query and Java Multi Threading - How to fix this -

select id table_name tkn1, (select id, rownum rnum table_name procs_dt null order prty desc, cret_dt) result tkn1.id= result.id , result.rnum <= 10 update of tkn1.id skip locked here problem. 2 threads accessing query @ same time thread 1 - executes select , locks 10 rows ordered descending priority , created date. next update procs_dt todays date separate query.. thread 2 - before update of procs_dt or commit happens thread 1 , thread executes query. requirement next 10 unlocked rows must handed on thread 2. happens same set of locked rows comes out of inner query since procs_dt still null , yet updated thread 1 , since skip locked given in outer query, 10 rows skipped , no records returned thread 2 process this defeats multi threading requirement. how fix query? tried adding skip locked inner query. oracle 11g doesn allow it. experts please help. using orac...

php - What is the proper way to validate a physical commercial/residential address? -

currently, limit address 100 characters no rules must composed of. punctuation, digits, letters; welcome. i use strip_tags upon saving address database (prepared statements). use $this->escape() (zend framework) when echoing page. i don't want go crazy, think need little more restrictive. missing? if these addresses, should use united states postal service's apis , standardize addresses. http://www.usps.com/webtools/

php - URL parameters to file -

how create , write file using url parameters for example: web.com/index.php?name=test.txt?input=halloworld file name should test.txt , content must halloworld. this have far if(isset($_get['name'])) { $file = $_get['name']; $handle = fopen($file, 'w'); $data = $_get['input']; fwrite($handle, $data); fclose($handle); } file output = test.txt?input=halloworld wrong thank you. your error in using ? instead of & in url, should web.com/index.php?name=test.txt&input=halloworld that said should never things this, because it's extremely dangerous. in way you're exposing server kind of attacks or defacing. attacker write php file on webserver , take control of it. keep in mind. edit: wrote in question comment, rewrite here, if attacker invoke script parameters: web.com/index.php?name=evil.php&input=<?php exec('rm -rf /'); and request url web.com/evil.php your filesyste...

Return date as ddmmyyyy in SQL Server -

i need date ddmmyyyy without spacers. how can this? i can yyyymmdd using convert(varchar, [mydatetime], 112) but need reverse of this. sql server 2008 convert style 103 dd/mm/yyyy. use replace function eliminate slashes. select replace(convert(char(10), [mydatetime], 103), '/', '')

ruby on rails - Repairing Postgresql after upgrading to OSX 10.7 Lion -

i upgraded osx 10.7, @ point rails installation borked when trying connect psql server. when command line using psql -u postgres it works totally fine, when try run rails server or console same username , password, error ...activerecord-3.0.9/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize': not connect server: permission denied (pgerror) server running locally , accepting connections on unix domain socket "/var/pgsql_socket/.s.pgsql.5432"? any ideas might going on super helpful! thanks! it's path issue. mac osx lion includes postgresql in system now. if which psql you'll see usr/bin/psql instead of usr/local/bin/psql homebrew's correct one. if run brew doctor should message stating need add usr/local/bin head of path env variable. editing .bash_profile or .profile, or whichever shell you're using , adding: export path=/usr/local/bin:$path as first export path either quit shell session o...

sql - Complicated mysql query across two tables -

table 1 : invtypes columns typeid , groupid , typename , description table 2 : item_value columns typeid , volume , avg , max , min , stddev , percentile , updated_on i need return of above columns latest updated_on (datetime) field deciding factor. return latest datetime each day of information table 1 , table 2 result. this how rows corresponding recent updated_on each date in item_value table: select invtypes.*, item_value.* item_value inner join ( select max(updated_on) `updated_on` item_value group date(updated_on) ) latest on latest.updated_on = item_value.updated_on inner join invtypes on invtypes.typeid = item_value.typeid order item_value.updated_on

iphone - Using nested NSDictionary with Picker -

newbie here, i have single component picker set plist, each item being array, multiple strings in each array app uses. currently plist structure this: nsdictionary -> nsarray -> nsstring | | items in picker data each item but now, want: nsdictionary -> nsdictionary -> nsarray -> nsstring | | | different picker data sets items in picker data each item so there multiple sets of picker components show using segmented control etc... i'm not sure if possible, , hoping save me making many different separate picker controllers. what has me stumped getting ingested properly this have now, builds crashes (debug info below): nsbundle *bundle = [nsbundle mainbundle]; nsstring *plistpath = [bundle pathforresource:@"camerasdatabase" oftype:@"plist"]; nsdictionary *dictionary = [[nsdictionary alloc] initwithcontentsoffi...

java - Glassfish, cannot find folder portlet-container in glassfish/domain/domain1 -

hello need run portlets on glassfish , use netbeans development, downloaded netbeans 7.0 bundle glassfish, installed. went http://portlet-container.java.net/public/download.html page, downloaded jar, tried install, here have problem cannot find portlet-container in folder glassfish/domain/domain1. opened directory /usr/local/glassfish-3.1/glassfish/domains/domain1, there no portlet-container folder! must install portlet container glassfish? here actual error: severe: portlet container configuration failed. /usr/local/glassfish-3.1/glassfish/domains/domain1/portlet-container/portlet-container.zip (no such file or directory) it looks portlet container installer assumes have write permission in domain1 directory. if have installed glassfish /usr/local, may not have write permission... discovered. you can run portlet container installer root or can following (which doesn't require rootiness): asadmin create-domain --domaindir ~/mydomains --adminport 4848 domain1 ...

java - How does XPath "evaluate" method work? -

i want understand difference between execution of evaluation when- document object's setnamespaceaware , isvalidating set true - in case, understand if xml uses namespace, need set namespacecontext. if not set namespacecontext, how evaluate method work/ handle condition? document object's setnamespaceaware , isvalidating set false - happens if these 2 set false? (this question linked issue mentioned in this question.) xpath not defined except on namespace-aware source documents. simple answer is, might happen depending on implementation. by constrast, xpath should work regardless of setting of isvalidating, , in cases should produce same results. exception might use of id() function, depends on id attributes being recognised.

jsp - How to access user-defined functions of a servlet? -

i tried searching this, didnt got solid answer. possible call functions other doget or dopost of servlet jsp. know can call them indirectly making call either doget or dopost , calling function there. for eg: public class fooservlet extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response){ } public void myfunc(){ } how call myfunc jsp no. published interface servlets doxxx methods (doget, dopost, etc). right way invoke other methods calling published interface , calling other methods.

ipad - I want to hide the bar which shows battery status,Time,Carrirer from application -

how hide bar application shows battery status,time,carrier signal? status bar or else yes, indeed statusbar. can hide line (preferably in applicationdidfinishlaunching: ): [[uiapplication sharedapplication] setstatusbarhidden:yes animated:no];

PHP: call to a REST api -

i trying call vchargeback api getting information on vcenter server. having issues this. i have pass request xml data in request body. , have pass version url parameter. code have written $xmlfile=simplexml_load_file('login.xml'); $ch = curl_init(); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields,$xmlfile);//passing xml file post field curl_setopt($ch, curlopt_timeout, 10); curl_setopt($ch, curlopt_url,"https://xx.xx.xx.xx/vcenter-cb/api/login");//setting url curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch , curlopt_ssl_verifypeer , false );//since requesting https curl_setopt($ch , curlopt_ssl_verifyhost , false );//since requesting https curl_setopt($ch, curlopt_httpheader, array ('accept: ' . $this->accepttype )); $response=curl_exec($ch);//getting response $responseinfo=curl_getinfo($ch);//getting response headers when execute, have 400 bad request response. noticed not sending version url paramet...

java - Simple Command Line calculator -

i have written code command-line calculator in java can't understand errors not allowing compile public class calculator{ public static void main(string[] args){ int numone = args[0]; int numtwo = args[1]; add(numone, numtwo) { result = numone + numtwo; system.out.println("{numone} + {numtwo} = {result}"); } subtract(numone, numtwo) { result = numone - numtwo; system.out.println("{numone} - {numtwo} = {result}"); } multiply(numone, numtwo) { result = numone * numtwo; system.out.println("{numone} * {numtwo} = {result}"); } divide(numone, numtwo) { result = numone / numtwo; system.out.println("{numone} / {numtwo} = {result}"); } } } the translation java of code is: public class calculator { public static void add(int numone, int numtwo) { int result = numone + numtwo; system.out.println(numone + " + " + numtwo + " = " + result); } public static void subtra...

iphone - Unable to display the bars in bar chart? -

- (void)constructbarchart { // create barchart theme barchart = [[cptxygraph alloc] initwithframe:cgrectzero]; cpttheme *theme = [cpttheme themenamed:kcptdarkgradienttheme]; [barchart applytheme:theme]; barchartview.hostedgraph = barchart; barchart.plotareaframe.maskstoborder = no; barchart.paddingleft = 70.0; barchart.paddingtop = 20.0; barchart.paddingright = 20.0; barchart.paddingbottom = 80.0; // add plot space horizontal bar charts cptxyplotspace *plotspace = (cptxyplotspace *)barchart.defaultplotspace; plotspace.yrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0.0f) length:cptdecimalfromfloat(300.0f)]; plotspace.xrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0.0f) length:cptdecimalfromfloat(5.0f)]; cptxyaxisset *axisset = (cptxyaxisset *)barchart.axisset; cptxyaxis *x = axisset.xaxis; x.axislinestyle = nil; x.majorticklinestyle = nil; x.minorticklinestyle = nil; ...

c# - Writing digital signage player in webgl? -

we in process of determining best technology write our signage player . although c# house experience in java, talk has been java , mono. platform going build on linux box. the player has intelligent , support scheduling, content change triggers external applications (by web services), time synchronization of content, content show in different portions of screen, video/live streamed feed etc. we need create designer allow design team create webgl content. there opengl experience in company leverage this. would choice? jd that excellent choice if , if have grasp on javascript or timeline isn't tight in case don't dominate javascript. if going on linux box, chances you're better off custom build of firefox or chromium running app alone without browser parts (menus, tabs, etc). my team here working html5+javascript+canvas/webgl on client side exclusively because fast develop , needs no setup.

java - Updating variables inside labels -

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class testswinglisteners1 { private static int cnt1; private static int cnt2; public static void main(string[] args) { jframe fr1 = new jframe("swing window"); container cp; jbutton bt1; jbutton bt2; cnt1 = 0; cnt2 = 0; string scr = null; string wnr = null; jbutton btok, btcancel; fr1.setdefaultcloseoperation(jframe.exit_on_close); fr1.setsize(300, 200); fr1.setresizable(false); cp = fr1.getcontentpane(); cp.setlayout(new gridlayout(5,1)); btok = new jbutton("ac milan"); btcancel = new jbutton("real madrid"); jlabel lbl1 = new jlabel("result: " + cnt1 + "x" + cnt2); jlabel lbl2 = new jlabel("last scorer: " + scr); jlabel lbl3 = new jlabel("winner: " + wnr); cp.add(btok); cp.add(btcancel); cp.add(lbl1); cp.add(lbl2); cp.add(lbl3);...

in javascript objects, do "static" functions and prototype functions share same namespace? -

regardless of wisdom of such naming scheme, following valid? var f = function() { this.f1 = function() {} } f.f1 = function() {} // "static" call var v1 = f.f1(); // prototype call var f = new f(); var v2 = f.f1(); it seems should ok since, example, var , this variables within object function not share same space. yes, valid. in example, f function assign property called f1 function itself. if change code read f = new f() , f object inherits f 's prototype, they're still 2 distinct objects.

MySQL query for searching subset of two tables -

i have 2 tables: create table if not exists `comments` ( `id` int(11) not null auto_increment, `photograph_id` int(11) not null, `created` datetime not null, `author` varchar(255) not null, `body` text not null, `email` varchar(255) not null, `liked` int(11) not null, primary key (`id`), key `photograph_id` (`photograph_id`) ) and this: create table if not exists `photographs` ( `id` int(11) not null auto_increment, `user_id` int(11) not null, `filename` varchar(255) not null, `type` varchar(100) not null, `size` int(11) not null, `caption` varchar(255) not null, `liked` int(11) not null, primary key (`id`), key `user_id` (`user_id`) ) i having trouble merging these 2 1 query. in query have sorting call of number of comments every photo have. in comments table, there column photograph_id, links photo id in photographs table. help. for photo's 1 or more comments do: select p.id, count(*) c...

ruby on rails - How to define suites in rspec2 -

how define suite in rspec2. indeed, suite? i want break specs down 2 suites , reset between running 2 suites (clean out test db, reset warden etc ..). guess can before(:suite) block. update: understanding example like: "should true" ... end a group like: describe model ... end this understanding seems validated putting few debug statements in code. how suite defined? specs in spec folder? in case there way achieve i'm trying do? (i'm surprised can't find googling or in answers previous questions.) as see it, there no thing suite in rspec itself. have digging around little bit , found following: there post called "my top 7 rspec best practices" find under section 6 "create several test suites speed workflow". explains how split specs "suites" in rakefile , calling them individually. what try reach explained in book "the rspec book" david chelimsky. there in chapter 16.5 explains global hooks...

asp.net - Button inside updatePanel doesn't works after downloading -

in application have updatepanel few buttons. 1 of button 'export' button - after clicking user can download report local computer. button created in way: btnsave = new button { id = "btnsave", causesvalidation = false, text = "save", commandname = commandnames.savetocsv }; controls.add(btnsave); scriptmanager.getcurrent(page).registerpostbackcontrol(btnsave); and after clicking code executed: string csv = generatereport(); page.response.clear(); page.response.buffer = true; page.response.contenttype = "text/csv"; page.response.appendheader("content-disposition", "attachment; filename=\"" + filename + "\""); page.response.write(csv); page.response.end(); downloading works corectly in update panel. problem after first click on export button buttons stop works - have page doesn't send server - checked in fiddler (but client javascrpts works correctly). know how resolve problem? maybe there wa...

java - Can't read a google static map via HtmlUnit -

i trying read static map google maps on following url . this works fine web browser, when try htmlunit unexpectedpage result. know means? according javadoc of unexpectedpage , you're receiving unexpectedpage because server returns unexpected content type. if check returned header in htmlunit can see contains: content-type=image/png here's little application retrieves image url: import java.awt.image; import java.io.ioexception; import java.io.inputstream; import javax.imageio.imageio; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jlabel; import com.gargoylesoftware.htmlunit.unexpectedpage; import com.gargoylesoftware.htmlunit.webclient; /** small test application used fetch map. */ public class fetchmapswingapp extends jframe { /** serial id. */ private static final long serialversionuid = 1920071939468904323l; /** * default constructor. */ public fetchmapswingapp() { // make sure application clo...

robots.txt - How to disallow bots from a single page or file -

how disallow bots single page , allow allow other content crawled. its important not wrong asking here, cant find definitive answer elsewhere. is correct? user-agent:* disallow: /dir/mypage.html allow: / the disallow line that's needed. block access starts "/dir/mypage.html". the allow line superfluous. default robots.txt allow: / . in general, allow not required. it's there can override access disallowed. example, want disallow access "/images" directory, except images in "public" subdirectory. write: allow: /images/public disallow: /images note order important here. crawlers supposed use "first match" algorithm. if wrote 'disallow` first, crawler assume access "/images/public" blocked.

jQuery form plugin - Uncaught TypeError on file upload -

there no problem when don't select file upload, when fill other inputs post form, it's working. when choose file image upload post it, i'm getting error, when folder, see file uploaded. javascript failed. jquery.form.js:357 uncaught typeerror: object function (a,b){return new d.fn.init(a,b,g)} has no method 'handleerror' here code, <form id="employeeaddform" class = "classform" enctype="multipart/form-data" action="inc/employeeadd.php" method="post"> <p><input type="file" size="32" name="my_field" value="" /></p> <p class="button"><input type="hidden" name="action" value="image" /> <label for="nname">personal name : </label> <input name="nname" id="nname" type="text" tabindex="11" /> ...

android - Process dialog problem..! -

i doing app in have activity 2 buttons(ex: submit , cancel) when user tapping on submit button displaying process dialog , doing background task or service calling stuff problem when user taps on home hard hey while process dialog showing app deactivated or paused, , when user app i.e when app re-activated or resumed unable click submit , cancel buttons again have press hard key focus on app, according observation came 1 conclusion process dialog blocker of app. how solve issue?? how suspend process dialog when app paused or deactivated?? thanks, ram. it better if can put code canceldialog(id) in onpause , showdialog(id) in onresume conditions of course. i hope creating dialogs noncreatedialog(int id)

C# Variable Naming -

i wondering best way of naming variable in c#? know there several different ways wondering why people prefer 1 on other? i tend use lowercase letter representing type (i think hungarian method?) lot of people don't this, best way? example: string smystring string mystring string mystring string mystring thanks the common convention have seen c# when naming fields , local variables camel case : string mystring here microsoft guidelines capitalization in c#. state (amongst others): the following guidelines provide general rules identifiers. do use pascal casing public member, type, , namespace names consisting of multiple words. note rule not apply instance fields. reasons detailed in member design guidelines, should not use public instance fields. do use camel casing parameter names. i add needs agreed team members.

backbone.js - What's the best way to reset deeply nested collections? -

i have following data structure: one modela has nested collection of modelbs. each modelb has nested collection of modelcs by overriding modela's parse method, can bootstrap attributes modela , populate nested collection of modelbs : assuming server sends { modela_attributes: { ... }, arrayofb_attributes: [{..}, {..}, ..]} can in parse method: modela.nestedbs.reset arrayofb_attributes , return modela_atrributes the problem how can reset attributes of modelcs each modelb ? have considered using backbone-relational ? it'll handle of these. found race condition doing kind of stuff few weeks ago, looks paul's fixed it.

excel - Problem with VBA script reading from MySql database -

i having trouble vba script in excel should reading mysql database. sql query should return 1 record returns empty resultset. generated statement works fine when run through phpmyadmin. here code: function getclientid(emailaddress string) dim rs adodb.recordset dim sql string connectdb set rs = new adodb.recordset sql = "select client_id clients email_address = '" & emailaddress & "' limit 1" debug.print sql rs.open sql, oconn debug.print rs.recordcount if (rs.recordcount = -1) getclientid = null else getclientid = rs(0) end if rs.close end function edit: database connect function. function connectdb() on error goto errhandler set oconn = new adodb.connection oconn.open "driver={mysql odbc 5.1 driver};" & _ "server=localhost;" & _ "database=mydb;" & _ "user=user;" & _ "password=pas...

Why python has limit for count of file handles? -

i writed simple code test, how files may open in python script: for in xrange(2000): fp = open('files/file_%d' % i, 'w') fp.write(str(i)) fp.close() fps = [] x in xrange(2000): h = open('files/file_%d' % x, 'r') print h.read() fps.append(h) and exception ioerror: [errno 24] many open files: 'files/file_509' the number of open files limited operating system. on linux can type ulimit -n to see limit is. if root, can type ulimit -n 2048 now program run ok (as root) since have lifted limit 2048 open files

a star - Understanding the AStar Algorithm -

from link: http://www.policyalmanac.org/games/astartutorial.htm if adjacent square on open list, check see if path square is better one . in other words, check see if g score square lower if use current square there . if not, don’t anything. example: parent (already traversed): o branches: a, b, c parent (working on): a branches: b, d the open list contains, a, b, c , d. now, bold statements in above quote comparing path with, path b? i.e. comparison of a b && o b or comparison of a b && a d please clarify. basic a* is: while we're not close enough / destination take point have now, lowest expected total cost (so known cost point plus estimated remaining cost). calculate cost surrounding locations & add them priority queue expected total cost. return route followed closest point in official a* terminology, g-score cost there. h-score estimate there want go. extremes if h-score overestimates; new score (...

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL -

i using google contacts javascript api. trying add contacts gmail account of authenticated users using code given in http://code.google.com/apis/contacts/docs/1.0/developers_guide_js.html#interactive_samples . i able login , logout. try create new contact chrome given error. have hosted javascript , html file in amazon s3 bucket , image. unsafe javascript attempt access frame url about:blank frame url https://s3.amazonaws.com/googlecontacts/google_contacts.html . domains, protocols , ports must match. and contacts not created. html file <!doctype html> <head> <title> google contacts </title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="auth.js" > </script> </head> <body> <h1> google contacts </h1> <img src="rss_icon.jpg" width="100" height="100" /> <input ...

html - Let list go out of screen bounds -

i'm making stuff using jquery. have, example, bunch of images in list. horizontal list (so every image displayed left right). list big 9 of 30 images displayed in page (depending on youre screen resolution). i'm using jquery slide left right (if youre mouse on de left side of screen, scrolls left , vice versa). to working, list wrapped in div. div uses width of 999999px. images can go width of 999999px until next row of images displayed. because list automatically lists horizontal until next image doesn't fit page anymore, next image displayed in new row. 3x3 'table' when i'm not using div. when i'm putting div around whole thing width of 999999px, list horizontal 999999px , after makes new row. my question is: there easier way perform this? can set width to: width:infinite; or that? or doing whole thing wrong? hopefully i've made self clear in average english. in advance! html: <div id="images"> <ul id="list...

report - SSRS Print Counter -

i'm quite new ssrs , i've completed report asked do, working intended client asked me indicated how time report has been printed in current form, in header of said report. so report has 2 parameters: beginning date , ending date. let's client brings report 05-05-2005 06-06-2006 period , prints indicate "report name (print #1)" in header/title. , if decides come week later , print same exact report indicate "report name (print #2)". is there anyways this? far researches leads me believe it's not possible. thanks in advance leads/solutions ! you'd have write custom print delivery extension record "print" in database somewhere. practically, no, in "pure" ssrs ideas: an approximation of log query database, when report rendered. don't know if report acxtually printed though use reportviewer control or other programmatic method launch , print in 1 go: database query is print. , log it, above.

design - Multiple classes in one file, Ruby Style Question -

i writing script takes data database , creates googlechart urls parsed data. need create 2 type of charts, pie , bar, wrong if stick both of classes in same file keep number of files have low? thanks if you're asking "ruby" way, put classes in separate files. others have alluded to, placing classes in separate files scales better. if place multiple classes in same file , start grow, you're going need separate them later. so why not have them separate beginning? update i should mention autoload works expecting classes in own files. instance, if you're in rails environment , don't separate classes different files, you'll have require file explicitly. best place in application.rb file. know you're not in rails environment, others may find answer, maybe info helpful. update2 by 'autoload', meant rails autoload. if configure own autoload, can put classes in same file; again, why? ruby , java communities expect classes in s...

c# - How to join 2 or more .WAV files together programatically? -

i need ability join 2 or more .wav files in 1 .wav file. must programatically, using c# (3rd-party products not option). know of system.media.soundplayer class, not looking play the .wav, create it. thanks in advance. here's basic wav concatenation function built using naudio . ensure data chunks concatenated (unlike code example in this codeproject article linked in answer). protect against concatenating wav files not share same format. public static void concatenate(string outputfile, ienumerable<string> sourcefiles) { byte[] buffer = new byte[1024]; wavefilewriter wavefilewriter = null; try { foreach (string sourcefile in sourcefiles) { using (wavefilereader reader = new wavefilereader(sourcefile)) { if (wavefilewriter == null) { // first time in create new writer wavefilewriter = new wavefilewriter(outputfile, reader.waveform...

c# - Make an UI to look like Google Chrome / Flash CS5 -

possible duplicate: custom titlebars/chrome in winforms app i've been trying make own ui, wasn't sucess. goal: menu strip @ same place controlbox (minimize, maximize , x) just in flash cs5 , google chrome (let's tabs becomes menu strips, controlbox placed same way), has controlbox in same row. researches: i've seen many post, , i've been searching hours, find post in website , guy's answer "try put formborderstyle none , make own ui". problem is, making controlbox of windows isn't easy @ , have ui of windows (borders arround page)... any appreciated! :) here's similar question: custom titlebars/chrome in winforms app . answers there should started. that question doesn't ask control box, 1 of answers links set of articles called " drawing custom borders in windows forms ", , first article in series shows how override wm_nchittest . if check mouse coordinates passed wm_nchittest, , return c...

forms - Call key press with javascript -

i trying press tab , enter key through javascript/jquery on page load. like: if(event.keycode == 13){ $("#submit").click(); } this work when user presses enter key want javascript stuff user on page load. you can simulate keypress code: function simulatekeypress(character) { jquery.event.trigger({ type : 'keypress', : character.charcodeat(0) }); } thanks thread: is possible simulate key press events programmatically? but ghyath serhal pointed out, there might better way simulate keypress catch same code.

objective c - "unrecognized selector" on "Save" button? -

could me understand error? project modalcontroller appears , let user save new text in mutablearray. receive error debugger : 2011-07-21 16:53:52.362 aeffa[18089:207] -[__nsarrayi addobject:]: unrecognized selector sent instance 0x4b042d0 i checked code can't see what's wrong : "cancel" button works fine, "save" button launches error. here's code : - (void)viewdidload { [super viewdidload]; self.navigationitem.leftbarbuttonitem = [[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel target:self action:@selector(cancel:)] autorelease]; self.navigationitem.rightbarbuttonitem = [[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbutto...

iframe - How to load the yandex to iiframe without redirect -

<iframe style="border:0;width:100%;" src="http://yandex.ru/yandsearch?text=text&lr=213"></iframe> this code redirecting me yandex.ru .. why?? how load yandex page iframe without redirect? the short answer can't. yandex contains javascript code prevent users loading page in iframe: if( document.domain != "yandex.ru" ) { document.domain = "yandex.ru"; }

c# - Simple update query NOT updating. No exceptions, no errors. Just... nothing -

i trying simple update, proving difficult. don't know going on; doesn't update: here's update code: if(request.querystring["action"] == "update") { var inpage = request["inpage"]; var positioninpage = request["positioninpage"]; var categoryname = request["categoryname"]; var imagepath = request["imagepath"]; database.execute("update categories set positioninpage = " + positioninpage + ", inpage = " + inpage + " categoryname = '" + categoryname + "' , imagepath = '" + imagepath + "'"); response.redirect("~/fashion.cshtml"); } here's form code: <form method="post" action="update.cshtml?action=update"> <input type="hidden" name="categoryname" value="@request.querystring["categoryn...

gwt rpc - GWT how can I reduce the size of code serializers for RPC calls -

i found more 60% of javascript code generated gwt on application rpc serializers. found serializers not shared between service interfaces, mean if have example accountdto type referenced on 2 rpc service interfaces, 2 serializer classes instead of 1 same type. in order reduce size of compiled code thinking maybe use deferred binding in order replacement of services interfaces have 1 big interface. if possible, maybe gwtcompiler produce 1 accountdto serializer instead of 2. i'm not sure idea or if there better solution problem. what trying implement this: // define new interface extends service interfaces public interface genericservice extends remoteservice, accountingservice, financialservice,..., { } public interface genericserviceasync extends accountingserviceasync, financialserviceasync, ..., { } // @ application.gwt.xml do: <module> ... ... <replace-with class="com.arballon.gwt.cor...