Posts

Showing posts from July, 2011

winforms - C# timer stop after some number of ticks automatically -

how stop timer after numbers of ticks or after, let's say, 3-4 seconds? so start timer , want after 10 ticks or after 2-3 seconds stop automatically. thanks! you can keep counter like int counter = 0; then in every tick increment it. after limit can stop timer then. in tick event counter++; if(counter ==10) //or whatever limit yourtimer.stop();

Google Maps for Android. Failed to load map. Could not contact Google servers -

i'm trying work google maps on android should appear map white , error: failed load map. error contacting google servers. i've followed many tutorials , answers related on problem still can't fix it. think have correct api key (google maps android) , permissions, perhaps forget , me. android version 4.1.1. lot. the androidmanifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mapmap" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="17"/> <uses-feature android:glesversion="0x00020000" android:required="true"/> <permission android:name="com.example.mapmap.permission.maps_receive" android:...

mongodb - Join Through Map reduce -

i have 1 collection in student_id primary key: test1:{student_id:"xxxxx"}, i have collection in student_id inside array of collection: class:{"class":"i",students:["student_id":"xxxx"]} my problem want join these 2 tables on basis of student id, i using map reduce , out "merge", won't work. my mr query follows. db.runcommand({ mapreduce: "test1", map : function map() { emit(this._id,this); }, reduce : function reduce(key, values) { return values; }, out : { merge: "testmerge" } }); db.runcommand({ mapreduce: "class", map : function map() { emit(this._id,this); }, reduce : function reduce(key, values) { return values; }, out : { merge: "testmerge" } }); but inserts 2 rows. can 1 guide me regarding this,i new mr as in example want details of student "test1" collection,studying in class "i". your requir...

matlab - PCA codes input, use for PalmPrint Recognition -

