Posts

Showing posts from April, 2012

List cakephp cache keys by prefix -

sometimes need write temporary keys using ids. for example: cache::write('tsi_' . $tid, 1, '5m'); is there way retrieve keys prefix (looking tsi_xxxx) ? using cakephp 2.5.3 directly cakephp can not it. possibility of getting keys cache may realized in cache engine( memcahed may memcached::getallkeys ()).

ruby on rails - Check Twitter user relationship created_at? -

i'm stuck trying extract twitter hash , can't seem find out how friendship attributes? my code: require 'twitter' require 'rubygems' client = twitter::rest::client.new |config| config.consumer_key = "..." config.consumer_secret = "..." config.access_token = "..." config.access_token_secret = "..." end puts client.friendship('user1','user2').to_s response: #<twitter::relationship:0x007f88c1e58de0> is there way extract info can retrieve hash array of info on relationship? i.e. when friendship created? i think cannot find created_at other attributes you can use direct attribute name data = client.friendship('user1','user2') data.source.screen_name # user1 if not convert json data = client.friendship('user1','user2').as_json handle = data["target"]["screen_name"] # user2 sample response after as_json {"

when to implement comparable and when to implement equals in Java -

in java, when should implement comparable<something> versus implementing equals method? understand every time implement equals have implement hash code . edit based on answers getting below: is safe if implement comparable don't need implement equals , hashcode ? in: whatever can accomplish equal included in compareto ? example, want able compare 2 bsts equality. implementing hashcode seems daunting; comparable sufficient? if ever need compare them equality (or put them in hashmap or hashset same) need implement equals , hashcode . if objects have implicit order , indend sort them (or put them in treemap or treeset sorting) must implement comparable or provide comparator .

Why does Preon give a java.lang.InstantiationException for references to inner classes? -

