Posts

Showing posts from July, 2011

java - Findbugs, PMD or Checkstyle rule to find access by a field -

i have class caches set of values internally. these values can updated periodically , cached contents updated appropriately. long users of class like: ... public void anymethod(anyparams) { anyobject value = cacheclass.getvalue(anykey); ... } then life fine "value" not maintained locally. if this: public class myclass { private anyobject value = cacheclass.getvalue(somekey); ... } then if cached value updated usage of may not see new value. we use findbugs, checkstyle , pmd in builds via sonar. wondering if there way define rule in of these systems detect , flag second type of usage above. have never written rule in these systems appreciate advice possible (like, "well can done, don't want go there..." :) following xpath on ast node catch field declarations calls cacheclass method. //fielddeclaration[//primaryexpression/primaryprefix/name/@image='cacheclass.getvalue'] how write pmd custom rule

Android Virtual Device Emulate Camera with Static Image -

i trying emulate static image on avd in settings there 2 options: -use computer webcam -emulate when checking emulate there moving rectangle believe there must possibility replace static image....! does have idea it? thanks, john

php - How to Get the transaction details once the payment via paypal completed -

i using parallel adaptive payment. got php coding following link of paypal developer` website. https://www.paypal-labs.com/integrationwizard/adaptive/main.php now transaction of amount takes place successfully. want store transactions details such as 1.transaction id,2. amount 3.status etc. after returns paypal website presently did paypal sand box account you use ipn information website pertains transaction. can find more on ipn on paypal developer's site.

How to make an events base class in javascript? -

i trying make events class little canvas library making! this have far, function events() { }; events.prototype.addevents = function() { this.mousemove = false; this.onmousemove = function() { if (this.mousemove) { this.mousemove(); } }; this.mousedown = false; this.onmousedown = function() { if (this.mousedown) { this.mousedown(); } }; this.mouseup = false; this.onmouseup = function() { if(this.mouseup) { this.mouseup(); } }; this.click = false; this.onclick = function() { if (this.click) { this.click(); } }; this.on = function(type, callback) { }; }; what cannot add other objects want assign events on. example object simple rectangle has draw method. function rect() { this.draw = function(context) { // code }; }; // how can add events prototype properties rect? have tried... // r

python - Parsing Apache log file into ipython notebook -

i'm new ipython , doing experiments following post. http://nbviewer.ipython.org/urls/github.com/koldunovn/nk_public_notebooks/raw/master/apache_log.ipynb in [10]: parsing log file in data dictionary not work. can please me figure out this?. log_list = [] line in log: try: data = p.parse(line) except: sys.stderr.write("unable parse %s" % line) data['%t'] = data['%t'][1:12]+' '+data['%t'][13:21]+' '+data['%t'][22:27] log_list.append(data) could plese try point , let me know error code?

opengl - Deleting global object in game.(C++) -

i making bubble pop game in c++ user clicks on randomly generated bubbles float screen(still in development). in order use opengl , glut game found best make bubbles global. have blank destructor not know how delete contents of bubble , create new one. tried using dynamic allocation didn't make difference. how can delete contents of bubble , make new one? here's necessary snippet: main.cpp bubble mybubble1; void display(void) { delete mybubble1;//error "cannot delete type bubble" } my destructor here: class bubble { public: //default constructor bubble() { radius=(rand() % 100 )+1; speed = rand() % 500 ; xval = rand() % 480; yval= -14; islive=true; } ~bubble() { } private: float radius; float speed; float xval; float yval; bool islive; }; the code runs fine when don't try delete anything. can run infinite looping bubbles you not using pointers in bubble destructor can stay blank. if want reassi

Loading files in a folder using php -

i tried loading names of files in books directory, following code: <?php if ($handle = opendir('/books')) { echo "directory handle: $handle\n"; echo "entries:\n"; while (false !== ($entry = readdir($handle))) { echo "$entry\n"; } closedir($handle); } ?> but seems not display names. doing wrong or not locating right directory? seems if you're using wrong directory... think books folder in same directory script? then use opendir('books') relative path directory. when use /books use books folder located in root directory of filesystem. (this called absolute path)

javamail - Java Mail authentication and connection -

while trying connect through java mail server responding unexpected the problem same program connects , mails times throws javax.mail.authenticationfailedexception: eof on socket @ com.sun.mail.pop3.pop3store.protocolconnect(pop3store.java:208) @ javax.mail.service.connect(service.java:295) @ javax.mail.service.connect(service.java:176) @ newpackage.pmspop3client.main(pmspop3client.java:44) error when server says s: +ok hello there. c: capa s: +ok here's can do: i can connect , fetch mails s: eof i cant connect server my code import java.util. ; import javax.mail. ; import javax.mail.event.connectionevent; import javax.mail.event.connectionlistener; import javax.mail.internet.*; public class pmspop3client { public static void main(string[] args) throws exception { try { string host = "host"; string user = "user"; string password = "pass"; properties props = syste

Multiple array with same object name in JSON Array in android? -

in application j son response { "orderdetails": [ { "order_details": { "branch_code": 0, "cust_code": 87, "custom_instructions": "<null>", "merchant_code": "<null>", "order_number": 419, "order_type_code": 1, "packing_charge": 0, "price": 200, "product_code": 21, "quantity": 1, "value": 200 }, "order_headers": { "branch_code": 0, "cust_code": 87, "delivered_time": "<null>", "delivery_charge": 23, "delivery_date": "2013-05-02", "delivery_support": "", "delivery_time":

Octave - compare matrix's columns with vector -

i have matrix , vector , want compare each column of matrix vector - want number of column equal vector. example: matrix m=1 1 0 1 1 0 0 0 0 1 1 0 vector v= 1 0 1 the result should 2 (since second column of m equal vector v) how do that? octave> m = [1 1 0 1; 1 0 0 0; 0 1 1 0]; octave> v = [1 0 1]; octave> sum(m == repmat(v', 1, 4)) ans = 1 3 2 2 octave> sum(m == repmat(v', 1, 4)) == size(m, 1) ans = 0 1 0 0 octave> find(sum(m == repmat(v', 1, 4)) == size(m, 1)) ans = 2

Pause an exe with batch file -

i don’t know if possible but can pause exe , wait batch file complete before resuming exe again? i sysinternals tool "pssuspend". can give process id: pssuspend suspends or resumes processes on local or remote nt system. usage: pssuspend [-r] [\\remotecomputer [-u username [-p password]]] <process id or name> -r resume. -u specifies optional user name login remote computer. -p specifies optional password user name. if omit prompted enter hidden password. go http://www.sysinternals.com , "process utilities" , "pssuspend". in general, recommend getting familiar sysinternals tools; extremely useful.

ruby on rails - Tweaking from :var to @var - makes problems and solves problems -

could on below issue. post content form not working. have laid out relevant code below. tweaking @video_post :video_post, breaks form form works on homepage. routing error no route matches [post] "/users/1" using @video_post - form works on home-page website breaks elsewhere. undefined method `model_name' nilclass:class can please me figure out? many many thanks. i have form in shared/form - _form.html.erb <%= form_for(@video_post) |f| %> <%= f.text_field :video_title, placeholder: "video title" %> <%= f.text_area :video_description, placeholder: "description" %> <%= f.text_field :video_url, placeholder: "url" %> <%= f.submit "post", class: "submit" %> <% end %> i render /users/_new.html.erb using: <%= render :partial => 'shared/form', :video_posts => @video_posts %> which rendered application.html.erb using: <%= re

