Posts

Showing posts from April, 2014

mule - Carry Original File Name to FTP endpoint -

using mule studio version: 3.5.0 build id: 201402101410 i have simple flow. need pick file 1 ftp server , transfer ftp server. when file written target, filename looks kind of uuid rather original file name. how file name carry through? have tried #[header:originalfilename] throws error assume maybe file connectors. here flow: <?xml version="1.0" encoding="utf-8"?> <mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" version="ce-3.4.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www

html5 - Scale round button on hover without scaling button icon -

i'm trying have round button search icon , when hovered round button should scale whereas search icon should remain same. this i'm trying for parent "div" in :after class i'm putting "search glypicon" , position middle of "button" , on hover of "button" scaled using css "transform" property , "search glyphicon" not affected outside "button". issue i'm facing "search glyphicon" part of parent "div" of "button" lies on top of "button" , hover not work of position on "search glyphicon". if there other alternative let me know, here's demo html <div class="global-search-form" role="search"> <button aria-label="search" class="btn btn-default" type="submit" data-toggle="modal" data-target="#global_search_widget"> <div class="mask-sear

python - Using PYQGIS to join 2 dbf files with common column(id) -

i new qgis , python. need join 2dbf files using qgis , python create shapefile.the 2 dbf files have common column(id). can give me idea how can join dbf files produce 1 shapefile? library can use same? since there no other answers, i'll offer solution batch joining 2 or more files using dbf commander professional . install app, create bat file contains sql commands follows: "c:\program files\dbfcommander\dbfcommander.exe" -q "insert 'd:\destination.dbf' select * 'd:\source.dbf'" type commands need, or use loop find dbf files in folder. run bat file. remember, dbf files should of same structure (field names , types). the app has full-featured 20-days trial period, can carry out operation free. more info on using dbf commander pro in batch mode can find here .

sql server - MS Access SQL Join Performance Improvement -

Image
i hoping on how can improve query below taking abosolute age execute. i'm aware it's left join that's causing statement run have no idea how else run query improve performance , return required results. query select s.id, s.first_name, s.last_name, count(a.absenceid) (( dbo_ds_staff s inner join dbo_ds_team_staff_member tsm on s.id=tsm.staff_id ) inner join dbo_ds_team_leader tl on tsm.team_id=tl.team_id ) left join ct_adt_absence on s.id=a.staffid tl.staff_id=2169 , tsm.start_date<now() , ( tsm.end_date>=now() or tsm.end_date null ) , tl.start_date<now() , ( tl.end_date>=now() or tl.end_date null ) group s.id, s.first_name, s.last_name order s.first_name, s.last_name; if there's further information can give assist, please let me know! thanks as suggested in comments question, pass-through query in access might speed things pushing processing o

how do i handle xml in chunks using python? -

i loading xml memory using elementtree, not problem when files of reasonable size of files dealing on 500mb in size , means xml fails load memory. current code pretty standard follows: tree = et.parse(xmlloc) root= tree.getroot() element in root.iter(elementname): # work here is there way of doing above in chunks?

sockets - How to listen on IP and Port in Java ? with ServerSocket? -

i'm creating client/server chat (multi-threading) app in java . i want listen clients on specific port , ip . when : serversocket serversocket = new serversocket(port); socket socket = serversocket.accept(); // accept connection // more code does mean ip i'm listening 127.0.0.1 ? i.e. localhost ? from on constructor of serversocket object , have 3 types of constructors : public serversocket(int port) throws ioexception public serversocket(int port, int backlog) throws ioexception public serversocket(int port, int backlog, inetaddress bindaddr) throws ioexception what constructor should use , if want clients other ip addresses this 1 : public serversocket(int port) throws ioexception or 1 : public serversocket(int port, int backlog, inetaddress bindaddr) throws ioexception ? much appreciated does mean ip i'm listening 127.0.0.1 ? i.e. localhost ? no. means listening on ip addresses of host. what constructor shou

java - Android Configuration Issues with ADT -

