Posts

Showing posts from August, 2010

SoapUI request response content externalize -

i need set request/response content of test request dynemically external xml folder(requestfolder, responsefolder) using groovy. there mockservice running. need kind of implementation because there number of mockservices , multiple responses within it. want externalize them , call them dynemically through groovy is have done before? amit why have multiple request xmls? because have different data in them? in case suggest put data in excel or csv , based on data in data source generate xml. if using pro version should able read xml files local drive , present response mock service. all can done using groovy.

WSO2 ESB 4.7.0 download on server -

how download 4.7.0 release of wso2 esb directly on server? have ssh terminal server, no gui. i tried wget. , without auth. tried --save-cookies method wget without success. i tried elinks & logging in wso2 site account there, got no way of downloading latest version through terminal. wonder why should open source project make difficult download product build? can me link or method download via terminal? please try this: wget --user-agent="testuser" --referer="http://connect.wso2.com/wso2/getform/reg/new_product_download" http://dist.wso2.org/products/enterprise-service-bus/4.7.0/wso2esb-4.7.0.zip

plugins - vim temporary disable undo? -

i followed add-custom-header-to-your-file create own custom header plugin. when save file auto. update current date time last-modified field. add edit history undo list. how can disable undo temporary ? you cannot disable undo without losing undo history. think undo implementation; pretty hard if had gap in there. if don't worry losing history, :set undolevels=-1 (and restoring previous value) do. also, :undojoin can used fuse 2 otherwise separate entries together. in situation, it's best keep (automated) change inside undo history.

jsf/primefaces load indicator during init of the bean -

in jsf/primefaces project, have lot of data loading in init (postconstruct) method of beans. that's why show gif indicator during bean load. i tried primefaces , ajax status (programmatic version of showcase) http://www.primefaces.org/showcase/ui/ajaxstatusscript.jsf so added template of project <p:dialog modal="true" widgetvar="loadwidget" header="status" draggable="false" closable="false"> <p:graphicimage value="../images/ajaxload.gif" /> </p:dialog> i able call loadwidget.show(); @ beginning of init method of bean , loadwidget.hide(); @ end. do have idea , how fire javascript display loading gif? thanks edit i add tried this. here part of template include content of page. it's not working either p:dialog included before or after content. <div class="content"> <script>loadwidget.show();</script> <ui:insert name="body&qu

Using powershell to return folder permissons -

