Posts

Showing posts from February, 2014

java - Regex to find variables and ignore methods -

i'm trying write regex finds variables (and variables, ignoring methods completely) in given piece of javascript code. actual code (the 1 executes regex) written in java. for now, i've got this: matcher matcher=pattern.compile(".*?([a-z]+\\w*?).*?").matcher(string); while(matcher.find()) { system.out.println(matcher.group(1)); } so, when value of "string" variable*func()*20 printout is: variable func which not want. simple negation of ( won't do, because makes regex catch unnecessary characters or cuts them off, still functions captured. now, have following code: matcher matcher=pattern.compile(".*?(([a-z]+\\w*)(\\(?)).*?").matcher(formula); while(matcher.find()) { if(matcher.group(3).isempty()) { system.out.println(matcher.group(2)); } } it works, printout correct, don't additional check. ideas? please? edit (2011-04-12): thank answers. there questions, why need that. , right, in case of bigger,...

javascript - Single page application with login and search robots -

in work javascript single page application, have run problem. whole idea behind project, avoid page reload. when user comes application won't need make reloads. done jquery , backbone.js , php service. i have static index.html file, hide login container , application container. show login container, if user not recognize application, , if have auth show application. if auth: application.show() elif not auth: login.show() // gmail or facebook etc.: information + login-form i wan't show users aren't authenticated, both login-form , general info. important site can found robots google etc. can done 2 different files, giving me reload? site.com , login.site.com. solution irritates me, because login, now, quite instant. not sure question if want check if user in authenticated, try ajax call. if fails "401 unauthorized" user needs login...

java - Hibernate OneToOne with a specific clause -

if knows how-to: i have entity @entity public class anentity { ... private string propertya; private string propertyb; private string propertyc; } and strings propertya, propertyb , propertyc stored in different table refference anentity, name , value fields, like: @entity public class property { ... private string name; private string value; } can specify onetoone joins in anentity clause, i'd have like: @entity public class anentity { ... @onetoone(table = "properties") @joincolumn("anentity_id") @wherejointable(name = "propertya") private string propertya; ... } any appreciated! thanks! i think easiest way this: @entity public class anentity { @onetomany @joincolumn("aentity_id") @mapkey(name = "name") private map<string, property> properties; ... public getpropertya() { return properties.get("propertya...

c# - Querying a user's group membership from Active Directory -

i wanted know if there's fast way query information active directory. specifically, i'm trying query current user's "member of" groups starts given string, "abc-" example. if 1 can me appreciate it. linq activedirectory option can consider.

javascript - jquery help with next() function -

i have html markup looks this, </a> <nav> <ul> <li><a href=""><img src="/media/icons/view.jpg" alt="views"/> 210</a></li> <li><a href=""><img src="/media/icons/like.jpg" alt="likes"/> 45</a></li> <li class="jobs"><a href="">52 new jobs</a></li> </ul> </nav> <ul class="job_listings"> <li><a href="">outbound telesales assistant &gt;</a></li> <li><a href="">business development manager &gt;</a></li> </ul </li> the .job_listings hidden on dom ready , needs show when li.jobs a clicked, have tried following, jquery: $('#jobwall .jobs ...

php - Retrieve DocComment from array element using Reflection? -

given array this: array( /** i'm foo! */ 'foo' => 1, /** i'm bar! */ 'bar' => 2, ); is possible retrieve doccomments array elements? far know, reflection api doesn't provide mechanism this. if possible, i'm guessing have pretty "creative" solution. the reflection api not able (or not @ if it's not class). per example, code: <?php $bar = array( /** i'm foo! */ 'foo' => 1, /** i'm bar! */ 'bar' => 2, ); the reflection api useless here (no classes, no functions). can still using tokenizer : $code = file_get_contents('input.php'); $tokens = token_get_all($code); foreach ($tokens $key => $token) { if (is_array($token)) { if ($token[0] == t_doc_comment) { ($i=$key+1; $i<count($tokens); $i++) { if (is_array($tokens[$i]) && $tokens[$i][0] != t_whitespace) { echo ...

html to pdf convertion in asp.net -

i wanted convert html page pdf format in asp.net 3.5. have many images , tables.the alignment of these images , tables should not changed while conveting pdf. the itextsharp library can this. here's example code .

Authoring a plugin function with jQuery -

hey dudes, have following function: $.fn.slideout = function(speed,dir) { this.animate({ dir: '-1000px' }, speed); }; but direction ( dir ) isn't being carried on , isn't giving me error either. i'm calling so: $('#element').slideout(500,'top'); so quesiton = why not animating? :( if want use variable property name, cannot use object literals. first have create object , set property "array access" syntax: $.fn.slideout = function(speed,dir) { var options = {}; options[dir] = '-1000px'; this.animate(options, speed); };

Integrating a .htaccess into a httpd.conf -

i'vee got following htaccess file in /connect folder , need integrate httpd.conf file (which has commands already): /connect/.htaccess setenv application_env development rewriteengine on rewritebase /connect rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^.*$ index.php [nc,l] httpd.conf ... namevirtualhost *:80 <virtualhost *:80> documentroot /var/www/html/alter servername www.mysite.com <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{http_host} !^www\. rewritecond %{https}s ^on(s)| rewriterule ^ http%1://www.%{http_host}%{request_uri} [l,r=301] ... .... i'm not sure how can fit above below? a .htaccess guts of block in httpd.conf, you'd want like <virtualhost *:80> documentroot ... servername ... etc.... <directory /var/www/html/alter> ... guts of .htaccess here ... </directory...

Why do we add a semicolon in java PATH variable and not for the JAVA_HOME variable? -

i have basic question ask, why need add semicolon @ end of path variable , why don't add semicolon in java_home variable? i read lot of books , forums, to separate different paths in path variable? or tell system or jre not further after that. java_home variable jre more files , extensions jdbc drivers etc. in future development. path operating system-specific idea. means, "when type command, check these paths well". current directory in on searched paths default. if think minute, can imagine how of pain use command line if didn't have idea of path. so, given path (with multiple directories), need way separate entries. each operating system can use whatever character, 2 popular semi-colon (on windows) , colon (on systems unix, e.g. mac os x). java_home points wherever preferred java installation located. 1 value, no need character separate entries. as aside, you'll run classpath, paths of of libraries (jars) , resources (e.g. propert...

sql server - How do I extract a database schema using T-SQL? -

i'd extract xml schema database (a "database schema") using t-sql query in sql management studio, rather c# code. schema should include tables in database. i can single table using following: declare @schema xml set @schema = (select * student xml auto, elements, xmlschema('studentschema')) select @schema but how combine remaining tables? of tables related in way. see this question , discusses how in code. you alway use sp_msforeachtable , dynamic sql: exec sp_msforeachtable ' declare @schema xml set @schema = (select * ? xml auto, elements, xmlschema(''?schema'')) select @schema ' you may have naming issue schema name since think have dbo. or schema prefix table name.

internet explorer - Kohana 3 Auth in IE -

kohana auth not validating in ie. have read stuff discussions on v.2 changing user_agent user_ip... presumably in orm file in auth module, how ever not resolving issue. another post on v.2 suggest using <?php defined('syspath') or die('no direct access allowed.'); /** * @package session * * session driver name. */ $config['driver'] = 'native'; /** * number of page loads before session id regenerated. * value of 0 disable automatic session id regeneration. */ $config['regenerate'] = 0; // kludge: windows xp sp3 running ie-7 , 8 // http://bit.ly/gpcv67 $config['validate'] = array('ip_address'); they not mention use @ however. we found kind of late in testing (where thread lack of importance of software engineering in school?) , pretty locked using auth @ point. have been beating head against wall hours on , have gotten virtually no where. please help! thank you, -david edit - noticed talking k...

.net - Where can one find a complete list of System Color Resources in a WPF / XAML project? -

i have made updates of system resource colors in style, there still random yellow hover , border colors showing on application. are there hidden or standard themes used if there isn't specified style provided? a link or list of system resources given here great confirm have them all. thanks in advance help! all of system colors listed in systemcolors class. can explicit color and/or brush, or resource keys same. this doesn't mean brushes used in case though. more specific example narrow down brush coming from.

c# - With VS 2010 create ASP.NET composite custom server control with JQuery (CDN) as embedded resource? -

first time asking question sorry if incorrect. after beating head against wall, , no hair pad asking direction. books, posts , articles on trying @ least 2 years old , don't cover vs 2010. can point me site/book/whatever gives meaningful examples of have asked in title? i trying create asp.net custom web control, using vs 2010 , asp.net, , using embedded rousource javascript file simple jquery routine attaches click event onto checkbox. trying on own weekend have successfullly gotten web user control work without having script embedded, can't seem references work correctly when using custom server control. i can list simple code don't want overwelm post code have seen on years. thanks patience, , hope able contribute more on levels. thanks, fsbarker i think lot problem http://weblogs.asp.net/dwahlin/archive/2007/04/29/creating-custom-asp-net-server-controls-with-embedded-javascript.aspx

xml serialization - XMl deserializer in C# -

i have following xml, , want deserialize streams of product1, syntax in c#? thanks. couldn't find documentations online. <arrayofproductdata> - <productdata> <productname>product1</productname> <productid>1</productid> - <streams> <productid>1</productid> <name>current stream</name> <id>1</id> </streams> - <streams> <productid>1</productid> <name>stream 1.1</name> <id>2</id> </streams> </productdata> - <productdata> <productname>product2</productname> <productid>2</productid> - <streams> <productid>2</productid> <name>current stream</name> <id>1</id> </streams> - <streams> <productid>2</productid> <name>stream 1.2</name> <id>2</id> </streams> </productdat...

C# .NET Unexpected Typing - Expanded foreach explanation -

as refactoring code morning, noticed weird behavior. iterating on collection of type a . declaration , usage of enumerable split (i declaring , defining variable using linq, iterating on later via foreach). however, when changed type of enumerable ienumerable<a> ienumerable<b> , left foreach following enumerable of type ienumerable<b> . ienumerable<b> enumerable = someenumerableofb foreach(a in enumerable) following contrived example of behavior found: ienumerable<ienumerable> enumerables = enumerable.range(1, 5).select(x => new list<int> { x }); foreach (stringcomparer in enumerables) //this compiles { //do here } foreach (int in enumerables) //this doesn't compile { //do here } ienumerable<stringbuilder> stringbuilders = enumerable.range(1, 5).select(x => new stringbuilder(x.tostring())); foreach (filestream sb in stringbuilders) //this doesn't compile {...

database design - Display Order in DB -

what's best way track display order in database? have been using integers (1 being displayed first , 5 last) worry corrupting data somehow. is there better way? for simple display purposes use simple integer increments of 10 if number manipulated manually. leaves room few adjustments. or if number maintained code, go increments of 1. when model more "important" or busineslike, consider adjacency list model. performance , scalability may of concern here, because if use number in list of 10,000 items, may have lock/update 10,000 rows. of course, use larger increments , peeky & sneaky @ cost of more complexity. adjacency list not have problem, more difficult query on other hand.

javascript - Does ES5 have a counterpart to __lookupGetter__? -

i know object.defineproperty lots of fun , great replacement __definegetter__ , __definesetter__ nonstandard apis, there similar counterpart __lookupgetter__ ? or way of achieving similar thing? i'm not sure of __lookupgetter__ semantics es5 provides new api object.getownpropertydescriptor gives descriptor object containing attributes of property , either value or get and/or set functions. eg. object.getownpropertydescriptor("foo", {get foo() { return 5} }).get will give getter function

iphone - In IB, I created a table and now want to assign a variable to it -

i want refer table, there isn't variable in .h file wasn't required when created. table works great, can add/display/etc. i tried adding "mytable" .h , linking in ib (the table linked "view" , could/did select "mytable"), first try didn't work , afraid of messing (somewhat) working app ;-) hope question makes sense!!! thx! if understand correctly, want link table code. if that's case, in header file need add property @property(nonatomic, retain) iboutlet uitableview *mytable; and synthesize in .m file so @synthesize mytable; once you've done able link in interface builder. bare in mind if want populate/interact table further need set data source/delegate of table file's owner. here tutorial on how - http://www.switchonthecode.com/tutorials/how-to-create-and-populate-a-uitableview does answer question?

c# - Order and OrderProduct -

i seem having problem when handling order shopping cart. firstly have create instance of order(orderid,custid,...)....but in orderproduct how assign orderid (it set has identity specification in sql), because required foreign key in orderproduct in database. public class order { string customerid; string shipping_firstname; string shipping_lastname; string shipping_address; string shipping_city; string payment_firstname; string payment_lastname; string payment_address; string payment_city; } orderproduct class, public class orderproduct { string orderid; string productid; string quanity; } try make objects represent things in real life. might sound little weird object named orderproduct doesn't represent in real life , bad design. after relationship between product , order . list<product> in class order ? can fill list products , remove product...

How to make script that make some things on SQL Server 2008? -

i need make things on sql server 2008 , need on file or script can take on computer has sql server 2008 i need this: to add field f1 (nvarchar) , f2 (bit) table mytable1 and make new table mytable2 to delete table3 how combine 1 script file ? thanks in advance you can try this, work in sql server management studio: alter table dbo.mytable1 add f1 nvarchar(100) alter table dbo.mytable1 add f2 bit go create table dbo.mytable2(... define columns here.......) go drop table dbo.table3 go this uses go separator keyword ssms - it's not valid sql keyword (e.g. cannot run code using sql server client library).

xcode - How to display "the" Assistant Editor? -

Image
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphone101/articles/05_configuringview.html in xcode, select view controller’s nib file (myviewcontroller.xib). display assistant editor. make sure assistant displays view controller’s header file (myviewcontroller.h). control drag button in nib file method declaration area in header file. how step 2? how display "the" assistant editor? it's exclusive xcode 4:

dictionary - how to increment tuple values and search a string in a loop in python -

i have code. arfffile = [] inputed = raw_input("enter evaluation name including file extension...") reader = open(inputed, 'r') verses = [] line in reader: verses.append(line) line in verses: if line.split('@') == "@": verses.pop(line) numclusters = int(raw_input("enter number of clusters")) clusters = {} in range(1,numclusters+1): clusters["cluster"+str(i)] = 0 print clusters # if verse belongs cluster, increment cluster count 1 in dictionary value. verse in verses: k in clusters: if k in verse: clusters[k] += 1 else: print "not in" print clusters yeslist = [] verse in verses: k in clusters: if k not in yeslist: yeslist.append((k,0)) elif k in yeslist: print "already in" + k verse in verses: k in clusters: if k in verse , "yes" in verse: yeslist....

asp.net profiles - ProfileCommon - where is it? -

i've added web config: <profile enabled="true" > <properties > <add name="gender" type="string"/> <add name="age" type="int32"/> </properties> <providers> <clear/> <add name="aspnetsqlprofileprovider" type="system.web.profile.sqlprofileprovider" connectionstringname="applicationservices" applicationname="/"/> </providers> </profile> though, if try use profilecommon class, doesn't find it. shouldn't have been generated when uilt project? using system.web.profile; did import namespace?

objective c - Storing Custom Object in NSMutableDictionary -

i trying store custom object in nsmutabledictionary. after saving when read object nsmutabledictionary it's null. here code //saving nsmutabledictionary *dict = [[nsmutabledictionary alloc] init]; customobject *obj1 = [[customobject alloc] init]; obj1.property1 = @"my first property"; [dict setobject:obj1 forkey:@"firstobjectkey"]; [dict writetofile:[self datafilepath] atomically:yes]; // reading nsstring *filepath = [self datafilepath]; nsmutabledictionary *dict = [[nsmutabledictionary alloc] initwithcontentsoffile:filepath]; customobject *tempobj = [dict objectforkey:@"firstobjectkey"]; nslog(@"object %@", tempobj); nslog(@"property1:%@,,tempobj.property1); how can store custom class object in nsmutabledictionary? writetofile method can store standard types of objects plist. if have custom object you'd have use nskeyedarchiver / nskeyedunarchiver this.

linux - Variables based on targets in Makefile -

when creating makefile, im trying figure out how(if) can change variable based on target. so likes this: ver = $(if target=release 1.0.0 elseif target=nightly 20110411) nightly: @@echo ${ver} >> version.txt release: @@echo ${ver} >> version.txt if make gnu make, target-specific variable allowed. example, in question's case, following definitions meet purpose: nightly: ver = 20110411 release: ver = 1.0.0 nightly: @echo ${ver} release: @echo ${ver} hope helps

c++ - (MFC) CListBox -> Edit Item in List? -

i'm using clistbox control mfc. possible retain data inside list item edit it, without deleting re-adding it? thanks! you can extending clistbox. check out code project article .

python - List lookup faster than tuple? -

in past, when i've needed array-like indexical  lookups in tight loop, use tuples, since seem extremely performant (close using n-number of variables). however, decided question assumption today , came surprising results: in [102]: l = range(1000) in [103]: t = tuple(range(1000)) in [107]: timeit(lambda : l[500], number = 10000000) out[107]: 2.465047836303711 in [108]: timeit(lambda : t[500], number = 10000000) out[108]: 2.8896381855010986 tuple lookups appear take 17% longer list lookups! repeated experimentation gave similar results. disassembling each, found them both be: in [101]: dis.dis(lambda : l[5]) 1 0 load_global 0 (l) 3 load_const 1 (5) 6 binary_subscr 7 return_value for reference, typical 10,000,000 global variable lookup/returns take 2.2s. also, ran without lambdas, y'know, in case (note number=100,000,000 rather 10,000,000). in [126]: timeit('t[500]', ...

WCF Rest Error Handling -

i'm having mind blowing problem using wcf 4.0 restful service. trying make rest service return, in case of error, xml document describing problem ex : <errorhandler> <cause>resource not available</cause> <errorcode>111103</errorcode> </errorhandler> in order make i've created default rest service using template provided visual studio here service class : public class service1 { // todo: implement collection resource contain sampleitem instances [webget(uritemplate = "")] public list<sampleitem> getcollection() { // todo: replace current implementation return collection of sampleitem instances\ // throw new webexception("lala"); throw new webfaultexception<errorhandler>(new errorhandler { cause = "resource not available", errorcode = 100 }, system.net.httpstatuscode.notfound); ...

silverlight - WP7 - Databinding + Italics + Wordwrap issue -

here trying do. can't seem able figure out solution yet: i have 2 string data sources webservice , on front end want combine them single sentence separated comma. the first part want in normal font, second part want in italics i want sentence word wrap i using mvvm want how bind these string data sources textblock how... the cases want able handle: normal: ex. sentence part 1, this sentence part 2 no second part no comma ex. sentence part 1 still want able word wrap the second part word wraps ex. sentence part 1, this sentence part 2 wrapped second line also second part word wrapping first part wordwraps followed second part there seems no easy solution. 1 can think have propertychangedeventhandler notifies me when strings returned webserver, format string in codebehind... in order achieve effect trying achieve continuous word wrapping italic formatting can sensibly achieved using <run> element within textblock . however, cannot b...

php - Alternative to ldap_rename for Sun Directory Servers -

php provides great function copying or moving directory records within ldap. unfortunately ldap_rename function doesn't seem work on sun directory . alternatives exist change account's ou without having create new account? my end goal have simple method switch between 2 ou's, such as: cn=username,ou=admin,dc=uaa,dc=alaska,dc=edu to cn=username,ou=student,dc=uaa,dc=alaska,dc=edu you can ldif. on directory point of view, job want called dn modification, there 2 ldap verbs moddn , modrdn . it can done in ldif way in openldap: dn: cn=username,ou=admin,dc=uaa,dc=alaska,dc=edu changetype: modrdn newrdn: cn=username deleteoldrdn: 0 newsuperior: ou=student,dc=uaa,dc=alaska,dc=edu i use way accros active directory : dn: cn=username,ou=admin,dc=uaa,dc=alaska,dc=edu changetype: moddn newrdn: cn=username deleteoldrdn: 1 newsuperior: ou=student,dc=uaa,dc=alaska,dc=edu be careful , copy/delete different moddn , modrdn in first solution create new objects (...

loops - Execute statement every N iterations in Python -

i have long loop, , check status every n iterations, in specific case have loop of 10 million elements , want print short report every millionth iteration. so, doing (n iteration counter): if (n % 1000000==0): print('progress report...') but worried slowing down process computing modulus @ each iteration, 1 iteration lasts few milliseconds. is there better way this? or shouldn't worry @ modulus operation? how keeping counter , resetting 0 when reach wanted number? adding , checking equality faster modulo. printcounter = 0 # whatever while loop in python while (...): ... if (printcounter == 1000000): print('progress report...') printcounter = 0 ... printcounter += 1 although it's quite possible compiler doing sort of optimization already... may give peace of mind.

iphone - memory management and class member variable -

i have following code: @interface reservation : rkobject { nsnumber * _uid; nsnumber * _did; nsnumber * _rid; nsstring* _origin; nsstring* _destination; nsstring* _time_range; nsdate * _start_date; nsdate * _end_date; } @property (nonatomic, retain) nsdate * start_date; @property (nonatomic, retain) nsdate * end_date; @property (nonatomic, retain) nsnumber * uid; @property (nonatomic, retain) nsnumber * did; @property (nonatomic, retain) nsnumber * rid; @property (nonatomic, retain) nsstring * time_range; @property (nonatomic, retain) nsstring * origin; @property (nonatomic, retain) nsstring * destination; @end #import "reservation.h" @implementation reservation @synthesize time_range= _time_range; @synthesize origin=_origin; @synthesize destination=_destination; @synthesize uid=_uid; @synthesize did=_did; @synthesize rid=_rid; @synthesize start_date=_start_date; @synthesize end_date=_end_date; + (nsdictionary*) elementtopropertyma...

Reusing an Open Source CRM -

i looking creating simplified version of crm without having reinvent wheel on of base functionality. would please recommend open source crm product use? note: interested in solutions php or java. have looked @ sugarcrm? it's pretty mature might not meet "simplified" qualifier, if in shoes i'd consider starting there. started life open-source project , there still "community edition". consider, however, have little familiarity crm in specific, can't comment 1 way or on quality of sugarcrm. luck.

dependency injection - JSF 2.0 + Primefaces richtext editor -

<p:editor value="#{editorbean.value}" widgetvar="editor" width="686" height="390" language="en" align="center"> </p:editor> following rich-text editor bean picked primefaces @managedbean(name = "editorbean") @sessionscoped public class editorbean { private static final string managed_bean_name = "editorbean"; private string value; public static editorbean getcurrentinstance() { return (editorbean) facescontext.getcurrentinstance() .getexternalcontext().getrequestmap().get(managed_bean_name); } public void setvalue(string value) { this.value = value; } public string getvalue() { return value; } } apart have bean a. have method inside populates html table. want when user opens editor, should pre-populated html table data , of course changes should reflected (string: value). therefore, can trying tie both values togeth...

java - How do I write a constructor that initializes 52 card objects -

this need do: this constructor initializes deck 52 card objects, representing 52 cards in standard deck. cards must ordered ace of spades king of diamonds. here attempt @ it: private card[] cards; string suit, card; private final int deck_size = 52; public deck() { cards = new card[deck_size]; string suit[] = {"spades", "hearts", "clovers", "diamonds"}; string card[] = {"ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "joker", "queen", "king"}; (int c = 0; c<13; c++) (int s = 0; s<4; s++) { cards.equals(new card(suit, card)); } } it giving me error part "(new card(suit, card));" saying constructor card(string[], string[]) undefined. im not sure if allowed add constructors. code written include card(int, int) though. ok this? ...

c# - The following code always fails with 400 bad request -

function sendeditcommand() { jquery.ajax({ url: 'http://localhost:15478/service.svc/gettest', type: 'get', contenttype: "application/json; charset=utf-8", datatype: "json", success: function () { alert('success'); }, error: function(request, status, error) { alert(error); } }); } jquery(document).ready(function () { sendeditcommand(); }); <configuration> <system.web> <compilation debug="true" targetframework="4.0" /> </system.web> <connectionstrings> <add name="entities" connectionstring="metadata=res://*/data.techiecms.csdl|res://*/data.techiecms.ssdl|res://*/data.techiecms.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=localhost\mss...

time - Subtracting "variable[#]" with two digits in python? -

i'm building script in python calculate amount of time in between hours entered user lets example did following time = input("enter times:") and user entered 3,11 show start time three, , end time 11. therefore, time equal 3,11. want able subtract show there 8 hour difference i tried using timesub= (int(time[3])-int(time[1])) but gives me -2 because time[3] equal 1. how make use 11 instead of 1? time_input = raw_input("enter times:") time_parts = time.split(',') time_diff = int(time_parts[1]) - int(time_parts[0])

sockets - the time() function (python) -

if data.find('!google') != -1: nick = data.split('!')[ 0 ].replace(':','') if last_google + 5 > time.time(): sck.send('privmsg ' + chan + " :" + ' wait few seconds' + "\r\n") else: last_google = time.time() try: gs = googlesearch(args) gs.results_per_page = 1 results = gs.get_results() res in results: sck.send('privmsg ' + chan + " " + res.title.encode("utf8") + '\r\n') sck.send('privmsg ' + chan + " " + res.url.encode("utf8") + '\r\n') print except searcherror, e: sck.send('privmsg ' + chan + " " + "search failed: %s" % e + " " + '\r\n') ok i'm trying make script wait few seconds before us...

javascript - Bing Maps streetview -

i'm using bing maps 7.0 ajax control api , wondering how display streetview. there doesn't seem way, can't case. there way? thanks, chris microsoft street*side* (streetview google's brand) available via bing maps website (www.bing.com/maps/explore), or using bing maps extended modes dll in silverlight application only. it not available in ajax v7.0 control. see here information on how add streetside view bing maps silverlight application: http://www.bing.com/community/site_blogs/b/maps/archive/2009/12/10/adding-streetside-and-enhanced-birds-eye-to-your-applications.aspx

asp.net mvc 2 - View is blank even though Firebug sees HTML -

my master page looks this: <%@ master language="c#" inherits="system.web.mvc.viewmasterpage" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <link rel="stylesheet" href="../../content/css/jquery.mobile-1.0a4.1.min.css" /> <script src="../../scripts/jquery-1.5.1.min.js"></script> <script src="../../scripts/jquery.mobile-1.0a4.1.min.js"></script> <title>test</title> </head> <body> <div> <asp:contentplaceholder id="maincontent" runat="server"> </asp:contentplaceholder> </div> </body> </html> and view looks this: <%@ page title="" language="c#...

recursion - Trying to reverse a list in Scheme -

be forewarned: homework problem. i'm trying write scheme function reverses list. '(1 2 3) becomes '(3 2 1), etc. i'm not allowed use predefined function this. am on right track wrote here? ;myreverse (define (myreverse list) (if (null? list) '() (append (myreverse(cdr list)) car list))) thanks! well, using list name going odd, since scheme lisp-1. call lst instead. think can foldl , cons , '() , , lst .

sockets - Running blackberry app into multiple emulators at the same time -

i developing blackberry application , i'm trying devices communicate. trying out socketdemo app , shed light socket process (which no different other platform far). only problem can't test app since can't app 2 different emulators. how accomplish this? if not need hook second simulator debugger (for breakpoint setting, etc), getting application run simultaneously on 2 simulators can done easily. build application, , run jde; standard procedure. then, outside jde, start simulator (it cannot same one), and, when that's , running, choose file->load java application second simulator's window menu. select .cod of application built. application installed onto second simulator, , either start automatically, or can start clicking on icon (depending on how project set up). with 2 simulators on same machine, applications need communicate through network, may needed change ports in .bat file launches second simulator, before starting -- otherwise, secon...

visual studio 2010 - How does one compile a CUDA Toolkit 4.0 RC2 program under VS2010 or VS2008? -

i'm complete cuda beginner , i'm trying figure out how write , compile test cuda program using visual studio. i have cuda 4 toolkit installed , both 2008 , 2010 versions of visual studio installed. read starting cuda 4.0, support vs100 compiler has been added, have no idea how set project use nvcc , whether or not need compile basic program. if there no support vs100, gladly use vs2008 , vs90 compiler, still don't know how make project use cuda 4.0 compiler. i grateful if explain how done. thank in advance! i wrote couple of tutorials on how this. http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/ http://www.ademiller.com/blogs/tech/2011/04/using-cuda-and-thrust-with-vs-2010-part-2-x64-builds/ these 4.0 rc not rc2 should fine. first thing i'd recommend install nvidia nsight 1.51. solve of basic setup issues you. need both vs 2010 , 2008 v90 compiler. then work through tutorials.

javascript - nodejs child_processes.exec can not return 'nohup' command -

i write function of nodejs execute 'nohup' command , send success result http response. function _nohup(cmd,res){ var child = exec('nohup ./' + cmd + '.sh &', function (error, stdout, stderr) { res.writeheader(200); res.end("start process success!"); }); } but when call function url address, response data can not return. child_process.exec() waits child process exit , invokes callback. in case, you've spawned background process, presumably isn't ever exiting. you want child_process.spawn() : http://nodejs.org/docs/v0.4.9/api/child_processes.html#child_process.spawn

web applications - Is MVC a golden hammer for web apps? -

the more around see mvc. except drupal of php cms systems rely on mvc. in fact last 2 projects worked on based on mvc , not web sites web front end communication infrastructure. safe assume mvc golden hammer for, if not then, web apps? it idea medium large sized web applications. but following mvc paradigm not guarantee code.

Rails doesn't use human name for error message -

in translation file activerecord: models: subject_choice: "subject choice" subject_preference: "subject preference" art_subject_choice: "group 1 preference" science_subject_choice: "group 2 preference" attributes: student: in_class: "class" subject_prefernce: math_preference_type: m1: "m1" m2: "m2" m1_m2: "m1>m2" m2_m1: "m2>m1" subject: subject_type: science: "science" art: "art" elective: "elective" the validation done in subject_preference model. error show on page "subject preference base art priority cannot same science priority." how can make display model name correctly? update: want rid of "subject preference base", how can it? thanks errors[:base] << "duplicated priority in science subject" i tried different approach, exam...

Windows Mobile - Internet Usage C# -

i need monitor internet traffic (both upload , download) on windows mobile. there api available monitor internet data traffic on windows mobile (c#)? using opennetcf in project. can use api opennetcf is available. unfortunately no, there no api monitor traffic (in managed or native code). best solution create ndis intermediate filter driver of computations, stores results , exposes api retrieving results. has written in c.

About redirecting page to another with querystring in asp.net c# -

hi creating online quiz. here in 1st form have dropdownlist list of tests & start button. in click of start button creating random list of questions(random ids). after clicking start button 2nd form appears here questions & answers , next button displays. after clicking next button next random question i.e (2nd id list created in first form) appear. want identify each question id in addressbar when clicking next question.that means first form : main.aspx redirects 2nd form(startexam.aspx?id=1) when click next button in form should identify question id. asp.net c# thank you. do mean have this: http://www.example.com/form.aspx?qid=1 ? if yes, can value querystring parameter qid request.querystring["qid"]; hope helps. if misunderstand said, please post code.

flash - How do I implement a infinite list in Flex (hero) -

i'm new flex/actionscript (.net/java has been main playground far). i'm trying build flex app has list meant , behave infinite list (of items - can object). idea user should able scroll or down , never reach end of list in either direction. an example list of numbers. scrolling show negative numbers; scrolling down show positive ones. now, list simple flex spark list (using flex hero). bound data provider arraylist. my initial idea listen scroll event , add/remove items needed. however, in current build of flex hero, there bug doesn't raise scroll events vertical scrollbars ( http://bugs.adobe.com/jira/browse/sdk-26533 ). so, i'm using workaround suggested in link above (i.e listening propertychanged event of list's scroller's viewport. event though gives me current verticalscrollposition. and looks default spark list supports smooth scrolling , raises event many times before list scrolling comes standstill (it nice visual effect). now, need : ...

c# - How to add items to dynamically created select (html) Control -

hi how add items dynamically created select (html) control.. thanks for adding items on server side, use htmlselect.items property. example, var select = control htmlselect; // may not needed var items = select.items; // add items collection. items.add(new listitem("apples", "1")); items.add(new listitem("bananas", "2")); items.add(new listitem("cherries", "3"));

monitoring - how to conntracking in suse9 ? ( ip_conntrack ) -

i'm working on suse-10 environment , using /proc/net/ip_conntrack file monitor net conntracking : tcp 6 431982 established src=.. dst=.. sport=34846 dport=993 packets=169 bytes=14322 ... but i'm working suse-9 environment , weevil need file monitor net conntracking! in suse-9 /proc/net/ip_conntrack file show : udp 17 30 src=.. dst=.. sport=57767 dport=53 [unreplied] src=.. dst=.. sport=53 dport=57767 this not show packets , bytes ! needed packets , bytes i quite sure because connection [unreplied] - reply see bytes , packets. if not true try install conntrack tool: # conntrack /usr/sbin/conntrack conntrack -l show data file /proc/net/ip_conntrack does. conntrack great monitoring allows show events using: conntrack -e, way don't have poll /proc/net/ip_conntrack anymore.

c# - Can AutoMapper Map Between a Value Type (Enum) and Reference Type? (string) -

weird problem - i'm trying map between enum , string , using automapper: mapper.createmap<myenum, string>() .formember(dest => dest, opt => opt.mapfrom(src => src.tostring())); don't worry im using .tostring() , in reality i'm using extension method on enum ( .todescription() ), i've kept simple sake of question. the above throws object reference error, when im doing setting mapping. considering works: string enumstring = myenum.myenumtype.tostring(); i can't see why automapper configuration not. can automapper handle this, doing wrong, or bug automapper? any ideas? edit i tried using custom resolver: mapper.createmap<myenum, string>() .formember(dest => dest, opt => opt.resolveusing<myenumresolver>()); public class myenumresolver: valueresolver<myenum,string> { protected override string resolvecore(myenum source) { return source.tostring(); } } same error on same...

type cast in c compiler -

consider following example mixed mode expression supported: c = + b*10.5 a , b integers , c float. describe how data typecast appropriate format you need 'usual arithmetic conversions' in text book, or in c standard (§6.3.1.8 in c11 — iso/iec 9899:2011), reads: 6.3.1.8 usual arithmetic conversions 1 many operators expect operands of arithmetic type cause conversions , yield result types in similar way. purpose determine common real type operands , result. specified operands, each operand converted, without change of type domain, type corresponding real type common real type . unless explicitly stated otherwise, common real type corresponding real type of result, type domain type domain of operands if same, , complex otherwise. pattern called usual arithmetic conversions: first, if corresponding real type of either operand long double , other operand converted, without change of type domain, type corresponding real type long double...

html - Select multiple checkboxes for a Cucumber test -

working on big project using cucumber our frontend tests. question this, have search page group of checkboxes, "select sites:", fieldname "sites[]" when click "submit" cucumber default submits last checkbox selected when set form have checkboxes default selected. there way have cucumber select multiple checkboxes these array notation?

objective c - ObjC / iPhone dictionary grep? -

i have large number of strings in iphone app containing random combinations of letters, , i'd check each of these random strings against dictionary. i'm looking way grep each string /usr/share/dict/words , return result (or number of results) app. possible in iphone app? edit: suggestions. wanted execute grep , ideally pipe results app, after more digging , playing around nstask seems not possible on iphone. ended loading words big nsdictionary approach: nsstring* allwords = [nsstring stringwithcontentsoffile:@"/usr/share/dict/words" encoding:nsasciistringencoding error:null]; nsarray* wordarray = [allwords componentsseparatedbystring:@"\n"]; easiest way add words sqlite database , grep against them using sql query or nspredicate

c++ - Qt - What is meant by those lines of code -

in c++ gui programming qt 4 book, part of creating dialog application, there following main.cpp file: #include <qapplication> #include <qdialog> #include "ui_gotocelldialog.h" int main(int argc, char *argv[]) { qapplication app(argc, argv); ui::gotocelldialog ui; qdialog *dialog = new qdialog; ui.setupui(dialog); dialog->show(); return app.exec(); } can describe lines of code? ui::gotocelldialog ui; qdialog *dialog = new qdialog; ui.setupui(dialog); thanks. "ui_gotocelldialog.h" file generated automatically based on file "gotocelldialog.ui" contains gui dialog. ui::gotocelldialog::setupui() must called ui initialized.

android - Raising events in C# from classes -

basically attempting write generic interprocess communication implementation between c# , android platform (using java). creating socket stack simple enough wondering pattern passing in delegates tcpserver class , raising required events. the idea far is. while (connected) { //compile required data , forth switch (currentstate) { case currentserverstate.eventreceived: //raise event... break; case currentserverstate.objectreceived: break; } } so correct implementation expose array of delegates , use reflection match event names or along lines? options? how make sure raised events raised in ui thread given occurring thread created server? if don't need pass custom arguments event handler can use default eventhandler delegate uses base eventargs. declare events want make available this: public event eventhandler eventreceived; public event eventhandler ...

android - How to highlight item currently selected in a gallery? -

i've come problem. need highlight selected item within gallery. i've tried changing appearance of selected view through method: @override public void onitemselected(adapterview<?> parent, view view, int position, long id) the second parameter of view current selected view, , i'm trying in case, increase size of text. doesn't work, not if call invalidate in selected item or in entire gallery. this code use change textview text size textview textview = (textview)view; textview.settextsize(50, typedvalue.complex_unit_sp); textview.invalidate(); do know how this? thanks try statelistdrawable - looks apt situation. update: have reversed parameters in settextsize. should be: textview.settextsize(typedvalue.complex_unit_sp, 50);

visual studio - "No symbols have been loaded for this document." But they have! -

Image
as can notice symbols been correctly loaded. i created view getcompanies.cshtml using addview shortlink but, no matter do, can't debug in view. what did far: close , open solution close , open visual studio shutdown asp.net development server's deleted symbol libraries .pdb clean solution re-build solution did not (yet) shutdown windows 7 x64 :-/ i finding same behavior time time when debugging silverlight. solution clean browser's cache (on latest ie click on wheel button, developer tools), cache binary files , not load new ones. perhaps same views?

animation - Silverlight - Animating Rectangle stroke in Code Behind -

i want able fade in border in code behind (c#) when user hovers on rectangle in application. i've seen few examples of creating animations in code behind cannot them work instance. as can see, have mouseenter event @ moment, created border around object want fade in (and out when have mouseleave event) can please understand need? private void imagerect_mouseenter(object sender, mouseeventargs e) { solidcolorbrush bluebrush = new solidcolorbrush(); bluebrush.color = systemcolors.highlightcolor; imagerect.strokethickness = 3; imagerect.stroke = bluebrush; } thanks much shaun try use when want create storyboard in code behind. storyboard strybrd = new storyboard(); var mycolor = new coloranimation { }; storyboard.settarget(mycolor, imagerect); storyboard.settargetproperty(mycolor, new propertypath("(rectangle.stroke).(solidcolorbrush.color)")); ...

textinput - can we set tabindex for textbox and other controls in javascript -

can set tabindex input , other html controls using javascript. i've seen in .net. can same in javascript? thanks you can set tabindex input html-elements, in javascript: [someelement].tabindex = [number]