i developing android application, downloaded adt bundle, jdk7 , processing2 used visualization. when run codes in java mode runs errors when run in android mode. when run android application in eclipse on emulator, runs too. if processing running in android mode, have been able run app on tablet.from errors got, read maybe path variables should set , did too, not help. maybe in details types of errors occur. here logcat error trace : build failed c:\users\user\nabandro\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:720: following error occurred while executing line: c:\users\user\nabandro\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:734: error running javac.exe compiler total time: 1 second

Delete lock in table - Oracle Sql Developer -

i want lock table "process" stop other users deleting contents of table. i have gone through forums not able conclude how lock works , how lock table. can please tell me how put in sql query format? lock table <table name> in exclusive mode - lock table till commit/rollback alter table <table name> read only - prevent dml operations (not deletions) until table read write http://docs.oracle.com/cd/b19306_01/server.102/b14200/statements_9015.htm http://docs.oracle.com/cd/b19306_01/server.102/b14200/statements_3001.htm#cjahhibi

c++11 - C++ Shuffle Vector -

i have seen other threads on none seem answer question. i'm trying use shuffle() function on vector keep getting error: deck_of_cards.cpp:34:5: error: no matching function call 'shuffle' shuffle (deck.begin(), deck.end(), std::default_random_engine(seed)); ^~~~~~~ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:3049:10: note: candidate function [with _randomaccessiterator = std::__1::__wrap_iter<card *>, _uniformrandomnumbergenerator = std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>] not viable: expects l-value 3rd argument void shuffle(_randomaccessiterator __first, _randomaccessiterator __last, ^ 1 error generated. i'm using clang++ compiler , code throwing error: void deckofcards::shuffledeck() { seed = std::chrono::system_clock::now().time_since_epoch().count(); shuffle (deck.begin(), deck.end(), std::default_random_engine(seed)); } i hav

ios - How set UIPickerView in cascade -

i'm trying set 2 uipickerview s, both filled nsdictionary , work ok, need second uipickerview implement refresh depends of selection of first uipickerview , understand me? the first uipickerview filled way: for (nsdictionary *local in json) { nsstring *nombre = [local objectforkey:@"name"]; nsstring *idlocal = [local objectforkey:@"id"]; self.diclocales = [nsdictionary dictionarywithobjectsandkeys: idlocal, @"idlocal", nombre, @"nombrelocal", nil]; [listalocales addobject:self.diclocales]; } and second uipickerview filled way: for (nsdictionary *servicio in json) { nsstring *nombre = [servicio objectforkey:@"name"]; nsstring *idservicio = [servicio objectforkey:@"id"]; self.dicservicios = [nsdictionary dictionarywithobjectsandkeys: idservicio, @"idservicio", nombre, @"nombreservicio", idlocal, @"idlocal", nil]; [listaservicios1 addobject:self.di

sql - MAX function in where clause mysql -