i new powershell , trying use script found return folder permissions : function get-secgroups($path) { $a = @{}; get-acl -path $path | %{write-host `n $path; $_.access} | %{ #only show permissions on folder, not files #check see if user/group has "list" permission if ($_.inheritanceflags -eq "containerinherit") { write-host `t $_.identityreference "list"; } else { write-host `t $_.identityreference, $_.filesystemrights; } } } #end get-secgroups get-childitem -path "d:\*\*\" | {$_.psiscontainer} | %{get-secgroups($_.fullname)} | out-file c:\output.txt the problem have creates output.txt no data. data displayed on screen. going wrong? juste replace write-host write-output in function.

api - Android SDK not installing components on linux (ubuntu) -

today trying update components of sdk new android 4.3 out. can't downloaded don't seem have proper flags (superuser) it. have found many solutions how fix on windows, don't see how can use them solution ubuntu-command-line. is there way launch sdk superuser via command-line? trouble api18 or general issue? errors: preparing install archives downloading android sdk platform-tools, revision 18.0.1 url not found: /opt/android-studio/sdk/temp/platform-tools_r18.0.1-linux.zip (permission denied) downloading documentation android sdk, api 18, revision 1 url not found: /opt/android-studio/sdk/temp/docs-18_r01.zip (permission denied) ................ is there way launch sdk superuser via command-line? sudo .../tools/android where ... path android sdk installation. in case, error message, appear expand to: sudo /opt/android-studio/sdk/tools/android

osx - Where should my .bash_profile file be for Python to update? -

i'm using mac osx 10.6.8 snow leopard , think i've got need install python 3.3.2, when type python terminal still says have 2.6.1. because can't find path newer version, , should fixed adding following .bash_profile: path="/library/frameworks/python.framework/versions/3.3.2/bin:${path}" export path i've done (and run cat command on several times check), keeps saying same thing. suppose .bash_profile file and/or python 3.3.2 folder might not in right directories? .bash_profile in /users/mac (home) , python folder in /library/frameworks/python.framework/versions . should somewhere else? thanks in advance! use python3 run python3 , , restart shell after modifying .bash_profile or source .bash_profile load new settings without restarting shell. $ python3 /usr/bin/python3 example: $ cat so.py #!/usr/bin/python3 print("hello, world!") $ chmod +x so.py $ ./so.py hello, world!

ios - Auto Layout: can't get the frame size of UICollectionViewCell subViews -

i have custom uicollectionviewcell subclass ( mycell ), interface setup in interface builder using auto layout. cell has image view , label. now, when configure cell, need know width , height of image view. sounds pretty simple, looks it's impossible. in view controller: - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { mycell *cell = [collectionview dequeuereusablecellwithreuseidentifier:@"mycell" forindexpath:indexpath]; cell.itemnumber = indexpath.item; return cell; } in cell subclass using property's setter customize cell: - (void)setitemnumber:(nsinteger)itemnumber { _itemnumber = itemnumber; self.label.text = [nsstring stringwithformat:@"%i", self.itemnumber]; // in actual project need know image view's width , hight request image // of right size server. sadly, frame {{0, 0}, {0, 0}} // (same bounds) nslog(@"%@",

c++ - ReadFile Rs232 Too Slow -

i have problem executing program on windows 8; use readfile retrieve data rs232 serial port. my code working since many year on os windows xp win 7 without problems, readfile opertion took between 94 , 100ms while fast or immediatly on precedent os : i have try modifying timeouts force 1ms same results : getcommtimeouts(handle, &cto); cto.readintervaltimeout=maxdword; cto.readtotaltimeoutmultiplier=0; cto.readtotaltimeoutconstant=0; cto.writetotaltimeoutmultiplier=0; cto.writetotaltimeoutconstant=0; if(setcommtimeouts(handle, &cto) == 0) // , read function : rol.offset = 0; rol.offsethigh = 0; if (readfile(handle, &byte, 1, &i, &rol) == true) i don't find solution after reading lot of post , msdn! i find , correct problem, hans passant wich indicate me right way ! so it's driver issue, big problem latest prolific driver made specially windows 8 , 7 , available on windows update , catalog.update.microsoft.com buggy : so downgrade 201

Java regex - overlapping matches -

in following code: public static void main(string[] args) { list<string> allmatches = new arraylist<string>(); matcher m = pattern.compile("\\d+\\d+\\d+").matcher("2abc3abc4abc5"); while (m.find()) { allmatches.add(m.group()); } string[] res = allmatches.toarray(new string[0]); system.out.println(arrays.tostring(res)); } the result is: [2abc3, 4abc5] i'd [2abc3, 3abc4, 4abc5] how can achieved? make matcher attempt start next scan latter \d+ . matcher m = pattern.compile("\\d+\\d+(\\d+)").matcher("2abc3abc4abc5"); if (m.find()) { { allmatches.add(m.group()); } while (m.find(m.start(1))); }

c++ - Getting Zeros When Reading A File Full of Numbers -

i trying read file has several hundred lines. each line looks (keep in mind these not actual numbers. sample of format.) r 111.1111 222.2222 123456 11 50.111 51.111 i tried reading file fscanf , printing out of values when print out values, 0 variables. have checked file , none of lines have value of 0 variables. writing in c++. #include <fstream> #include <iostream> #include <string> using namespace std; int main(int argc, char** argv) { file *myfile; myfile = fopen("tmp.txt", "r"); string type; float dx; float dy; float intensity; int nsat; float rmsy; float rmsx; if (myfile == null) exit(1); else { while ( ! feof (myfile) ) { fscanf(myfile,"%s %f %f %f %i %f %f\n",&type, &dx, &dy, &intensity, &nsat, &rmsx, &rmsy); printf("f %f %f %f %i %f %f\n", dx, dy, intensity, nsat, rmsx, rmsy); } } } there multiple prob

vb.net - WPF ListView Style Borders -

Image
today started teaching self how create wpf application (finally) so starting used have hit bit of snag styling listview. in top picture can see working (no border around selection) however in second picture can see small border around selection.. seems happens when use keyboard go next item in list. is there missing in styles can rid of border? code: (remember started learning today messy) listview styles <style targettype="{x:type listview}"> <setter property="borderthickness" value="0" /> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="borderthickness" value="0" /> </trigger> <trigger property="isselected" value="true"> <setter property="borderthickness" value="0" /> </trigger> </style.triggers> &l

php - header() function removes HTTP_REFERER -

this question has answer here: http_referer empty when redirected auth component 3 answers there might many releated question on , many articles it, unable understand reason it. what trying achieve have affiliate sort of thing. in if user clicks on of our ads in google or anywhere else. taken page redirect him approprite page. redirecting use following code. header("http/1.1 301 moved permanently"); header("location: http://www.example.com/page2.php"); suppose code written on page1.php , user redirected page2.php . on page1 referer user arrived (google.com instance). on page2.php don't referer page1 . seems me strange behavior. can put light on reason of behavior. ps: have workaround adding cookie before redirect , retriving value on page2 . thanks if i'm not mistaken, referrer sent browser (if allowed, not browsers

javascript - Textboxes matching table column width -

i have table textbox each column (they going used filtering). textboxes should same width corresponding column. this far i've gotten (simplified version): http://jsfiddle.net/9uupp/ pseudo-code explaining trying current script: document ready{ var index = 0; each(th){ textboxnr(index).width = this.width; index++; } } as can see, textboxes doesn't match columns in width. important: table + content generated , may change time time, have make dynamic solution. number of columns same, width may change first child not 0th child. index should 1 initially. look here . says children index starts 1. then px not needed in width, value enough. check here here updated working jsfiddle your code should be, $(document).ready(function () { var index = 1; $("#table th").each(function () { $('input[type="text"]:nth-child('+index+')').css('width',$(this).width()); in

SQL Server Cumulative Sum by Group -

i have table (sql server 2005) of format: dummy_id, date_registered, item_id, quantity, price and want add new column ( cumulative ) calculates cumulative totals of each item_id order date_registered shown: dummy_id date_registered item_id quantity price cumulative 1 2013-07-01 100 10 34.5 10 2 2013-07-01 145 8 2.3 8 3 2013-07-11 100 20 34.5 30 4 2013-07-23 100 15 34.5 45 5 2013-07-24 145 10 34.5 18 thanx in advance in sql server 2005, using correlated subquery: select dummy_id, date_registered, item_id, quantity, price, (select sum(quantity) t t2 t2.item_id = t.item_id , t2.date_registered <= t.date_registered ) cumulative table t; if want add table, need alter table add column , update. if table has inserts , updates, ne

matlab - How to select rows from character array that match char string and save them in a new array? -

i have char array contains list of files names (each row 1 file) (char, 526x26) val = 0815_5275_uba_a_1971.txt 0815_5275_uba_a_1972.txt 0823_6275_uba_a_1971.txt 0823_6275_uba_a_1972.txt 0823_6275_uba_a_1973.txt ... i have variable b = '0815_5275' i'd select rows (filenames) start b , save them in new array c. this should simple, somehow can't make work. i've got this: c = a(a(:,1:9) == b); but error message: error using == matrix dimensions must agree. i not know in advance how many rows match, can not pre-define empty array. thanks, appreciated! try ismember(a(:, 1:numel(b)), b, 'rows') rather logical vector indexes rows want and now a(c,:) extract rows the reason you're getting dimension mismatch error because a(:,1:9) has many rows b has 1 , matlab not automatically broadcast octave or python. using either repmat or bsxfun in case ismember correct function choose.

r - Delete rows based on values in the columns and a thresh hold value -

i have table, start below: sm_h1455 sm_h1456 sm_h1457 sm_h1461 sm_h1462 sm_h1463 ensg00000001617.7 0 0 0 0 0 0 ensg00000001626.9 0 0 0 0 0 0 ensg00000002587.5 10 0 6 2 0 2 ensg00000002726.15 8 14 0 2 16 2 ensg00000002745.8 6 2 2 0 0 4 i want delete rows in >= 80% of columns have value 0. have 6 cols here, if 5 or more of columns in row have 0, row needs deleted. i have code: data = data[!rowsums(data == 0), ] but code delet

javascript - Handling AJAX timeouts -

i know how timeouts (case server down) can handled ajax call. using chrome v28. i did lot of search on google , couldn't find convincing answer other checking status == 0 on readystate callback function. way of handling it? not using jquery or other frameworks. although highly recommend using jquery since simplifies ajax calls , can have response set these kinds of situations, use settimeout(timeoutcallback, amountoftime) achieve without worrying statuses. basically, callback abort ajax request , handle error want if request wasnt satisfied in time. if want more details, got information question on stack overflow: how detect timeout on ajax (xmlhttprequest) call in browser? . hope helps!

orchardcms - Orchard, to use customerPart or CustomerPartRecord -

looking through orchard examples , wondering when correct time use (for exmaple im using customer so...) customerpart or customerpartrecord. when referring them in orchard projects? most of time want use part. record used storing data in part database. view templates , drivers refer part , handler how record persisted. if follow example through creating simple orchard module , do, should become clearer. in particular check 'creating model part' section.

php - Fatal error: Call to a member function bind_param() error -

i trying insert data table getting frustrating error couldn't figure wrong. error below: fatal error: call member function bind_param() on non-object i have read means prepare returning false.. here code error occuring $insert = $mysqli->prepare("insert `hm_desktop`(`username`, `title`, `condition`, `description`, `price`, `brand`, `color`, `hard_drive_capacity`, `others`, `graphics_card`, `ram_capacity`, `operating_system`, `os_edition,` `processor_type`, `processor_speed`, `model`, `product_series`, `included_items`, `country`, image_one, image_two, image_three, image_four, image_five, `date`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $insert->bind_param('sssssssssssssssssssss', $username, $title, $cond, $desc, $price, $brand, $color, $hard_drive_type, $others, $garphics_card, $ram_capacity, $operating_system, $os_edition, $processor_type, $processor_speed,$model, $product_series, $included_items, $country, $random_name_gener

python - Change to Django's User Model - Migration issues -

i have used own user model till , realized django's user model offers me things have create on own... why not take django's user model.. now changed user model , made inherit django user model adding: class user(user).. and tried migrate db these steps: 1. python manage.py schemamigration home --auto -- asked me give default values these 2 columns mean down here 2. python manage.py migrate home 3. error 3. error says user_ptr_id exists double , thats why couldnot create unique index user_pkey . what can can migrate?

nfc - Android Beam - special usecase -

i have use-case android beam. have tested myself app not available in google play yet. here goes: i want beam content phone , receiver phone not have it. aar, app fetched google play on receiver phone. far good. download , login. my question is: once app downloaded receiver app still have information beamed or should sender initiate beam again? data in first beam lost? how should handled? theoretically, onresume should called handle intent. any thought if has come across such kind of case. the data lost, unfortunately. think of if ndef message aar have been delivered play store app. (the play store app not able deliver newly installed app.) solution beam again.

insert - Oracle merge into statement -

trying insert lists python oracle database. want insert 4 pieces of data each list oracle , if 3 of data entries match want update. if don't match want insert. equip_id parameter_name parameter_value customer so 1 entry if equip_id, parameter_name, , customer match entry in db want update parameter value. if don't match want insert of data db. have far doesn't seem working. merge dbname.tablename using '26522931','customer','para001','99999' on (tablename.equipment_node_id = '26522931' , tablename.stream_name = 'customer' , tablename.parameter_name = 'para000') when matched update set tablename.parameter_value = '99999' when not matched insert (equipment_node_id,stream_name,parameter_name,parameter_value) values('26522931','customer','para000','99999') my guess want this. you'll need select data dual if don't have other table use source. me

javascript - CSS Background color fill for the Icons -

Image
i planning use flag image status. please see image in image want fill background color of flag using css. background color code coming server want update flag's color according color got server i tried svg not working in ie8. please me how this. in advance help note: need support ie7 latest browsers. don't want use separate images different colors. if flag on same background-color, can use .png, cut hole color should appear , use background-color , background-image create desired result. html <div class="flag"></div> css .flag { width: 45px; height: 54px; background-color: #f00; background-image: url(http://i.imgur.com/dd84kjr.png); } example on jsfiddle: http://jsfiddle.net/a4ez9/

Is it possible to authenticate in Deezer by server side? -

is possible authenticate in deezer server side? we building website deezer player , don't want end-user login deezer connect listen entire music. also, if not possible authenticate server side, possible login javascript 1 "master user" emulates end user authentication? if want provide full-tracks access users, absolutely have identified deezer premium users. therefore, have ask them log in. in js sdk, dz.login method work you: http://developers.deezer.com/sdk/javascript/login . that's matter of rights management, deezer can't provide full-track access everyone, master user solution not work either.

ios - Map View - Disclosure Button to a View -

i started programming recently, , have question! have created mapview annotation , disclosure button. how can create multiple annotations disclosure button that, after tap, go different descriptions based on annotation choice? this code: @synthesize mapview; -(void)viewdidload { [super viewdidload]; [mapview setmaptype:mkmaptypehybrid]; [mapview setzoomenabled:yes]; [mapview setscrollenabled:yes]; [mapview setdelegate:self]; mkcoordinateregion bigben = { {0.0, 0.0} , {0.0, 0.0} }; bigben.center.latitude = 51.50063; bigben.center.longitude = -0.124629; bigben.span.longitudedelta = 0.02f; bigben.span.latitudedelta = 0.02f; [mapview setregion:bigben animated:yes]; annotation *ann1 = [[annotation alloc] init]; ann1.title = @"big ben"; ann1.subtitle = @"your subtitle"; ann1.coordinate = bigben.center; [mapview addannotation: ann1]; mkcoordinateregion bridge = { {0.0, 0.0} , {0.0, 0.0}

android - How to decode data using Zxing C++ -

i'm having troubles using c++ sources zxing project. downloaded whole project https://code.google.com/p/zxing/downloads/list , took cpp files (core , cli). i want have method that: decode(byte[] datatodecode, int widthframe, int heightframe) but don't know how (i'm new c++ , zxing project). i've done research on web , found http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample needed. unfortunately, zxing core has changed , have problems because of arrayref is there easy way decode byte array (rgb) , return result string ? help appreciated, problem has been solved modifying bufferbitmapsource class example ( http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample ) according zxing library 2.2. bufferbitmapsource.hpp: #include <zxing/luminancesource.h> #include <stdio.h> #include <stdlib.h> using namespace zxing; namespace qrviddec { class bufferbitmapsource : public luminancesou

javascript - How do I connect between parent $scope, directive $scope and a modal $scope? -

i'm trying create directive label selector. <label-selector label="label1">label1</label-selector> label1 default label should selected, value comes $scope in controller view label-selector present. the behaviour want follows, when user clicks label1 modal should open. modal lists collection of labels, (the collection should loaded array somhere). label1 in collection should marked selected, e.g. class="selected" . when click label say, label2 , label2 should selected , modal should closed. event update label-selector. <label-selector label="label2">label2</label-selector> i encapsulate both label-selector element , modal in same directive. is possible? update i'v done small example here. html <div ng-app="app" id="app"> <div ng-controller="mainctrl"> <label-select color="{{color}}"></label-select> </div> </div

java - In python, is "args = [temp[n] for n in array(index)]" doing a check of temp[n]? -

i converting python java. my question 'args' doing? args = [this.scrath[c] c in this.connections(n)]; //python is it: [this.scrath[c] //get data @ index c of this.scratch[] c in // number of c in connections this.connections(n)]; //connections ann_neuron n in case "this.scratch[c]" checking data matches c in "this.connections(n)"? this.scratch = arrays.copyofrange(inputvalues, this.scratch.length-this.input_length, this.scratch.length+1); //java //inputvalues given negative values. (int i=0; i<this.scratch.length; i++){ this.scratch[i] = inputvalues[i]*-1; } //loop through active genes in order (ann_neuron n : nodes){ if (n.active){ float func = n.function; (ann_connection c : n.connections){ //argument here!! } } args = [this.scrath[c] c in this.connections(n)]; //python //apply function inputs scratch, save results in scratch this.scratch[n] = function(*args); } this:

ruby - Create an array of arrays -

i'm trying create array of arrays used in javascript function. here format of array i'm trying create: [[1,1],[2,3],[3,6],[4,10],[5,15],[6,21]] here ruby code create array: total=0 foo=[] (1..6).each |number| foo.push [number, total+=number] end puts foo here output of puts foo : 1 1 2 3 3 6 4 10 5 15 6 21 any ideas how output correctly formatted array? if understand correctly, want output array somewhere in document interpreted javascript browser. when comes using ruby objects in javascript, can use json gem. require 'json' #create array foo.to_json should trick. this works hashes , other object types.

node.js - Decrypt cipher text using NodeJs createDecipheriv. What am I doing wrong? -

i have following code should decrypt encrypted text: var crypto = require('crypto'); var buffer = require('buffer').buffer; var iv = new buffer('the-iv', 'binary'); //length=16 var key = new buffer('the-secret-key', 'binary');//length=30 var encryptedtext = new buffer('base64-encoded-encrypted-data', 'base64'); var decipher = crypto.createdecipheriv('aes-128-cbc', key, iv); //using aes-128-cbc algorithm decrypted = decipher.update(encryptedtext, "binary", 'utf8'); decrypted += decipher.final('utf8'); when execute script node test-main.js , following error: node-crypto : invalid key length 30 crypto.js:355 this._binding.initiv(cipher, tobuf(key), tobuf(iv)); ^ error: decipherinitiv error @ new decipheriv (crypto.js:355:17) @ object.decipheriv (crypto.js:352:12) @ object.<anonymous> (path/to/file/test-main.js:9:19) @ module._compile (modu

algorithm - Are there performance issues from using large numbers of objects in Java -

i working on system performance important consideration. going used processing large quantities of data (some of object types in millions) non-trivial algorithms (think integer programming problems etc.). @ moment have working solution creates these data points objects. is there performance increase gained, treating them arrays example? there best practices working large numbers of objects in java (should avoided?). i suggest start using commercial cpu , memory profiler. give idea of bottleneck. reducing garbage , making memory more compact helps more when have optimised code point profilers cannot suggest anything. you might consider structures fit in cpu caches better can improve performance 2-5x. e.g. l3 cache might 8 mb, , more 5x faster main memory. more can condense working set fit better. btw l1 cache 32 kb , ~10x faster again. this assumes time perform gc doesn't bother you. if create enough objects can see multi-second, multi-minute gc stop-the-

javascript to determine the ending of mp3 song in embed tag -

i wanted know if there way determine duration of mp3 song through javascript play next song in embed tag according ending time of first song in embed tag. no, there isn't. <embed> has no standard api information embedded content. use <audio> element if want sort of data.

html - Form is not getting submitted on pressing Submit button -

my form not getting submitted. designed in photoshop , later coded. works if remove <div class="form3 clear fix"> . throws layout out. appreciated. image of form: http://postimg.org/image/j4h64gv59/ <form action="http://www.mywebsite.com/cgi-bin/cgiemail/special/hot.txt" method="post" name="form3" class="form3-form"> <div class="form3 clearfix"> <img class=" to_get_started_call_us_or" src="images/to_get_started_call_us_or.png" alt="to started call us, or we’ll call you!" width="183" height="43" title="to started call us, or we’ll call you!" /> <img class=" line" src="images/line.png" alt="" width="132" height="2" /> <input name="name" type="text" id="name" placeholder="name" /> <input name="em

Spring: Apply Annotation based on properties -

say using @scheduled annotation on function. want annotation take effect if property defined in properties file. how configure scenario? use case: same app deployed on multiple servers @scheduled should active on 1 server. my idea: use bean (myscheduler), contains nothing more method annotated @schedule. method "forward" invocation real service. then annotate myscheduler class @component , @profile the use properties file enable or disable profile sketch: @component @profile("ontheserver") public class myscheduler{ @autowire private realservice realservice; @schedule(cron="1****") { realservice.dosomething(); } } @see: spring 3.1 m1: introducing @profile @see: @profile java doc

python - Creating loops from xml data -

please @ following code: from xml.dom import minidom xmldoc = minidom.parse("c:\users\...\xml") #this address document soccerfeed = xmldoc.getelementsbytagname("soccerfeed")[0] soccerdocument = soccerfeed.getelementsbytagname("soccerdocument")[0] competition = soccerdocument.getelementsbytagname("competition")[0] country = competition.getelementsbytagname("country")[0].firstchild.data name = competition.getelementsbytagname("name")[0].firstchild.data season = competition.getelementsbytagname("stat")[1].firstchild.data matchday = competition.getelementsbytagname('stat')[3].firstchild.data lst = [country, name, season, "matchday: "+ matchday] print lst #match data matchdata = soccerdocument.getelementsbytagname("matchdata")[0] matchinfo in matchdata: matchinfo = matchdata.getelementsbytagname("matchinfo")[0] attendance = matchinfo.getelementsbytag

C# How to loop through the source folder or subfolders that match the destination -

i need overwrite files source destination directory. structure of each folder different i'm trying in generic way. thing is, each folder (source , destination) have numerous subdirectories or none @ all. the code have this: //copy , overwrite files depending on whatever in destination //search through destination find file foreach (var dstfile in directory.getfiles(targetdir)) { //search through source find matching file foreach (var srcfile in directory.getfiles(sourcedir)) { //cut off source file source path strsrcfile = srcfile.split(path.directoryseparatorchar).last(); strdstfile = dstfile.split(path.directoryseparatorchar).last(); //if destination , source files match up, replace desination source if (strsrcfile == strdstfile) { file.copy(srcfile, path.combine(targetdir, path.getfilename(strsrcfile)), true); } } } //look through subfolders see if files match foreach (var srcfolder in directory.getdirectories(sourcedir

bash - How do you specify a file's name as part of the input directory? -

i have files in 1 directory format - 0163-301_02_29_2008_off.nii - 0163-301_02_29_2008_on.nii - 0164-303_11_30_2007_off.nii - 0164-303_11_30_2007_on.nii i run command involves names of files inputs. address path be /users/jjuan/documents/mtautism/new_mtr_datasets/usablenii/0163-301_02_29_2008_off.nii and on. so far, i've code i've written for file in *_on.nii; set fileroot = ${file} cut -b 1-78 echo $fileroot /usr/local/fsl414/bin/flirt -in $file  -ref /users/jjuan/documents/mtautism/new_mtr_datasets/usablenii/$fileroot_off.nii -out /users/jjuan/documents/mtautism/new_mtr_datasets/usablenii/$fileroot_ontooff -omat /users/jjuan/documents/mtautism/new_mtr_datasets/usablenii/$fileroot_ontooff.mat -bins 256 -cost corratio -searchrx -90 90 -searchry -90 90 -searchrz -90 90 -dof 6  -interp trilinear done however, $fileroot set doesn't appear in path specified, , ouputs blank space. fix variable naming, starters: for files in *_on.nii; ^^^

Colored representation of objects in IPython terminal shell -

if want have colored representation of objects in qtconsole or ipython notebook, have add _repr_html_ method objects class. in [1]: class test(object): def __init__(self, x): self.x = x def _repr_html_(self): return '''<span style="color: green"> test{<span style="color: red">%s</span>} </span>''' % self.x in [2]: test(33) test{33} this give me nice colored representation test{ green, 33 red , } green again. is there way in terminal version of ipython shell in cross platform way? ideally work same way the templates prompt customization : in [1]: class test(object): def __init__(self, x): self.x = x def _repr_shell_(self): return '{color.green}test{{color.red}%s{color.green}}' % self.x if not, can somehow import , use ipython's int

android - How do I get the OnClickListener working on a custom view with a RelativeLayout? -

Image
question hello, i have built custom view relativelayout use custom image button. far, selecting works (pic2) , when click (using googletv remote), view changes it's state pic3 (thanks android:duplicateparentstate="true") but unfortunately onclicklistener not fire (doesn't matter if click view remote "ok" button or use touchpad..) i need same behavior normal button. how accomplish that? spent few hours on searching google , stackoverflow... (btw. when setting android:clickable="false" relativelayout, onclicklistener working, when use mouse pointer (touchpad) , afterwards focus lost , state (pic 3) not displayed) pictures pic1 pic2 pic3 code rounded_button.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android

grails app layout horking on bootstrap-responsive.css -

i have simple grails application. did not author front end, business logic layer. i checked out source svn , app starts, cannot load main url. errors out messages below. have tried refreshing dependencies, no avail. i have spelunked every file think of try fix this. gets attention forward slash in front of css, while other delimiters in path backslashes. does have idea going wrong , how fix it? maybe front end developer needs check in? error 2013-07-31 13:50:24,036 [http-bio-8080-exec-4] error [/myclientappname].[grails-errorhandler] - servlet.service() servlet grails-errorhandler threw exception message: error applying layout : main line | method ->> 1110 | runworker in \grails-app\views\layouts\main.gsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 603 | run in '' ^ 722 | run . . . in '' caused groovypagesexception: error processing groovypageview: error executing tag <r:layoutresources&

regex - Load .NET PDB Symbols from Microsoft (Resolved) -

i have set symbol server in vs 2010 according this: http://msdn.microsoft.com/en-us/library/vstudio/b8ttk8zy(v=vs.100).aspx but goal step regex class in regularexpressions namespace: imports system.text.regularexpressions module module1 sub main() dim matobject match = regex.match("abc", "a") end sub end module i know regularexpressions symbols in system.dll assembly made public long time ago because read article on while excited , did small overview. can't find article. as stands, when "step into" match function, doesn't give me step-over dialog. steps over. turns out there multiple issues surrounding this. part of them include visual studio 2008 sp1, hardly relevant issue in late 2013. the solution me was... don't use symbol server. @ least in vs 2010, forces use "microsoft symbol servers" which, depending on 1 or 2 factors, may load generic location, or may load http://referencesource.m

django - Code to run in all views in a views.py file -

Image
what best way of putting bit of code run views in views.py file? i come php background , put in constructor/index bit ran whatever page being requested. has specific views.py file though, want check user has access 'this app/module' , want avoid having use decorators on views if possible? tl;dr you should check middlewares . allows execute code before view execution, template rendering , other stuff. some words middlewares you can represent middlewares in head this: as can see, request (orange arrow) go through every middleware before executing view , can hitting every middleware after (if want before template processing example). using django 1.10 arcitecture of middlewares have changed in django 1.10, , represented simple function. example, here's counter of visits each page: def simple_middleware(get_response): # one-time configuration , initialization. def middleware(request): try: p = page.objects.get(url=req

c - Linux: exit forked child process when parent exits -

this question has answer here: how make child process die after parent exits? 22 answers best way kill child processes 29 answers i'm writing program in c. program fork() once when starts. what's best way let child process die on own when parent process exits (without parent killing child process explicitly)? for example, if send sigterm parent process, child doesn't exit. you can set signal handler, , send signal child process parent when parent reaches end of execution. fork function returns process id of child parent, can supplied kill function. can pass sigint or sigterm or signal of choosing. #include <signal.h> #include <stdio.h> #include <unistd.h> int main( int argc, char* argv[] ) { pid_t id = 0; id = fork();

java - Binding enum to form <select> element in Play! Framework 2.1 -

i'm trying figure out best practice bind enum form drop-down <select> in play! 2.0 here enum: public enum contacttype { client(1), contractor(2), supplier(3); public final int id; contacttype(int id) { this.id = id; } } and here's i'd result in view: <select name="contacttype"> <option value="1">client</option> <option value="2">contractor</option> <option value="3">supplier</option> </select> something in template should work: <select name="contacttype"> @for(ctype <- contacttype.values()){ <option value="@ctype.id">@ctype.name()</option> } </select> note: may better use tostring() instead of name() . if override tostring() in enum return contractor instead of contractor. note 2: if enum not in models package need prefix right package name i.e.: @f

javascript - Create new record and commit transaction with ember-data -

i trying trigger adequate put request when add new record 1 many field using ember-data. var track = genre.get('tracks').createrecord({name: "hit me baby 1 more time!"}) track.get('transaction').commit() this send put request '/genres' , send genre attributes , other tracks well. // put /genres {"genre":{"name":"pop","tracks": [{"name":"hit me baby 1 more time!","genre_id":null}]}} but prefer sth. like: // put /tracks {"track": {"name":"hit me baby 1 more time!", "genre_id":1}}} if somehow possible add additional parameter automatically put requests on /tracks. these models: app.genre = ds.model.extend({ name: ds.attr('string'), tracks: ds.hasmany('app.track') }) app.track = ds.model.extend({ genre: ds.belongsto('app.genre'), uri: ds.attr('string') })

Is it possible to run cmd through a java program -

this question has answer here: start cmd using processbuilder 2 answers i know if possible run cmd through java . not 1 command @ time continuous stream of user input commands relays info received . possible or should stop trying now? i'm not sure why i'm attaching this; it's not relevant, trying accomplish with. however, resets cmd after every command. (yes, realize bad coding, i'm attempting boss asked about.) import java.io.*; import java.util.scanner; public class cmd { public static void main(string[] args) throws ioexception { string line; while (true) { scanner scanner = new scanner(system.in); string comm = scanner.nextline(); processbuilder builder = new processbuilder("cmd.exe", "/c", comm); builder.redirecterrorstream(true); proc

vsix - Open xaml window, lock Visual Studio UI -

i building visual studio extension (2012 vsix) want is: open xaml window, bring front. , "lock" visual studio, have close window before can accomplish els. for example when right clicking on project , selects "add new item", have close "add new item window" before can els. i did try simple fetching click event, var window = new xamlwindow(); window.show(); opened window, couldnt find settings want. (lock visual studio untils close window again) should accomplish this? you try window.showdialog() .

css - jQuery convert applied classes to style attributes -

Image
i working on bookmarklet project. when user clicks on bookmarklet can grab partial part of web page , view somewhere else. the problem partial element (lets assume div) has css styles , classes applied. is there way loop through child elements of selected div , convert class properties style properties can keep formatting? for example below sample screenshot; need take out applied classes , convert them style attributes in selected area. (function($) { $.extend($.fn, { makecssinline: function() { this.each(function(idx, el) { var style = el.style; var properties = []; for(var property in style) { if($(this).css(property)) { properties.push(property + ':' + $(this).css(property)); } } this.style.csstext = properties.join(';'); $(this).children().makecssinline();

javascript - XMLHttpRequest cannot load "THIS URL" Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. -

im getting error when trying post , xml company website freshdesk api here javascript $(document).ready(function(){ var data = '<helpdesk_ticket>' + '<description>this test</description>' + '<email>sample@example.com</email>' + '</helpdesk_ticket>' $.support.cors = true; $.ajax({ url: 'http://onehouse.freshdesk.com/helpdesk/tickets.xml', type: 'post', crossdomain: true, data: data, datatype: "text", username: 'my api code', password: 'x', success: function (result) { alert(result); }, }); the full error xmlhttprequest cannot load http://onehouse.freshdesk.com/helpdesk/tickets.xml. origin http://localhost:3000 not allowed access-control-allow-origin. contacts?oid=00du0000000i430&returl=http%3a%2f%2fwww.ironridge.com&email=ma…utes%5d%5bdescription_html%5d=safsadfsdaf&00nu0000002xpyp=&submit

ruby on rails 3 - Getting input from view to scope an index -

so trying add ability select user in view, , return lists associated user. can hard coded in controller. def show @some_lists = list.sort(:boolean => true, :user_id => 3) respond_to |format| format.html # show.html.erb format.json { render json: @some_list } end end but want able choose user views <% @some_lists.each |list| %> <tr> <td><%= list.id_name %></td> <td><%= list.day %></td> <td><%= list.start_time %></td> <td><%= list.end_time %></td> </tr> <% end %> what best way go doing this, plan on adding ability sort list.start_time , list.end_time well you'll want ajax. specific thing want (filtering/sorting table) there's javascript plugin recommend: datatables (you'll want check out documentation on server-side processing ) there's nice tutorial using rails in

c++ - Segmentation Fault upon call to GetSystemTime() function (Windows) -

i'm having trouble dealing segmentation fault. following sanity check throws one: #include <windows.h> int main() { lpsystemtime starttime; getsystemtime(starttime); } however, i've used same code in larger program, , runs without problem. i've tried adding delays in various places in case problem stems sort of multithreading within getsystemtime() , did not solve problem. i'm compiling mingw-gcc in codeblocks. lpsystemtime pointer systemtime structure. don't initialize pointer it's pointing somewhere scenery, hence access violation/seg fault. in order make code work, have make sure pointer points valid systemtime structure. per msdn docs , microsoft explicitly warns passing in null pointer result in access violation.

installation - Android - update of custom preinstalled app -

i creating app preinstalled on android phones manufactured business partner. app not published on google play. is there convenient way of performing updates of application without user interaction (download apk in background , install without prompting)? you need permission android.permission.install_packages (which requires app within /system/app or signed manufacturer), can have @ this question installing apps silently , there multiple ways how that. easy way downloading apk, , executing pm install /path/to/apk .

windows - Two listeners on the same port? -

i surprised see netstat reporting 2 processes listening on same port: c:\windows\system32>netstat -ao | find "8083" tcp 0.0.0.0:8083 ***qa-w2k8-05:0 listening 5532 tcp 0.0.0.0:8083 ***qa-w2k8-05:0 listening 1572 tcp [::]:8083 ***qa-w2k8-05:0 listening 5532 tcp [::]:8083 ***qa-w2k8-05:0 listening 1572 c:\windows\system32>tasklist | find "5532" java.exe 5532 rdp-tcp#0 2 1,448,776 k c:\windows\system32>tasklist | find "1572" frameworkservice.exe 1572 services 0 11,016 k the java process web server, frameworkservice mcafee. http request not reach server assuming reaches mcafee. shouldn't 1 of them bind error/address in use or such error? i running microsoft windows server 2008 r2 enterprise, 6.1.7600 n/a build 7600 generally correct. however,

asp.net mvc - Is it a bad practice to have separate try/catch blocks inside the same Action method -

i have following delete action method, perform 2 separate tasks:- delete record third party application using api call. delete record database on our own system using entity framework. my action method looks follow:- [httppost, actionname("delete")] public actionresult deleteconfirmed(int id) { var message = ""; var status = ""; var tag = ""; resource resource = new resource(); try { rack rack = repository.findrack(id); tag = rack.technology.tag; resource = repository.getresource(rack.technology.it360id.value); } catch (nullreferenceexception) { return json(new { issuccess = "false" }, jsonrequestbehavior.allowget); } catch (dbupdateexception) { return json(new { issuccess = "alreadyused" }, jsonrequestbehavior.allowget); } using(var client = new webclient())