Posts

Showing posts from January, 2011

java - How to use one-to-many and many-to-one annotations correctly? -

good day, i have started first jpa project based on crm application , have difficulties understanding correct usage of manytoone , onetomany annotations. instance, let's have 2 classes; these account , user classes: public class account { @onetomany private set<user> userlist = new hashset<user>(); and public class user { @manytoone private account account; how correctly annotate many-to-one , one-to-many relationships? i've tried reading docs still not retrieve correct conclusion. thank attention a 'canonical' onetomany mapping case, meaning meaning bidirectional, foreign key in table of many-side (the owning side) in case this: public class account { @onetomany(mappedby="account") private set<user> userlist = new hashset<user>(); and public class user { @manytoone private account account; the difference existing code mappedby attribute, change 2 unidirectional relationships single, bidirectional ...

fluentvalidation - Multiple partial validations -

the system i'm developing uses fluentvalidation (v5.0.0.1). what want create several validators partially validate object, can combine in other validators depending on required @ time. for example, class has name , address. (this can't split separate class in examples). for scenario 1, want validate name only, write name validator class. for scenario 2, want validate address, write address validator class. for scenario 3, want validate both name , address, want write new validator class calls name validator , address validator. i don't want repeat code in different places, why want them separate. don't want use when operator there no way determine when contents of object. i know can call setvalidator, how write call? rulefor(j=>j).setvalidator(new namevalidator()); rulefor(j=>j).setvalidator(new addressvalidator()); doesn't work. i explain solution example. i'am going validate contact entity: public class contact { p...

kernel - OpenCL build log provides no information -

my opencl kernel not being built, clbuildprogram returns -11. however, when try read build log using //get build log size_t len; char *buffer; clstatus = clgetprogrambuildinfo(program, device_list[0], cl_program_build_log, 0, null, &len); buffer = (char *)malloc(len); clstatus = clgetprogrambuildinfo(program, device_list[0], cl_program_build_log, len, buffer, null); fprintf(stdout, "kernel build log: %s\n", query_buffer); free(buffer); all i'm getting output is kernel build log: opencl 1.2 for i've resorted copy-pasting kernel code separate c-program , compiling, trying find compile errors way, needless pretty tedious :p know what's going on? fafner ok, merely typo, printing correct buffer solved problem.

plot - gauss curve in R, resizing the x axis to SD -

Image
i plot histogram , resize x axis standard deviation (sd) value. if plot just: hist(df) the x axis show real values. the sd of these values = 0.38. convert x axis sd size, -1 sd in histogram equal -0.38. cheers try this: set.seed(1) x <- rnorm(1000) hist(x, col='red', xaxt='n') # exclude x-axis # manually specify axis m <- c(-3,-2,-1,0,1,2,3) s <- m*sd(x) l <- paste(m,'sd') l[4] <- '0' axis(1, s, l)

angularjs - How to dynamically load a controller? -

i've 2 controller ensted: <div ng-controller="maincontroller" ng-init="init({role='widget1'})"> <div ng-controller="ctrltoload" ng-init="init({action='put'})" ng-include="avariable"> </div> <div ng-controller="ctrltoload" ng-init="init({action='delete'})" ng-include="avariable"> </div> </div> the aim dynamically load template second div controller, depending of parameters managed maincontroller like: myapp.controller('maincontroller', function($scope, $sce, ...) { if(/*something*/){ $scope.ctrltoload = 'anothercontroller' } }); myapp.controller('anothercontroller', function($scope, $sce, ...) { // jobs... });

html - When to use Partial view in ASP MVC? -

i have page has 4 hidden div s, there 4 buttons bring corresponding div s. instead of writing code on 1 page, have split partial views (so div s in partial views) e.g. <div class="hide" id="doctor"> @html.partial("~/views/medical/_doctor.cshtml") </div> it feels wrong reason this, doesn't it? i don't see reason why "wrong". if helps reduce complexity of code, helps. partials typically used following reasons (but not strictly): for child actions , ajax requests for reuse of common code to simplify complex pages the thing watch out if pass object partial it's model, may not render form fields in correct manner bound on postback. editortemplates for, although if know you're doing can make partials work well.

html - Why is position: fixed not working? -

why position: fixed; not working in following css body { text-align : center ; min-width : 770px ; } div.wrapper { width : 770px ; text-align : left ; margin-left : auto ; margin-right : auto ; } div.header { color: blue; padding: 15px; margin: 0px; text-align: center; position: fixed; } div#main { margin-left: 30%; margin-top: 1px; padding: 10px; } div.footer { color: blue; padding: 15px; margin: 0px; text-align: center; } html: <body> <div class="wrapper"> <div class="header"> <form action="<?php $_php_self ?>" method="get"> start datum: <input type="text" name="start" pattern="[0-9]{4}"/> eind datum: <input type="text" name="eind" pattern="[0-9]{4}"/> <input type="submit" /> </form>...

Wix Toolset CustomAction for determining if the OS is windows 7/xp home edition or starter edition and display message for not -

i new wix toolset installation. using wix 3.7 , visual studio 2010 sp1. i going through tutorial uses bootstrapper in there conditional message in product.wxs file checking .net framework 4.0 installed there propertyref id variable , condition message <propertyref id="netframework40full"/> <condition message="this application requires .net framework 4.0. please install .net framework run installer again."> <![cdata[installed or netframework40full]]> </condition> how can 1 check condition windows xp starter/home , windows 7 starter/home/home premium editions , show conditional message installation not support os listed , require professional editions. i have gone through links on wixtoolset website, didn't help: checking windows versions http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/block_install_on_os.html http://msdn.microsoft.com/library/aa370556.aspx i have tried place...

converting c# lambda expression LINQ to vb.net -

i having trouble converting following query vb c#. cant syntax right , ok not great linq. appreciated. var result = (from d in projectionentities.projections d.symbolid <= 42 join t in projectionentities.symbols on d.symbolid equals t.id group d d.symbolid g select new { symbolid = g.key, projectionperformances = g.select(gg=>new projectionperformance{ symbolid = gg.symbolid, name = gg.symbol.name, rpdate = gg.date.tostring(), actualrange = gg.highprojection - gg.lowprojection }) .todictionary(g=>g.symbolid); my approach start valid c# , use tool translation. generated ...

mathjax - Choose a profile when installing a quickinstaller product (Plone 4) -

i had performance problems when loading mathjax dynamically in plone 4 application. thus, found plone integration @ https://github.com/collective/collective.mathjax and, noticed same, forked it, works well; included current mathjax 2.3 , changed profile use "local" copy. now wonder whether possible choose between "online"/"remote" behaviour (load rackcdn.com ) , "default" behaviour (use included copy) choosing profile when installing product in plone quickinstaller tool . i changed configure.zcml this: <configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="collective.mathjax"> <browser:resourcedirectory name="mathjax" directory="resources/mathjax" /> <genericsetup:registerprofile name="default...

javascript - Date displaying a day off using date filter in Angularjs -

hi have following date being returned data "2008-02-25t00:00:00z" when display using <span>{{meetingdate | date: 'mm/dd/yyyy'}}</span> i date display "02/24/2008" basically showing 24 instead of 25 loosing day. can tell me how fix this? thanks try out working code script var localdate = new date('2008-02-25t00:00:00z'); var localtime = localdate.gettime(); var localoffset = localdate.gettimezoneoffset() * 60000; $scope.mydate = new date(localtime + localoffset); html {{mydate | date:'mm/dd/yyyy'}} output 02/25/2008

javascript - Detect application version change on a single page application -

today question raised here , don't have evident answer. assume concatenate , minify resource files (css , javascript) , declare them in "master-page". on multi-page app, if css file changes recharged on next full page load. on single-page app, user can keep working days , never recharge main page css files declared. user never see changes until ctrl-f5 issued. i'm sure thought of , have experience share :) for me, using websockets not option. first because it's overkill , second because not clients support technology. same reason applies websockets fallbacks... won't keep hitting servers because of this. so, ideas anyone? :) btw, we're using angularjs if can specific solution. thanks! i've getting through same problem. solution opiniated , may not respond criterias : when package front-app , server-app, share configuration file containing current version of front-app. front side : 75% of routes change implicitely call ...