how can use max() function in clause of mysql query, trying: select firstname,lastname,max(id) max id=max; this giving me error: unknown column 'max' in 'where clause' any help? in advance. you can't reference result of aggregate function (e.g. max() ) in clause of same query. the normative pattern solving type of problem use inline view, this: select t.firstname , t.lastname , t.id mytable t join ( select max(mx.id) max_id mytable mx ) m on m.max_id = t.id this 1 way specified result. there several other approaches same result, , of can less efficient others. other answers demonstrate approach: t.id = (select max(id) ... ) sometimes, simplest approach use order limit. (note syntax specific mysql) select t.firstname , t.lastname , t.id mytable t order t.id desc limit 1 note return 1 row; if there more 1 row same id value, won't return of them. (the first query return rows have

php - Mercurial changes the file's owner after update -

i have php webapp controlled mercurial. it's in /var/www/directory/. files owned user , group 'www-data'. after pull changes, files become owned root.root. that's because hg run root? it's remote server , have root access, how fix this? don't want run chown manually , recursively in directories after every pull, because there subdirs can't belong www-data . don't know if i'm doing right, tried modify hgrc with [trusted] users = www-data groups = www-data didn't work a new file created root when root running hg going owned root. can use sticky group bit set group, you're stuck root user. you can put hook in repo's .hg/hgrc pretty easily. like: [hooks] post-pull = chown -r user:www-data .hg you said there directories want exclude, can in hook too.

mysql - #1005 - Cant create table... (errno: 150) -

i have primary keys , drop tables in correct order. i want stockid foreign key in refund table. my schema looks this... create table refunds ( refundid smallint auto_increment, stockid smallint, refunddate date, foreign key (stockid) references tblstock(stockid), primary key (refundid) ); create table tblstock ( stockid smallint auto_increment, stockname varchar(60), stocknumbers smallint ); when referencing table foreign key reference, table needs exist. and, column being referenced should primary key. try this: create table tblstock ( stockid smallint auto_increment primary key, stockname varchar(60), stocknumbers smallint ); create table refunds ( refundid smallint auto_increment, stockid smallint, refunddate date, foreign key (stockid) references tblstock(stockid), primary key (refundid) );

c# - Finding the maximum value of an array -

i want find maximum result of string "differenceasstring". need convert patientinfo[itemcountinteger].differenceasstring int in order code work, put statement convert.toint32.patientinfo[itemcountinteger].differenceasstring i error : system.convert.toint32(string, int)' 'method', not valid in given context private void button3_click(object sender, eventargs e) { int maximun = findmax(); messagebox.show(" maximun is" + convert.tostring(maximun)); } private int findmax() { = convert.toint32.patientinfo[itemcountinteger].differenceasstring; int max = a[0]; (int = 1; < a.length; i++) { if (a[i] > max) max = a[i]; } return max; } public class patient { public string patientidstring; public string firstnamestring; public string lastnamestring; public string datestring; public string differenceasstring; } patient[] patientinfo = new patient[10]; private void button1_click

web deployment - I'm trying to publish a website to Azure and I keep getting an error with AspNetMergePath -

i'm trying publish azure web site - i've set deploy bitbucket , building when push master branch, deploy fails aspnetmergepath error. i can't seem recreate issue locally - working fine. i've attached log , i'm hoping can offer guidance, i've not used azure before , getting quite lost... command: d:\home\site\deployments\tools\deploy.cmd handling .net web application deployment. packages listed in packages.config installed. packages listed in packages.config installed. packages listed in packages.config installed. ministry.ministryweb -> d:\home\site\repository\ministry.ministryweb\bin\ministry.ministryweb.dll ministryweb -> d:\home\site\repository\ministryweb\bin\ministryweb.dll transformed web.config using d:\home\site\repository\ministryweb\web.release.config obj\release\transformwebconfig\transformed\web.config. copying files temporary location below package/publish: obj\release\aspnetcompilemerge\source. d:\program files (x86)\m

php - PDO prepared statements and their execution -

i have 'upgraded' mysql* pdo, , have couple of related questions: 1/ have form on webpage submits alot of data. rather have 1 looong prepared statement maybe 50 items in it, id split maybe 5 separate statements: //tods $stmt = $db->prepare("update first_page_data(tod_house, tod_bung, tod_flat, tod_barnc, tod_farm, tod_small, tod_build, tod_devland, tod_farmland) set(?,?,?,?,?,?,?,?,?) email_address=?"); $stmt->bindvalue(1, $_post['tod_house'], pdo::param_str); $stmt->bindvalue(2, $_post['tod_bung'], pdo::param_str); $stmt->bindvalue(3, $_post['tod_flat'], pdo::param_str); $stmt->bindvalue(4, $_post['tod_barnc'], pdo::param_int); $stmt->bindvalue(5, $_post['tod_farm'], pdo::param_str); $stmt->bindvalue(6, $_post['tod_small'], pdo::param_str); $stmt->bindvalue(7, $_post['tod_build'], pdo::param_str); $stmt->bindvalue(8, $_post['tod_devland'], pdo::param_str); $stmt->bi

java - ClassCastException casting error -

i'm getting error on code , dont understand why it's happening: for(pacote<par<string, double>> pacote : pacotes) /snippet of code error occurs/ trying cast to public class pacote <e> { private int capacidade; private arraylist <e> pacote; public pacote (int capacidade){ pacote= new arraylist <> (capacidade); this.capacidade=capacidade; } public par (a itema, b itemb){ this.tipo=itema; this.peso=itemb; } public primeiro(){ return tipo; } public b segundo () { return peso; } } public class pacote { private int capacidade; private arraylist <e> pacote; public pacote (int capacidade){ pacote= new arraylist <> (capacidade); this.capacidade=capacidade; } public int getcapacidade (){ return capacidade; } public int getnumitems (){ return pacote.size(); } public boolean estacheio () { return getnumitems()<capacidade-1; }

php - How to access $_POST variables with unknown keys in a safe way? -

my php file receives $_post variables unknown numbered keys, e.g. textpart of keys known, numbers , amount of $_post variables unknown. example: $_post[name1], $_post[name2], $_post[address1],$_post[address2]. the way see access these values means of code below: foreach($_post $k => $v){ if(strpos($k, 'name') === 0) { //do $v } if(strpos($k, 'address') === 0) { //do $v } } however, netbeans produces warning 'do not access superglobal $_post array directly'. looked @ php filter input functions ( http://www.php.net/manual/en/function.filter-input.php ) not find way access these type of $_post variables in safe way. suggestions? , starters (question beginner:), why unsafe practise access $_post vars directly? when working variable number of keys input, format html looks like: <input type="text" name="multi_values[1]" /> <input type="text" name="multi_values[2]" /> now can

c# - asp.net where to put the head tag -

i working on project. asp.net page starts with: <head runat="server"> <meta charset="utf-8"> <title>online sms choose</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <link id="link1" rel="stylesheet" runat="server" media="screen" href="~/css/tablestyle.css" /> <link id="link2" rel="stylesheet" runat="server" media="screen" href="~/css/loadingstyle.css" /> <link id="link3" rel="stylesheet" runat="server" media="screen" href="~/css/selectstyle.css" /> <script src="//code.jquery.com/jquery-1.9.1.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link rel="stylesheet" href="/

minitest - How to test a second redirect in Rails' controller test -

i using wicked redirects self-defined link after finishing wizard. happens second redirect. so, put update triggers 302 /orders/1/finish_wicked, redirects /orders/1. works expected, hard test in controller tests. it "must redirect order" put :update assert_redirected_to "/orders/1/finish_wicked" #=> passes, not interested in assert_redirected_to order #=> fails, yet, in end, user being redirected here. end how can test second redirect in functional -controller- tests? right now, have split 2 tests: describe "finalize" "should redirect wicked_finish page" put :update, id: :finalize, order_id: order.id, order: { accepted: true } assert_redirected_to controller: "build", action: :update, id: :wicked_finish, order_id: order.id end describe "wicked_finish" "should redirect order page" :show, id: :wicked_finish, order_id: order.id assert_redirect

colors - Python: colorsys.hls_to_rgb returning odd values -

i trying complimentary colors in rgb format. following guidance here , performing following steps: generate random hsl color create complimentary hsl doing 1-h of previous color, keeping s , l same. convert both colors rgb my code follows: bg_color_hls = (random.random(), random.random(), random.random()) fg_color_hls = (1-bg_color_hls[0], bg_color_hls[1], bg_color_hls[2]) print bg_color_hls print fg_color_hls print colorsys.hls_to_rgb(*bg_color_hls) print colorsys.hls_to_rgb(*fg_color_hls) however, printing following: (0.5536645842193463, 0.489454360526385, 0.47696160643815266) (0.4463354157806537, 0.489454360526385, 0.47696160643815266) (0.2560034224515616, 0.5725687282723873, 0.7229052986012084) (0.2560034224515616, 0.7229052986012084, 0.5725687282723875) note how r value same, , switches g , b. this not how complimentary colors work. problem? that's not how generate complimentary hue. you need add 0.5, take range [0, 1). fg_color_hls = ((

php - JavaScript HTTP Client that maintains session -

i have written little php scoreboard monitors mysql table realtime sports scores in it. users use loading page, reloads every 5 seconds. last-loaded scoreboard stored in session , compared current-loaded scoreboard. if player has changed ranking php script adds javascript page shows red or green highlight effect player depending on if lost or gained rank. what i'm looking way write javascript script can host on site remote includable on other sites maintain session server, loading scoreboard every 5 seconds , displaying results, including highlighting of changed rank players. basically guess need http client implemented in javascript can this. i've googled around there's lot of jargon parse. prefer not use jquery or whatever other library since these may present on remote sites , don't want cause conflicts. pure javascript solution ideal think. there 2 approaches can think of when dealing scoreboard application: 1) using php + ajax + mysql great if appl

actionscript 3 - Can I pass a button into its own MouseEvent function? -

i have multiple movieclip symbols published flash flashdevelop (i'll use 2 in example). each have 3 frames default, hover , click i'm using buttons. private var btnplay:playbutton, btnquit:quitbutton; btnplay = new playbutton(); btnquit = new quitbutton(); btnplay.addeventlistener(mouseevent.roll_over, onrolloverhandler); btnplay.addeventlistener(mouseevent.roll_out, onrollouthandler); btnplay.addeventlistener(mouseevent.mouse_down, onpresshandler); btnplay.addeventlistener(mouseevent.mouse_up, onreleasehandler); btnplay.buttonmode = true; btnplay.usehandcursor = true; function onrolloverhandler(myevent:mouseevent):void { btnplay.gotoandstop(2); } function onrollouthandler(myevent:mouseevent):void { btnplay.gotoandstop(1); } function onpresshandler(myevent:mouseevent):void { btnplay.gotoandstop(3); } function onreleasehandler(myevent:mouseevent):void { btnplay.gotoandstop(2); } // same code btnquit here, replace btnplay btnquit instead of adding

c# 4.0 - Certificate issue while writing script using selenium -

imported certificate security purpose of our website. doing manually page loads using script throwing error ![enter image description here][1] an error occur during connection url(required website) ssl peers cannot verify certificate. error code (ssl_error_bad_cert_alert) thanks lot kind of help. maybe self-signed certificate? have @ question, suggesting use -trustallsslcertificates switch. selenium testing https trust certificates working ff not ie switch

Need help advancing to the next record in Visual Basic -

ok attempting have form retrieve results. however, when retrieve results can retrieve next result if there 2 sets of results within file. need being able retrieve next sets of results if there more 2 sets of results in file for c = 0 ubound(scoring) step 3 txtsearch.text = scoring(c) txtname.text = scoring(c + 1) txtmarks.text = scoring(c + 2) next i think be: public intposition integer ' variable has public keep position dim bytstep byte bytstep = 3 ' go forward if intposition <= ubound(scoring) - (bytstep - 1) intposition = intposition + bytstep txtsearch.text = scoring(intposition) txtname.text = scoring(intposition + 1) txtmarks.text = scoring(intposition + 2) end if 'go backwards if intposition >= 0 intposition = intposition - bytstep txtsearch.text = scoring(intposition) txtname.text = scoring(intposition + 1) txtmarks.text = scoring(intposition + 2) end if

php - How do I write a code that produces a table of a party cost based on seven values? -

php – how write code produces table of party cost based on 7 values? so example, if min , max 60 , cost1 5, cost2 10, cost3 15, cost4 20 , cost5 25 this should start. //the (int) changes input integer, prevent code injection. //$_get takes variables url string, http://google.com?min=30&max=60 //$_post takes variables form on page gets submitted <input type="text" name="min" value="30" /> $min = (int) $_get['min']; $max = (int) $_get['max']; $costs = array( '5', '10', '15', '20', '25', ); echo '<table>'; for($i = $min; $i <= $max; $i++) { //if number divisible 5, show in table if($i % 5 === 0) { echo '<tr>'; echo '<td>' . $i . '</td>'; foreach($costs $cost) { echo '<td>' . $cost . '<br>' . $cost * $i . '</td>&#

php - Getting the number of affected rows including those not changed -

i doing statement this: update tbl set x = 1 y = 2 and using rowcount pdo whether or not row changed ( y unique, either none or 1 row updated). isn't need though, since, using previous example, if x already 1, rowcount() 0 since no row changed previous value. need know whether row matched where clause. is there way without doing query? it turns out pdo has thing: pdo::mysql_attr_found_rows .

osx - how to run cut command using single tick as a delimiter? -

i'm on mac 10.9.2 , trying take out data sql file. it has portions of csv values wrapped in single ticks ('), , take out field 5 here have far, , reason > @ end, asking me complete action, expect results? sh-3.2# more data.sql | cut -d ',' -s -f 5 | cut -d '\'' -f 1 > maybe there easier solution cutting? :) the problem using attempting escape single quote within single quotes. use different pair of enclosing quotes without escaping, or eliminate quotes altogether, i.e. either: cut -d\' -f2 or cut -d"'" -f2 (an alternate solution might available given sample data.)

knockout.js - How to handle many to many relationship in knockout viewmodels -

i have many many relation in schema between 2 tables service , employee ( a service can performed multiple employees , employee can perform multiple services ) . used serviceemployee junction table creating relationship. i using knockout @ client side. knockout viewmodels create through knockout.mapping plugin server side viewmodel. @ server side have 3 viewmodel are: employeemodel ( contain list of serviceemployeemodel ) servicemodel ( contains list of serviceemployeemodel ) serviceemployeemodel ( contains serviceid, employeeid) [cant include employee , service object in order avoid self reference loop @ client side] now @ client side have 3 modules: employee module function employee(data) { var self = this; ko.mapping.fromjs(data, { "services": { create: function (options) { return new serviceemployee(options.data, options.parent); } } }, self); .... } service module fu

batch file - Find and replace string between two documents (more times) -

i new @ programming , wanna make .bat script, take first string new.txt and find in text.txt , replace second string new.txt (there more 1 exact string in text.txt , script must search whole document). and then, after search whole document, script take new.txt third string, find in text.txt , replace fourth string new.txt , find fifth string new.txt , replace sixth string etc. i hope it, because english isn´t :-) everyone. here examples documents, if helps: text.txt: ale ne, ne, ne! try tape slot, maybe it's in there. try tape slot, maybe it's in there. hey now… hey now… you, "sheriff"? next time i'm gonna have charge you. blablabla. vsadil bych se, ze je tohle skvele misto pro veci, ktere nechces, aby nekdo videl. nevedel bych. byl tady uz kdy jsme se pristehovali, nemam k nemu klic. blablabla. new.txt: blablabla. blbblbblb. ale ne, ne, ne! no, no, no! try tape slot, maybe it's in there. zkus packu, mozna bude tam. this work

jquery - How to drop elements to a dynamically generated DIV, Drag function is working Fine -

here jquery code i'm using: jquery(function() { jquery(".component").draggable({ // use helper-clone append 'body' not 'contained' pane helper: function() { return jquery(this).clone().appendto('body').css({ 'zindex': 5 }); }, cursor: 'move', containment: "document" }); jquery('.drag-drop-box').droppable({ accept: '.component', drop: function(event, ui) { if (!ui.draggable.hasclass("dropped")) jquery(this).append(jquery(ui.draggable).clone().addclass("dropped").draggable()); } }); }); this code works fine on pre-loaded div. creating divs dynamically how can working dynamically generated div. this html code f static code dropping elements working well <div class="item-box"> <div id="tabs-1"> <div class

jquery - Search through a list of items to find a specific item with content in a specific attribute -

i have list of items. in each li custom attribute called data-index . i want search through items , find each item specific string present in attribute. i'm including whole thing here. suggestions? headed in right direction? my expectation if search bg19 i'll 1 report in console.log. i'm getting 10 each time. <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>a selectable list</title> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js" ></script> <style> .hidden { display:none; } .show { display:block; } </style> <script> $(document).ready(function() { $('#id-submit').on('click', $(this), function() { var userid = $('#user-

python - How many times does my code multiply the number: -

i given code (which integer exponentiation) , i'm supposed find out how many times code loops on while using (n1) , how many times if true using (n2) , how many multiplications done using (n3), think placed n1 , n2 correctly don't know should place n3 or how should count it. def power(a,b): n1=0 n2=0 n3=1 result = 1 while b>0: n1+=1 if b%2 == 1: # b odd result = result*a n2+=1 = a*a # squares power of b = b//2 # removes least significant bit of b n3+=1 return result,n1,n2,n3 since inside if statements multiplication done: result = result * you should increment n3 there: def power(a, b): n1 = 0 n2 = 0 n3 = 1 result = 1 while b > 0: n1 += 1 # loop if b % 2 == 1: result = result * n2 += 1 # if n3 += 1 # multiplication = * b = b // 2 n3 += 1 # multiplication ret

Weird Path in Git directory Structure -

i have seen following path in directory of .git. .git/object/3b/12abef878787483abeceddaa5544489abff789a when infact sha 3b12abef878787483abeceddaa5544489abff789a which sha of contents of file , hence should stored without /. why did git store blob in weird path,what advantages of doing so? the reason prevent there being many files in 1 directory. sha values start 3b stored in sub-directory 3b , workload on single directory 1/256 th of if blobs in single directory. ultimately, speeds performance; there less searching find particular blob. you can see similar effects in terminfo directory, entries sub-divided directories based on first letter of terminal entry. cpan system has authors/id/a/aa/aardvark in naming hierarchy. please elaborate little bit me. suppose git wants find blob 3b12abef878787483abeceddaa5544489abff789a , directory partitioning scheme not in use. there might be, sake of argument, 512 blobs, , file, kernel might have read 512 dire

Dynamically add image to android listView item -

Image
i'm trying dynamically add image listview row. have create custom cursor or something? don't know put code change image source. thanks. here activity, public class viewplayersactivity extends activity { listview namelist; mysqliteadapters adapter_ob; mysqlitehelper helper_ob; sqlitedatabase db_ob; button registerbtn; cursor cursor, cursor2, cursor3; string context; public static final string prefs = "exampleprefs"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_view_players); namelist = (listview) findviewbyid(r.id.listview); adapter_ob = new mysqliteadapters(this); bundle extras = getintent().getextras(); sharedpreferences exmaple = getsharedpreferences(prefs, 0); context = exmaple.getstring("teamname", "cant find team"); string[] = {helper_ob.key_fname, helper_ob.key_lname}; int[

java - What's wrong with my modified merge sort implementation? -

i'm trying write modified merge sorting excercise. stuck in why code doesn't work , cannot se problem?! hint or appreciate. in advance. here code: public class mergesort { public static void mergesort(int[] list) { mergesort(list, 0, list.length - 1); } private static void mergesort(int[] list, int low, int high) { if (low < high) { int middle = (high + low) / 2; mergesort(list, low, middle); mergesort(list, middle + 1, high); int[] temp = merge(list, low, high); system.arraycopy(temp, 0, list, low, high - low + 1); } } private static int[] merge(int[] list, int low, int high) { int low1 = low; int high1 = high; int mid = (low + high) / 2; int end_low = mid; int start_high = mid + 1; while ((low <= end_low) && (start_high <= high1)) { if (list[low] < list[start_high]) {

c++ - How should I provide library binaries to developers? -

i want make easy others work on repository. however, since of compiled dependencies on 100mb in size, cannot include them repository. github rejects files. what best way handle large binaries of dependencies? building libraries source not easy under windows , takes hours. don't want every developer struggle process. i've been working on using ivy ( http://ant.apache.org/ivy/ ) c++ binaries. basic idea build binaries every build combination. zip each build combination file name mypackage-windows-vs12-x86-debug.zip. in ivy.xml, associate each zip file 1 configuration (ex: windows-vs12-x86-debug). publish package of multiple zip files ivy repo. can either host repo or can try upload existing ivy repo. create package of zip files each dependency, , ivy.xml files describe dependency chain among packages. then, developers must set ivy. in ivy.xml files, list package dependency, along configuration need (ex: windows-vs12-x86-debug). need add ivy resolve/retrie

Instantiating Java objects from JavaScript -

i can instantiate java.lang.string object blank constructor like: var classstring = obj.getclass().forname ('java.lang.string'); var objectstring = classstring.newinstance(); but when want obtain reference constructor, code: var array = [classstring]; var constr = classstring.getconstructor (array); objectstring = ">>>>>>>>"; var objectstring2 = constr.newinstance ([objectstring]); produces empty string if zero-arguments constructor had been called. the constr variable points string() rather string(string tocopy) how can , call constructors arguments?

ios - JSON parsing: show data on UITableView -

this given api have parse.i have show name on uitableview . want fetch value of name n show on table view. code: - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [ episodes count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *simpletableidentifier = @"simpletableitem"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } cell.textlabel.text = [[ episodes objectatindex:indexpath.row] objectforkey:@"names"]; return cell; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { uialertview *logoutconfirm = [[uialertview alloc]initwithtitle:@"toilet finder" message:@"

java - Error while parsing a time string -

this question has answer here: unable parse datetime-string am/pm marker 4 answers i trying parse time strings this: string time_string = "10:00 am"; simpledateformat format = new simpledateformat("hh:mm a"); date date = null; try { date = format.parse(time_string); // 'date' } catch (parseexception e) { log.w("time", e.tostring()); } but parser failing exception: java.text.parseexception: unparseable date: "10:00 am" what doing wrong? the am/pm marker may not match of default locale try simpledateformat format = new simpledateformat("hh:mm a", locale.english);

sql - Generate 10,000 random values in a table -

i have oracle table. development purposes want generate 10,000 different values table. how can this? create table errorlog( errorid integer not null, errorcontent clob not null, errordate timestamp(6) not null ) if looking chaotic in clob (including length , content) may use dbms_random: sql> select dbms_random.string('p',dbms_random.value(1,30)) rand_str dual connect level <= 10 2 / rand_str -------------------------------------------------------------------------------- #<a tv&og8=:f}is/sr2l>f\7wcl)_v2 /wbp y)v5zd.v _yw(o_ b:5&e}7\a1gt]x}$}e*-w[6u=1

Parsing html with lxml in python -

i have following html code: ... <p class="footer">[[footer]] - <a href="/rss">feed</a> if want.</p> ... i trying extract "[[footer]] - feed if want." code including spaces (general task in find strings on page containing text "[[footer]]"). import lxml.etree et html = """ <p class="footer">[[footer]] - <a href="/rss">feed</a> if want.</p> """ elem = et.fromstring(html) infos = elem.xpath('/p') info in infos: print 1, info.text print 2, et.tostring(elem) # results: 1, [[footer]] - 2, <p class="footer">[[footer]] - <a href="/rss">feed</a> if want.</p> desired result [[footer]] - <a href="/rss">feed</a> if want. question it humbling have ask question, since doesn't seem should hard. how can extract strings on page containing text "[[footer]]

javascript - Full calender - Remove Events on day click and remove Bg-color of particular cell -

i need limit events 1 in particular date, , on click of date if events present, has removed. while adding event date, color of cell should turned orange, , while deleting event, has turned white. $(function () { // full calendar var date = new date(); var d = date.getdate(); var m = date.getmonth(); var y = date.getfullyear(); var calendar = $('#calendar').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, selectable: true, selecthelper: true, select: function(start, end, allday) { var title = prompt('event title:'); if (title) { calendar.fullcalendar('renderevent', { title: title, start:

xml - Android Studio requiring layout_width/height within <wallpaper> tag -

android studio insisting layout_width , layout_height required within tag. i'm pretty darn sure they're not reading here . i'm trying figure out if due error on part or weird android studio quirk. my layout file: <?xml version="1.0" encoding="utf-8"?> <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:thumbnail="@drawable/icon" android:description="@strings/description"/> a snippet of manifest: <service android:name="com.handmade.tavern.livewallpaper" android:label="@string/app_name" android:permission="android.permission.bind_wallpaper"> <intent-filter> <action android:name="android.service.wallpaper.wallpaperservice"/> </intent-filter> <meta-data android:name="android.service.wallpaper" android:resource="@layout/wallpaper_layout"/> </service&g

javascript - Change a background color of text by taking text name form url -

i want change background colour of text matches url value. have tried this <script> var full_url = document.url; var url_array = full_url.split('='); var textname = url_array[url_array.length-1]; $("a:contains(textname)").css("background-color", "white"); but it's not working can me? in advance note here aren't using value of textname variable in selector, because "a:contains(textname)" string. what want is: $("a:contains("+textname+")").css("background-color", "white");

ios - I have extra "cells"/lines in ipad scene -

Image
i creating app , on ipad's @ end of table lines. there way see plain gray color after table ends? not sure if doing wrong or trying impossible. on iphones don't have problems, because whole menu cannot fit screen when scroll bottom thats stops, on ipad has fill rest of screen something. yes. try your_tableview.tablefooterview = [[uiview alloc] initwithframe:cgrectzero];