Posts

Showing posts from January, 2010

android - Update native library without reinstalling the app -

i have app include 2 native library (for example libfirst.so, libsecond.so). loading libraries standard method. system.loadlibrary("first"); system.loadlibrary("second"); now need able update library without reinstalling app (without update .apk). can loaded native libraries method system.load("/storage/emulated/0/armeabi/libfirst.so"); system.load("/storage/emulated/0/armeabi/libsecond.so"); i think bad practice. tried copy manual libraries in folder getapplicationinfo().nativelibrarydir , system error: open failed: eacces (permission denied) best practices update native libraries without update apk ? what best practices update native libraries without update apk ? i don't believe contingency covered. code signing 2 things. first, ensures developer publishes app same 1 updates app. second, creates trust relationships between related apps (but not apply here). nikolay elenkov discusses topic @ code signing in

Access local server(WAMP) on an android device -

i trying access wamp running on computer (win 8.1) through android device. followed steps given in link . when run go ip address specified, " forbidden " error on phone. says: "you don't have permission acccess / on server." help?

azure - Cloud Service deployment rolled back -

we had strange issue couple of times our azure service. have cloud service installed has web application running on it. the service created sometime around beginning of december , first deployment done time well. after did multiple deployments cloud service, (it happens couple of times now) sometime azure decides roll deployment initial 1 - 1 made 2 months ago. happened midnight once again , see files creation date on "restored" or "rolled back" instance 12/5/2013, seems date when did initial deployment. a question: 1) why happen? 2) how can determine caused rollback? 3) how can prevent rollback? or 4) how can make "snapshot" of cloud service when rollback happens, rolls latest stable image? thanks, denis how doing "after did multiple deployments cloud service"? doing via webdeploy or via rdp azure vm? paas cloud service vms stateless. code running website rebuilt original .cspkg uploaded. see http://blogs.msdn.com/b/kwill

html - Circle leaking out of border -

i have designed countdown timer website. problem circle of countdown 'leaks' out of border. link picture: http://imgur.com/lpr11lu html code div#sectioner { position: relative; background-color: white; z-index: 200; display: inline-block; height: auto; border: 500px; width: 100%; padding-top: 5%; padding-bottom: 5%; } .countdown-container { position: relative; width: 100%; margin-left: auto; margin-right: auto; align-content: center; height: 40%; display: inline-block; } .clock-item .inner { height: auto; float: left; position: relative; width: 15%; display: inline-block; padding-right: 5%; padding-left: 5%; } .clock-canvas { background-color: rgba(54, 194, 182, 0.96); border-radius: 100%; display: inline-block; height: 0px; position: relative; width: 100%; height: 100%; } .text { color: #ffffff; font-size: 30px; font-weight: bold; position: absolute; to

java - Is there any difference between == null and .equals("null")? -

i confused following code. why compare both == , equals method? (validfolderrow.getbondtafoldertype() == null || validfolderrow.getbondtafoldertype().equals("null")) what's difference between equals() , ==? can tell me difference between validfolderrow.getbondtafoldertype() == null and validfolderrow.getbondtafoldertype().equals("null") ? validfolderrow.getbondtafoldertype() == null compares null (i.e. checks if validfolderrow.getbondtafoldertype() null). validfolderrow.getbondtafoldertype().equals("null") compares validfolderrow.getbondtafoldertype() string value "null" . note first comparison must done first, since if validfolderrow.getbondtafoldertype() null, can't call equals on (since throw nullpointerexception ). since || short circuit operator, evaluating first operand true prevent second operand being evaluated.

javascript - Change link color on click Jquery -