ios - Sort NSDictionary as per date-wise in iphone -

i have dictionary like: { "2014-04-12" = ( { "can_remove" = 1; "date_created" = "12-04-2014 04:23:57"; "is_connected" = 0; name = "j j"; status = gbn; "user_id" = 94; } ); "2014-04-14" = ( { "can_remove" = 0; "date_created" = "14-04-2014 02:36:52"; "is_connected" = 0; name = abc; "user_id" = 89; } ); } the keys of dictionary represent dates. how can sort date? i tried this, doesn't work: nsarray* keys = [dict allkeys]; nsarray* sortedarray = [keys sortedarrayusingcomparator:^(id a, id b) { return [a compare:b options:nsnumericsearch]; }]; use following way short according date : nsmutablearray *dictkeys = [[dict allvalu...

javascript - Bookmarklet JS Location doesn't change on second click -

with following bookmarklet want open url: javascript:function z() {return 'https://www.google.com/analytics/web/?hl=de&pli=1#dashboard/x-gsslprqzqukvo4_jarxg/a3789910asdf263939/%3f_u.date00%3d20140413%26_u.date01%3d20140413%26_.useg%3d/'; } window.location = z(); it works fine, on second time click on bookmarklet not loading url anew, diplays it. html content. should load same url again.

javascript - Add PlusMinus to Accordion Menu -

