Posts

Showing posts from July, 2010

c# InnerException of socket in XamlParseException -

i have been developing basic c# chat application practice networking in c# , have built stable build application came across strange thing when started second instance of application in visual studio debugger. while first instance running flawlessly second instance gave xamlparseexception in initializecomponents() function. had inner exception of only 1 usage of each socket address (protocol/network address/port) permitted . what confuses me working , creating , managing of sockets being done in subsequent lines of code on end, how simple parsing of xaml giving rise exception (which parsed flawlessly in case of first instance of application running). even if program needs have exception thrown due conflicting sockets, should thrown later(while binding tcp/ while sending udp) can debug transmission throwing exception, in case fails @ first line initializecomponents() only. thanks lot in advance , please edit title/content more appropriate if needed. if code needed please c

msysgit - Windows git difftool cannot parse extcmd path with spaces -

in windows, git msys command line, run command: git difftool --extcmd=/c/program files/beyond compare 4/bcomp.exe -- file_to_diff.ext i'm struggling have extcmd parameter parsed correctly. i found correct way write command: git difftool -y --extcmd="'/c/program files/beyond compare 4/bcomp.exe'" -- file_to_diff.ext notice double quotes followed single quotes.

Yesod Hamlet type error in for all loop is confusing -

i have yesod handler returning list of type [(category, [product])] trying loop through in hamlet template. $if null rows <p>no products $else <div class="list-group menu"> $forall (category, products) <- rows <h4>#{categoryname category} $forall product <- products <p>#{productname product} - #{productprice product}</p> when compile though error message: handler/menu.hs:11:7: couldn't match type ‘[(category, [product])]’ ‘(category, t0 product)’ expected type: readert sqlbackend m1 (category, t0 product) actual type: readert sqlbackend m1 [(category, [product])] in second argument of ‘data.foldable.mapm_’, namely ‘rows’ in stmt of 'do' block: data.foldable.mapm_ (\ (category_aiv7, products_aiv8) -> { (aswidgett ghc.base.. towidget) ((blaze-markup-0.7.0.3:text.blaze.internal.preescapedtext

python - py2exe import numpy and scipy -

i used py2exe build exe of program uses scipy , numpy , next error in log file when tried run program. traceback (most recent call last): file "glp2-e admin.pyw", line 24, in <module> file "c:\python34\lib\site-packages\scipy\ndimage\__init__.py", line 161, in <module> .filters import * file "c:\python34\lib\site-packages\scipy\ndimage\filters.py", line 37, in <module> scipy.misc import doccer file "c:\python34\lib\site-packages\scipy\misc\__init__.py", line 51, in <module> scipy.special import comb, factorial, factorial2, factorialk file "c:\python34\lib\site-packages\scipy\special\__init__.py", line 629, in <module> .basic import * file "c:\python34\lib\site-packages\scipy\special\basic.py", line 18, in <module> . import orthogonal file "c:\python34\lib\site-packages\scipy\special\orthogonal.py", line 101, in <module> scipy import linalg file "c:\python34\lib\sit

IIS 8 in Windows server 2012 R2 to run classic asp and web.config -

i have old application developed using classic asp, running fine under windows server 2008 , iis 7.0. upgrade windows server 2012 r2, since application not running fine: when set detailed errors true iis generate web.config file: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <httperrors errormode="detailed" /> </system.webserver> </configuration> after "500 - internal server error" occurred in pages, if delete web.config works fine. i need enable detailed errors find out wrong pages, errors occurred after moving new server. any idea why happening!!? , should enable detailed errors? thanks in advance. i believe web.config part of asp.net, not compatible asp. it's running 32-bit version of windows 2008, whereas windows 2012 r2 64-bit. i recommend make separate app pool web site, configure (right-click , select "advanced settings...&qu

php - Refresh token validation fails with Codeception test -