i code in html / css , jquery : $('.myfilters li').click(function() { $(".category").hide(); var v = $(this).text()[0] $('.title li').hide().filter(function() { return $(this).text().touppercase()[0] == v; $(".category:first").show(); }).show().first().find('a[data-toggle]:first').trigger('click'); }) $("a[data-toggle]").on("click", function(e) { e.preventdefault(); // prevent navigating var selector = $(this).data("toggle"); // corresponding element $(".category").hide(); $(selector).show(); }); $('.myfilters li:first').trigger('click'); //$('.title li:first a[data-toggle]').trigger('click'); .myfilters, .title { margin: 0; padding: 0; } .myfilters { display:inline-block; margin-right: 10px; margin-bottom: 15px; } .myfilters li { display:inline-block; margin-

java - How to import netbeans project to eclipse ignoring package declaration? -

i have (legacy) netbeans project i'd import , maintain in eclipse . sake of have provide backwards compatibility netbeans project recourses. problem: source folders have hirarchie src/java/de/mycompany/... , classes themself have following package imports: package de.mycompany; //error public class mainclass { } when opening project in netbeans ide not complain package source mismatch. eclipse does: error: declared package "de.mycompany" not match expected package "java.de.mycompany" . question: how can overcome this, if possible @ all? cannot move java classes "right" package declaration of packages have left untouched compatibility reasons... you need configure source folders in eclipse. right-click on project , select properties navigate java build path open source tab click on add source button , select src/java folder in order add source folder. you note change adds classpathentry entry within eclipse specif

javascript - how to insert property in all objects? -

i trying add properties in object present in array.i explain more in other words have array of objects .i need add “selected” property in object .the value of “selected” property true first 2 object , rest element false .i need add “selected” :true first 2 element , rest “selected” :false secondly can remove object array have property "hidden" : true , ? angular.module('app', ['ionic']).controller('firstcntrl',function($scope){ $scope.copyarrary =[]; angular.foreach($scope.data, function(value,key) { console.log(value + key) }); }) js fiddle https://jsfiddle.net/93afl7kq/1/ to remove filter first: $scope.data = $scope.data.filter(function (element) { return !element.hidden; } after set properties: for(var = 0; < $scope.data.length; ++i) { $scope.data[i]['selected'] = <= 1; }

single sign on - Sugarcrm and Auth0 SSO enabling -

i have 1 sugarcrm application , web application. user login purpose using auth0 in web application. when user logged application, same user want login in sugarcrm. possible using sso? or need pass corresponding logged in user details sugarcrm login? please suggest better option yes possible. need enable saml in sugarcrm. in auth0 add sugarcrm other app ( dashboard > apps/api > new ), configure saml ( addons > saml ). the parameters in auth0's saml config app dependent (whatever sugarcrm expects). important parameters are: the "acs". url saml response sent (this location in sugar) the signing certificate (you find on usage section of auth0's saml config). certificate samlresponse signed with.

regex - Regular expression: add string at start and end of line -

i have text file , want add string each row @ start , end of line. for example: binary_xml_record_prefix_dictionary_attribute_z after regex action: case binary_xml_record_prefix_dictionary_attribute_z: thanks. you can use following match: (.+) and replace with: case $1: see demo

android - volley how to parse params to JsonObjectRequest getParams does not work -

as old version of volley.jar . pass params following method: @override public byte[] getbody() { if (params != null && params.size() > 0) { return encodeparameters(params, getparamsencoding()); } return null; } but need update volley, , find method(encodeparameters()) changed private. i found override method of getparams() , did not work me. method getbody of jsonobjectrequest following: public byte[] getbody() { try { return mrequestbody == null ? null : mrequestbody.getbytes(protocol_charset); } catch (unsupportedencodingexception uee) { volleylog.wtf("unsupported encoding while trying bytes of %s using %s", mrequestbody, protocol_charset); return null; } } getparams() never called. cannot pass params now. i tried pass params in construct method has jsonobject param, did not work either. hope i'm understanding correctly. an easier way pass p

assembly - Memory occupied by STP instruction -

assume following instruction: stp x29, x30, [sp, -32]! assuming stack pointer @ address 0, address x29 , x30 stored: option 1: [sp-16] , [sp-32] option 2: [sp-32] , [sp-40] i know stack grows towards low addresses, whenever storing occupy towards growing addresses, hence think 'option 1' right answer. what think? regardless of addressing modes, memory accessess of more 1 byte start @ given base address , ascend, "option 2" 1 part either side of base address not right. beware initial stack pointer of 0 invalid given you're trying store below - result of address calculation underflows or overflows architecturally unknown, whilst hardware might happen produce expected address, shouldn't rely on it. in case, if example initial sp 0x1000, you'd have bytes of first register ( x29 ) stored addresses 0x0fe0..0xfe7 (in appropriate order current endianness), bytes of second ( x30 ) stored 0xfe8..0xfef, , 0xfe0 written sp .

ios - Adaptive layout for iPad -

Image
i following article building adaptive layout in ios building adaptive user interfaces ios 8 . it work fine on iphones . wan't give same effect on ipad. ipad adaptive layout not work. here screenshot of application in iphone5 (green box represent view1 , yellow box represent view2) 1.portrait mode landscape mode question : how can achieve same effect ipad? expanded question: how set initial orientation of ipad in landscape mode? the problem ipad both orientation represented regular. one of solution add 2 iboutlet collection view controller want orientation change happened, example: @iboutlet var landscapeconstraints: [nslayoutconstraint]! @iboutlet var portraitconstraints: [nslayoutconstraint]! go storyboard, switch adaptive layout want happened in ipad portrait orientation , control drag every active constraints portraitconstraints iboutlet. change adaptive layout 1 want happened landscape , again control drag active constraints lands

swift - Nest a table view into a grouped table view -

good morning everyone, i newbie swift developer , receive advice experts on how solve following problem dealing with. i have table view 2 sections: first 1 contains 4 rows , second one. want display below second section, new table view showing data loaded core data; far have dragged , dropped container view controller embedding new table view (the 1 want display) , coded population of table view in corresponding tableviewcontroller class created. is there clever way embed nested table within main table (the 1 2 sections mentioned before)? following right path or on wrong one? in advance kindness , cooperation. nested tableviews not thing in ios. should re-consider design. if need offer options depends on previous selection, present new view (a new "page") tableview containing "sub-options".

testng - Eclipse with MoreUnit - Running test with Ctrl+R gives error: "Cannot find 'junit.framework.TestCase' on project build path -

i have defined class this: @service public class storeservice { ... } now, moreunit installed press ctrl+j , dialog box pops , create corresponding test class: @test public class storeservicetest { ... } this fine, , able move , forth between implementation class , test class using ctrl+j. the problem comes when try run test using ctrl+r. in eclipse projects works fine, in other projects following message: cannot find 'junit.framework.testcase' on project build path. junit 3 tests can run if junit on build path. now bit annoying since not using junit @ all, testng instead. i have searched through eclipse project settings couple of times no luck. quite sure solution in there somewhere. kinda hoping bit more experienced in ways of "eclipse project configuration" point me in right direction. i don't know if still needed, here. can set in preferences, like following

aggregation framework - need expert opinion - mongodb query -

i need expert evaluation concerning created queries. there collection "myresults" documents of such view: { "_id": 0, "name": "aimee zank", "scores": [{ "type": "exam", "score": 1.463179736705023 }, { "type": "quiz", "score": 11.78273309957772 }, { "type": "homework", "score": 6.676176060654615 }, { "type": "homework", "score": 35.8740349954354 }] } task: to write query searching students, have "score" > 93 , < 95 in "type". to write aggregate query in order select students, have "exam" result > 90. to add field "accepted" value = true student dan doe. solution: 1. db.myresults.find({ $or: [{ $and: [{ "scores.type": "exam" }, { "scores.score&

Why Output of c++ code changes when I change the function return type? -

class test { private: int x; int y; public: test(int x = 0, int y = 0) { this->x = x; this->y = y; } test &setx(int a) { x = a; return *this; } test &sety(int b) { y = b; return *this; } void print() { cout << "x = " << x << " y = " << y << endl; } }; int main() { test obj1(5, 5); obj1.setx(10).sety(20); obj1.print(); return 0; } the above code has output 10 20 when change return type of test &setx test setx , test &sety test sety , output changes 10 5 . can explain reason same ? not assignment quoestion or related homework. it temporary object. in version without return reference, i.e. return type test code equivalent test obj1(5, 5); test temp1 = obj1.setx(10); test temp2 = temp1.sety(20); // temp2 have x = 10 , y = 20, object discarded obj1.print(); as can see sety(20) called on temporary object, , returned value discarded. first setx(10) modify obj1 on other h

Classical Inheritance in JavaScript : Reassigning the constructor -

i trying learn inheritance in javascript using prototype keyword. i came code across web-site explained me classical inheritance in javascript. using mozilla rhino command-line javascript this code var fn55 = function(){ var employee = function(name){ var name = name; this.getname = function(){ return name; }; this.setname = function(empname){ name = empname; }; }; var contractemp = function(name,sal){ var salary = sal; this.getsalary = function(){ return salary; } //calling super constructor employee.apply(this,[name]); }; contractemp.prototype = new employee(); contractemp.prototype.constructor = contractemp; var emp1 = new contractemp("jack",3000); var emp2 = new contractemp("john",4000); print(emp1.getname()); print(emp2.getname()); print(emp1.getname()); employee.

powershell - How to count files in FTP directory -

i have script. i'm trying count how many file in. clear $ftp_uri = "ftp://ftp.domain.net:" $user = "username" $pass = "password" $subfolder = "/test/out/" $ftp_urix = $ftp_uri + $subfolder $uri=[system.uri] $ftp_urix $ftp=[system.net.ftpwebrequest]::create($uri) $ftp.credentials=new-object system.net.networkcredential($user,$pass) #get list of files in current directory. $ftp.method=[system.net.webrequestmethods+ftp]::listdirectorydetails $ftp.usebinary = $true $ftp.keepalive = $false $ftp.enablessl = $true $ftp.timeout = 30000 $ftp.usepassive=$true try { $ftpresponse=$ftp.getresponse() $strm=$ftpresponse.getresponsestream() $ftpreader=new-object system.io.streamreader($strm,'utf-8') $list=$ftpreader.readtoend() $lines=$list.split("`n") $lines $lines.count $ftpreader.close() $ftpresponse.close() } catch{ $_|fl * -force $ftpreader.close() $ftpresponse.close() } in directory have 3 files $lines.cou

c++ - Open Pegasus 2.14.1 client connection issue -

i build new version of open pegasus client (2.14.1). unfortunately i'm facing build issues. know workaround these issues? my environment is: os: windows 8.1 enterprise make version: gnu make 3.81 pegasus sources version: 2.14.1 openssl version: 1.0.2a my scenario quite easy: i have downloaded source code of open pegasus 2.14.1 i have downloaded openssl binaries (actual version v1.0.2a). after extraction of pegasus source code set environment these settings: call "c:\program files (x86)\microsoft visual studio 12.0\vc\bin\vcvars32.bat" set pegasus_root=d:/dev/pegasus-2.14.1/pegasus set pegasus_home=%pegasus_root% set pegasus_platform=win32_ix86_msvc set path=%path%;%pegasus_home%\bin set openssl_home=d:/dev/openssl-win32 set pegasus_has_ssl=true next step building of mu.exe tool. so, have executed "make buildmu" => build , copied "/bin" folder. build pegasus so: "make build" => after time got error: message.cpp(4

javascript - Getting the size of a resized BG image -

i have div background image, size set contain : .image{ width: 95%; height: 95%; position: absolute; margin: 0 auto; left: 0; right: 0; top: 50%; -webkit-transform: translatey(-50%); background-image: url('image_url'); background-size: contain; background-repeat: no-repeat; background-position: center center; } large images being "scaled down" fit in div. want width , height of image after scaled down background-size: contain; i tried following: var myimg, frame; document.addeventlistener("domcontentloaded", onload); function onload() { myimg= document.getelementbyid('image'); frame = document.getelementbyid('frame'); var img = new image(); img.src = window.getcomputedstyle(myimg).getpropertyvalue("background-image").replace(/url\(|\)$/ig, ""); img.onload = function() { var imgheight = img.height; console.log(imgheight); }

java - Event on chekbox -

i'm developing java interface coding in swing , use checkbox. when click on checkbox make continuous event (because in event make weft , send microcontroller) don't know how do. tried make actionlistener make action 1 time. who can me please ? :) here code tried : checkbox.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { // ------------------------------------------------------------| // déclaration des variables de la trame de la liaison // montante| // -----------------------------------------------------------| float capgps = -30; float longi = 30; float lat = 50; float h = 50; float capm = 50; float v = 50; float r = 50; float tsurvol = 50; float dist =

android - how can I change the color of the tabBar in tab fragment (Viewpager) -

i tried many times it's not ok. try change actionbar in mainactivity tabbar doesn't change, don't no how change it. this code : mainactivivty public class mainactivity extends fragmentactivity implements actionbar.tablistener { private viewpager viewpager; private actionbar actionbar; private tabspageradapter madapter; private string[] tabs = { "bài hát", "yêu thích"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); actionbar ac = getactionbar(); ac.setbackgrounddrawable(new colordrawable(color.rgb(72, 209, 204))); //ac.setbackgrounddrawable(new colordrawable(color.parsecolor("#e64260"))); viewpager = (viewpager) findviewbyid(r.id.pager); actionbar = getactionbar(); madapter = new tabspageradapter(getsupportfragmentmanager()); viewpager.setadapter(madapter); actionbar.setnavigationmode(actionbar.n

testcomplete - How to connect database with test complete tool -

i want connect mysql database of test complete. able connect mysql work bench never try test complete tool. you can use script in language php, python, java ....etc. , call test complete example use python can use code import mysql.connector cnx = mysql.connector.connect(user='scott', password='tiger', host='127.0.0.1', database='employees') cnx.close() you find read more here http://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html good luck!

R trying to create start and stop times from single column -

i r beginner , have got stuck seemingly simple problem. have large data frame 4 columns; id, date of observation, value (alb) , end date. single id may have between 1 , 15 or observations @ different dates. end date time of event or censoring 1 per id. id date alb end 1143 2010-03-23 41 2010-12-15 1143 2010-06-29 39 2010-12-15 1144 2008-01-01 34 2009-08-06 1145 2010-03-23 42 2012-10-25 1145 2011-01-12 45 2012-10-25 for survival analysis using alb time varying covariate trying create episode each observation start , stop time column. trying create column stop time start time next alb observation or end time if there no further alb observation id. so: id date alb end start stop 1143 2010-03-23 41 2010-12-15 2010-03-23 2010-06-29 1143 2010-06-29 39 2010-12-15 2010-06-29 2010-12-15 1144 2008-01-01 34 2009-08-06 2008-01-01 2009-08-06 1145 2010-03-23 42 2012-10-25 20

Unable to detect Nvidia Graphic on Fedora -

i bought lenovo y50 9 months has nvidia geforce gtx 4gb graphic card coupled intel 2gb internal graphic card. worked fine in windows. formatted system install fedora 21 favorite os. 2 bad things happened me. 1. dealing uefi first time, lost windows permanently. 2. fedora not detecting nvidia graphic card. i searched lot past 8 months solution. changed bios setting switchable graphic uma , , reinstalled fedora several times , without uefi. i cant started because when lspci | grep vga shows 1 graphic card (intel's), , everywhere written should show both graphic cards. same case when tried install fedora 22 week. how can nvidia's graphic card detected in fedora. ( 21 or 22 ), if not both? , proper drivers it?

javascript - Uncaught Error: Container Is Not Defined - Google Charts -

i'm trying load google chart , getting following answer: uncaught error: container not defined i've read other questions message google charts , common problem seems if getelementbyid isn't working correctly. however, don't believe issue me, or @ least not issue in same way others. this google charts code have: google.load('visualization', '1.0', {'packages':['gauge']}); google.setonloadcallback(drawchart); function drawchart() { var data = google.visualization.arraytodatatable([ ["label", "value"], ["match", state.greens[0].score] ]); var options = { redfrom: 90, redto: 100, yellowfrom: 75, yellowto: 90, minorticks: 5 }; var chart = new google.visualization.gauge(document.getelementbyid("chart-div")); chart.draw(data, options); setinterval(function() { d

python - Remove all style, scripts, and html tags from an html page -

here have far: from bs4 import beautifulsoup def cleanme(html): soup = beautifulsoup(html) # create new bs4 object html data loaded script in soup(["script"]): script.extract() text = soup.get_text() return text testhtml = "<!doctype html>\n<head>\n<title>this example </title><style>.call {font-family:arial;}</style><script>getit</script><body>i need text captured<h1>and this</h1></body>" cleaned = cleanme(testhtml) print (cleaned) this working remove script it looks have it. need remove html tags , css styling code. here solution (i updated function): def cleanme(html): soup = beautifulsoup(html) # create new bs4 object html data loaded script in soup(["script", "style"]): # remove javascript , stylesheet code script.extract() # text text = soup.get_text() # break lines , remove leading , trailing spac

Android Firebase, simply get one child object's data -

i have been looking way 1 child object's data in android firebase. i have found things firebase retrieve child android . solutions suggesting using "childeventlistener", need data @ moment, not when moved, deleted, updated, etcetera. my data kept in https://.firebaseio.com/users//creation string. figure there must simple way access without needing much, because if copy exact url browser, can see the: 'creation: "2015/05/31 21:33:55"' right there in "firebase forge dashboard". if knows how access without listener change appreciated! thank you! firebase listeners fire both initial data , changes. if you're looking synchronize data in collection, use childeventlistener . if you're looking synchronize single object, use valueeventlistener . note in both cases you're not "getting" data. you're synchronizing it, means callback may invoked multiple times: initial data , whenever data gets updated. thi

ios - Swift: remove layer, without removing UIView in UITableViewCell -

i have uitableviewcell uiview in it. made cabasicanimation , attach new cashapelayer, add layer super layer in uitableviewcell: self.layer.addsublayer(mylayer!) all nice except mylayer (and animation) showing above uiview . want label below uiview . i achieve adding uiview layer same way: self.layer.addsublayer(myviewlayer!) in case, uiview layer on top of cashapelayer animation. but have problem, need remove layer of uiview - myviewlayer because violates width of uiview when scroll. when animation done, , need remove layers, can remove cashapelayer - mylayer without troubles. mylayer?.removefromsuperlayer() but when try same myviewlayer , uiview removed too. don't want that, need uiview on screen , in view hierarchy. i don't understand why, if self.layer.sublayers see (before adding layers): [<calayer: 0x7fd1f0d4fe40>, <calayer: 0x7fd1f0ddc950>] and after animation done , mylayer removed: [<calayer: 0x7fd1f0d4fe40>, <cal

http - Making requests with node.js in a loop performance -

i'm trying benchmark node.js express app following using request library: var request = require('request'); var totalrequests = 100000; for(var = 0; < totalrequests; i++) { (function(i) { request('http://localhost:3000/', function(error, response, body) { console.info('request ' + (i + 1)); }); })(i); } when run it, don't see console.info() request callback requests on 40 seconds, start. should'nt see requests firing right away? 40 seconds may amount of time takes prepare 100,000 requests. since you're looping synchronously, callbacks can't called until after of requests have been initiated. i suggest library async if intended make or of requests in series rather in parallel.

javascript - MVC - Using Viewbag variable to determine Partial View not working -

i set viewbag variable (flag) determine partial view show in shared layout view. partials set of icons. when "more" icon clicked want swap in different partial different set of menu icons. "more" icon click code set in layout javascript: $(function () { $('#moreicon').click(function () { $.ajax({ url: 'home/loadmoreicons', datatype: "html", success: function (data) { } }); }); }); the controller action is: public emptyresult loadmoreicons() { viewbag.arrowclick = true; return null; } the _layout view (razor) code is: <div id="headicons"> @if ((bool?)viewbag.arrowclick == false) { @html.partial("mainiconspartial") } else { @html.partial("moreiconspartial") } </div> whats happening "else" logic never happens though can break @ point viewbag variable g

Send private message with phpbb - Delphi -

i've spent hours trying understand why doesn't work, no success ;( i want send private messages delphi application. i can login, read , delete messages, can't manage send messages (my forum use phpbb3). analysing post data, got this: post url: http://example.com/ucp.php?i=pm&mode=compose&action=post&sid=xxxxx post data: username_list= icon=0 subject=assunto message=texto address_list[u][2]=to lastclick=xxxx status_switch=0 post=submit attach_sig=on creation_time=xxxx form_token=xxx the xxx values need before send. i've manually checked values, , correct. my code: procedure envia(); var form_token, cr_time, sid: string; pp: tstringlist; begin //download page values (token, sid...) fpagesource.text := fcon.get('http://example.com/ucp.php?i=pm&mode=compose&u=2'); //form token form_token := tregex.match(fpagesource.text, 'form_token" value="(\w+)"').groups[1].value; //creation time cr_ti

pip - Python packages -- system and user's have different versions -

if have sudo pip install python package system-wide location and pip install --user different python package user location what python use when import packagename ? how control version? or python uses updated one?

java.util.scanner - Java Scanner hasNextLine returns false -

i have several files (actually java source files saved in eclipse on ubuntu) need read , process line line. i've noticed cannot read 1 of files. code using below try (scanner scanner = new scanner(file)) { while (scanner.hasnextline() ) { builder.append(scanner.nextline()).append("\n"); } } catch (filenotfoundexception ex) { system.out.println("error"); } i checking beforehand if file exists. , does. can rename it. cannot read single line. hasnextline returns false. (i try hasnext). at end take @ content of file , find there different looking character (which in comment section of java file). following character. ¸ when delete character, can read file normally. not acceptable. can read files character in it? this character set issue, caused fact platform running java code uses default different set; always practice specify expected/needed character set used when parsing, , scanner class matter of calling constructor a

java - Writing a "\t" to a text file creates a line? -

i'm writing 2 textfiles , wanted eaiser way read textfiles without words , number laying close eachother chose write them tab seperate them. when class linenumberreader seems think tab new line. i have 2 classes. textwriting , comparetextfiles when run textwriting class can output this: (1)       word1 (2)       word2 (3)       word3 so working intended. (i used spaces formatting purposes, file contains tabs correctly) and in other class comparetextfiles i compare 2 textfiles wrote first class. important code this. string word,word2; int i; lnr = new linenumberreader(new filereader(file)); while (sc.hasnext() && sc2.hasnext()) { word = sc.next(); word2 = sc2.next(); lnr.readline(); if (word.equalsignorecase(word2)) { = lnr.getlinenumber(); system.out.println("line number: " + + " , word: [" + word + "]" + " , word " + "[" + word2 + &

java - Access web service with basic authentication -

i need access web service authentication. give me soap , wsdl. can input username/password in soapui , response. told me use basic authentication in web service. how username , password transferred? htp://xxx/xxxservice?userid=&password=? or username/password saved in soap message? and how can deal username/password in client code generated wsimport? can input them? i using jax-ws, wsgen , wsimport access service. i'm not expert myself if you're using basic auth jax-ws can use authenticator myauth = new authenticator(){ @override protected passwordauthentication getpasswordauthentication() { string user="user",pass="pass"; return new passwordauthentication(user, pass.tochararray()); } }; authenticator.setdefault(myauth); i call inside method actionperformed(actionevent ae), when call action of button, , works fine. i've read security risk, basic test works fine.

c# - TcpClient- how to connect to an external IP address? -

i have been trying setup basic scenario tcpclient connects tcplistener on same machine, far works 127.0.0.1 , 192.168.x.y . here code: var server = new tcplistener(ipaddress.any, 51328); server.start(); var client = new tcpclient(); client.connectasync(ipaddress.parse("address whatismyip"), 51328); server.accepttcpclient(); // hangs indefinitely here console.readkey(); i got external address whatismyip i'm not sure if i'm doing correctly. incorrect procedure? i assuming trying connect on internet? if connected via internet provider comcast have cable modem? sort of thing going need setup port forwarding on router. the internet see's cable modem, requests internet go out cable modems ip, router able "route" packets , 192.168.x.x address on behalf, in order have 192.168 machine able listen , accept must tell router forward messages on port 51328 machine. so code listen port 51328 using 192.168.x.xx address, setup router. t

Clickable Icon in Python GTK -

does know how create custom button custom icon in pygtk? make program in python gtk works similar settings menu or control panel. know pygtk has stock buttons cancel, exit, , ok; i'm unable change labels or icons of buttons. you can put button on screen, , put image in it. #!/usr/bin/env python # -*- coding: utf-8 -*- # # test_icon.py # # copyright 2015 john coppens <john@jcoppens.com> # # program free software; can redistribute and/or modify # under terms of gnu general public license published # free software foundation; either version 2 of license, or # (at option) later version. # # program distributed in hope useful, # without warranty; without implied warranty of # merchantability or fitness particular purpose. see # gnu general public license more details. # # should have received copy of gnu general public license # along program; if not, write free software # foundation, inc., 51 franklin street, fifth floor, boston, # ma 02110

sorting - How do you sort by ascending order from a txt file in python? -

i new python , have simple question. have txt file road names , lengths. i.e. main street 56 miles. stumped on how call on file in python , sort road lengths in ascending order. help. let's assume there "miles" after every number. (this untested code can edited think idea right). edit: tested import collections originaldict = {} newdict = collections.ordereddict() def isnum(string): try: if string ".": return true float(string) return true except exception: return false line in open(input_file, "r"): string = line[:line.find("miles") - 1] print string curnum = "" c in reversed(string): if not isnum(c): break curnum = c + curnum originaldict[float(curnum)] = [] originaldict[float(curnum)].append(line) num in sorted(originaldict.iterkeys()): newdict[num] = [] newdict[num].append(originaldict[num][0])

javascript - jsfiddle Amchart example not working -

i have implemented amchart example codepen: http://codepen.io/amcharts/pen/e44996db5f40cf18b586f089a9988d32 var chart = amcharts.makechart("chartdiv", { (code above required stackoverflow have posted codepen.io link) in jsfiddle: http://jsfiddle.net/3j9pnr6v/ var chart = amcharts.makechart("chartdiv", { (code above required stackoverflow have posted jsfiddle link) i cannot produce chart - "result" pane remains empty - suggestions? if @ console log in chrome see says error uncaught referenceerror: weekendguides not defined categoryaxis: { guides: weekendguides << not defined. }, what weekendguides need set to.. problem set value , work. tip @ console log see if tells whats wrong code.. javascript let know issue. :)

ruby on rails - `Assigns` isn't working in my integration test -

i'm trying write test following suggestion on https://stackoverflow.com/a/17002140/4499505 . my simplified test: test "test" log_in_as(@user) users_path assert_template 'users/index' assigns[:users].each assert_select 'a[href=?]', users_path(user) end end the error result: nomethoderror: undefined method `each' nil:nilclass the controller method: def index @users_grid = initialize_grid(user.where(verified: true), per_page: 15, order: 'users.username', order_direction: 'desc') end apparantly assigns[:users] empty though there users in fixtures file. doing wrong? understand assigns[:users] should assign exact same users shown on users/index , want. well, correct code : test "test" log_in_as(@user) users_path assert_template 'users/index' # in controller have instance var # @users_gird, not @users. assigns[:users_grid].ea

Kartik Yii2 Typeahead Widget event listener not working -

i have kartik yii2 typeahead widget in view: echo \kartik\typeahead\typeahead::widget([ 'name' => 'serial_product', 'options' => [ 'placeholder' => 'product name / sku / serial number / coupon code', 'autofocus' => "autofocus", 'id' => 'serial_product' ], 'scrollable' => true, 'pluginoptions' => [ 'highlight' => true, 'minlength' => 3 ], 'dataset' => [ [ 'remote' => [ 'ttl' => 0, 'url' => url::to(['invoice/ajaxgetinventoryitemsnew']) . '?search=%query', 'ajax' => ['complete' => new \yii\web\jsexpression("function(response){jquery('#serial_product').removeclass('loading');checkresult(response.responsetext);return tr

android - How to start fragment from a specific position and be able to go to previous positions? -

i have listview. when click on element of listview pass 2 string arrays , list position. use information start pager of fragments. working fine. information, displayed. let's click on listitem-5, new fragment start @ 5 , i'll able go 6,7,8 etc., won't able go left @ 4,3,2,1.how can achieve ? public class viewpagerfragment extends fragmentactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_view_pager_fragment); arraylist<string> email=getintent().getextras().getstringarraylist("email"); arraylist<string> about=getintent().getextras().getstringarraylist("about"); int listposition = getintent().getextras().getint("position"); viewpager vppager = (viewpager) findviewbyid(r.id.vppager); adapterviewpager = new mypageradapter(getsupportfragmentmanager(),email,about,listposition)

python - Cannot figure out what input to use to get cv2.calcOpticalFlowPyrLK method to work -

i trying make program in python opencv user can define points on video , optical flow track it. i tried create own coordinates in form of numpy array , tried pass calcopticalflowpyrlk method in opencv, error instead: traceback (most recent call last): p1, st, err = cv2.calcopticalflowpyrlk(old_gray, frame_gray, d, none, **lk_params) error: /build/buildd/opencv-2.4.8+dfsg1/modules/video/src/lkpyramid.cpp:593: error: (-215) (npoints = prevptsmat.checkvector(2, cv_32f, true)) >= 0 in function calcopticalflowpyrlk my code: # params shitomasi corner detection feature_params = dict( maxcorners = 1, qualitylevel = 0.01, mindistance = 10, blocksize = 7 ) p0 = np.array([[[348.0, 251.0]]]) # calculate optical flow p1, st, err = cv2.calcopticalflowpyrlk(old_gray, frame_gray, p0, none, **lk_params) i know caused p0 variable because if make p0 this: p0 = cv2.goodfeaturestotrack(old_gray, mask = mask_use, *