my accordion menu has counter count submenus. want change plus minus. if there submenu "plus" should add if closed, if opened minus. if there no submenu nothing should added. the counter code $('#cssmenu > ul > li ul').each(function(index, e){ var count = $(e).find('li').length; var content = '<span class="cnt">' + count + '</span>'; $(e).closest('li').children('a').append(content); }); jsfiddle demo well achieve first getting 2 icons 1. plus 2. minus , putting in css: #cssmenu > ul > li.has-sub > span { background: url(images/icon_plus.png) 90% center no-repeat; } #cssmenu > ul > li.has-sub.active > span { background: url(images/icon_minus.png) 90% center no-repeat; } here menu follows: <div id="cssmenu"> <ul> <li><a href="#"><span>products</span></a...

php - phalcon validate form fields without saving to database -

am in need validate form fields , manipulate them out saving database. have done in controller <?php use phalcon\mvc\model\criteria; use phalcon\paginator\adapter\model paginator; use phalcon\mvc\view; class userscontroller extends controllerbase { public function loginaction() { if($this->request->ispost()) { $user = new users(); $validates = $user->validation($this->request->getpost()); // validation works fine, cancelonfail in model doesn't seems work, if($validates) { echo 'valid inputs'; } else { print_r($user->getmessages()); // how can show these error messages below corresponding input fields in view. // show error message follows, if field has more 1 validation conditions, // eg: username have notempty , valid e-mail validation set in model if username empty show not ...

php - CodeIgniter/TankAuth forgot_password function sending emails with no content -

recently moved existing codeigniter product own vps, working away. however, reason password has been invalidated , when forgot_password function run email arrives intact subject line, however, emails have no content. @ all. offending code: function _send_email($type, $email, &$data) { $this->load->library('email'); $this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth')); $this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth')); $this->email->to($email); $this->email->subject(sprintf($this->lang->line('auth_subject_' . $type), $this->config->item('website_name', 'tank_auth'))); $this->email->message($this->load->view('emai...

Cassandra table structure suggestion and way of query -

i trying create following hierarchy: userid rowkey, hourly time series columns , inside each hourly column want have user specific information such hourly activity. { userid:long { timestamp:datetime{ pageview: integer, clicks:integer } } i've read possible achieve using supercolumns @ same time mentioned supercolumns outdated right now. if true, alternatives can use? could please provide me cql / java thrift example how should create , insert such type of structure in cassandra? thanks! you can user composite primary key this, add table creation cql query table. , can use counter column clicks. create table user_click_by_hour( userid long, time_stamp timestamp, clicks int, pageview int, primary key(userid,time_stamp) )

android - How to create a JSON structure using Arraylist and Hashmap -

i'm beginner in android development ... want know how create json structure, using arraylists , hashmaps ... can find structure follows ... note: don't want use jsonarray or jsonobject [ [ { "blog_owner" : "user", "icalissueeventid" : "", "updated_date" : "2014-02-17 07:05:53 +0000", "icaleventid" : "", "blog_stage" : "cancelled", "blog_id" : "gmpk20140206160708281", "created_date" : "2014-02-06 10:37:38 +0000", "emailflag" : false } ], [ { "blog_inotes_id" : "", "blog_name" : "", "blog_status" : "", "blog_duration" : "" }, { "pid" : "0", "isopen" : true, "id" : "r1", "level" : 0, "value" : [ { "level" : 0, "id...

arrays - PHP Lost value of foreach after if -

i lost value in foreach after if foreach ($etc_uloziste $id => $etc_id) { foreach ($etc_id $id2 => $etc_id2) { if($rodic1==$id) { if( ! in_array( $etc_id2, $etc_mn) ) { //check if season displayed $sql.= ",\n"." ".$etc_id2."_id"." int"; $etc_mn[] = $etc_id2; //store season in array } } } } before if have value like: [book] => array ( [0] => library [1] => room ) but after if have [book] => array ( [0] => library ) the $etc_id2 library or room , $id book i lost value in 2. echo foreach ($result2 $rodic1 => $rodic_hodnot1) { foreach ($etc_uloziste $id => $etc_id) { foreach ($etc_id $id2 => $etc_id2) ...

javascript - D3 : Retrieve data from SVG -

is possible retrieve data svg via d3? i have following scenario: on page resize need update widths of svg generated on server via d3 . example x-axis. client side d3 library has no knowledge of svg. noticed each dom object there __ chart__ object. there way can access range , domain example , update them accordingly? when create svg on server , transfer client, actual svg dom gets transferred, not javascript objects or properties (such d3 __data__ property) used in creating it. so in order attach data svg elements gets passed file, need create attribute of element contains data. can select element client side , parse data attribute. example: /*** server side ***/ /* if `bars` d3 selection of rectangles in bar graph */ bars.attr("data-name", function(d){return d.name;}) .attr("data-value", function(d) {return d.value;}); /*** client side ***/ var bars = d3.selectall("rect.bar") .datum(function(){ retu...

coffeescript - interpolate rails expression in slim javascript -

i interpolating array in slim javasrcipt: javascript: values2 = #{facet.map{|v| [type[0].html_safe,v[1]]}} in browser gives me error: uncaugh syntaxerror: unexpected token & because rendered strings rendered way: values = [[&quot;agency&quot;, 3301], [&quot;agency&quot;, 225], [&quot;agency&quot;, 63]]; how can done properly? this correct way javascript: values = #{facet.map{|v| [v[0], v[1]]}.to_s.html_safe};

Dynamic Security - Power View Cabable of? -

i trying create dashboard reports using power view employees. but can't allow users being able see data of other. is power view capable of determining user logged on , give tabular project, can filter data through dynamic security implemented in tabular model? if using tabular ssas (not power pivot) , have security set appropriately ( with roles , row filters ), , connecting tabular ssas model ( through sharepoint shared data connection or bism connection ) windows authentication uses current user's credentials, can take advantage of security in tabular model. excel have capability current user , pass context model apply appropriate security when returning results.

Unix - List all files in all directories without displaying full path? -

is possible? find /home/me/subdir -type f the code above alright, dont want display full path , hidden files. try this: find /home/me/subdir -type f ! -name ".*" -exec basename {} \; or find may allow this: find /home/me/subdir -type f ! -name ".*" -printf "%f\n" added afterwards to list largest files, first need find size, maybe this: stat --printf "%n:%s\n" somefilename where %n size , %s name. then if want sizes of all files, need run find : find /home/me/subdir -type f -exec stat --printf "%n:%s\n" {} \; then if want them sorted, , 10 biggest, need add sort , head : find /home/me/subdir -type f -exec stat --printf "%n:%s\n" {} \; | sort -rn | head -n 10

php - MySQL Image Storing -

Image
i want create online rpg game..! searched tutorials on net storing images in mysql.. different..from needed! i don't want "upload" images! server having images..for example.. pokemons!!.. stored in server! need user select 1 pokemon , store related data in account! above example want. there's no upload image etc etc... data , images stored , users have fetch them in account! i don't want exact code... if can explain me how done..or give similar tutorial thankful you don't have store images in database: store somewhere in server, , in database store the path image in table pokemon(id, name, path_to_image) . then in code, use path stored in database link image. , also, when user capture pokemon, you'll need table capture(user_id, pokemon_id) .

moose - Perl export to child modules -

i have parent module myapp.pm: package myapp; use moose; use base 'exporter'; our @export = qw(msg); sub msg { print "hello msg\n"; } 1; which inherited child module myapp2.pm: package myapp2; use moose; extends qw(myapp); 1; and when used in app.cgi script this: #!/usr/bin/perl use myapp2; msg(); i error message: undefined subroutine &main::msg called @ app.cgi line 3. so exported function not work in child class myapp2 works if use "use myapp" instead of "use myapp2". assume exported function should accessible child modules extending parent class. doing wrong. inheritance changes how method calls handled; function calls or variable accesses (like our @export ) not affected. instead of exporting function, use method: use myapp2; myapp2->msg; but in case, cleaner explicitly load myapp in order import msg function, , additionally load myapp2 in order load class. use myapp; use myapp2; msg; it a...

jquery div not respnding to other javascript/jquery methods -

i have added 1 div inside div using $(select).append() method want close on click on image hav added image , $(select).button().click( { $(select).hide() }); on clicking close image nothing happens.... $(document).ready(function() { $("#subcre").click(function() { cust = $("#customer").val(); address = $('#address').val(); phone = $('#phone').val(); amt = $('#initamount').val(); user = '<%= session.getattribute("user").tostring()%>'; type = '<%=session.getattribute("type").tostring()%>'; alert(cust + address + phone + amt + user + type); $.post("../processor/proc2.jsp", { customer: cust, address: address, phone: phone, ...

java - emma code coverage on jenkins is not creating reports -

i trying generate code coverage reports using emma on jenkins, failing builds successful. emma reports failing. here pom.xml <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>thinclientmanager</groupid> <artifactid>thinclientmanager</artifactid> <version>0.0.1-snapshot</version> <name>thinclientmanager</name> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <included.packages>-dincluded.packages=hob.tcm</included.packages> <included.adapters>-dincluded.adapters=coverage,complexity,dependency</included.adapters> </properties> <build> ...

c# - adding several elements via foreach loop -

i trying parse array of double numbers instead of static string did here test, enter number in textbox , after clicking button pick relevant coordinates database. need parse many pairs of coordinates (lat,lon) tried foreach loop couldn't figure out @ 3rd last line. name of field in databse longitude , latitude. new xelement(n + "linestring", new xelement(n + "coordinates", lat+","+lon)))))); code: protected void page_load(object sender, eventargs e) { //string[] values = {"12.1", "2.1","3.1","2.1" }; string values = "12.1,2.1,3.1,1.1"; string[] latlon = values.split(','); sqlconnection sqlcon = new sqlconnection(constr); // string com = "select latitude, longitude coordinates imei=@txtimei"; sqlcommand sqlcom = new sqlcommand("getlatlon", sqlcon); sqlcom.commandtype = commandtype.storedprocedure; s...

Extract string between two words in Java -

i have following string. want extract string between 2 words <cases> , </cases> using java. want extract string form valid xml per requirement. <cases><final-results><row> <crdattim>2014-03-26-05.22.22.339840</crdattim> <recordcd>c</recordcd> <crnode>01</crnode> <ckey>2014-03-26-05.22.22.339840c01</ckey> <statcd>created</statcd> <unitcd>csmhcqa</unitcd> <wrktype>call</wrktype> <issues><row> <ikey>2014-03-26-05.22.22.193840t01</ikey> <prty>999</prty> <issueid>20140326-155047-dt81694</issueid> <subject>group</subject> <isstyp>group</isstyp> <isscat1>group inquiry</isscat1> </row></issues></row></final-results></cases><?xml version=...

php - get_post_meta() returning an arrary when it shouldn't -

why using get_post_meta() of sudden start returning array when $single set true? $sync = get_post_meta( $pid, '_subscription_sync', true ); if ( 'yes' != $sync ) return; var_dump($sync) returns this: array(1) { [0]=> string(3) "yes" } is there global setting i'm not aware off? you have saved array database. update_post_meta automatically serializes you. $single setting on get_post_meta refers whether pull entries post id , key.. var_dump variable saving before update_post_meta , check how ending array.

python - Alternative dependencies (fall back) in setup.py -

say want install pyodbc . can't build on windows machines there's alternative - pypyodbc pure python implementation of pyobdc . is there way specify install_requires=["pyobdc"] setuptools.setup falling pypyodbc if former package wasn't installed? upd: solution particular situation: import sys setuptools import setup if sys.platform.startswith("win"): pyodbc = "pypyodbc>=1.2.0" else: pyodbc = "pyodbc>=3.0.7" ... setup( ... install_requires=[pyobdc] ) but still more general solution. your solution correct 1 situation. best , more flexible way @ moment achieve task.

javascript - D3.js: Align X-Axis to specific value on Y-Axis (e.g. the origin) -

i want simple this: http://alex.nt.fh-koeln.de/bilder/wlet1.jpg the axis aligned origin. however, figure out how adjust axis in terms of width/height using transform: svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height/2 + ")") .call(xaxis); this put x-axis in middle of graph, not origin. guess there simple solution, can't seem find it.

backbone.js - Is it possible to pass cid field in template? -

i have view have template looks following: <script type="text/template" id="template"> <div id="<%=cid=>"></div> <label><%= label %></label> <input type="text" id="search_input" /> <input type="button" id="search_button" value="search" /> </script> and need render template using model data, following: render: function () { var template = _.template( $("#template").html(), this.model.tojson()); this.$el.html( template ); return this; } but unfortunately this.model.tojson() doesn't pass cid (clientid) template. may explain how access cid in template , how handle thing? tojson clones attributes array. that's why there's no cid. if need cid model, may mix in template object: var templatedata = _.extend(this.model.tojson(), { cid: this.model.cid }); var template = _.template( $("#...

CORDOVA (PhoneGap) Android 4.2. "Unknown chromium error: -0" -

after using fragments instead of activities web view i've got unknown chromium error: -0 on sending ajax requests. domains whitelisted, cache = false. in of cases, error due files, the files not dynamically loading correctly (no permission, looking in wrong place). url have provided may wrong.

Microsoft's high compression rate in their installation files -

i trying understand in .net installation package, did unpack /x option. @ point 70 mbyte file have 1.1 gbyte folder. folder removed half (all x64 stuff don't care) , repack 7-zip ultra compression rate. @ end had 110 mbyte compressed file! now question: how ms compress installation packages high compression rate?

apache - I want to redirect requests to domain A to a sub folder of domain B in vhosts config -

i have issue i'm having problems with: i need redirect requests http://domaina.com http://domainb.com/somefolder/ it's understanding site has been built there, need requests come in http://domaina.com i understand rewriting domain like, example, http://domaina.com/blog/index.php http://domainb.com/blog/index.php can pointers on how achieve rewriting url, , adding in new path? thanks, sounds need use reverse proxy here. in domaina config, can do <virtualhost *:80> servername domaina.com proxypreservehost on proxypass / http://domainb.com/somefolder proxypassreverse / http://domainb.com/somefolder </virtualhost> you'll take requests domaina , pass them domainb, proxypreservehost directive ensure requests arriving @ domainb appear have come domaina. end user, browsing domaina, though content being served domainb. you need make sure mod_proxy , mod_proxy_http enabled work.

Using phpseclib via resource of type (SSH2 SFTP) -

i'm working on intranet application company need actions on sftp servers. so, want use phpseclib because need complex functions rawlist, lstat... problem don't have access host, or password. have access function return me resoource of type (ssh2 session). can obtain ressource of type (ssh2 sftp) using php function ssh2_sftp. basically, want use ressource connect phpseclib. possible (even if changement in constructor of phpseclib net_sftp needed)? thanks. that, unfortunately, cannot done. phpseclib implements sftp sending raw ssh2 packets. libssh2 pecl extension gather you're using doesn't let programs send own raw requests, hence phpseclib's being unusable it. i gather server you're using running modified version of php ssh2_return_resource() -type function built binary already?

use JSON value PHP -

this question exact duplicate of: decode below json using php [closed] 3 answers after making api call, json in following format: {"token":"value"} this used auth, value different every time. it's pretty long string. need use append url make yet api call. what best way parse , value, not entire response body (json)? sorry asking noob questions. you can use json_decode() function. http://php.net/json_decode

regex - JavaScript: detection of regular expression in source code -

i need parse javascript source code , match regular expressions of regular expression :). first tried regular expression: (?:\/.*\/) but not work if regular expression contains slash, in next source code while (line.match(/[+*/]/)) line = line.replace(/([+*/])\s(\d+)\s(\d+)/, function (s, op, a, b) { return operators[op](+a, +b); }); i don`t know how keep possibilities in 1 regular expression. there way match regular expression in javascript source code using regular expressions?

c++ - Is it better to pass-by-value and then move-construct or to pass-by-reference and then copy-construct -

this question has answer here: why copy move? 4 answers in c++11 in constructor, better do: class { a(std::string str) : mstr(std::move(str)) {} std::string mstr; } or do class { a(const std::string& str) : mstr(str) {} std::string mstr; } in cases can copy elision occur when rvalue passed in constructor? you should "pass value , move construct" if type's move constructor cheap, , use "pass reference , copy construct" otherwise. for lvalues pass value , move construct you doing 1 copy followed 1 move. pass reference , copy construct you doing 1 copy for rvalues pass value , move construct in best case (when rvalue temporary expression) doing no copy/no move, followed move. in normal case (when rvalue not temporary expression) doing move followed move. pass reference , copy construct you do...

.net - Incompatibility using managed array and std:array at same time -

i have c++/cli code using arrays (for example): array<string^>^ getcolnames() { vector<string> vec = impl->getcolnames(); array<string^>^ arr = gcnew array<string^>(vec.size()); (int = 0; < vec.size(); i++) { arr[i] = strconvert(vec[i]); } return arr; } it's compiling fine until add library "array" project: #include <array> then don't know how use managed cli array, because compiler thinks declared arrays std::array . errors examples: array<string^>^ arr // ^ error here: "too few arguments class template "std::array"" gcnew array<string^>(vec.size()) // ^ error: "expected type specifier" how solve this? tried removing using namespace std file, makes no difference. should remove every other c++ file on project? clearly have using namespace std; in scope somewhere. watch out being used in .h file if cannot find it. ...

java - Check if member is new-initialized -

how check in java if membervariable/memberarray (of every standard type int/double/float... etc) new-initialized? difference double/integer/float? class class { double[] memberarray; double membervariable; class() { } void init() { memberarray = new double[12]; //membervariable = new double(); //edit: not compile } void foo() { // check here if membervariable/memberarray has been new-initialized } } constructing these in ctor not option, arraysize isn't known @ point. , i'd use primitive types here, not container. example, not used in project. there 2 basic types of variables given different default values member variables ( when not member/instance variables not given default values @ all ). 2 types reference variables , primitive variables. reference variables 'refer' variables objects ( anything not primitive ). others primitives. primitives given default values of 0, except boolean ...

asp.net mvc - How to store Dictionary<string, string> in hidden field and retrieve the same in controller through FormCollection Id -

the scenario :- controller part : public actionresult goht() { dictionary<string, string> col = new dictionary<string, string>(); col.add("a", "c"); col.add("b", "c"); viewbag.cols = col; return view(); } view part : <input type="hidden" id="hd" name ="hd" value="@viewbag.cols" /> in case hidden value not showing dictionary element id defined instead show as <input type="hidden" id="hd" name="hd" value="system.collections.generic.dictionary`2[system.string,system.string]"> here question , how assign dictionary element viewbag , store in hidden field. and how same dictionary made available @ form submission. controller : [acceptverbs(httpverbs.post)] public actionresult goht(formcollection formcollection) { var mode = (dictionary<string,...

Uploading files to Zoho API with PHP Curl -

i trying attach file zoho crm account page using zohocrm api , not having success. using curl , php5.3 (no curl_file_create, using hand rolled version). in log following report curl::post url: https://crm.zoho.com/crm/private/json/accounts/uploadfile?authtoken=my_token&scope=crmapi params: array( [content] => @/tmp/b2d-jbjvmy;filename=b2d-jbjvmy;type=application/pdf [id] => my_account_id ) i no response zohocrm , file not attached target account record. doing wrong? here's excerpts code may or hinder: ... other methods zohoapi class such getsearchrecords appear working fine... class curl { ... protected static function post($url, $params) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header,0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $params); $data = ...

java - NullPointerException in PhoneDirectory programme -

i have come across error in phonedirectory programme. when try , compile arrayphonedirectorytester, builds returns error: exception in thread "main" java.lang.nullpointerexception @ arrayphonedirectory.addchangeentry(arrayphonedirectory.java:60) @ arrayphonedirectorytester.main(arrayphonedirectorytester.java:17) java result: 1 from little bit of research online, understand means variable trying use has been set null, , occurs in arrayphonedirectory java file in line 60, , in arrayphonedirectorytester java file in line 17 (both commented in code below.). still unsure variable pointing @ , regarding fixing exception appreciated. arrayphonedirectory code: import java.io.*; import java.util.*; public class arrayphonedirectory implements phonedirectory { private static final int init_capacity = 100; private int capacity = init_capacity; //holds telno of directory entries private int size = 0; //array contain directory entries private directoryentry[] thedirectory =...

c# - Waiting for a ThreadState to be "Stopped" in a Button Click Event -

i'm having issues while waiting threadstate during click event of button control. whenever click button it'll execute code below. problem won't wait until threadstate "stopped", never enables btnimportdata or btnexportbellijst . i've tried t.join() freezes whole form , use richtextbox logger, that'd result in logger freezes few seconds , shows lot of text @ once. reason put importdata function on thread keep form running people can see logs happening realtime. what i'd have when click button: change enabled of 1 or more buttons. run function importdata on thread logger can keep logging. ( void importdata(){} ) change enabled of 1 or more buttons after function done doing something. private void btnimportdata_click(object sender, eventargs e) { //disable current button btnimportdata.enabled = false; imgbonne.visible = false; //random image rtconsole.visible = true; //richtextbox logger //create new thread bu...

java - Exercice with scan files -

i have print lines of file "text", how can that? public static void main(string[] args) throws filenotfoundexception{ file f =new file("text.txt"); scanner scanner = new scanner(f); while(scanner.hasnextline()){ system.out.println(scanner.nextline()); } } thank you. here easy way keep track of line on , how tell if number or not. if indeed number, print it. public static void main(string[] args) throws filenotfoundexception { file f = new file("text.txt"); scanner scanner = new scanner(f); int counter = 1; //this tell line on while(scanner.hasnextline()) { if (counter % 2 == 0) { //this checks if line number system.out.println(scanner.nextline()); } counter++; //this says looked @ 1 more line } }

jquery - Select2 dropdown does not stay open when the bottom of the options block extends below the browser window -

when bottom of options box extends below browser window, options block not stay open when clicked unless mouse happens hovering on box's scroll bar. if click in middle of dropdown menu, snaps immediately, selecting whatever house happens have been hovering over. can see talking here: http://what-key-am-i-in.herokuapp.com/ , click on 'fretboard' link, try change dropdown showing keys (lower left dropdown menu) bottom of browser window below menu is. shouldn't menu open upwards instead? thanks! looks fixed in select2 repo. https://github.com/select2/select2/pull/2620/commits

html - Media queries not relating to pixels on website -

i'm building responsive site when resize window media queries aren't corresponding screen resolution, instance, @media screen , (min-width:640px) , (max-width: 800px) resulting in these design elements when screen above 800 pixels , when i'm @ 700 pixels designs being set @media screen , (min-width: 400px) , (max-width:640px) reason. know why happening? update: max-width 640px media query being set screen @ on 700 pixels still. @media screen , (max-width: 1024px) { .body{ width:800px; } } @media screen , (max-width: 800px) { .body { width:600px; } } @media screen , (max-width:640px) { .body { width:480px; } } @media screen , (max-width:400px) { .body { width:260px; } } to start troubleshooting, double check in head of document have <meta name="viewport" content="width=device-width, initial-scale=1.0"> let me know how on. edit thanks code. check out this working...

innerhtml - jQuery Wraping innterHTML div with Class -

i want able copy text element id 'mymodal' 'purchasenotice' , wrap 'purchasenotice' new class. var mydiv1 = document.getelementbyid('mymodal'); var mydiv2 = document.getelementbyid('purchasenotice').wrapinner( "<div class='new'></div>"); mydiv2.innerhtml = mydiv1.innerhtml; the code above works until add .wrapinner( "") - how shall wrap this? if you're using jquery can : demo $(document).ready(function(){ $('#purchasenotice').html($('#mymodal').html()).wrapinner("<div class='new'></div>"); }); update sorry, noticed wanted wrap purchasenotice in new div. use wrap() see here : http://jsfiddle.net/32tax/1/ $(document).ready(function(){ $('#purchasenotice').html($('#mymodal').html()).wrap("<div class='new'></div>"); });