i have phpleague/oauth2 server implementation, working fine, ie generating access/refresh tokens, validating etc. i have following problem. when refresh token grant_type=refresh_token console curl, new access_token, when doing test: $i->sendpost('access_token', [ 'grant_type' => 'password', 'client_id' => '111', 'client_secret' => '222', 'username' => 'exampleuser', 'password' => 'examplepass', ]); $i->seeresponsecodeis(200); $i->seeresponsecontainsjson(['token_type' => 'bearer']); // receive proper string, checked out $token = $i->grabdatafromresponsebyjsonpath('$.refresh_token')[0]; $i->sendpost('access_token', [ 'grant_type' => 'refresh_token', 'client_id' => 1, 'client_secret' => 'pass2', 'refresh_token' => $token ]); $i->

go - How to control file access in Windows? -

Image
go provides os.chmod() setting file , directory permissions. example, if want ensure file accessible current user, can following: os.chmod("somefile.txt", 0600) this works great on linux absolutely nothing on windows. after digging go source code, came across its implementation . seems s_iwrite attribute supported. how control access file or directory on windows using go? explanation windows not use traditional unix permissions. instead, windows controls access files , directories through access control . each object has acl (access control list) * controls access object. each acl list of aces (access control entries) determine access specific trustee (user, group, etc.) granted. example, file may contain ace granting specific user read access ( generic_read ) file. manipulating acls , aces done through authorization functions in windows api. * technically each object has 2 acls - dacl , sacl solution thankfully, learning of these functions

r - Looping through names in a csv file -