i'm new matlab. i'm trying apply pca function(url listed below)into palm print recognition program generate eigenpalms. palm print grey scale images dimension 450*400. before using it, trying study these codes , add codes save eigenvector .mat file. of %comments added me self understanding. after few days of studying, still unable answers. decided ask helps.i have few questions ask regarding pca.m. pca.m what input of "options" should be? of "pca(data,details,options)" (is integer reduced dimension? trying figure out "options" value passing, still unable ans. msgbox of "h & h2", check codes run until where. trying use integer of 10, pca.m processed dimension 400*400.) the "eigvector" save ".mat" file ready perform euclidean distance classifier other eigenvector? (i'm thinking eigvector equal eigenpalm, in face recognition, eigen faces. trying convert eigenvector matrix image, image after pca proces...

javascript - Hover over an image so that another hover image can perform an animate -

so, have project school , and partially got answer reveal image underneath mask css/javascript awesome. the thing is, not want color move when point mouse on glass. instead, if have 5 small thumbnails of different colors (listing on side of glass), when point each of them, color moving in glass. possible? me please. thank much! basically need change color of div water "animation". can $("div").css("background-color", color); attached events on display objects (5 small thumbnails in case). here small example @ jsfiddle: http://jsfiddle.net/martintale/mz6vh/1/

visual studio 2010 - Parameterless constructor in c# -

i writing unit test existing class "person" in visual studio 2012 , class has constructor 2 parameters , business logic. testmethod() public void verifypersontest() { //using privateobject class privateobject privatehelperobject = new privateobject(typeof(person)); //some business logic } when try run above test got exception "system.missingmethodexception {"no parameterless constructor defined object."}" .so have added parameterless constructor person class , able run test without issue. i have following questions 1)as have added parameterless constructor person class ,will break existing functionality of person class? 2) privateobject privatehelperobject = new privateobject(typeof(person)); the above statement invokes parameterless constructor of person class.suppose if want invoke constructor 2 parameters,how can write above statement? you instantiate person object yourself: v...

javascript - Angularjs typehead directive -

i trying create reusable typehead directive in angularjs i've hit few bumps on road. here working example: directives.js app.directive('autosuggest', function() { return { restrict: 'a', link: function (scope, elem, attrs) { /* nothing here yet */ } }; }); app.directive('suggestinput', function() { return { restrict: 'a', link: function (scope, elem, attrs) { // bind keys elem.bind('keydown', function (e) { if (e.keycode == 38 || e.keycode == 40 || e.keycode == 13) { scope.$emit('listnavigate', { code: e.keycode }); } else { // suggestions scope.getsuggest(attrs.source, elem.val()); } }); // listen suggestion list scope.$on('listselect', function (e, data) { elem.val(data.name); }); } }; }); app.directive('suggestlist', function() { var selectedindex = -1; return { restrict: ...

Checking Facebook Status Using Ruby -

i wanted check facebook status of page ruby script. first of possible. have been doing following: i got developer account i got app key , secret i installed json_pure gem here code: require 'rubygems' require 'json/pure' require 'net/http' url ="https://graph.facebook.com/user_id/feed?access_token=app_id|app_secret" uri = uri.parse(uri.encode(url.strip)) #to remove specia codes encode #to remoce whitespace strip req = net::http::get.new(uri.to_s) res = net::http.start(uri.host, uri.port) {|http| http.request(req) } html = res.body res = json.parse(html) here error: c:/ruby187/lib/ruby/1.8/net/protocol.rb:135:in `sysread': existing connection forcibly closed remote host. (errno::econnreset) i recommend using koala gem instead of net::http @graph = koala::facebook::api.new(oauth_access_token) status = @graph.get_connections("me", user_id, "status...

c# - Accessing the Phone's Music in Windows Phone 7 (and 8) -

i'm trying make more intuitive music playing app, question is: how can access music stored on phones music library? i need information such as: -song name -song artist -song album -track number is there way so? the medialibrary class api access mediafiles on phone (pictures, music, ...) can access song-collection following snippet: using(medialibrary library = new medialibrary()) { foreach(var song in library.songs) { debug.writeline("name: " + song.name); debug.writeline("artist: " + song.artist.name); debug.writeline("album: " + song.album.name); } } you can play song: mediaplayer.play(song); reference microsoft.xna.framework.media in project , make sure dispose medialibrary after access.

spring - Error creating bean with name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml] -

we using spring 3.0.5 , cxf 2.7.5. writing jmock mock data , test locally. initialzing variables spring config (appcontext.xml) entries this: <import resource="classpath:meta-inf/cxf/cxf.xml" /> <import resource="classpath:meta-inf/cxf/cxf-servlet.xml" /> my junit class has code: applicationcontext = new classpathxmlapplicationcontext(new string[] {"/spring/applicationcontext.xml"}); while running junit test file, getting error: org.springframework.beans.factory.beancreationexception: error creating bean name 'cxf' defined in class path resource [meta-inf/cxf/cxf.xml]: initialization of bean failed; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'producerclient': instantiation of bean failed; nested exception org.springframework.beans.beaninstantiationexception: not instantiate bean class [org.apache.cxf.jaxws.spring.jaxwsproxyfactorybeandefinitionparser$jax...

node.js - Should js Cannot read property 'should' of null -

i try use testing tool mocha in node. consider following test scenario var requirejs = require('requirejs'); requirejs.config({ //pass top-level main.js/index.js require //function requirejs node modules //are loaded relative top-level js file. noderequire: require }); describe('testing controller', function () { it('should pass', function (done) { (4).should.equal(4); done(); }); it('should avoid name king', function (done) { requirejs(['../server/libs/validate_name'], function (validatename) { var err_test, accountexists_test, notallow_test, available_test; validatename('anu', function (err, accountexists, notallow, available) { accountexists.should.not.be.true; done(); }); }); }); }); as testing result have got: $ make test ./node_modules/.bin/mocha \ --reporter l...

android - Genymotion didn't get an ip address from virtual box -

i've installed genymotion 2 days ago , i've been facing same problem every time tried start device. after downloaded device in genymotion (nexus s - 4.2.2 - api 17 - 480*800) launched it. after box poped telling me have wait, got error: the virtual terminal genymotion didn't ip address. unknown reason virtualbox's dhcp servor didn't assign ip adress virtual terminal. please launch virtualbox find solution problem i can't figure out how solve problem. looked on many websites seems if i'm 1 error. i'm on windows xp-sp3. graphic card radeon hd 3600 driver date. does have idea? thank you. try downgrading virtual box 4.2.18, if using 4.3.x. i had similar situation yours. i using genymotion 1.3.0 on win7, latest virtual box 4.3.2. genymotion broke down after computer shutdown, , never worked again. i kinda stumbled onto solution. after downgrading, genymotion survived 1 shutdown now.

ruby - How can i delete from list while using ransack search in rails -

i trying delete list when trying getting deleted database @course = course.find(params[:id]) @search = lesson.search(params[:q]) @lessons = @search.result.paginate(:page => params[:page], :per_page => 10) @search.build_condition if @search.conditions.empty? @course.lessons.each |lesson| @lessons.each |l| if lesson.id == l.id @lessons.delete(l) end end end i getting error: delete_all doesn't support limit scope thanking you delete activerecord method. assume don't want delete database result list. can this: @course.lessons.each |lesson| @lesson.reject { |l| l.id == lesson.id } end

javascript - Open new page in JQuery bPopup -

i using bpopup open page in popup container. now, there link in popup page, want open new page in opened bpopup container. assigning new page link in anchor tag opens new page in parent window. have used following approach in popup page: $('.iconext').bind('click', function(e) { e.preventdefault(); $('.popup').bpopup({ contentcontainer:'.popup_content', modalclose: false, closeclass: 'closefx', loadurl:'device_new_assigntag.htm' }); }); where $('.iconext') link in popup page , $(.popup) in parent page. you use onclose function given on website. it close popup, in callback can open new popup. $('element_to_pop_up').bpopup({ onopen: function() { alert('onopen fired'); }, onclose: function() { alert('onclose fired'); } }, function() { alert('callback fired'); }); http://dinbror.dk/bpopup/

c++ - How do use a template object of any type -

code changed below use smart pointers: i have template class: class irequest; template<class t> class request : public irequest { public: request(t in) : m_data(in) {} virtual ~request() {} t get() { return m_data; } void set(t in) { m_data = in; } private: t m_data; } in class have methods: template<t> void invoke(request<t>& request) { // stuff } std::unique_ptr<irequest> getrequest(int which) { switch(which) { case 1: return std::unique_ptr<irequest>(new request<int>(1)); case 2: return std::unique_ptr<irequest>(new request<bool>(true)); case 3: return std::unique_ptr<irequest>(new request<double>(2.0)); default: throw std::exception(); } } void run() { int type = getrequesttype(); std::unique_ptr<irequest> request = getrequest(type); invoke(*request); } the problem this, run() method cannot templated, there must 1 or them, , needs able deal type of ...

pom.xml - maven copy-dependencies includeGroupIds and all transitive elements to those -

i try figure out how can copy dependencies explicite version , required dependencies. for example: project requieres version 3 of third party lib, called foobar. want copy version 3 libraries folder named lib-foobar-${foobar.version}. in folder jars required use foobar in version 3. means jar , dependent jars declared in foobar pom. i use org.codehaus.mojo:maven-dependency-plugin:2.1 goal copy-dependencies in phase package. configuration is <configuration> <outputdirectory>${project.build.directory}/lib-foobar-${foobar.version}</outputdirectory> <includegroupids>com.foobar</includegroupids> <excludetransitive>false</excludetransitive> <excludescope>test</excludescope> <includescope>compile</includescope> </configuration> i don't want list allowed , not allowed lib's because step newer version takes place every month. are there other tools can or there dodge that? reply! ...

How can I obtain the cube root in C++? -

i know how obtain square root of number using sqrt function. how can obtain cube root of number? sqrt stands "square root", , "square root" means raising power of 1/2 . there no such thing "square root root 2", or "square root root 3". other roots , change first word; in case, seeking how perform cube rooting . before c++11, there no specific function this, can go first principles: square root: std::pow(n, 1/2.) (or std::sqrt(n) ) cube root: std::pow(n, 1/3.) (or std::cbrt(n) since c++11) fourth root: std::pow(n, 1/4.) etc. if you're expecting pass negative values n , avoid std::pow solution — it doesn't support negative inputs fractional exponents , , why std::cbrt added: std::cout << std::pow(-8, 1/3.) << '\n'; // output: -nan std::cout << std::cbrt(-8) << '\n'; // output: -2 n.b. . important, because otherwise 1/3 uses integer division , results...

c# - Return a constant string array -

i created string[] getter information on class. want return same value, , not create new object on each call. i have implemented this: string[] _somestrings = { "foo", "bar" }; protected string[] somestrings { { return _somestrings; } } which seem ok. however, first inkling write this: protected string[] somestrings { { return { "foo", "bar" }; } } but doesn't work (i error ; expected ). why? (this "getting-to-understand-c# question). update made typo. not want create new object on each call. the correct syntax this: return new [] { "foo", "bar" }; the reason short syntax without new [] valid assignment. as correctly note in comment, create new object on every call. way avoid field stores created instance , return field. solution have. please note however, allows consumers change contents of array , affect other consumers: var a1 = foo.somestrin...

.net - Cross-platform Video/Audio codec -

i'm looking dotnet audio/video codec should work on different platforms windows/linux/(later)ios/(later)android. because of these platforms can't use directshow ( windows ) , looked codecs open source. all of them ( h.323 ) written in c++ , need in dotnet ( c# ) because working mono in project. writing c++/cli wrapper seems huge work because thoose codecs huge. has ever before? there video codecs or commercial solutions on www ( found none )? even if tools off topic, there question behind question, is: "how create codec if there aren't c# codec format x." i can give tip finding several sources , project progressing: java. cross-platform tools come cross-platform language. search java projects, on open source hosting platforms. java similar c#, beginner, porting code can done in hours. use translation tools. apart obsession customized byte buffers, , absence of delegates, it's rather similar. observe. use 1 of 3 or 4 major decompilers, , ...

Google plus API - how to add "communities" as 'data-recipient' -

i trying include community recipient using plus api , 'data-recipients' property. when add community id, shows "unknown user". if click manually, click on iframe, allows me see , choose community want share post with. any on how appreciated. thank-you. i don't believe supported. communities not users , api not support treating them users though in cases function similarly. i tried testing myself , got name unavailable value in share dialog , posted, share never displayed in community.

ruby - List cookbook dynamically without sub-shell -

i can retrieve cookbook list invoking knife in sub-shell (and parse output) such as: cb = `knife cookbook list` another approach invoking ruby classes/modules directly such as: require("chef") require("chef/knife") chef::config.from_file(knifepath) #knifepath declared priori cookbooks = chef::knife.run(["cookbook", "list"]) puts(cookbooks) # => nil how can store data printed on screen calling chef::knife.run() variable? you need outside of knife one. knife delegates chef::cookbookloader (lower down stack) , therefore can use cookbook loader directly: require 'chef/config' require 'chef/cookbook_loader' chef::config.from_file(path) cookbooks = chef::cookbookloader.new(chef::config.cookbook_path).map(&:cookbook_name) for example, knife-spork uses pattern load cookbooks. note actual cookbook objects, not names. if want little more lightweight, iterate on each cookbook_path , metadata.rb : # ...

python - wxpython, showing modal dialog one by one -

i have multi threaded wxpython app , main gui thread receives notification other threads show under modal dialog box. want kind of scheduling/queuing dialog should appear 1 after other if multiple notification (from other threads) comes @ same time. as each notification arrives add queue, (i.e. list), , each dialog closed remove notification queue , if not empty show next - and listen users complain . n.b. careful not situation spotted few times clicking on dismiss button caused notification. classic case error window reporting many error windows open.

Android ListView with main View - timeline effect - possible? -

Image
how can create this? i want have "selected image" main view, , time line effect @ bottom; gallery work, has been deprecated . i'm thinking horizontalscrollview @ bottom, recycle view s properly? can implement viewholder pattern here? what stackview ? found this: http://www.gdgankara.org/2012/03/25/stackview-non-widget-sample/ cool, couldn't find lot of things stackview s online, i'm wondering how gets implemented? i solved problem using custom horizontal listview mukesh yadav i changed horizontalimageadapter.java class use cursoradapter . my solution here: public class horizontalimageadapter extends cursoradapter { //...some initialization here public horizontalimageadapter(context context, cursor c, int count) { super(context, c, true); this.context = (activity) context; this.count = count; this.cursor = c; inflater = layoutinflater.from(context); ...

php - block access to file while using opendir/openfile etc -

i want deny access file data.xml functions file_exists/opendir/openfile etc my file test.php contains: $path="./mydata.html"; if ($handle = opendir($path)) { } closedir($handle); how make unreadable without blocking functions? possible? .htaccess? should block file via chmod set different user execute php script? other way? thanks the easiest way write function check filepath, , call (i.e.) sanitize_filepath($path) whenever accept user data or before every fopen() / opendir() / file_get_contents() . in sanitize_filepath() function, explode $path on path_separator , use in_array() check internal blacklist against provided path. return false or throw exception if don't watch continue, filepath or true if do. preventing access via .htaccess means cannot go http://example.com/your/website/data.xml , see file. still potentially access file exploiting php script if requested http://example.com/your/website/script.php?file=data.xml , assu...

ios - Sharing iCloud documents between apps -

i have 2 apps in app store use icloud. they're using different entitlement identifiers, i'd able access documents first app in second app. is possible add first app's ubiquity container identifier second app in order access first app's documents, without damaging ubiquity container that's in place second app? obviously should've had them share identifiers in first place, did not think of when apps first submitted. from docs, looks indeed possible want. see section configuring common ubiquity container multiple apps in icloud design guide, says in part: for example, provide free , paid version of app. you’d want users, upgrade, retain access icloud documents. or, perhaps provide 2 apps interoperate , need access each other’s files. in both of these examples, obtain needed access specifying common ubiquity container , requesting access each app. the section goes on explain how configure 1 of apps' containers common one: ...

mercurial - Git — tracking the moving of already tracked files -

mercurial has single command addr stages both added , removed paths, able track moving of given file different path in directory. to in git, find have use 2 separate commands: git add -u <path> will note disappearance of files original path, , then git add <path> will note appearance somewhere else. but there doesn't seem one-step equivalent mercurial's addr command. or mistaken? git has move command can used move files/folders: git mv <file or directory> <destination> you can use --all or -a flag of add update both new files , removed files in index git add -a from official linux kernel git documentation git add (emphasis mine): -a --all like -u , match <filepattern> against files in working tree in addition index. means it find new files staging modified content , removing files no longer in working tree .

PHP - lost reference in object array? -

i have array stores employee objects ie. var $this->employeearray = array(); $this->employeearray[] = $empobjecta; $this->employeearray[] = $empobjectb; ... which employee object has id, firstname, lastname etc. have function search employee object id. ie: public function searcharraybyid($id) { $targetobject = null; foreach($this->employeearray $e) { if ($id == $e->id) { $targetobject = $e; break; } }//foreach return $targetobject; } but when do: $targetemployee = $this->searcharraybyid(1); $targetemployee->firstname = "someothername"; and print_r($this->employeearray); that object inside array not being changed. try this, & prepended, pass reference. simplified search function. since dont know why isnt working you, because working me on 2 different servers without & can suggest 'safest' method => force references wherever poss...

c# - htmlagilitypack getting an element's node by the name -

how can node of element name. there getelementbyid, why no getelementbyname. element in question is: <select class="box1" name="day" tabindex="31"> … </select> i want able node. have no idea how. pete: please remove question has been answered. totally wrong go try yourself. node.name not name of attribute 'name' tagname not need. you not accessing node attribute called "name" of "select" tags in descendants. using property name of tag (xe.name). correct approach can : document.documentnode.descendants("select").where(node => node.getattributevalue("name", "").equals("day", stringcomparison.invariantcultureignorecase));

windows 7 - VB6 Crystal Reports 8.5.0.217 - Access Violation Application Crash -

background: our company uses crystal reports in our legacy product written in vb6 i'm performing maintenance duties for. its using version 8.5.0.217 [rtm] no service packs. the problem: has worked on windows xp x86 date. in windows 7 [x86 , x64] access violation followed application crash , no further usable error information. the details: the application crashes large datasets report using active x viewer. visual studio crash whilst debugging. the offending code here: crv_obj(0).reportsource = reportparametersfrm.report crv_obj(0).enablepopupmenu = true crv_obj(0).viewreport i have checked that: crv_obj(0) valid object reference. reportparametersfrm.report valid reference. the information have event viewer: faulting application name: pyramid.exe, version: 2.2.0.8, time stamp: 0x51e53053 faulting module name: craxdrt.dll, version: 8.5.0.217, time stamp: 0x3a849e1a exception code: 0xc0000005 fault offset: 0x002ac3d1 faulting process id: 0x15a8 ...

if statement - Powershell Out-file with variable -

i'm trying write script check if string null , if output user name file can go , check file , see null. below code, script not writing out-file ideas? $user = "user@domain.com" #just gets users info $user_info = gam info user $user $suspended = $user_info | select-string -pattern "account suspended: true" if ($suspended = $null) { $user | out-file -filepath c:\scripts\not_suspended.txt -append -encoding utf8 } you assigning $null $suspended in if statement. use -eq instead comparison: if ($suspended -eq $null) { $user | out-file -filepath c:\scripts\not_suspended.txt -append -encoding utf8 }

C# CAML query to sharepoint returns all items in the list (instead of only ones that mach query value) -

i have following code in app pull details sharepoint list. string siteurl = "http://sharepointurl"; clientcontext clientcontext = new clientcontext(siteurl); clientcontext.credentials = new networkcredential("un", "pw", "domain"); sp.list olist = clientcontext.web.lists.getbytitle("licences"); camlquery camlquery = new camlquery(); camlquery.viewxml = "<where><eq><fieldref name='account' /><value type='text'>123456</value></eq></where>"; listitemcollection colllistitem = olist.getitems(camlquery); clientcontext.load(colllistitem); clientcontext.executequery(); console.writeline("filtered list: " + colllistitem.count.tostring() + "\n"); foreach (listitem olistitem in colllistitem) { console.writeline("account: {0} \nlicence: {...

php - do not reuse tab in case target is _BLANK -

i have 2 php pages: 1.home page 2.view page on home page have thumbnails of featuring items , each item has link view page, differentiated parameter. i.e.: viewpage.php?id=1, viewpage.php?id=2, etc... i use because need view pages open in new tabs or new browsers (doesn't matter which) as click on first item, view page opens in new tab; however, click on second item replaces tab of first item. how can force home page open each view page in new separate tab? i'm not asking, try javascript function instead. <script type="text/javascript"> $(document).ready(function(){ $('a[rel="_blank"]').click(function(){ window.open($(this).attr('href')); return false; }); }); </script>

python - Comparing file creation date -

i trying archive old files based on creation date. have data starting 12-17-2010 setting base date , incrementing there. here code import os, time, tarfile datetime import datetime, date, timedelta import datetime path = "/home/appins/.scripts/test/" count = 0 set_date = '2010-12-17' date = datetime.datetime.strptime(set_date, '%y-%m-%d') while (count < 2): date += datetime.timedelta(days=1) tar_file = "nas_archive_"+date.strftime('%m-%d-%y')+".tgz" log_file = "archive_log_"+date.strftime('%m-%d-%y') fcount = 0 f = open(log_file,'ab+') #print date.strftime('%m-%d-%y') root, subfolders, files in os.walk(path): file in files: file = os.path.join(root,file) file = os.path.join(path, file) filecreation = os.path.getctime(file) print datetime.fromtimestamp(filecreation)," file creation date" ...

openCV cvSaveImage and cvCvtColor crash on android -

i'm working on android version 2.3.5 , 4.0.4 both version crash on execution of same code. have been trying frame video, save it, , convert hsv. (i posted same question on opencv website here ) this code , error get. public void process(){ iplimage orgimg = this.getframe(2); cvsaveimage(environment.getexternalstoragedirectory().tostring() + "/opencv/orgimg.jpg", orgimg); iplimage hsv = hsv(orgimg); } private iplimage getframe(int id){ file testfile = new file(environment.getexternalstoragedirectory().getabsolutepath() + videofile); if(testfile.canread()){ ffmpegframegrabber grabber = new ffmpegframegrabber(testfile); try { grabber.start(); grabber.setframenumber(id); final int height=grabber.getimageheight(); final int width=grabber.getimagewidth(); ipli...

php - Unable to make a file auto-download from an FTP server when script is run -

i attempting write php page takes variable filename within ftp , download it. however, not seem work. function (ftp_get) returning true echo statement being run, nothing else happens , there no errors in console. <?php $file = $_get['file']; $ftp_server = "127.0.0.1"; $ftp_user_name = "user"; $ftp_user_pass = "pass"; // set connection or die $conn_id = ftp_connect($ftp_server) or die("couldn't connect $ftp_server"); // login username , password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (ftp_get($conn_id, $file, $file, ftp_binary)) { echo "successfully written $file\n"; } else { echo "there problem\n"; } ?> ideally, link them to: ftp://example.com/testfile.txt , download file them, however, shows them contents of file in browser rather downloading it. i've gone through php manual site reading ftp functions , believe ftp_get correct 1 i'm suppose...

r - Expand spacing between tick marks on x axis -

Image
i want expand spacing between tick marks on x axis in r. i have years on x axis c(2005:2012) , 1 value per year on y axis. say: a <- c(5,4,6,7,3,8,4,2) b <- c(2005:2012) plot(b, a, type="l") i need expand spacing between each tick mark in order "stretch" plot horizontally better overview. @ end of r knowledge , haven't found in internet, please help. use standard graphic packages of r. it's not plot function determines aspect ratio of interactive plotting device. each of 3 major branches of r has own default interactive device: macs has quartz() , windows have (i thought window() checking page wrong, , checking ?dev.interactive revealed correct function windows() ), , linux, x11() or x11() . if want open device different dimension default, need issue command different height , width values default (or can stretch existing window if gui supports action): quartz(height = 5, width = 10) <- c(5,4,6,7,3,8,4,2) b <- c(20...

java - How do I lose focus on a JComboBox? -

i have jcombobox key listener. when hit <enter> , fire off action, and need to lose focus on jcombobox ! to focus on it, can jcomboboxobject.grabfocus(); but doing transferfocus() focus next element (i don't care focus goes, away combo box) not work. doing grabfocus() combo box works, seems pretty annoying hack me. there better solution? i can suggest first use .getnextfocusablecomponent() and use the .requestfocusinwindow() that means implementing this, jcombobox.getnextfocusablecomponent().requestfocusinwindow(); one important note .getnextfocusablecomponent() has become obsolete can work better, can use if have other solution, prefer not using this.

python - A* pathfinding on 2D grid doesn't find optimal path -

i trying implement a* algorithm on 2d square grid. however, never finds optimal path, , can't see why. code suspiciously slow, python. i've tried anything, i'm out of ideas. this have far: file astar.py: end = none nlut = [ (1,0) , (0,1) , (-1,0) , (0,-1) ] class tile: def __init__(self,x,y,g=0,parent=none): self.x = x self.y = y self.g = g self.parent = parent def __eq__(self,other): if other == none: return false return ( (self.x == other.x) , (self.y == other.y)) def __ne__(self,other): return not self.__eq__(other) def __hash__(self): return hash((self.x,self.y)) def __str__(self): if self.parent == none: sss = "" else: sss = " <- "+str(self.parent.coords()) return "<"+str(self.x)+"."+str(self.y)+"g"+str(self.g)+">"+sss def __repr__(self): ...