Posts

Showing posts from January, 2014

c++ - Increase stack size of a program -

i'm looking way increase stack size of program, reason i've recursive call casusing stack overflow. there anyway can change default stack size? if *nix, use ulimit -s <number_in_kb> you'd set in environment before running program. can set programatically described in this answer . you can view current value running ulimit -a .

ios - Tab Bar Not Showing -

i have specific view opening when opening app notification. navigation bar shows , navigation works correctly. problem i'm having getting tab bar show up. here didfinishlaunchingwithoptions method. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // prevents ua library registering uiapplcation default when // registerforremotenotifications called. allow prompt // users @ later time. gives app opportunity explain benefits // of push or allows users turn on explicitly in settings screen. // if want prompted push, can // leave line out. // [uapush setdefaultpushenabledvalue:no]; //create airship options dictionary , add required uiapplication launchoptions nsmutabledictionary *takeoffoptions = [nsmutabledictionary dictionary]; [takeoffoptions setvalue:launchoptions forkey:uairshiptakeoffoptionslaunchoptionskey]; // call takeoff (which creates uairship singleton), passing

node.js - how to execute custom javascript code in webdriverjs -

how execute custom javascript code in webdriverjs ( https://code.google.com/p/selenium/wiki/webdriverjs ) found execute method it`s purpose completly different. here go: var yourclientjsfunction = function (param1, param2) { // js code want run in browser } driver.executeasyncscript(yourclientjsfunction, param1, param2).then(function (res) { // deal response });

Java Bean Persistence with XMLEncoder -

i've written bean class containing hashmultimap (from guava library). xml encode bean using jre's xmlencoder. using custom persistencedelegate i've written bean file. however, when attempt deserialize xml exception: java.lang.nosuchmethodexception: <unbound>=hashmultimap.put("pz1", "pz2") what doing wrong? // create bean somebean sb = new somebean(); // add data hashmultimap<string, string> statemap = hashmultimap.create(); statemap.put("pz1", "pz2"); statemap.put("pz3", "pz4"); sb.setstatemap(statemap); // encode xml fileoutputstream os = new fileoutputstream("myxmlfile.xml"); xmlencoder encoder = new xmlencoder(os); encoder.setpersistencedelegate(hashmultimap.class, new custompersistencedelegate()); encoder.writeobject(sb); // decode xml fileinputstream = new fileinputstream("myxmlfile.xml"); xmldecoder decoder = new xmldecoder(is); object deserializedobject

jsf 2 - Reference a managedBean inside Controller bean -

i want pass reference of managedbean inside controller bean argument. domain entity brand. , want set properties of brand jsf page component. , want pass managedbean reference in controller method , controller addbrand method getbrandservice , save respective brand bean. please guide me. :) managed bean code: @managedbean @requestscoped public class brandbean implements serializable{ private static final long serialversionuid = 1l; private string brandname; private string branddecription; //getters , setters } and controller bean brand: // addbrand method takes brand instance parameter. brand model object. @managedbean @requestscoped public class brandcontroller extends abstractcontroller{ private ibrandservice brandservice; public ibrandservice getbrandservice() { brandservice = new brandservice(); return brandservice; } public void setbrandservice(ibrandservice brandservice) { this.brandservice = brandservice; }

xamarin.ios - Issues while using Stylecop addin for Monodevelop -

i trying use stylecop addin monodevelop - http://addins.monodevelop.com/project/index/54 . have custom policy file use in visual studio (its settings.stylecop file), , want use same in monodevelop (xamarin studio). put settings.stylecop file in solution directory, stylecop not seem use policies file. has used stylecop addin monodevelop (xamarin studio)? stylecop read policies in case? much! well, able working restarting xamarin studio, , putting settings.stylecop file solution. picks rules now.

Manually trigger receive event for jquery-ui sortable -

here's working demo of code far. when drag open space, empty group created. may going wrong way, item dragged new group populated list. there way call receive event jquery-ui sortables widget achieve this. alternately, should prepopulate group being added item un drop method of droppable item drop: function (event, ui){ $(element).append($(ui.helper).clone()); } or that? you can manually trigger sortable event using jquery's .trigger() event so: $('#sortable-name').trigger('sortreceive'); i think code looks bit strange, perhaps because have never seen use jquery ui in widget format. josh

c# - Excel: Dump cell attributes to array -

i know can dump values of excel cells array so: object[,] values = worksheet.usedrange.value2 object[,]; can similar attributes of cells other values? example, i'd cell colour, object[,] cc = worksheet.usedrange.interior.color object[,]; results in cc being null. looping through sheet cell attributes takes orders of magnitude longer. better late never. briefly, in absence of code stub, save sheet xml formatted file. read file in xml reader, query xml object styleid (or else want or need). query styleid's color attrbiute, , match same each cell. linq queries on xml database should need couple of lines this.

c# - Are SQL operator functions for Entity Framework safe against SQL injection? -

these functions give access specialty functions (sqlclient) in sql. example 'like' or 'between'. , give nicer common abstraction layer them. not confused stored procedure(s) "functions" topic of other question . my question can't seem find full answer is. safe use, or opening system sql injection attack ? use bound variables when writing regular sqlcommands. but in moving entity framework. there less control on sql statements. don't mind it, can't worrying when concatenate string coming browser , pass function. here example: var queryresult = efcontext.table.where(x => sqlfunctions.patindex("%" + potentially_unsafe_search_keyword + "%", x.column) > 0); i did tests , traced actual sql sent server. single quotes escaped out automatically. there protection there. there sanitization taking place. insert statements use bind variables. should content single quote replacement? there e

php - Multi row toJSON function using Propel and Backbone -

i'm trying make should simple "list all" function using propel orm - backbone.js read. want do, , in opinion, should work: $users = usersquery::create() ->find(); echo $users->tojson(); however, when i'm running that, results i'm getting are: {"users_0":{"id":1,"emailaddress":"sdf","password":"sdf","createdat":null,"modifiedat":null}, "users_1":{"id":2,"emailaddress":"dsf","password":"sdf","createdat":null,"modifiedat":null}} whilst it's valid json, fact ever row array in main array throwing off json. need return json this: [{"id":1,"emailaddress":"sdf","password":"sdf","createdat":null,"modifiedat":null},{"id":2,"emailaddress":"dsf","password":"sdf","createda

c# - Making a method asynch -

i have method calls bing api. ienumerable<webresult> search(string query) i want make asynchronous if make many calls it, each 1 of calls independant. so, following advice here changed signature async task<ienumerable<webresult>> searchasynch(string query) but warning this async method lacks 'await' operators , run synchronously... i want entire method asynch (at least that's how think should work). how do that? here's code public async task<ienumerable<webresult>> searchasynch(string query) { if (query == null) { throw new argumentnullexception("query cannot null"); } dataservicequery<webresult> webquery = _bingcontainer.web(query, null, null, null, null, null, null, null); ienumerable<webresult> webresults = webquery.execute(); return webresults; } the issue i'm not sure await in code.

android - Appropriate use BaseAdapter class specifically getView method -

so far have seen several examples of applications use baseadapter , arrayadapter<?> . still not clear reasons why should way. the first example extending arrayadapter<?> , example used in listview, following getview method @override public view getview(int position, view convertview, viewgroup parent) { view row = convertview; holder holder = null; // holder represents elements of view use // here initialized if(null == row) { row = layoutinflater.from(mcontext).inflate(layout_item_id, parent, false); holder = new holder(); holder.titletextview = (textview)row.findviewbyid(android.r.id.title); row.settag(holder); } else { holder = (holder) row.gettag(); } // here operations in holder variable example holder.titletextview.settext("title " + position); return row; } public static class holder { textview titl

css - dt (float left) and first dd (float right) on the same line -

i using definition list define sections of resume. i have each dt , first dd show on same line. dt should on left, , dd on right. remaining dds each dt show below dt. i need responsive, screen width decreases first dd goes next line. right now, can't seem floats clear @ right point. any ideas? here's code: http://jsfiddle.net/wgkzp/ html: <dl> <dt class="position">position name 1</dt> <dd class="side-time clearfix"> <time datetime="2010-08-01" class="start">august 2010</time><span class="end">present</span> </dd> <dd class="organization first">organization name</dd> <dd>location, usa</dd> <dd class="additional"> <ul> <li>described task 1</li> <li>described tesk 2</li> </ul> </dd> <dt class="position">position name 2</dt&

c# - How to preserve order in Gridview -

in program (asp.net, c#) using gridview show data. gets data following query. select * nametable nameid in (4,3,1,22,15,8,9,5,7) but problem gridview showing data in ascending sort order of nameid (1,3,4,5,7,8,9,15,22) . dont want data sorted, should show way mentioned in query (4,3,1,22,15,8,9,5,7) here code private void loadgridview() { query = "select * nametable nameid in (4,3,1,22,15,8,9,5,7)" dataset ds = sqlhelper.executedataset(commonsettings.constring, commandtype.text, query); gridview1.datasource = ds; gridview1.databind(); } that pretty difficult code you've provided. doesn't have gridview , it's how data returned sql. sql won't order results way. you'd have specify explicit case in order by this: query = "select * nametable nameid in (4,3,1,22,15,8,9,5,7) " + "order case nameid when 4 0 " + "when 3 1 " +

iis 7 - GoPro Camera Live Stream with IIS7 -

has here been able setup gopro camera stream through iis7 live smooth streaming service? would gopro camera ideal live streaming or guys have other suggestions better alternative. of course needs compatible iis. thank taking time read this.

php - $this->{$this->varname}() syntax -

this question has answer here: php curly brace syntax member variable 5 answers http://www.php.net/manual/en/functions.variable-functions.php#24931 that function $this->{$this->varname}() . tried out , confirmed that's valid syntax leaves me wondering... php.net discuss use of curly brackets in variable names that? variable variables : class properties may accessed using variable property names. ... curly braces may used, delimit property name. see examples on page, too.

javascript - expand / collapse floated divs on mouseover without falling to the next row -

i'm looking ideas on how resolve little problem have when expanding divs on mouseover. i have series of divs percentage width floated left. when move cursor on 1 div grow 3 times size, moving divs after right. right now, 4 divs fits on signgle row, problem when move mouse on last 2 elements of each row, fall next row since not fit anymore in current row. here's example of i've been working far: css: #mosaicwrapper{ width:70%; background:#ccc} .mosaic{ width:20%; background:#06c; height:150px; float:left; margin:20px 20px 0 0; color:white; text-align:center; font-size:74px; position:relative; cursor:pointer} code: var wrapper = $('#mosaicwrapper'); var mosaic = $('.mosaic'); var mosaicwidth = mosaic.outerwidth(true); var elesperrow= math.floor(wrapper.width()/mosaicwidth); var expandedwidth = (mosaicwidth*(elesperrow-1))-mosaic.margin('right'); var lastitems = []; var intialwidth = mosaic.width(); (var = elesperrow; < mosai

Delayed subtask in django-celery -

this code: add.apply_async((1, 2), countdown=5, link=delete.subtask()) how can add custom delay on delete subtask passing result of add task parameter? is possible syntax/format? ok, i've found solution add.apply_async((1, 2), countdown=2, link=delete.subtask((), countdown=10))

node.js - saving session variables within a callback -

i'm using express.io... in 1 of routed events, load stored 'vote' database, try set against request's session: app.io.route('ready', function(req){ if(req.session.username || req.session.twitter_user){ if(!req.session.username){ //makes username store in session. req.session.username = 't_' + req.session.twitter_user.screen_name; } winston.debug(req.session.username + ' connected'); //redders6600 connected. db.getvote(req.session.username, function(err, vote){ //gets votes user. if(!err){ req.session.vote = vote[0].vote; req.io.emit('user data', {username: req.session.username, vote: req.session.vote}); //on client, receive event, , correctly contains username , vote } }); } }); this works okay, but when try access session data routed event, req.session.vote undefined. req.session.username gets s

javascript - Node.js cluster child process path -

started exploring node.js , faced following problem let's i've got 3 files: start.js, core/core.js , core/child.js start.js requires core.js in code core.js creates child process (core/child.js) using cluster these settings cluster.setupmaster({ exec: './core/child.js' }); core.js , child.js in same folder, error (not found) if use exec: './child.js' didn't find similar in documentation, however require('./child.js') works perfectly. have no problem if path bit longer, trying understand why can't use path local core.js require() works relative location of current code file, other operations in node.js (including launching other processes) relative current working directory process.cwd() . if need generate path relative current file, can use __dirname variable available in every module @ runtime. var childpath = require('path').join(__dirname, 'child.js');

r - Rolling joins: roll forwards and backwards -

data.table awesome, because can rolling joins, , rolling joins within groups ! library(data.table) set.seed(42) metrics <- data.frame( id=c(rep(1, 10), rep(2,5), rep(3,5)), time=c(1:10, 4:8, 8:12), val1=runif(20), val2=runif(20), val3=runif(20), val4=runif(20) ) metrics <- data.table(metrics[sample(1:nrow(metrics), 15),], key=c('id', 'time')) calendar <- data.table(expand.grid(id=1:3, time=1:12), key=c('id', 'time')) metrics[calendar,roll=true] however, isn't awesome enough me. data.table still has nas: > metrics[calendar,roll=true] id time val1 val2 val3 val4 1: 1 1 0.9148060 0.9040314 0.3795592 0.675607275 2: 1 2 0.9370754 0.1387102 0.4357716 0.982817198 3: 1 3 0.9370754 0.1387102 0.4357716 0.982817198 4: 1 4 0.8304476 0.9466682 0.9735399 0.566488424 5: 1 5 0.8304476 0.9466682 0.9735399 0.566488424 6: 1 6 0.5190959 0.5142118 0.9575766 0.189473935 7: 1

python - flask with wtforms how to improve my code with either pluggable views or decorators or other? -

i'm newbie programmer using flask wtforms on gae take in data via forms , list data. working of views use similar methods of form creation, posting, , listing. wanted way simplify mess , reduce amount of code used. i've seen 3 potential options: pluggable views flask just simple flask decorator somehow possibly method views? (see 1). currently have few of these /new/post /new/home etc.. relevant snipets of code below: views: @app.route('/new/post', methods = ['get', 'post']) @login_required def new_post(): form = postform() if form.validate_on_submit(): post = post(title = form.title.data, content = form.content.data, hometest = form.hometest.data, author = users.get_current_user()) post.put() flash('post saved on database.') return redirect(url_for('list_posts')) form.hometest.choices = [ (h.key.id(),h.homename)for h

Native Java API for Checking Valid XML -

how determine whether document object in java contains valid xml. checked when object constructed? i can't appear find information on in http://docs.oracle.com/javase/1.5.0/docs/api/org/w3c/dom/document.html how determine whether have valid xml document without using external libraries? note: received document object parsing input stream dom xml parser. use java dom api. can handle valid xml document. valid document give no exception. need no external libraries dom. in case of error exception message looks this: [fatal error] myxmlfile.xml:6:2: end-tag element type "lastname" must end '>' delimiter. end-tag element type "lastname" must end '>' delimiter. build successful (total time: 0 seconds)

ajax - jQuery .append(html) command appending incorrectly -

Image
i using jquery/ajax call append partial view table. when page loads, partial view created correctly. however, once use attempts append item table, formatting incorrect despite exact same partial view being used. here table. when loads, items loaded onto page correctly picture below illustrates: <table id="fixedrows"> <thead> <tr> <th>state code</th> <th>agent id</th> <th></th> <th></th> </tr> </thead> <tbody> @foreach (var item in model.banklistagentid) { if (!string.isnullorwhitespace(item.agentid) && item.fixedorvariable.equals("f")) { @html.editorfor(model => item, "fixedpartialview") } } </tbody> </table> <br /> <a href="#" class="addfixed">

How to convert NSString to NSArray with characters one by one in Objective-C -

this question has answer here: is there simple way split nsstring array of characters? 3 answers i'd convert nsstring(ex. @"hello") nsarray(ex. [@"h", @"e", @"l", @"l", @"o", nil]) . first, tried use componentsseparatedbystring . needs indicate separator, not. how can that? here code: @interface nsstring (converttoarray) -(nsarray *)converttoarray; @end @implementation nsstring (converttoarray) -(nsarray *)converttoarray { nsmutablearray *arr = [[nsmutablearray alloc]init]; (int i=0; < self.length; i++) { nsstring *tmp_str = [self substringwithrange:nsmakerange(i, 1)]; [arr addobject:[tmp_str stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]]; } return arr; } @end : - (void)foo { nsstring *exstring = @"hello"; nsarr

multithreading - How does the recursive(reentrant) mutex works? -

i read 2 articles @ http://preshing.com/20120305/implementing-a-recursive-mutex http://en.wikipedia.org/wiki/reentrant_mutex on recursive(reentrant) mutex, neither article made sense. could explain how recursive(reentrant) mutex works ? (i found little material explaining how recursive mutex works. if has link explanation, close question.) thanks ! one simple way pair standard mutex following auxiliary information: a pointer thread owns mutex (or null if it's not acquired), and a counter, 0. you can acquire mutex in following way: if current mutex owner, increment counter , return immediately. if not, acquire mutex , set counter 0. in other words, if own mutex already, increment counter indicating own more. if not, acquire mutex usual. you can release mutex in following way: if counter nonzero, decrement counter , return immediately. otherwise, release mutex. in order work, need able read counter , mutex owner in thread-safe way. can

html - How do I get an element to fill the remaining vertical area of its containing div? -

Image
i want "go!" button fill remaining vertical area within each section. section defined area blue text light grey border @ bottom of each section. right now, hangs out in top right corner. as can see, each section variable in size, can't use "static" solution. furthermore, in future, may dynamically changing content within each section, cause further reflows. i using twitter bootstrap , dart, code below dart html use rendering of each section. <!doctype html> <html> <head> <title>x-search-result</title> <link rel="components" href="packages/widget/components/collapse.html"> </head> <body> <element name="x-search-result" constructor="searchresultcomponent" extends="div"> <template> <div class="row-fluid" style="border-bottom: 1px solid #eee;"> <span class="span10&quo

r - Get a list of all function parameters from inside the function -

is there way all function parameters within function? match.call() doesn't return parameters defaults set not overridden. example: xf <- function (a, b="hi", c=true) { print(as.list(match.call(expand.dots=false))) } >xf(3) [[1]] xf $a [1] 3 i writing package function calls existing function, want able set defaults not on existing function. (i planning on using list match.call , passing other function do.call , returning result. update: interesting issue relates s3 methods. created new s3 method, , used @ferdinand.kraft's answer. as.list(environment(), all.names=true) all.names argument keeps names starting . in list. turns out the method dispatch adds several arguments function environment, including .generic .class .method , several others. cause problems if pass these on function in do.call . 1 of other answers may better around solution, simplicity of as.list(environment()) . you can return environment @ beginning of function

nhibernate - HBM mapping image/binary -

i having trouble mapping our byte[] field. i've been looking several solutions none work far. exception: the length of byte[] value exceeds length configured in mapping/parameter. below i've got far in hbm.xml <property name="data" type="binaryblob"> <column name="attachmentdata" sql-type="varbinary(max)"/> </property> am doing not right here? update - solution: it turned out have done incorrectly. inserting byte[] via stored procedure property mapping has nothing it. instead, need tell nhibernate type of sprocs parameter so: query.setparameter(param.key, param.value, nhibernateutil.binaryblob); nhibernate doesn't understand varbinary(max) , use default of 8000 bytes. therefore need supply number. i.e. varbinary(2147483647) i think used work regression bug.

android - java dx utility: UNEXPECTED TOP-LEVEL ERROR java.lang.ExceptionInInitializerError -

i'm trying convert normal java application library use on android. library dates java 1.1 , has been maintained, improved, etc, time, , in service on other platforms it's unlikely source code involved. normally, due details of deployment, library not encapsulated in jar, merely kept in tree classpath magic. however, purposes of putting on android, jar created. went fine - no warnings or errors. as there new development - , therefore debugging - step of processing through proguard skipped - time come later. the error comes in next step, running dx convert use android. processing proceeds without error until fatal 1 described here. (there's 1 minor warning.) the error splash: unexpected top-level error: java.lang.exceptionininitializererror @ java.io.bytearrayoutputstream.expand(bytearrayoutputstream.java:91) @ java.io.bytearrayoutputstream.write(bytearrayoutputstream.java:201) @ com.android.dx.cf.direct.classpathopener.processarchive(cla

How to write to file in C -

i have program working on start , stop servo. can issue following command command line , works. echo 2=120 > /dev/servoblaster start servo in motion. have following program #include <stdio.h> #include <stdlib.h> int main(void) { file *fp; fp = fopen("/dev/servoblaster", "w"); if (fp == null) { printf("error opening file\n"); exit(0); } fprintf(fp, "2=120"); fclose(fp); fflush(fp); return 0; } but when execute nothing happens, when try echo 2=120 > /dev/servoblaster command bad input: 2=1202=120 if repeat same echo 2=120 > /dev/servoblaster command work again. if try , execute above program 3 times output when try execute echo command output bad input 2=1202=1202=120 2=120 me seems file not finished being written in program. can point out if missing something? you need add newline after command, echo does: fprintf(fp, "2=120\n"); presumably, servo&

jquery plugins - cufon.js conflict with fabric.js -

i using cufon.js render text. text not in fabric canvas exists on page. removing fabric.js allows text rendered ok, breaks when put fabric.js back. script render text is: <script type="text/javascript"> cufon.replace('#signature'); </script> how can fix this? updated: these script links have on page (fabric.js all.min.js version 1.1.0 found in dist folder) <script type="text/javascript" src="../scripts/cufon-yui.js" type="text/javascript"></script> <script type="text/javascript" src="../scripts/font.js" type="text/javascript"></script> <script type="text/javascript" src="../scripts/fabric.js" type="text/javascript"></script> you need render font replaces. this: $("#signature").change(function(e){ var object = canvas.getactiveobject(); if(object && object.type == "text"){

How to read a text file in reverse using python 2.2 -

this question has answer here: read file in reverse order using python 11 answers is there way read text file in reverse python 2.2? =) try following. # method not using `reverse` function def read_file_reversed(filename): return open(filename, 'r').readlines()[::-1] it reverses list using slicing. mindful these load entire file memory.

canvas - Mouse Highlighting Interfering with HTML5 Game -

so, having lot of fun html5 canvas gaming. 1 issue, however, if using dom elements in addition canvas elements, clicking , dragging on canvas highlight , "select" dom elements. subsequent click operation start "drag" dom elements around instead of registering canvas. it's extremely annoying, , cannot find way prevent it. there way make dom elements "not highlight-able" were? else having issue? addenda: game shooter, hold mouse click down keep shooting. health , points stored inside dom elements. render score/health canvas, faster dom element. in mousedown/click event handlers, add event.preventdefault() / return false. example window.addeventlistener('click', function(e) { e.preventdefault(); return false; }, false);

ruby on rails - Passenger No Such File To Load config/environment -

i trying make simple changes old app of mine (rails 3.0.0, ruby 1.8.7) last night , ran number of issues upon deploy. i'm using moonshine handle deploys. i can run cap deploy without error, following passenger error no such file load -- /srv/bbratboard/releases/20130409025824/config/environment i'm not sure if it's relevant, when ssh box, whole config folder under /srv/bbratboard/current/config empty. design or going wrong in deploy? a number of people have been able solve adjusting permissions on environment.rb file ( https://www.sit.auckland.ac.nz/ruby_on_rails_deployment ), i'm not able see on production server. i can provide details necessary, appreciated app in broken state. thanks much. you need files present within config directory. looks cap deploy output shows it deleting release's config directory: executing "chmod -r -- g+w /srv/bbratboard/releases/20130409032459 && rm -rf -- /srv/bbratboard/releases/201304

sml - filtering values into two lists -

so i'm new sml , trying understand ins/out out of it. tried creating filter takes 2 parameters: function (that returns boolean), , list of values run against function. filter returns list of values return true against function. code: fun filter f [] = [] | filter f (x::xs) = if (f x) x::(filter f xs) else (filter f xs); so works. i'm trying return tuple contains list of true values, , false. i'm stuck on conditional , can't see way. thoughts on how solve this? code: fun filter2 f [] = ([],[]) | filter2 f (x::xs) = if (f x) (x::(filter2 f xs), []) (* error *) else ([], x::(filter2 f xs)); (* error *) so show way it, , better way (imo). 'better way' future reference when learn: fun filter2 f [] = ([], []) | filter2 f (x::xs) = let fun ftuple f (x::xs) truelist falselist = if (f x) ftuple f xs (x::truelist) falselist else ftuple f xs truelist (x::falselist) | ftuple _ [

php - Saving console application output in an array directly -

how can further comparision or computation on output of console application. believe in ascii form. have called console application in php gives huge amount of numeric datas. want data saved on array , not in txt file process of reading , writing file takes time want directly save in array. used exec($command,$result) cannot result saved in proper form. output shown below: columns 1 through 7 0.1373 0.0414 0.0541 0.1342 0.5606 0.5293 0.1652 columns 8 through 14 0.0341 0.0396 0.0633 0.0778 0.0289 0.0654 0.0752 columns 15 through 21 0.3055 0.4602 0.0631 0.0360 0.0188 0.0497 0.0228........... i dont want columns line saved in array , want each element in column saved in different index of array. eg array[1]=0.1373 , array [2]=0.414. my suggestion simple regular expression run on each line of output: if (preg_match_all('/\d+\.\d+/', $line, $matches)) { print_r($matches[0]); } if expression matc

java - Android PreferenceActivity selections to a file -

i have preferenceactivity have list of items , checkboxes. public class bevcat extends preferenceactivity { sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(this); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.bev_pref); } } here corresponding xml: <?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" > <preferencescreen android:key="button_voicemail_category_key" android:persistent="false" android:title="juice" > <checkboxpreference android:defaultvalue="false" android:key="applejuice" android:summary="" android:title="apple juice" /> <checkboxpreference android:defaultvalue="false" android:key=&

c++ - cout print hex instead of decimal -

has occurred simple std::cout might print value in hex format when supposed format decimal(like integer)? for example, have line : std::cout << "_agent [" << target << "] still among " << ((target->currworker)->getentities().size()) << " entities of worker[" << target->currworker << "]" << std::endl; which print : _agent [0x2c6d530] still among 0x1 entities of worker[0x2c520f0] note: 1-the said out put sometime decimal , times hex 2- behaviour smae if change ((target->currworker)->getentities().size()) (int)((target->currworker)->getentities().size()) any hints? thanks you have set std::cout print hex in prior in context of code forget reset. example: std::cout<<std::hex<<12; /*blah blah blah*/ std::cout<<12; //this print in hex form still so have following std::cout<<std::dec<<12; to print in d

c# - How do you get a DbEntityEntry EntityKey object with unknown name -

shouldn't able entitykey object using complex property method or property method dbentityentry. couldn't find examples msdn , presume possible in entity framework 5. not know name of entity key or entity using generic repository interface. if have dbentityentry object entitykey first finding wrapped objectcontext : var oc = ((iobjectcontextadapter)dbcontext).objectcontext; then can find entity key by oc.objectstatemanager.getobjectstateentry(dbentityentryobject.entity) .entitykey edit i created 2 extension methods close want: public static entitykey getentitykey<t>(this dbcontext context, t entity) t : class { var oc = ((iobjectcontextadapter)context).objectcontext; objectstateentry ose; if (null != entity && oc.objectstatemanager .trygetobjectstateentry(entity, out ose)) { return ose.entitykey; } return null; } public static entitykey getentitykey<t>( dbcontext c

luabind - My lua script load .so library, how can I write the host program with Lua 5.2? -

i searched , tried days. problem this: i wrote script load shared library locker.so , runs lua interpretor, can not write out correct host program. my lua script load_so.lua simple: locker = require("locker") print(type(locker)) k, v in pairs(locker) print(k, v) end my host program is: int main(int argc, const char *argv[]) { lua_state * l = lual_newstate(); lual_openlibs(l); if (lual_dofile(l, "load_so.lua") != 0) { fprintf(stderr, "lual_dofile error: %s\n", lua_tostring(l, -1)); lua_pop(l, 1); } lua_close(l); return 0; } when run host program, error print out: lual_dofile error: error loading module 'locker' file './locker.so': ./locker.so: undefined symbol: lua_pushstring and locker.c: static int elock_get(lua_state * l) {...} static int elock_set(lua_state * l) {...} static const struct lual_reg lockerlib[] = { {"get", elock_get}, {"set"

php - Changing array to display the_title Wordpress -

i have <?php $attr = array( 'title' => 'here title', 'alt' => 'here alt attribute' ); ?> div class="s-o-column"> <div class="s-o-thumb"><a href="<?php echo $termlink; ?>"><?php echo wp_get_attachment_image( $term->image_id, 'standard-options-thumb', false, $attr ); ?></a> <div class="s-o-title"><a href="<?php echo $termlink; ?>"><?php echo $term->name; ?></a></div> </div> </div> how change title , alt say; <?php the_title(); ?> instead of "here title" or "here alt attribute"? you should use get_the_title() instead of the_title() since get_the_title() returns title while the_title() echoes it. $attr = array( 'title' => get_the_title(), 'alt' => 'here alt attribute&

ios - Loading images from file to UICollectionView, using GCD -

when take picture, save image file in folder made in nsdocuments directory. (/documents/photos/....png) then load photos in photo's folder in collection view. since files big, decided use grand central dispatch perform grabbing image on background thread. when scroll , down uicollectionview can see images changing randomly before displaying correct image. assume whenever grab image set on main thread, don't know how deal this. - (uicollectionviewcell *)collectionview:(uicollectionview *)cv cellforitematindexpath:(nsindexpath *)indexpath { nsuinteger rownumber = [indexpath row]; //nsstring *imagepath = [self.photopatharray objectatindex:rownumber]; nsarray *directorycontent = [[nsfilemanager defaultmanager] contentsofdirectoryatpath:[[nshomedirectory() stringbyappendingpathcomponent:@"documents"] stringbyappendingpathcomponent:@"photos"] error:null]; nsstring *imagepath = [nshomedirectory() stringbyappendingformat:@"/docu

android - Determining if process has died? -

is there way determine whether process has died? have system service stores information on each client connects it. when process hosting client dies, clean cache. i've searched on google seems not possible :( one solution came across using binder's linktodeath, design not mesh current design. there alternative ? thanks the state of thread can determine using isalive() method thread, or use getstate() determine thread state more precisely. binder has method isbinderalive(), didn't use can't add uncovered in officical docs.

android - Whats the best way to do a loop for listview selections -

i have listview populated list of checkboxes..i want add button when press it sth each item user selected in listview..whats best way find check box checked?i know can use setoncheckedchangelistener how call if each checkbox in list?and if create array string , each time checkbox checked addes text array list can loop each selected item? here code pupulate list view @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_database_list); file path=new file(clubcp.sdcardpath); list<string> file_lists = main.directorypath(path); listview database_list=(listview)findviewbyid(r.id.database_list); arrayadapter<string> adapter = new arrayadapter<string>(this, r.layout.database_list_item,r.id.chk_database_list_item,file_lists); arrayadapter<string> adapter1 = new interactivearrayadapter(this,file_lists); database_list.setadapter(adapter1); }