i trying loop through names in csv file following loop retrieve twitter data: require(twitter) require(data.table) consumer_key <- 'key' consumer_secret <- 'con_secret' access_token <- 'token' access_secret <- 'acc_secret' setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret) options(httr_oauth_cache=t) accounts <- read.csv(file="file.csv", header=false, sep="") sample data in csv file (each name in 1 1 row, first column): timberghmans alyssabereznak joshualenon names <- lookupusers(c(accounts)) for(name in names){ <- getuser(name) print(a) b <- a$getfollowers() print(b) b_df <- rbindlist(lapply(b, as.data.frame)) print(b_df) c <- subset(b_df, location!="") d <- c$location print(d) } however, not work. every new row contains twitter screenname.when type in this: names <- lookupusers(c("user1",&q

python - How to check if an element in the list exists in another list -

how check if element in list exists in list?and if append list.how can make values in list? common=[] def findcommon(interactor,interactor1): in interactor: if in interactor1: common.append(a) return common interactor=['rishi kapoor','kalkidan','aishwarya'] interactor1=['aishwarya','suman ranganathan','rishi kapoor'] you can using list comprehensions: common = [x x in iter_actor1 if x in iter_actor2] or using sets: common = set(iter_actor1).intersection(iter_actor2)

javascript - Advantages/Disadvantages of Passing a Function into Deferred's Constructor -

in playing deferred's see many different combinations of use. same, see ones differ slightly. for example... normally, see this : here merely using deferred. // see this... function dosomething(){ var deferred = $.deferred(); var myclass = new myclass(); myclass.dosomething(function () { deferred.resolve(); }); return deferred.promise(); }; occassionally, see this: here passing function deferred's constructor...then using it. // see this... function dosomething() { var deferred = $.deferred(function (deferred) { //q: there advantage doing instead? //q: mis-use? var myclass = new myclass(); myclass.dosomething(function () { deferred.resolve(); }); }); return deferred.promise(); }; my question is: is there advantage doing 2nd 1 instead? is mis-use of constructor? does practice create issue haven't seen yet? i have yet see issue's arise method 2. s

linux - How to grep and output block of string separated by spaces from a single line output -

is there way grep single line of output items separated spaces , output exact block of string begins , ends spaces? for instances, here output: ok - server: supermicro super server s/n: 0123456789 system bios: 1.1 2015-04-09|p2vol_0_memory_device_1_vdimmab=1.19;1.34;1.42 p2vol_10_system_board_19_3.3vsb=3.21;3.55;3.65 p2vol_11_system_board_20_1.5v_pch=1.5;1.64;1.67 p2vol_12_system_board_21_1.2v_bmc=1.21;1.34;1.37 p2vol_13_system_board_32_3.3vcc=3.35;3.55;3.65 p2vol_14_system_board_33_5vcc=5;5.38;5.54 p2vol_1_memory_device_2_vdimmcd=1.19;1.34;1.42 p2vol_2_memory_device_3_vdimmef=1.2;1.34;1.42 p2vol_3_memory_device_4_vdimmgh=1.19;1.34;1.42 p2vol_4_processor_3_vcpu1=1.82;1.89;2.08 p2vol_5_processor_4_vcpu2=1.82;1.89;2.08 p2vol_6_system_board_12_1.05v_pch=1.05;1.19;1.22 p2vol_7_system_board_15_5vsb=5.07;5.38;5.54 p2vol_8_system_board_17_12v=12.18;12.94;13.25 p2vol_9_system_board_18_vbat=2.87;3.67;3.78 p4tem_0_memory_device_64_p1-dimma1_temp=45;80;85 p4tem_10_processor_1_cpu1_temp=

javascript - Is a parsing between a parse of a script tag and his onload function possible? -

i wanted know if possible between script tag being parsed , executed , onload function called, other script parsed , executed ? include script directly after first script tag, , should executed loaded browser, before whole page loaded (and onload events run).

swift - Can a Complication access Healthkit when the watch screen is off? -

if watch screen off , periodic complication reload happens, can healthkit accessed? cmpedometer? yes, data both frameworks should accessible complications during periodic updates.

linux - BASH: Check if user is root -

how can check whether user root or not within bash script? i know can use [[ $uid -eq 0 ]] || echo "not root" or [[ $euid -eq 0 ]] || echo "not root" but if script invoked via fakeroot, uid , euid both 0 (of course, fakeroot fakes root privileges). but there way check whether user root? without trying root can (i.e. creating file in /)? thank you, fabian fakeroot sets custom ld_library_path contains paths libfakeroot . example: /usr/lib/x86_64-linux-gnu/libfakeroot:/usr/lib64/libfakeroot:/usr/lib32/libfakeroot you can use detect if application running inside fakeroot iterating paths , looking libfakeroot . sample code: is_fakeroot=false path in ${ld_library_path//:/ }; if [[ "$path" == *libfakeroot ]]; is_fakeroot=true break fi done echo "$is_fakeroot"

java - Why does my program not accept a custom exception? -

i trying make cat clone , i'm requiring receive input when presented - . the main(); here: import java.io.*; import java.util.*; class cat { public static void main(string[] args) { (int = 0; < args.length; i++) { try{ fileprint(args[i]); } catch(dashexception letstrythis){ catdash(); } catch(filenotfoundexception wrong) { system.err.println(string.format("%s: file not found.", args[i])); } catch (ioexception nowords) { system.err.println(string.format("%s: file can't read.", args[i])); } } } } fileprint() prints file line line , catdash() receives , prints stdin. nothing special. what i'm trying have custom exception catches - , calls catdash() (first catch block above). however, no matter what, try/catch block throws filenotfound wrong exception (second catch block above). question is, how catch specific cause , throw first before second

c# - Error When Posting Back From Drop Down .NET MVC 5 -

i new .net mvc have spent great deal of time crawling through other posts on answers problem haven't been able find anything. i working on extending identity 2.0 sample project. have been able implement drop-down using html helper on create form new applicationuser, cannot move past error " there no viewdata item of type 'ienumerable' has key 'teamlist' ". can see issue - viewmodel , model applicationuser have different type team property (icollection), have no idea it. my code below: snippet applicationuser model : [display(name = "first name")] public string firstname { get; set; } [display(name = "last name")] public string lastname { get; set; } [display(name = "hawks number")] public int number { get; set; } [display(name = "successful logins")] public int successfullogins { get; set; } [display(name = "password status")] public bool temppassword { ge

java - How to show alertdialog before asynctask start -

i want show alertdialog , input user , after that, processing inputs in asynctask alertdialog become dismissed before inputs , asynctask start execute. what should do? please me. here code; private string[] newspapers,newspapersurl,newspaperspath; private string[] choosed,choosedurl,choosedpath; private boolean[] checked; private int pernewspaper; private boolean returned = false; private alertdialog.builder builder; private fetchingnewsbychoice fetchingnewsbychoice; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); returned = alertdialogcreation(); if(returned) { fetchingnewsbychoice = new fetchingnewsbychoice((appcompatactivity)mainactivity.this,choosed,choosedpath,pernewspaper); fetchingnewsbychoice.execute(); } floatingactionbutton fab = (

java - Best practice for wrapping the body of ResponseEntity ajax style? -

with responseentity have direct control on http response; can set headers, body , http response code. , let's on client side have generic ajax data service expecting 3 response status conditions: success , fail , , error - status evaluated separately http status code, of course taken care of $.ajax . result, need generic object of sort body of responseentity , maybe below, data in jsonresponse whatever piece of data client requested; list of users, map of arbitrary data, (more on in second): responseentityfactory.java public class responseentityfactory { private enum responsestatus { success, fail, error } public static responseentity success (string message, object data) { return getresponseentity(httpstatus.ok, responsestatus.success, message, data, null); } /* additional success, fail, error factory methods */ private static responseentity getresponseentity(httpstatus httpstatus, responsestatus responsestatus, string messag

javascript - complex hex color value in three.js -

i messing around three.js , came across following example here . see following init function(i not posting whole function , part of it): function init() { renderer = new three.webglrenderer( { antialias: true } ); renderer.setpixelratio( window.devicepixelratio ); renderer.setsize( window.innerwidth, window.innerheight ); container.appendchild( renderer.domelement ); scene = new three.scene(); camera = new three.perspectivecamera( fov, window.innerwidth / window.innerheight, 1, 1000 ); camera.position.z = 100; camera.target = new three.vector3(); controls = new three.orbitcontrols( camera, renderer.domelement ); controls.mindistance = 50; controls.maxdistance = 200; scene.add( new three.ambientlight( 0x443333 ) ); var light = new three.directionallight( 0xffddcc, 1 ); light.position.set( 1, 0.75, 0.5 ); scene.add( light ); var light = new thre

angularjs - angular navigation (editing items list)--NOT WORKING -

i beginner on ionic/angularjs. developing side menu app on windows 10. populated page select statement on sqlite. , i'm edit individual item navigating edit page using state params not responding. many kind assistance: <a href="#/edit/{{task.id}}" class="item" ng-repeat="task in ourdata"> <h2>{{task.id}}</h2> <p>{{task.name}}</p> </a> .config(function($stateprovider, $urlrouterprovider){ $stateprovider .state('list',{ url: '/list', templateurl: 'templates/list.html' }) .state('edit',{ url: '/edit:taskid', templateurl: 'templates/edit.html' }); $urlrouterprovider.otherwise('/list'); }) you should insert slash / before : i edited , add controller it: .config(function($stateprovider, $urlrouterprovider){ $stateprovider .state('list',

ios - Is there frame rate limit on the iPhone? -

i test, setup opengl game's update() , render() functions in while loop on separate nsthread. runs @ 60fps. how possible? it's want actually, why doing that? thought nsthread run fast could...? seems v-synced. func setupgl(){ glthread = nsthread(target: self, selector: "glrun", object: nil); glthread.start(); } func glrun(){ //start , run opengl on separate thread setuplayer(); setupcontext(); setuprenderbuffer(); //setupdepthbuffer(); setupframebuffer(); engine.setupengine(glfloat(self.frame.size.width) * glfloat(scale), screenheight: glfloat(self.frame.size.height) * glfloat(scale)); //setupdisplaylink(); print("thread started!"); while(true){ update() render(); logger.logframe(); } } it's because ios reduces usage of hardware reasonable levels. truth not need more 60fps because screen no

android - Get Current Location on Google Map not working properly? -

i take current location put marker on map working time not working don't know why me find out fault in code. code take current location , put marker on map. this java file mapactivity.java try { if (googlemap == null) { googlemap = ((mapfragment) getactivity().getfragmentmanager() .findfragmentbyid(r.id.map)).getmap(); googlemap.getuisettings().setzoomcontrolsenabled(false); } googlemapoptions options = new googlemapoptions(); options.maptype(googlemap.map_type_normal).compassenabled(false) .rotategesturesenabled(false).tiltgesturesenabled(false); // current location locationmanager locationmanager = (locationmanager) getactivity() .getsystemservice(context.location_service); criteria criteria = new criteria(); location location = locationmanager .getlastknownlocation(locationmanager.getbestprovider(

c++ - How does shared_ptr increase counter when passed by value? -

i have sample code below. know little bit rvo (return value optimization) , how copy constructor , assignment operator skipped during optimization , return of value placed directly on memory on left. if shared pointer rvo how shared pointer know when increase counter? because reason thought shared pointer class know when increase counter based on number copies or assignment made. #include <iostream> #include <memory> using namespace std; class a{ public: a(){} a(const a& other){ std::cout << " copy constructor " << std::endl; } a& operator=(const a&other){ std::cout << "assingment operator " << std::endl; return *this; } ~a(){ std::cout << "~a" << std::endl; } }; std::shared_ptr<a> give_me_a(){ std::shared_ptr<a> sp(new a); return sp; } void pass_shared_ptr_by_val(std::shared_ptr<a> sp){ std::cout

sockets - Connecting to a device in LAN over TCP/IP using C -

i'm trying connect device(allen-bradley plc) residing in lan using c. device i'm trying connect not host application listens application (since have no control on it). once connection established, can send , receive packets requesting data. developed working application in c# (using system.net.sockets) connects , communicates device. however, c code i'm writing seems fail @ part establishes connection. here's source code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #ifdef windows #include <winsock2.h> #else #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #endif #include <errno.h> int main() { char *servip = "192.168.10.31"; in_port_t servport = 503; int sock = socket(af_inet, sock_stream, ipproto_tcp); if (sock < 0) { fprintf(stderr, "socket() failed: %s\n", strerror(errno)); exit(1); }

neo4j - Neo4jClient Transaction Error -

when try update existing node in neo4jclient without using transaction, has unique constraint on id , name property, receive exception: cypherexecutionexception: node 6 exists label user , property "name"=[mike] but when try update node in transaction, receive exception: received unexpected http status when executing request. the response status was: 404 not found the response neo4j (which might include useful detail!) was: {"results":[],"errors":[{"code":"neo.clienterror.transaction.unknownid","message":"unrecognized transaction id. transaction may have timed out , been rolled back."}]} my code this: using (var transaction = client.begintransaction()) { client.cypher .merge("(user:user { id: {id}})") .oncreate().set("user = {user}") .onmatch().set("user = {user}") .withparams(new { id = user.id, user = user })

node.js - Manage Nuget Package in VS 2015 grey out -

Image
i want use nuget download package vs 2015 node.js project, however, grey out shown below: how resolve it? this happened me when running in debug mode. make sure not debugging part of solution or vs not let this. yes, restart of vs should work if else fails.

mongodb - Bulk insert / Insert many with Play Framework, ReactiveMongo -

i building app using play framework 2.5.0 , reactivemongo , spending lot of time, stuck, on easy in web languages. that thing inserting many documents @ once. so, must use reactivemongo function bulkinsert . i found this google group had simple example, 2013 , signature changed from def bulkinsert[t](enumerator: enumerator[t]) to def bulkinsert(documents: stream[p.document], ordered: boolean, writeconcern: writeconcern)(implicit ec: executioncontext): future[multibulkwriteresult] so here tried take example , find way convert enumerator stream (did not find way so) : val schemasdocs: seq[jsobject] = { jsonschemas.fields.map { case (field, value) => json.obj(field -> value) } } val enumerator = enumerator.enumerate(schemasdocs) val schemasstream = source.frompublisher(streams.enumeratortopublisher(enumerator)) // attempt turn enumerator stream val schemasinsert = { getcollection("schemas").flatmap( _.bulkinsert(schemasstream, true) )

infinite loop in Hangman game in Python -

i trying build simple hangman game, following program creating infinite loop when letter entered user not part of word guess (it's printing "*" indefinitely). missing here? advice appreciated. import re import random folder = open("datas.txt","r") data = folder.read() word_list = re.sub("[^\w]"," ", data).split() chosen_word = random.choice(word_list) letter_player = input('enter letter pls:\n') continue_game = false masked_word = [] letter in chosen_word: masked_word.append("*") found_letters = [] def guess_letter(): letter in range(0,len(chosen_word)): if letter_player == chosen_word[letter]: found_letters.append(letter_player) masked_word[letter] = letter_player else: masked_word[letter] = '*' print(masked_word[letter]) return found_letters str_found_letters = ''.join(found_letters) print(str_found_letters) if(str_found_letters != chosen_w

linux - "xargs -a file" to copy files to a folder -

i tring use xargs -a read contents of file has list of filenames in it. my directory working in looks like: backups file1.bak file2.bak file3.bak bakfiles.txt file name filenames in it: bakfiles.txt bakfiles.txt contents: file1.bak file2.bak file3.bak so i'm trying copy file1.bak,file2.bak,file3.bak folder backups . using contents of bakfiles.txt so. i tried: xargs -a bakfiles.txt | cp {} backups but error: cp: cannot stat `{}': no such file or directory i should mention tried: xargs -a bakfiles.txt cp {} backups and error: cp: target `file3.bak' not directory this works me on windows 7 using mks toolkit version of 'xargs' cat bakfiles.txt | xargs -i '{}' cp '{}' backups/'{}'

How to implement Spring Data Jpa Dynamic Query and Joint inquiry -

current project used spring data jpa , spring boot, time found it's convinence until meet requirement, found hard deal. have buyer entity , supplier entity , middle entity(buyersupplier), if i'd search buyer phone or name or both or all, have supply many methods, below: if(phone!=null&&name!=null) list<buyer> findbyphoneandname(phone,name) else if(phone!=null) list<buyer> findbyphone(phone) else if(name!=null) list<buyer> findbyname(name) else list<buyer> findall() obviously, above code bad.and actually, business logic more complex, meantime want search buyer belong special supplier , maybe special status buyer. corresponding sql below: select b.* buyer b, buyer_supplier bs b.id = bs.buyer_id , bs.supplier_id = 1 , bs.stauts = 'activated' , b.name '%foo%' , b.phone '%123%' and want build dynamic sql, below: select b.* buyer b, buyer_supplier bs b.id = bs.buyer_id if(name != null) , b.nam

sorting - Python: comparing strings with numerals. Decoding radio call-signs -

i've got feeling core concept of might repeat question can't find it. okay, have bunch of radio callsigns , want find country of origin here . i've tried basic comparison find country location way python orders numerals , characters vs way callsigns different: in python "zr1" < "zra" == true false in callsign convention. is there anyway can change python's ordering "... 7 < 8 < 9 < < b ..." "... x < y < z < 0 < 1 < 2 ..."? you create dict mapping characters positions in "correct" ordering , compare lists of positions: import string order = {e: i, e in enumerate(string.ascii_uppercase + string.digits)} positions = lambda s: [order[c] c in s] def cmp_callsign(first, second): return cmp(positions(first), positions(second)) # (cmp removed in python 3) usage: >>> positions("zr1") [25, 17, 27] >>> cmp("zr1", "zra")

c# - What windows service state is appropriate if OnStart failed -

i have windows service on c#. in end of onstart set state service_running. what would appropriate status if onstart caught exception? also how should stop service in such event? you may set status stopped , throw exception: public override void onstart(string[] args) { . . . if(somethingwrong) throw new exception("something wrong"); }

sqlite3 - Why does SQLite not use an index when using a literal column value in the WHERE clause? -

here's sqlfiddle of example , let me explain: when have simple table this: create table forgerock (`id` int, `productname` varchar(7), `description` varchar(55)) ; and simple index on productname column this: create index test_idx on forgerock(productname); i can select data using productname in clause , index being used. nice. when add hard-coded value list of columns i'm selecting, works , index used, too: select 0 foo, 0 bar, productname, description forgerock (foo = 0 , productname in ('openidm', 'opendj')) even using hard-coded foo column in clause still uses index (as should). here's question: why index not being used when add or (foo = 1 , bar in (1)) clause? select 0 foo, 0 bar, productname, description forgerock (foo = 0 , productname in ('openidm', 'opendj')) or (foo = 1 , bar in (1)); any appreciated. once again, here's sqlfiddle . the documentation says: where

Python - Regex no group is found -

how add group regex? here regex: (?<=code )(\d+) here code: rsize= re.compile(r'(?<=code )(\d+)') code = rsize.search(codeblock).group("code") how come when run code error: indexerror: no such group ? how write regex create group named code ? edit read responses, but, question is, how append regex? the "named group" syntax little bit different: (?p<name>group) example: >>> import re >>> >>> s = "1234 extract numbers" >>> pattern = re.compile(r'(?p<code>\d+)') >>> pattern.search(s).group("code") '1234'

javascript - JS: Function call over-rides my other 2 function calls? -

Image
i trying design menu system upgrading attack skills. example, when click upgrade "strike skill", circle 3 subset skills upgrade to. the problem running function calls. last function of similar type, seems over-ride first 2 functions, instead of filling 3 circles in numbers, instead overwrites last 2 instead. why , how can fix it? the problem: skills("skills", "attack1", "i"); skills("skills", "attack2", "ii"); skills("skills", "attack3", "iii"); javascript code: function upgradebar() { menu("upgrademenu", "systemmenu"); } function menu(classid, id) { var button = dom.el("skill"); // apply div location var x = document.createelement("div"); x.setattribute("class", classid); x.setattribute("id", id); button.appendchild(x); function skills(classid, id, te

python - Wrong result for pandas timestamp - dateoffset -

strangely enough: in[]: import pandas pd pd.timestamp('2015-10-10') - pd.dateoffset(month=1) out[]: timestamp('2015-01-10 00:00:00') what doing wrong? ps: pd.show_versions() installed versions ------------------ commit: none python: 2.7.10.final.0 python-bits: 64 os: linux os-release: 3.13.0-63-generic machine: x86_64 processor: x86_64 byteorder: little lc_all: none lang: en_us.utf-8 pandas: 0.16.2 nose: 1.3.7 cython: 0.23.3 numpy: 1.9.2 scipy: 0.16.0 statsmodels: 0.6.1 ipython: 4.0.0 sphinx: 1.3.1 patsy: 0.3.0 dateutil: 2.4.2 pytz: 2015.4 bottleneck: 1.0.0 tables: 3.2.0 numexpr: 2.4.3 matplotlib: 1.4.3 openpyxl: 1.8.5 xlrd: 0.9.3 xlwt: 1.0.0 xlsxwriter: 0.7.3 lxml: 3.4.4 bs4: 4.3.2 html5lib: none httplib2: none apiclient: none sqlalchemy: 1.0.5 pymysql: none psycopg2: none you want this: >>> pd.timestamp('2015-10-10') - pd.dateoffset(month=9) timestamp('2015-09-10 00:00:00', tz=none) this may better though:

python - pyparsing Optional() & Optional() allows repetitions -

i've simple grammar: word = word(alphanums + '_') with_stmt = suppress('with') + oneormore(group(word('key') + suppress('=') + word('value')))('overrides') using_stmt = suppress('using') + regex('id-[0-9a-f]{8}')('id') modifiers = optional(with_stmt('with_stmt')) & optional(using_stmt('using_stmt')) pattern = stringstart() + modifiers + stringend() it seems optional() & optional() erroneously allows multiple repetitions of either modifier , , labels last one: >>> print dict(pattern.parsestring('with foo=bar bing=baz using id-deadbeef using id-feedfeed')) { 'with_stmt': ( [ (['foo', 'bar'], {'value': [('bar', 1)], 'key': [('foo', 0)]}), (['bing', 'baz'], {'value': [('baz', 1)], 'key': [('bing', 0)]}) ], {'overrides':

html5 - How can we integrate bxslider in to Angularjs app? -

iam using bxslider in angularjs app.but when use ng-repeat not working.below angular code. in advance. <ul class="bxslider" ng-repeat="image in vm.listfullproductdetails[0].productimage"> <li> <img src="/{{image.productimagefilepath}}" /> </li> </ul> when remove ng-repeat , add images , works fine.how can resolve problem.below code. <ul class="bxslider"> <li> <!--<img ng-src="/{{image.productimagefilepath}}" />--> <img src="/images/user4.jpg" /> </li> <li>