ios - Add NewLine character in localizable.strings -

how add newline character in localizable.strings ? i tried putting \n , no success. edit 1: how add links inside localizable.stings ? using \n should work. line in "localizable.strings": "abc" = "foo\nbar"; and code: nsstring *s = nslocalizedstring(@"abc", null); nslog(@"%@", s); i output 2013-05-02 14:14:45.931 test[4088:c07] foo bar

javascript - How to Avoid Class Conflicts in jQuery -

in code generate dynamic divs according our requirement number of appointments per day. our main requirement on mouseover, fetch details of patient particular encounter.. my html follows <div class="schediv" id="1"></div> <div class="schediv" id="2"></div> <div class="schediv" id="3"></div> and jquery written follows $('.schediv').mouseover(function() { var id = $(this).attr('id'); alert(id); ------- ); it works fine single div doesn't work multiple divs. you need use .on() because addind dom dynamically. $(document).on('mouseover','.schediv',function(){ //code goes here });

php - selecting the data from database except a particular name -

i listing users have registered in users table. want hide name 'superadmin' in name column. my query this $sql = "select u.rowid, u.name, u.firstname, u.email, u.job, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; $sql.= " u.statut, u.lang, u.entity,"; $sql.= " u.datec datec,"; $sql.= " u.tms datem,"; $sql.= " u.datelastlogin datel,"; $sql.= " u.datepreviouslogin datep,"; $sql.= " u.photo photo,"; $sql.= " u.openid openid,"; $sql.= " u.ref_int, u.ref_ext"; $sql.= " ".main_db_prefix."user u"; if (! empty($conf->multicompany->

jquery - Backbone Create model with Django Rest Framework -

Image
im trying create new model rest api using django rest framework. this serializer: class fooserializer(serializers.hyperlinkedmodelserializer): class meta: model = foo this view.py @api_view(['post', 'get','delete','options']) def foos(request): """ api endpoint create, delete , foos """ authentication_classes = (authentication.tokenauthentication,) permission_classes = (permissions.isauthenticated,) model = foo serializer_class = fooserializer if request.method == "post": data = jsonparser().parse(request) serializer = fooserializer(data=data) if serializer.is_valid(): serializer.save() return jsonresponse(serializer.data, status=201) else: return jsonresponse(serializer.errors, status=400) return response(serializer.data) then in backbone view: foo = new foo name

jQuery Autocomplete UI search all directions -

i'm using jquery autocomplete show results list of approximately 2000 records. because list in opinion long need filter search through these records. i modified source able search not in label field, in value field. want can search "s4 galaxy" wil find "samsung galaxy s4". standard jquery autocomplete can search left right, "galaxy s4" found, not "s4 galaxy". want @ "gal s4" , find "samsung galaxy s4". as extra, nice if match made bold > "samsung galaxy s4 " the complete code use stands below: var completeresults = [{ value: "s4 iv", label: "samsung galaxy s4", image: "samsung_galaxy_s_iv_1.jpg" }, { value: "stackoverflow", label: "nokia lumia 920", image: "nokia_lumia_920_1.jpg" }]; completeresults short list! normaly 2000 records. function custom_source(request, response) { var matcher = new regexp($.ui.au

unable to query the external hive table in which data is being parsed using regex -

i being able fire select * kind of queries not select col1....type of queries. throws following exception error during job, obtaining debugging information... examining task id: task_201305021530_0007_m_000002 (and more) job job_201305021530_0007 exception in thread "thread-90" java.lang.runtimeexception: error while reading task log url @ org.apache.hadoop.hive.ql.exec.errors.tasklogprocessor.getstacktraces(tasklogprocessor.java:240) @ org.apache.hadoop.hive.ql.exec.jobdebugger.showjobfaildebuginfo(jobdebugger.java:227) @ org.apache.hadoop.hive.ql.exec.jobdebugger.run(jobdebugger.java:92) @ java.lang.thread.run(thread.java:722) caused by: java.net.unknownhostexception: avishkar-vb @ java.net.abstractplainsocketimpl.connect(abstractplainsocketimpl.java:178) @ java.net.sockssocketimpl.connect(sockssocketimpl.java:391) @ java.net.socket.connect(socket.java:579)

sencha touch 2 - Two lists same container same store -

Image
i got class i'm trying show data same store in same container. did way because want have 2 rows each on separate line , not having control on them. here's class: ext.define('clue.view.listquestions', { extend: 'ext.container', requires: ['ext.dataview.list'], xtype: 'listquestions', config: { id: 'listquestions', items: [{ xtype: 'list', id: 'questionli1', basecls: 'questionli1', flex: 1, store: { xtype: 'levelstore', filters: [{ filterfn: function(item) { return item.data.levelid < 2 && item.data.questionid < 6; } }] }, itemtpl: '<div>{questionid}</div>' },{ xtype: 'list', id: 'questionli2', basecls: 'questionli2', flex: 1, store: {

android - Cannot get a hold on my Preferences with Unified Preferences -

i use this library create preferenceactivity . works quite fine far can not set listeners on preference. that how activity looks like: public class prefactivity extends unifiedsherlockpreferenceactivity { @override public void oncreate(bundle savedinstancestate) { setheaderres(r.xml.preference_headers); // set desired preference file , mode (optional) setsharedpreferencesmode(context.mode_private); super.oncreate(savedinstancestate); getsupportactionbar().sethomebuttonenabled(true); getsupportactionbar().setdisplayhomeasupenabled(true); preference p = (preference)findpreference("deletesavedsearches"); p.setonpreferenceclicklistener(new preference.onpreferenceclicklistener() { @override public boolean onpreferenceclick(preference arg0) { //code want return true; }

entity framework - C# MVC4 EF Ninject - repository in domain class -

i have class: question with properties: bool istextanswer list<string> answers the answers question are: 2-4 answers stored in list of answers or 4 colors (stored in db, every question same). boolean decides if answers list or colors. the colors table in database 4 rows, every color row. these colors aren't linked made new repository: colorrepository can colors. i did in code: constructor public question(icolorrepository colorrepository) { _colorrepository = colorrepository; } in getter of answers try this: if(istextanswers) return answers return _colorrepository.findall but ninject doesn't work because it's not controller message there no parameterless constructor. how can retrieve 4 colors database? i need able read database, questions + answers made administrator in java program. it looks question entity, , entity framework needs have parameterless constructor. your repository should separate class, domain objects sho

php - preg_match with UTF8 -

i have string: $string = 'this test'; and array of words: $array = array('test','example','blahblah'); i want $string, , see if there of words of $array in or not: $string_arr = explode(' ', $string); foreach($string_arr $value){ if (preg_match("/\b$value\b/iu", $array)) return true; } as see, used 'u' flag utf-8 support, wired thing works on wamp(localhost), on real server on centos it's not working, googled , found this: http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/ but don not have access server upgrade rpm, how should it? thanks in advance anybody come solution? appreciate help. i'm not sure if can simpler this: array_intersect($array,explode(' ',$string)); check if returned array has value , tell if of words in $array in $string. following tested , works. if( count(array_intersect($array,explode(' ',$string))) > 0

python - Drag'n'Drop from Outlook only for one Attachment in Qt? -

i accept drops outlook in application. extract filenames funny torture, have list of them. if ask filecontents empty messages (.msg files). , dropped attachments see content of first one. environment only windows + python 3.3 + pyside + qt 4.8 use data = event.mimedata().data("filecontents") print(len(data)) how can filecontent of message type? , how drop multiple files? there type names "qwindowsmime", have no idea if me. // jay ok, till bug , pyside has no qwindowsmime. think fix in qt 4.x never comes, must wait pyside qt 5.0, has class qwindowsmimeconverter. // jay

wpf - putting artboard XAML on separate window / screen -

simple question, there way of putting artboard designer on 1 screen, , xaml on in blend 4? it's real pain flicking between 2 when i've got 3 monitors play with! short answer, no. what can though set designer & code view side-by-side via view -> split view orientation -> split views horizontally drag blend window across 2 of screens split between 2 screens. works pretty well. otherwise have design open in blend in 1 screen, , xaml open in vs on screen...becomes pain though since whenever save on one, you'll prompted update on other. wish there better way, i'm pretty sure none exist besides mentioned. hope helps.

jQuery/JavaScript function not updating textbox -

i'm using bootstrap datepicker: https://github.com/eternicode/bootstrap-datepicker i have attached 2 boxes - invdate , invduedate - , pops ok, , sets dates etc fine. i have drop down box though, when selected, want take date in invdate box, , add val() of dropdownlist invdate, , populate invduedate. however, cannot seem invduedate change it's date (does nothing) - dropdown box trigger function, line doesn't appear anything: $("#invduedate").datepicker("setdate", duedate); : html is: <div class="editor-label"> <label for="invdate">invdate</label> </div> <div class="editor-field"> <input class="textbox datepicker" data-val="true" data-val-date="the field invdate must date." data-val-required="the invdate field required." id="invdate" name="invdate" type="text" value="02 may

css - Style Header Title Based on Column Cell Type -

i have table filled cells css classes string , currency . want headers of string columns left aligned, , headers of currency columns right aligned. is there way purely css? in following code, strings header left aligned , currency header right aligned, , should know detecting class type of cells in column. note: cells in single column (under header) share same class type. there no mixing , matching. <table> <thead> <tr> <th>strings</th> <th>currency</th> </tr> </thead> <tr> <td class="string">this string.</td> <td class="currency">100.00</td> </tr> </table> my idea this: table td.string thead th { // if cells in column of string type text-align:left; } table td.currency thead th { // if cells in column of currency type text-align:right; } i know css above won't work

python - Work with list of lists of tuples -

i have list: dcf3v=[[(1.90689635276794, -44704.76171875)], [(1.90689635276794, -44705.76171875)], [(1.90689635276794, -44706.76171875)], [(1.90689635276794, -44707.76171875)] ] i'd compare second element of each tuple , find absolute maximum: -44707.76171875 my code looks like: cf3=0 x in dcf3v: if abs(x[1])>abs(cf3): cf3=x[1] you have list holds lists hold tuple. so, want abs(x[0][1]) . command can be: max(abs(x[0][1]) x in dcf3v) more point, actually want change data structure list holding tuples: dcf3v = [x[0] x in dcf3v] which like: max(abs(x[0]) x in dcf3v) or, if wanted entire tuple returned instead of second element: max(dcf3v,key=lambda x:abs(x[0]))

android - How to fit image in full screen in ImageViewTouch -

Image
i using [imageviewtouch][1] library zoom image instead of imageview. <it.sephiroth.android.library.imagezoom.imageviewtouch android:id="@+id/imageweb" android:layout_width="fill_parent" android:layout_height="fill_parent" android:adjustviewbounds="true" android:background="@drawable/bg_loading" android:scaletype="fitcenter" /> i want load image on imageviewtouch control , width of image auto fits screen. how fit width , height both mobile screen? here when 3 times double tap means in 1st time zoomed in 2nd time in 3rd times fits height , width of the device screen why not fit @ time of first time. but not loaded fit height , width @ first time.? please me sort out issue. i used library classes may have change here thing. 1) [first][2] 2) [second][3] please check screenshots : when first time loaded automatically : after 3 times d

eclipse - Running Maven project on glassfish server -

i want run web based maven project on glassfish server. totally new on maven. however, have build maven project , glassfish server , running also. moreover, there war file in target folder confused next step run project on glassfish ? any highly appreciated. you have different options solve task: if new eclipse suggest change netbeans . comes integrated support application server deployments. add maven (or other type of project war, ejb , ear) project , desired application server instance (glassfish) , ready: right-click project , choose deploy , it'll deployed server. netbeans supports hot-deployment. you can deploy war file manually in glassfish_root/glassfish/domains/domain1/autodeploy , it'll deployed if server running. not efficient during development. if want stay eclipse can use maven-glassfish-plugin or maven plugin deployment you. i'm not sure 1 better topic discussed in this question , this question .

javascript - Time diff code is not working -

here want find total time spent user on page. for using following code not working. using jquery1.8. please see it. var entertime; var endtime; var difftime; $(document).ready(function (e) { entertime=e.timestamp; }); $(window).bind('beforeunload', function(f){ endtime=f.timestamp; difftime=endtime-entertime; alert(difftime); }); try using following: var entertime; var endtime; var difftime; $(document).ready(function () { entertime=new date().gettime(); }); $(window).bind('beforeunload', function(){ endtime=new date().gettime(); difftime=endtime-entertime; }); please note cannot raise alert() s before closing page in way described in original post.

c# - FileStream.copyTo(Net.ConnectStream) what happens intern? -

this code works fine. question happens within net.connectionstream when use copyto() method? system.net.httpwebrequest request using (filestream filestream = new filestream("c:\\myfile.txt") { using (stream str = request.getrequeststream()) { filestream.copyto(str); } } more specific: happens data? 1. write memory , upload then? (what's big files?) 2. write network directly? (how work?) thanks answers it creates byte[] buffer , calls read on source , write on destination until source doesn't have anymore data. so when doing big files don't need concerned running out of memory because you'll allocate as buffer size, 81920 bytes default. here's actual implementation - public void copyto(stream destination) { // ... bunch of argument validation stuff (omitted) this.internalcopyto(destination, 81920); } private void internalcopyto(stream destination, int buff

c# - Centering OK button within a MessageBox in winforms -

Image
i learning c#, , part of wrote small app consists of form 2 groups of buttons, 2 buttons each. button closing of app added well. , works ok. there messagebox, showing app going closed. and here little problem bugs me: ok button within messagebox not centered horizontally. guess there method align button, puzzles me why it's not centered default? illustration here screenshots: here code well: using system; using system.drawing; using system.windows.forms; public class myform : form { private groupbox gboxgrp1; private groupbox gboxgrp2; private radiobutton butn1a; private radiobutton butn1b; private radiobutton butn2a; private radiobutton butn2b; private button btnclose; public myform() { initializecomponent(); } private void initializecomponent() { this.btnclose = new button(); this.gboxgrp1 = new groupbox(); this.gboxgrp2 = new groupbox(); this.butn1a = new radiobutton();

gruntjs - differences between rubygem guard and grunt.js? -

besides obvious language architecture differences (respectively ruby vs. nodejs) there differences between rubygem guard , grunt.js ? or wrong comparing two. dissimilar? also, project has larger development community? guard , grunt perform similar functions, differ in ways triggered. guard based on watching files events, while grunt based on running 'tasks' based on if events occur. real differences language, , how run code based on file events , such. as guard/grunt communities, virtually equal utilize different ruby/node.js tools. both great tools. use guard if use ruby/rails, , grunt if use node.

vb.net listen for parent form event on each child form -

i trying implement function on parent form, when event fires, want perform actions on of child forms open. because given child form may or may not open @ given time, can't handle directly event on parent form: i.e., cant following child1 may not initiated @ time: --parent form-- public sub parentevent() doparentaction() dochild1action() dochild2action() end sub is there way on each child page listen parentevent() fired? essentially, want handle parentevent() being fired, on child page same if button clicked on child page, this: --child1-- public sub childevent() handles parentform.doparentaction() dochild1action() end sub this easy do, have step around vb's withevents , handles syntax @ it. public class parentform event ondosomething() private sub dosomething() raiseevent ondosomething() end sub end class and then public class childform public sub new() initializecomponent() addhandler parentfor

performance - What are the differences of explicit and implicit instantiating String class in java -

i have been told creating string instance this string s = new string("don't this"); // explicit has performance problem since creates 2 instance of string on double quoted phrase "don't this" , 1 new string() constructor! today had time test self created 2 classes: public class string1 { public static void main(string[] args) { string s = new string("hello"); system.out.println(s); } } public class string2 { public static void main(string[] args) { string s = "hello"; system.out.println(s); } } here output of javap: c:\jav>javap string1 compiled "string1.java" public class string1 extends java.lang.object{ public string1(); public static void main(java.lang.string[]); } c:\jav>javap string2 compiled "string2.java" public class string2 extends java.lang.object{ public string2(); public static void main(java.lang.string[]); } seems same -c flag outputs deferent.

Insheet a Specific Variable in Delimited Data in Stata -

i have data in .txt in variables delimited symbol | , first row contains variable names. have insheeted data as: insheet using "filename.txt", delim("|") clear however, insheet 1 variable data set. when try insheet 1 variable in, have tried: insheet variable using "filename.txt", delim("|") clear unfortunately, not work, , using reduced down version of .txt, receive error: too few variables specified error in line 2 of file the .txt looks follows: v1|v2 123|456 note there more variables , more rows i've reduced ease of exposition. in addition, .txt formatted automatic return after each row. i appreciate can provide task. please let me know whether there further information can provide make issue clearer. it's difficult me why doesn't work, insheet old code seems little more fragile other import commands. did try import excel ? is out of question insheet , drop don't want? did think of

asp.net mvc - Ext.Net this.Direct() not recognized -

i installed ext.net through nuget, working vs2012, .net 4.5 mvc. following first sample in book on ext.net, there 2 methods in controller: index empty, , here second one: // get: /directeventexample/notify/ public actionresult notify(string message) { var config = new notificationconfig { icon = icon.accept, title = "working", html = message }; x.msg.notify( config ).show(); return this.direct(); } the last command, this.direct() not recognized. have referenced both libs: using ext.net; using ext.net.mvc; what missing?

php - uploading with SFTP : CURLOPT_SSLKEY is not used -

i have upload via sftp files server another here sftp() function : function transfert_curl_sftp($local_filename, $distant_filename, $host_destination, $user_destination,$pubkey_filename,$privkey_filename,$port) { if ( !extension_loaded('curl') ) return 'no_curl_extension'; $distant_filename = ltrim($distant_filename,'/'); $fp = fopen($local_filenam, 'r'); $sftp_server = $host_destination.'/'.$distant_filename; $curl = curl_init(); curl_setopt($curl, curlopt_upload, true); curl_setopt($curl, curlopt_header, true); curl_setopt($curl, curlopt_verbose, true); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_protocols, curlproto_sftp); curl_setopt($curl, curlopt_noprogress, false); curl_setopt($curl, curlopt_followlocation, true); $trace = tempnam( dirname($local_filenam),'temp_curl_' ); $fptrace = fopen($trace, 'w'); curl_setopt($curl, curlopt_file, $fptrace); curl_setopt($curl, curlopt_stderr, $

java - Is the connection Pool configuration kept outside JPA Context? -

hello extracting connection object eclipselink context calling: connection con = entitymanager.unwrap(connection.class); i responsible releasing connection in order comeback pool need know if extracted connection supposed keep original configuration set eclipselink mean number of connections, maximum number of connections , on..if once returned eclipselink supposed keep same performance working normally.. i need know cause maybe experience of can me in choosing if getting connection in way keep performance eclipselink when working native jpa, in advance.. you can unwrap connection in scope of transaction. same connection entitymanager bound (from pool). must not release connection, eclipselink release when transaction ends. so, clear, not responsible releasing connection.

javascript - Setting the initial value in a Knockout select -

i'm having problems getting initial value of select equal value in knockout model. http://jsfiddle.net/npearson99/bjwat/2/ in fiddle, group should "group 2", it's not selecting group. if change value: 'selectedgroupid' value: 2 , works. <div data-bind="with: selectedworkout"> <h3>current workout</h3> workout id: <label data-bind="text: id"></label> <br/>workout name: <label data-bind="text: name"></label> <br/>group: <select data-bind="options: $root.grouplist, optionstext: 'groupname', optionsvalue: 'id', optionscaption: 'no group', value: 'selectedgroupid'"></select> function group(id, groupname) { var self = this; self.id = id; self.groupname = groupname; } function workout(id, name, sel

c - Parse string and subtract a substring -

i'm parsing http header in c , need subtract host name full url. i managed full url ( http://www.example.com/hello.html ) , path name (hello.html) couldn't subtract (full url - path name) host name (example.com). example full url: http://www.example.com/hello.html - done host name: example.com - todo path name: /hello.html - done any appreciated. thanks you can use memcpy , this: char *url = "http://www.example.com/hello.html"; // find last index of `/` char *path = url + strlen(url); while (path != url && *path != '/') { path--; } // calculate length of host name int hostlen = path-url; // allocate byte null terminator char *hostname = malloc(hostlen+1); // copy string newly allocated buffer memcpy(hostname, url, hostlen); // null-terminate copied string hostname[hostlen] = '\0'; ... // don't forget free malloc-ed memory free(hostname); here demo on ideone .

Qt QML: Keyboard and mouse does not work together to change the source image -

i struggling problem, guess not difficult not able solve it. experience qml small. appreciate help. i have 3 radio buttons images. focus moves among radio buttons press keys , buttons highlighted. ( focus of radio button changes source images change radio button focus highlighted other image). problem: when interact mouse (see source code) source (image) not change more…..no idea… while source changing before mouse interaction. checked in debugger source line never reached after mouse interaction. i guess not right way change source image…please me solve or give me suggestion alternative rectangle { //main container id: rectangle1 x: 0 y: 0 width: 480 height: 620 color: "#ffffff" item { // focus scope container id: focus_object focus : true image { // radio button 1 id: rock x: 5 y: 6 fillmode: image.preserveaspectfit smooth: true focus:true

Extracting data from multiple variable sized arrays in bash onto one line -

i writing small bash script find mx records of given domain, print out hostname, ip address, , reverse address ip address. able store each hostname, ip, , reverse address 3 arrays: $mxhosts[@] $mxips[@] $mxrhost[@] each contains same number of values, , depend on how many mx records domain has. want do, print out line data 3 arrays, number of values in arrays. how able either a. create new array condenses 3 arrays 1 data or b. print out data 3 arrays using echo? examples: $mxhosts[0] = aspmx.l.google.com. $mxips[0] = 74.125.129.27 $mxrhost[0] = ia-in-f27.1e100.net. from that, i'd print out this: aspmx.l.google.com. :: 74.125.129.27 :: ia-in-f27.1e100.net. for each mx record, run this: [~/scripts]# ./whomails google.com aspmx.l.google.com. :: 74.125.129.27 :: ia-in-f27.1e100.net. alt1.aspmx.l.google.com. :: 74.125.129.27 :: qe-in-f27.1e100.net. etc.. so far i've tried few different methods, using loops, if domain has multiple mx records print out possib

c# - How do I turn this synchronous method into one that returns a Task? -

i have method more or less calls 3 different async methods , returns "result" object containing success message. of 3 async methods may throw sshexception , i've placed 3 within try{}catch{} traps aggregateexception , handles sshexception , , returns failure result object. since i'm on .net 4.0, can't use async/await (which believe solve problem easily), turn method 1 returns task containing 1 of 2 results: "success" if 3 previous tasks completed successfully. "failure" if any of previous tasks faulted. ideally, task execution stop @ first canceled task (e.g. taskcontinuationoptions.notonfaulted 3 work tasks). here's sample code: public uploadresult uploadfiletodir(string dir, string text) { try { sftpclient.cd(dir).wait(); // task var filename = this.getfilename().result; // task sftpclient.writefile(filename, text).result; // last task return uploadresult.success; } catc

AngularJS Manually Render Controller and Template -

i'm trying implement plugin system in angularjs allow users configure "widgets" see on page. each widget defined controller , template(url). possible create directive instantiates controller, invokes template , transcludes resulting content? the goal this: <div class="widget" ng-repeat="widget in widgets"> <widget controller="widget.controller" templateurl="widget.templateurl"></widget> </div> there 2 ways this; 1 uses helper directives available (like nginclude , ngcontroller ) , second manual; manual version might faster, cannot sure. the easy way: the easy method simple create new element ngcontroller , nginclude attributes, append directive's element, , $compile it: var html = '<div ng-controller="'+ctrl+'" ng-include="'+tpl+'"></div>'; element.append(html); $compile( element.contents() )( scope ); the manual wa

c# - How do I Find an object up the list I am iterating through -

i iterating through list of objects of type "prvemployeeincident". the object has following properties: public datetime dateofincident { get; set; } public bool iscountedasapoint; public decimal originalpointvalue; public bool isfirstincollection { get; set; } public bool islastincollection { get; set; } public int positionincollection { get; set; } public int daysuntilnextpoint { get; set; } public datetime datedroppedbysystem { get; set; } public bool isgoodbehaviorobject { get; set; } my list sorted dateofincident property. find next object up list iscounted == true , change iscounted = false. one question: 1) how find object list ? if understand question correctly, can use linq firstordefault : var nextobject = list.firstordefault(x => x.iscountedasapoint); if (nextobject != null) nextobject.iscountedasapoint = false;

matlab - Plotting the hyperplane of LDA (ClassificationDiscriminant) -

i trying compare various classifiers on data, such lda , svm etc, visually investigate separation hyperplane. currently using classificationdiscriminant lda classifier, unlike svm can draw hyperplane on graph, not find way plot hyperplane of lda classifier. the following script how produce sample data , been classified using classificationdiscriminant: %% data & label x = [randn(100,2); randn(150,2) + 1.5]; y = [zeros(100,1); ones(150,1)]; %% plot gscatter(x(:,1),x(:,2),y); %% train lda classifier c = classificationdiscriminant.fit(x,y); can please me plot hyperplane of separation c ? suggestion great help. furthermore, sample above in 2d, however, i'm interested in plotting them in 3d (i.e. sample data x has 3 columns). more great if can help. borrowing example in matlab's classify() documentation: class1 = 1; class2 = 2; k = c.coeffs(class1,class2).const; l = c.coeffs(class1,class2).linear; f = @(x,y) k + [x y]*l; hold on; ezplot(f, [min(x(:,1)

symfony - Symfony2 Sometimes Slow Dev and Production Response Time -

Image
i have been working on new project work , have been running weird issue application takes long time return response both in dev , prod. returns response fast. read few posts on here possible reasons why none of them have solved issues. at first thought because had few sub requests made removed still had same issues. my average request between 20-30mb in dev. trying use profiler me figure out may coming from, every request shows longest part of request different area. example, in 1 request longest section controller, in request same page template listener, on security/firewall listener. for example, fast request on homepage takes 116ms. wait min, refresh , takes 9467ms, or have seen take 30,000+ms. while can live little slowness in dev mode, prod doing same things. fast, slow. apc cache enabled. doctrine queries take 4-20ms complete depending on page. i running php 5.3 decided upgrade 5.4 see if helped, still same issues. using latest stable build of nginx. php in fpm. ser