this modified version of imagetest file embeds image class inside main class , produces instantiationexception. i'm wondering why runtime exception being thrown , if there's away work around without splitting out inner class separate file... /* * copyright (c) 2009-2010 wilfred springer * * file part of preon. * * preon free software; can redistribute and/or modify under * terms of gnu general public license published free software * foundation; either version 2, or (at option) later version. * * preon distributed in hope useful, without * warranty; without implied warranty of merchantability or fitness * particular purpose. see gnu general public license more details. * * should have received copy of gnu general public license along * preon; see file copying. if not, write free software * foundation, inc., 51 franklin street, fifth floor, boston, ma 02110-1301 usa. * * linking library statically or dynamically other modules making * combined work base

windows - Reading the last n lines from a huge text file -

i've tried file_in <- file("myfile.log","r") x <- readlines(file_in, n=-100) but i'm still waiting... any appreciated i'd use scan this, in case know how many lines log has : scan("foo.txt",sep="\n",what="char(0)",skip=100) if have no clue how many need skip, have no choice move towards either reading in , taking last n lines (in case that's feasible), using scan("foo.txt",sep="\n",what=list(null)) figure out how many records there are, or using algorithm go through file, keeping last n lines every time the last option : readlastlines <- function(x,n,...){ con <- file(x) open(con) out <- scan(con,n,what="char(0)",sep="\n",quiet=true,...) while(true){ tmp <- scan(con,1,what="char(0)",sep="\n",quiet=true) if(length(tmp)==0) {close(con) ; break } out <- c(out[-1],tmp) } out } all

sql server - SQL configuration for MVC Entity Framework -

need straightforward mvc deploy ... i cannot db connection mvc web app other using localhost on azure vm. the problem occurs webapp i'm developing and out-of-the-box vs2013 mvc template ... when deployed bizspark preconfigured vm. when browsing vs on local host , can update records, cannot iis hosted site. workflow pre-deploy: enabled ef migrations deploy: web publisher connectionstrings: <add name="defaultconnection" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|aspnet-webapplication1-20150429124346.mdf;integrated security=true;connect timeout=30" providername="system.data.sqlclient"/> <add name="defaultconnection_databasepublish" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|aspnet-webapplication1-20150429124346.mdf;integrated security=true;connect timeout=30" providername="system.data.sqlclient"/> question are the

python - Read groups with extensible attributes from Infoblox API (WAPI) -

i have no experience infoblox api. need write little script reads configured networks extensible attributes (i need "location" attribute). after need re-writing , posting via api different machine. i searched net , have found examples nothing can read networks location attribute. has done before? thanks andre not sure can answer of - perhaps add more detail precise problem facing... however, recommend requests python library. you'll need set variables url of infoblox wapi infoblox_address , version. can query network , json response external attributes. attribs_request = requests.get(infoblox_address + infoblox_version + network_reference + "?_max_results=5&_return_fields=network,extattrs") response = attribs_request.json() print response['extattrs']['location']['value'] you query each network in range , store value in list when value exists in location external attribute.

java - Deleting Cookies and Cache in chrome browser -

could please confirm can use the: driver.manage().deleteallcookies() for delete cookies in chrome. , please provide statements deleting cache in chrome , ie. , how confirm cookies , cache deleted in browsers. using deleteallcookies() clear cookies not cache . there not way clear cache selenium, @ last not know. however, think not need either since selenium default creates new profile every time. see issue has been opened since 2010. , more detail discussion here

javascript - Update gauge dial with fusionCharts and AngularJs -

i have fusionchart gauge want update every second in angularjs i have json object values want use update gauge with. think proplably should use function "setdata(dialindex, value)" somehow. know how create interval not how use update function dail. app.controller('startcontroller',function($scope... $scope.datasource = { "chart": { ... "dials": { "dial": [ { "value": "65", ... }] } }; }); this fiddle might you. need instance of particular fusioncharts , need call api method ( setdata or feeddata )

attachment - Attach a file to rich text item in Lotus Document -

i'm trying attach file document in lotus.my file situated here in c:\dev\3.txt, form test , richtext field want attach field "test". tried lotusscript code attach file field 'test' put file in end of document , not in field: dim uidoc notesuidocument dim w new notesuiworkspace dim object notesembeddedobject dim doc notesdocument dim rtitem notesrichtextitem set uidoc=w.currentdocument set doc = uidoc.document set rtitem = doc.getfirstitem( "test" ) set object= rtitem.embedobject(embed_attachment, "", "c:\dev\3.txt") doc.form = "test" call doc.save( true, false) call uidoc.close try use code: files = workspace.openfiledialog(true, "file list","", "") forall in files set object = rtitem.embedobject(embed_attachment, "",i,"") end forall

jquery - on `Route` refresh getting issue with `angularjs` -

i have router this: "user strict"; angular.module("ngtenderdocument", ["ngroute", "ngresource", "docnavidir"]) .config(function ($routeprovider, $locationprovider) { $locationprovider.html5mode(true); $routeprovider.when('/', { controller : 'homecontroller', templateurl : 'views/home.html' }); $routeprovider.when('/chart', { controller : 'chartcontroller', templateurl : 'views/directiveviews/chart.html' }) }); as in home.html page there link this: <nav class="navbar navbar-inverse"> <ul class="nav navbar-nav"> <li class="active"><a id="first" href="#">first</a></li> <li><a id="prev" href="#">

regex - Extracting several strings from a range of cells -

Image
i have couple thousand of cell need extract document numbers out from. cells have no format ever, every document number starts "doc#-" example b2: this example cell showing doc number doc#-12351-2432-1b , second document doc#-2342-rtf-dd-09, there may several more or one. i looking way extract document numbers individual numbers, separate cells, line, etc. best way go this? current have extremely rough formula. =mid($b2,find("doc#-",$b2,1),find(" ",$b2,find("doc#-",$b2,1))-find("doc#-",$b2,1) which: finds first doc, find space after it, returns number mid. thinking vba way solve this, i'm stumped on how. select cells wish process , run small macro: sub qwerty() dim long, v string, k long each r in selection v = replace(r.value, ",", " ") ary = split(v, "doc#-") k = 1 = 1 ubound(ary) bry = split(ary(i), " ")

HTML + values out of two text forms -

i need way values out of 2 text forms/fields , put them in 1 hidden textbox. e.g. password 1: water password 2: 12561 the hidden password-form should contain "water12561" why need this? have otrs-login otp(one time password) , want authenticate user otp , password stored in mysql-db/ldap. normal way is, user has type in both values in 1 filed isn't way in opinion. because of reason want create 2 field , set password in 1 field submit perl-script. btw - there no php installed on machine. here quick snippet works via javascript. made password field visible can see working. you'll need make password field hidden meet requirements. document.getelementbyid("button").addeventlistener("click", function(){ concatfields(); }); function concatfields() { var val1 = document.getelementbyid("input1").value; var val2 = document.getelementbyid("input2").value; var password = val1 + val2; doc

Sed script match condition fails at the end of file -

i'm using following script make ip addr print 1 line per interface: ip addr | sed -nr '/^\w+: /{ h :top n /^\s/ { h ; b top } x s/\n//g \ ========== p b top } ' input: 1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state unknown link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth2: <broadcast,multicast,noarp,promisc,up,lower_up> mtu 1600 qdisc pfifo_fast state qlen 1000 link/ether 08:00:27:33:58:cb brd ff:ff:ff:ff:ff:ff inet6 fe80::a00:27ff:fe33:58cb/64 scope link valid_lft forever preferred_lft forever 3: eth0: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state qlen 1000 link/ether 08:00:27:33:58:ca brd ff:ff:ff:ff:ff:ff inet 192.168.122.10/24 brd 192.168.122.255 scope global eth0 inet6 fe80::a00:27ff:fe33:58ca/64 scope link output:

php - Pear Mail sends email without attachment -

i trying send mail using php pear mail attached files. reading text file filenames , using create filepath can attach file per pear addattachment() syntax. when receive mail has no attachments. my code function sendmail() { $pdf_filename = file_get_contents("/tmp/uploads/filelog/pdffiles.txt"); $csv_filename = file_get_contents("/tmp/uploads/filelog/csvfiles.txt"); $text = 'text version of email'; $html = '<html><body>html version of email</body></html>'; $csv_file = '/tmp/uploads/csv/' . $csv_filename; $pdf_file = '/tmp/uploads/pdf/' . $pdf_filename; $crlf = "\n"; $hdrs = array ( 'from' => 'you@yourdomain.com', 'subject' => 'test mime message' ); $mime = new mail_mime ( array ( 'eol' => $crlf ) ); $mime->settxtbody ( $text ); $mime->sethtmlbod

fit 2d surface using LOESS in R -

i want take noisy 2d data , use loess smoothing find smoother 2d surface. data form of data frame or matrix of r rows , c columns. 'asbio' package surface plots n*n data, , can work out how 1d fits 'loess' stats base package can't work out how 2d plot. library(rgl) age <- 1:100 year <- 1959:2012 z<- data.frame(matrix(array(0, length(age)*length(year)),nrow=length(age), ncol=length(year))) rownames(z) <- age colnames(z) <- year distyear <- dnorm(1:length(year), 26, 10) distage <- dnorm(age, 50, 15) for(theyear in year){ #for(theage in age){ z[,theyear-year[1]+1] <- as.numeric(distyear[theyear-year[1]+1]*distage*runif(length(age))*50000) #} } z<- data.matrix(z) z <- data.frame(z) colnames(z) <- year # first define colours z values. zlim <- range(z) zlen <- zlim[2] - zlim[1] scale <- 20/zlen colorlut <- terrain.colors(20,alpha=1.0) # height color lookup table col <- colorlut[ (t(as.matrix(z))-zlim[1]

php - Modifying new code to support PHP5.3 -

i'm using roots.io wordpress starter theme. it's coded php 5.5 server i'm posting site on running php 5.3 i need change code supported php on server, don't know how. function asset_path($filename) { $dist_path = get_template_directory_uri() . dist_dir; $directory = dirname($filename) . '/'; $file = basename($filename); static $manifest; if (empty($manifest)) { $manifest_path = get_template_directory() . dist_dir . 'assets.json'; $manifest = new jsonmanifest($manifest_path); } if (wp_env !== 'development' && array_key_exists($file, $manifest->get())) { return $dist_path . $directory . $manifest->get()[$file]; } else { return $dist_path . $directory . $file; } } the issue in line: return $dist_path . $directory . $manifest->get()[$file]; the [$file] confusing php think no idea how modify this. tips? if more code needed please let me know. you'll need split return reques

ios - Parse Swift Update Errors -

after recent swift update, have been trying debut few lines of code , don't seem understanding what's wrong.. the lines are pfgeopoint.geopointforcurrentlocationinbackground { with error message "cannot invoke 'geopointforcurrentlocationinbackground' argument list of type '((pfgeopoint", nserror!) -> void)'" the second line pfuser.loginwithusernameinbackground(username:usernametextfield.text, password:passwordtextfield.text, target: self) { with error "extra argument 'target' in call" i've tried looking online , debugging these, have no idea what's going on. seems error in parse code , i'm not sure why is... edit: fixed second error having. code: pfuser.loginwithusernameinbackground(usernametextfield.text, password:passwordtextfield.text) { start swift 1.2, failable casts introduced. can use pfgeopoint.geopointforcurrentlocationinbackground method following: if you're quite

liquid - Loop trough files in _posts subfolder - Jekyll -

i using prose.io cms github. in have set root directory /_posts. in /_posts have made folder "staticpages", contains markdown files text. can loop trough these files? can't seem figur out how. so file tree looks like: root | _posts/ | staticpages/ | myfile.md and want to: {% pages in posts.staticpages %} {{ page.title }} {% endfor %} here go: in _config.yml specify defaults: - scope: path: "_posts/staticpages" values: static: "true" and in layout file (or page) filter posts , loop with: {% assign posts = site.posts | where:"static", "true" %} {% post in posts %}... this works me...

emacs24 - Is it possible to use emacsclient to pre-load emacs, but have each window operate independently? -

i have been enjoying having emacs load daemon when login , using emacsclient -c pop open emacs window superquick . however, have multiple emacs windows open @ time. each 1 dedicated particular project. before used emacsclient each of these emacs windows independent of other, now, share same set of buffers. how can continue use emacsclient, have windows act independently?

python - SQLalchemy: joining one table on two columns -

i have join 2 tables, first table contains 2 reverences second. e.g. first table owns columns start_id , end_id. second table contains positions. how can join them in way have access start , end values. here have tried: endp = aliased(positions) startp = aliased(positions) trans_data = self.atomic_db.session.query(one, endp, startp ).join( endp, one.start_id == startp.id).join(source_level, one.end_id == endp.id).values( one.id, endp.value , startp.value) t your joins not ordered right, should write: endp = aliased(positions) startp = aliased(positions) trans_data = self.atomic_db.session.query(one, endp, startp)\ .join(endp, one.end_id == endp.id)\ .join(startp, one.start_id == startp.id)\ .values(one.id, endp.value ,startp.value) also, did want update or query results? if latter - not need ".values"

numpy - Putting multiple columns of data into one array, python -

so have set of data has singular column x data , multiple columns y data, of form. x_title y_title_1 y_title_2 y_title_3 .... y_title_n data_x1 data_y2 data_y3 data_y4 data_yn .... .... .... .... .... .... i trying graph data, different plot each y_data_i, on same graph. i using numpy arrays, matplotlib , scipy. , genfromtxt read in. imagine best way put each column array, there array y_data_1,y_data_2 , on. have no idea how this? know how read them in singularly, set data, so: y_data_1=data[0:number_of_rows,1] however don't know how code way hundreds of columns. the basic plotting function be: import matplotlib.pyplot plt x = data[0] y in data[1:]: plt.plot(x, y) plt.show() where data[0] first column, , data[1:] except first column. see here more options.

javascript - Function in object is being declared as not a function -

this question has answer here: how access correct `this` inside callback? 5 answers so have created small table row generator json. when started building hadn't put in object , worked absolutley fine. after, made abstract , needes parameters passed it. put in object re use other sets of data. however, after putting in object console message: typeerror: this.gettablerow not function but... function: gettablerow: function(data) { row = "<tr>"; (i in data) { row += "<td>" + data[i] + "</td>"; } row += "</tr>"; return row; } here full script have in context: var datacollector = { basedataurl: 'http://tourn.dev/data/', displaydatatable: function(datapath, tableidentifier, datakeys, dataopts) { $.getjson(this.buildpath(datapath, dataopts

java - How to loop through a text file and return a card object every two lines? -

Image
so, i've got text file formatted have tried turn single cards , put them array, have put textfile , classes below show i've done: a h 2 h 3 h 4 h 5 h 6 h 7 h 8 h 9 h t h j h q h k h d 2 d 3 d 4 d 5 d 6 d 7 d 8 d 9 d t d j d q d k d c 2 c 3 c 4 c 5 c 6 c 7 c 8 c 9 c t c j c q c k c s 2 s 3 s 4 s 5 s 6 s 7 s 8 s 9 s t s j s q s k s so comment i've added following classes: card: public class card { public string number; public string suit; public card(string n, string s) { number = n; suit = s; } @override public string tostring() { return number + suit; } } and deck (unfinished currently) - import java.io.ioexception; import java.nio.file.files; import java.nio.file.paths; import java.util.arraylist; import java.util.list; public class deck { private arraylist < card > cards; public deck() { cards = new arraylist < card > (); } public list < card > builddeck() throws ioexcep

scala - How to remove parentheses around records when saveAsTextFile on RDD[(String, Int)]? -

i'm using saveastextfile(path) in order save output text file in later import result db. output looks this: (value1, value2) how remove parentheses? you can try following basic: rdd.map(x => x._1 + "," + x._2).saveastextfile(path) you map rdd[(a,b)] rdd[string] , save it.

javascript - Onclick attribute with if statement -

click1=document.getelementbyid("job1"); click2=document.getelementbyid("job2"); if (click1.onclick) { x=1; store(x); } else { x=2; store(x); } why won't work , instead loads next function without clicking? you can try instead: click1=document.getelementbyid("job1"); click2=document.getelementbyid("job2"); click1.onclick= function() { x=1; store(x); } click2.onclick = function() { x=2; store(x); }

Display three lists in one Android activity by swiping or selecting an arrow button -

Image
i have 15 data items in json. want display 6 items in android gridview , 6 items in view, , 3 items in third view in one activity only on swipe or selecting arrow towards right in android. how this? why not use tablelayout , collapse columns onclick ? let got 6 items in row on screen, , show first 3 items. (start collapsecolumns="3,4,5" ) example: tablelayout: <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mytable" android:collapsecolumns="3,4,5"> <tablerow android:layout_width="fill_parent" android:layout_height="fill_parent"> <imageview android:layout_width="wrap_content" android:layout_height="100dp" android:id="@+id/imageview" android:layout_column="0" android

How to refresh the previous page using AngularJS? -

we have asp.net application use angularjs. there's page table (list) contains pictures , properties. pictures in first column of table. code looks following: <td> <a ng-href="{{pic.fullurl}}" target="_blank"> <img class="img-thumbnail" ng-src="{{pic.fullurl}}" alt="{{pic.alttext}}" /> </a> </td> we can edit picture clicking "edit" button , go next page (edit). after made changes, click "back" button return previous page (list). the issue image on first page hasn't been refreshed if changed on edit page, pic.fullurl doesn't take effect. i've tried use watch function, no luck. how make work? update we have service: pictureapp.factory('pictureservice', function ($http, $location) { var pictureservice = function () { this.tolist = function (objtype, objid, mode) { $location.path('/' + objtype + '/

Liquibase's DbDoc listing all changes as "Pending / Not yet ran" -

liquibase integrated our spring application , database migration executed during application startup phase. when running dbdoc via maven plugin changes reported "pending changes (not yet ran)". cannot create diff view our next release. the issue found spring bean uses classpath relative path changelog entries in databasechangelog table. when running dbdoc via maven plugin filepath relative maven project's root used. the code of notranchangesetfilter cannot deal difference: http://grepcode.com/file/repo1.maven.org/maven2/org.liquibase/liquibase-core/3.3.2/liquibase/changelog/filter/notranchangesetfilter.java particularly following comparison not work: ranchangeset.getchangelog().equalsignorecase(changeset.getfilepath()) the methods return following values: getchangelog(): classpath:changelog/5.3.3/nos_add_acp_data.xml getfilepath(): src/main/resources/changelog/5.3.3/nos_add_acp_data.xml thus equalsignorecase comparison fails, results in changes being l

sql - Unable to use SQLPS CmdLet Backup-SQLDatabase with -InputObject parameter -

having run same timeout issue found here , trying workaround, i'm finding error: backup-sqldatabase : cannot bind parameter 'inputobject'. cannot convert "[instdw_qa0]" value of type "microsoft.sqlserver.management.smo.server" type "microsoft.sqlserver.management.smo.server". @ line:21 char:50 + backup-sqldatabase -database msdb -inputobject $server -backupaction database ... + ~~~~~~~ + categoryinfo : invalidargument: (:) [backup-sqldatabase], parameterbindingexception + fullyqualifiederrorid : cannotconvertargumentnomessage,microsoft.sqlserver.management.powershell.backupsqldatabasecommand when running simple script: $servername = "instdw_qa0" $server = new-object ("microsoft.sqlserver.management.smo.server") $servername $server.connectioncontext.statementtimeout = 0 $db = $server.databases["msdb"] backup-sqldatabase -database msdb -i

asp.net - how to remove version information from server error "the resource cannot be found" -

while browsing page, getting error : server error in '/' application. the resource cannot found. description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly. requested url: /webresource.axd version information: microsoft .net framework version:4.0; asp.net version:4.0.33 the error expected , need way hide/remove version information .!? if there any... create custom page want users see , in web.config file have like <system.web> <customerrors mode="remoteonly" defaultredirect="404.aspx" redirectmode="responseredirect"> <error statuscode="404" redirect="404.aspx" /> ... </customerrors> </system.web> there 3 different mode on , off , remoteonly on - specifies custom errors enabled. if no defaultredirect attribute sp

android - java.lang.IllegalStateException: attempt to re-open an already-closed object SQLiteQuery -

04-29 18:24:24.676: e/androidruntime(5640): fatal exception: main 04-29 18:24:24.676: e/androidruntime(5640): process: com.example.mapsproject, pid: 5640 04-29 18:24:24.676: e/androidruntime(5640): java.lang.illegalstateexception: attempt re-open already-closed object: sqlitequery: select distinct _id, name, loc, lat, lng, zoom, uid mapsproject group uid 04-29 18:24:24.676: e/androidruntime(5640): @ android.database.sqlite.sqliteclosable.acquirereference(sqliteclosable.java:55) 04-29 18:24:24.676: e/androidruntime(5640): @ android.database.sqlite.sqlitequery.fillwindow(sqlitequery.java:58) 04-29 18:24:24.676: e/androidruntime(5640): @ android.database.sqlite.sqlitecursor.fillwindow(sqlitecursor.java:152) 04-29 18:24:24.676: e/androidruntime(5640): @ android.database.sqlite.sqlitecursor.onmove(sqlitecursor.java:124) 04-29 18:24:24.676: e/androidruntime(5640): @ android.database.abstractcursor.movetoposition(abstractcursor.java:214) 04-29 18:24:24.676: e/androidru

Get non numeric values from string value c# -

i have value below string value = "11,.ad23"; int n; bool isnumeric = int.tryparse(value, out n); i control if string numeric or not.if string not numeric , has non numeric need get non numeric values below result must below ,.ad how can in c# ? if doesn't matter if non-digits consecutive, it's simple: string nonnumericvalue = string.concat(value.where(c => !char.isdigit(c))); online demo: http://ideone.com/cromht if use .net 3.5. mentioned in comment there no overload of string.concat (or string.join in dmytris answer ) takes ienumerable<string> , need create array: string nonnumericvalue = string.concat(value.where(c => !char.isdigit(c)).toarray()); that takes non-digits. if instead want take middle part, skip digits, take until the next digits: string nonnumericvalue = string.concat(value.skipwhile(char.isdigit) .takewhile(c => !char.isdigit(c)));

Android get elements from json array -

i'm trying elements json array. this json response: {"ids":["635426812801493839","635429094450867472","635433640807558204"]} this i've tried far: itemlist = new arraylist<hashmap<string, string>>(); jsonarray = jsonobj.getjsonarray(constants.ids); int arrsize = a.length(); arraylist<string> stringarray = new arraylist<string>(); (int = 0; < arrsize; ++i) { jsonobject obj = a.getjsonobject(i); stringarray.add(obj.tostring()); item = new hashmap<string, string>(); item.put(constants.id, obj.tostring()); itemlist.add(item); } log.e("arr count", "" + stringarray.size()); but i'm getting empty list. wrong code? appreciated. thanks. the loop should be for (int = 0; < arrsize; ++i) { stringarray.add(a.ge

cURL PHP SSL - Unable to verify server side, but not always -

i ran troubles using mandrill php api ssl certificate problem: unable local issuer certificate i have dig informations on net configuring cacarts file curl. have current cert extract http://curl.haxx.se/docs/caextract.html , , configured (valid) path file in php.ini curl.cainfo=some\local\path\\certs\cacert.pem now testing multiple https websites (src of test here ) $this->nxs_curltest("https://mandrillapp.com/api/1.0/users/ping.json", "testapicall", "mandrill api cert"); $this->nxs_curltest("https://www.google.com/intl/en/contact/", "https google", "mountain view, ca"); $this->nxs_curltest("http://www.google.com/intl/en/contact/", "http google", "mountain view, ca"); $this->nxs_curltest("https://www.facebook.com/", "https facebook", 'id="facebook"'); $this->nxs_curltest("https://www.linkedin.com/", "https linkedin&q

Defining an object with a pointer to an object and operator new in c++ -

this question has answer here: what member-functions created compiler class? happen time? 4 answers simple example regarding definition of objects pointer object. define object a *a = new a(123.4); , 1 a *b = new a(*a); what not understand how work b(pointer to) object? how copy constructor kicks in here , initializes value same object a? thought work, should declare custom copy constructor in class. #include <iostream> using namespace std; class { public: a(float v) { a::v = v; } float v; float set(float v) { a::v = v; return v; } float get(float v) { return a::v; } }; int main() { *a = new a(123.4); *b = new a(*a); cout << a->v << endl; cout << b->v << endl; a->v = 0.0; cout << a->v << endl; cout << b->v << endl;

php - Enabling Middleware in Lumen (Laravel) -

i've been trying out lumen (a micro php framework based on laravel 5 ) few hours , i'm not able add middlewares project means i'm not able use features sessions or csrf protection. my .env looks this: app_env=local app_debug=true app_key=some32charslongkey app_locale=en app_fallback_locale=en db_connection=mysql db_host=localhost db_database=somedbname db_username=someusername db_password=somepw queue_driver=database cache_driver=memcached session_driver=memcached and bootstrap/app.php this: require_once __dir__.'/../vendor/autoload.php'; dotenv::load(__dir__.'/../'); $app = new laravel\lumen\application( realpath(__dir__.'/../') ); $app->withfacades(); $app->witheloquent(); $app->singleton( 'illuminate\contracts\debug\exceptionhandler', 'app\exceptions\handler' ); $app->singleton( 'illuminate\contracts\console\kernel', 'app\console\kernel' ); $app->middleware([

python - unpack_from requires a buffer of at least 4 bytes -

i receiving packet client, consisting of many fields. read fields successfully, when comes last field tag_end, python gives me error: unpack_from requires buffer of @ least 4 bytes not found. this code: def set_bin(self, buf): """reads vector of bytes (probably received network or read file) , tries construct packet structure it, reading each packet member buffer. somehow deserializing packet. """ assert isinstance(buf, bytearray), 'buffer type not valid' offset = 0 print("$$$$$$$$$$$$$$$$ set bin $$$$$$$$$$$$$$$$$") try: (self._tag_start, self._version, self._checksum, self._connection_id, self._packet_seq) = packet.packer_1.unpack_from(str(buf), offset) except struct.error e: print(e) raise deserializeerror(e) except valueerror e: print(e) raise deserializeerror(e) #i=4 h=2 b=1 offset = packet.offset_guid #14 c

delphi xe2 - Parallel installation of EurekaLog 6.1 and 7 -

Image
according blog post using eurekalog 6 , eurekalog 7 on same machine and/or in same ide version a parallel installation of eurekalog 6.1 , 7.x on same machine possible. background: in case, old software working eurekalog 6.1.5 enterprise , plan keep way adaption made heavy use of different event handlers offered eurekalog (which refactored in version 7). new software supposed work newest version of eurekalog (7.2.1 enterprise) support 64-bit version. unfortunately, setup process kills after following dialog (according source above) supposed answered "no" . has else encountered problem , found solution? according eurekalog support, a parallel installation of version 6.x , 7.x no longer possible . linked blog post outdated. if legacy applications still want use interface of eurekalog 6, use of "wrapper unit" recommended: eurekalog 6 compatibility mode enables use behaviour eurekalog 6 instead of behaviour of eurekalog 7. enabling mode

TypeError; Must use key word argument or key function in python 3.x -

i new python, trying port script in 2.x 3.x encountering error typeerror; must use key word argument or key function in python 3.x. below piece of code: please help def resort_working_array( self, chosen_values_arr, num ): item in self.__working_arr[num]: data_node = self.__pairs.get_node_info( item ) new_combs = [] in range(0, self.__n): # numbers of new combinations created if item appended array new_combs.append( set([pairs_storage.key(z) z in xuniquecombinations( chosen_values_arr+[item], i+1)]) - self.__pairs.get_combs()[i] ) # weighting node item.weights = [ -len(new_combs[-1]) ] # node creates of new pairs best item.weights += [ len(data_node.out) ] # less used outbound connections produce more new pairs while search continues item.weights += [ len(x) x in reversed(new_combs[:-1])] item.weights += [ -data_node.counter ] # less used node better item.weights += [ -len(da

java - Removing anonymous listener -

when trying adopt style of implementing listener using anonymous or nested class in order hide notification methods other uses listening (i.e. don't want able call actionperformed). example java action listener: implements vs anonymous class : public myclass() { mybutton.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e) { //dosomething } }); } the question if theres elegant way remove listener again using idiom? figured out instantiation of actionlistener not produce equal objects every time collection.remove() won't remove added object. in order considered equal listeners should have same outer this. implement equals need hold of outer other object. go (which find little bit clumpsy): interface mylistener { object getouter(); } abstract class myactionlistener extends actionlistener implement mylistener { } public myclass() { mybutton.addactionlistener(new actionlistener() {

sql server - python sqlalchemy - can't get cascade delete to work - in mssql manager -

i have code, thats been taken sqlalchemy site class order(base): __tablename__ = 'order' id = column(integer, sequence('tri_id_seq'), primary_key=true) text = column(string(1024), nullable=false) items = relationship("item", cascade="save-update, delete-orphan, merge, delete", backref="parent") class item(base): __tablename__ = 'item' id = column(integer, sequence('tri_id_seq'), primary_key=true) text = column(string(1024), nullable=false) parent_id = column(integer, foreignkey('order.id')) i want deletes order cascade down , delete items well. in code: # test insert/delete - save data mssql server i1 = item(text="item one") i2 = item(text="item two") o = order(text="one", items=[i1, i2]) session.add(o) session.commit() session.delete(o) # delete # tests make sure items/order gone .... session.commit() this works ok. but if try , delete ord

php - Undefined property: stdClass::$account_id error in my code -

i have encountered following error undefined property: stdclass::$account_id (view: c:\xampp\htdocs\laravel\awsconfig\app\views\search.blade.php) here code causing error : $resource_types = array(); $resource_types['aws::ec2::instance'] = 'ec2instance'; $resource_types['aws::ec2::networkinterface'] = 'ec2networkinterface'; $resource_types['aws::ec2::vpc'] = 'vpc'; $resource_types['aws::ec2::volume'] = 'volume'; $resource_types['aws::ec2::securitygroup'] = 'ec2securitygroup'; $resource_types['aws::ec2::subnet'] = 'subnet'; $resource_types['aws::ec2::routetable'] = 'routetable'; $resource_types['aws::ec2::eip'] = 'eip'; $resource_types['aws::ec2::networkacl'] = 'networkacl'; $resource_types['aws::ec2::internetgateway'] = 'internetgateway'; $accounts = db::table('aws_account')->get(); $account_list =