Posts

Showing posts from May, 2010

java - Unable to set reference variable in recursive call -

Image
i using recursive method find node in binary tree using key. when find node, set reference variable(foundnode) , return. problem when read object value still null. can help. findgivennode(root, key, foundnode, parentstack); private boolean findgivennode(node node, int key, node foundnode, stack<node> parentstack) { if (node == null) { return false; } parentstack.add(node); if (node.getdata() == key) { foundnode = node; return true; } boolean leftreturn = findgivennode(node.getleftchild(), key, foundnode, parentstack); boolean rightreturn = findgivennode(node.getrightchild(), key, foundnode, parentstack); if (leftreturn || rightreturn) { return true; } else { parentstack.pop(); return false; } } java doesn't pass arguments reference, passed value. read more here let's clarify example. make key looking integer value 21 . situation @ beginning of function fol

c# - Implementing LoadMore pagination for a grouped ListView in Windows Phone 8.1? -

is possible apply listviewbase.loadmoreitemsasync method pagination in grouped listview (collectionviewsource). or maybe know way, please let me know. you can this: on listview add "loaded" event code: private void lvpictures_onloaded(object sender, routedeventargs e) { scrollviewer viewer = getscrollviewer(this.lvpictures); viewer.viewchanged += lvpictures_viewchanged; } public static scrollviewer getscrollviewer(dependencyobject depobj) { if (depobj scrollviewer) return depobj scrollviewer; (int = 0; < visualtreehelper.getchildrencount(depobj); i++) { var child = visualtreehelper.getchild(depobj, i); var result = getscrollviewer(child); if (result != null) return result; } return null; } and in viewchangeevent can specify when want load more items , this: private async void lvpictures_viewchanged(object sender, scrollviewerview

c# - Gmail sending email timing out -

i trying send email gmail code isn't working, gives connection time out error. if make port '587' gives error: the smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required. learn more at string email = // email string password = // password string smtp = // smtp.gmail.com int port = // 465 var = new mailaddress(email, ""); var = new mailaddress(message.destination); var client = new smtpclient() { host = smtp, port = port, enablessl = true, deliverymethod = smtpdeliverymethod.network, usedefaultcredentials = false, credentials = new networkcredential(email, password) }; var mail = new mailmessage(from, to) { subject = subject, body = body, isbodyhtml = true }; return client.send

multithreading - Spring Batch: OutOfMemoryError swallowed -

as part of larger application, set spring batch job made chunk oriented tasklet: reader, processor , writer. job not run in main thread. occasionally tasklet code throws outofmemoryerror. so, set thread's uncaughtexceptionhandler able react such errors, terminating application. but outofmemoryerror never reaches thread's uncaughtexceptionhandler. outofmemoryerror "swallowed", abstractstep, if i'm not sure. repeattemplate has sure role. able inform repeatlisteners outofmemoryerror no listeners registered default, , seems not possible register of them through usual tag in taskled definition. anyhow, happens after outofmemoryerror, jvm keeps on running, because oome swallowed. not nice because not make explicit application has crashed. so, have advice on how can prevent spring batch swallow such kind of errors , have possibility handle them ? obviously we're working on fixing oome, think safe if jvm crashes in case of errors. i'm using spri

unity3d - UnityEngine.Social not working with IOS 8. Unsure how to resolve the issue -

when running our game on device uses game center error related authentication/connection game game center. works on ios 7 versions, not ios 8. we return authentication attempt, failed authenticate local user requested operation not completed because application not recognized game centre. has encountered issue/problem? unity related issue, or xcode and/or apple , game centre? built xcode v6.0.1, ios 8.

java - Consume web service providing updating JSON object -

i need school project, need connect web service providing json document updating every 3 or 4 second, consume , use of information contained. json looks this: { "firstname": "john", "lastname": "smith", "isalive": true, "age": 25, "height_cm": 167.6, "address": { "streetaddress": "21 2nd street", "city": "new york", "state": "ny", "postalcode": "10021-3100" }, "phonecalls": [ { "type": "home", "number": "212 555-1234", "duration": "32" }, { "type": "office", "number": "646 555-4567", "duration": "79" } ] } every x second json file updated random calls added document, need use informatio

angularjs - Is this an acceptable process in Angular-JS -

ng-model="$parent.$parent.$parent.something" is there better way write this? inside serval ng-repeats. unless have isolated scopes, should able reference something property directly. scopes inherit parent properties. ng-model="something" edit: there gotchas around this. take @ https://github.com/angular/angular.js/wiki/understanding-scopes

ios - Swift - Typealias dictionary with value that implements a generic protocol -

Image
i want typealias dictionary of string keys , values of objects/structs implements equatable protocol. wrote line of code gave me error didn't know how go on fix. typealias storage = [string: equatable] i want use type [string: equatable] variable in protocol, e.g: protocol storagemodel { var storage: storage { set } init(storage: storage) } error: protocol 'equatable' can used generic constraint because has self or associated type requirements can suggest solution? generally speaking, protocol tag isn't required, protocol names first-class type names , can used directly: typealias storage = [string:equatable] in case, error telling because equatable includes func == (lhs:self, rhs:self) -> bool , lhs:self , equatable can't used except constraint on generic: class generic<t:equatable> { ... } without more details you're trying achieve , how you're trying use storagemodel, best can come is: protocol m

php - Preg_replace pattern for BBCode quote tag -

i want use php preg_replace function on 2 strings unsure of regular expression use. for first string, require author value (so after author= , nothing after space): [quote author=username link=1150111054/0#7 date=1150151926] result: [quote=username] for second string, there no author= tag. username appears after closed open quote [quote] username link=1142890417/0#43 date=1156429613] ideally, result should be: [quote=username] make string author= , ] optional inorder replacement on both type of strings. regex: ^\[(\s+?)\]?\s+(?:author=)?(\s+).*$ if want mention string quote on regex use this, ^\[(quote)\]?\s+(?:author=)?(\s+).*$ replacement string: [$1=$2] demo <?php $string =<<<eot [quote author=username link=1150111054/0#7 date=1150151926] [quote] username link=1142890417/0#43 date=1156429613] eot; echo preg_replace("~^\[(\s+?)\]?\s+(?:author=)?(\s+).*$~m", "[$1=$2]", $string); ?> output: [quote

node.js - Simple REST HTTP-Proxy for xmpp -

we're working on xmpp server used android app , want use xmpp-ftw , node.js contact web server through http request. now our question: how handle specific requests react on request? https://github.com/xmpp-ftw/xmpp-ftw e.g. 127.0.0.1:3000/login { "jid": "test@evilprofessor.co.uk", "password": "password", "resource": "xmpp-ftw", "host": "127.0.0.1" } to login server. should simple wrapper. thank you the problem doing xmpp on http/rest need hold session open on server each request, or re-authenticate each request later being slow. we created on buddycloud project allowed former ( https://github.com/buddycloud/buddycloud-http-api ) allowed easy creation of apps using xmpp + http/rest. lose realtime aspect. you won't rest wrapper around xmpp-ftw http like. on authentication return cookie user, keep xmpp session open , use cookie session out of storage each

c# - Entities inheritance in OData -

i have poc service similar odata.org's demo service in thier demo have person base type , customer , employee derived types. i want query (or filtered) instances of derived type employee. since spec says "an entity can member of @ 1 entity set @ given point in time. entity sets provide entry points data model." entry point employees through persons entityset, far good. i'm can't find way filter @odata.type. i've tried many queries like: /persons?$filter=@odata.type eq odatademo.employee /persons?$filter=odata.type eq odatademo.employee /persons?$filter=type eq odatademo.employee ... (the root is: http://services.odata.org/v4/odata/(s(eq1ncar1ktn55khwjrukic3c))/odata.svc/persons ) but nothing returned 200 ok status code. try following uri: http://services.odata.org/v4/odata/(s(eq1ncar1ktn55khwjrukic3c))/odata.svc/persons/odatademo.employee the related spec: addressing derived types

Core Data and User Defaults in Swift -

i'm pretty new programming , i'm working on first app app store. have data model working in core data, want have singleton user settings , reference current project. i'm having trouble getting singleton work in core data. i've gotten kinda work user defaults seems clunky use core data , user defaults. else way? ps. there general references use of predicates in swift? haven't found one.

php - symfony2: unable to persist entity and insert into database -

i'm new symfony2, please me solve it. have entity report , entity organization. report mapping looks like: <entity name="acme\reportsbundle\entity\report" table="reports_report"> <lifecycle-callbacks> <lifecycle-callback type="prepersist" method="setcreatedat"/> <lifecycle-callback type="prepersist" method="setupdatedat"/> </lifecycle-callbacks> <many-to-one field="organization" target-entity="acme\organizationbundle\entity\organization" inversed-by="reports"> <join-column name="organization_id" referenced-column-name="id" /> </many-to-one> <many-to-one field="year" target-entity="acme\reportsbundle\entity\year" inversed-by="reports"> <join-column name="year_id" referenced-column-name="id" /> &

Celery: linked task throws connection error -

i tried run simple task linked task mentioned in tutorial add.apply_async((2, 2), link=add.s(16)) and got exception in worker process: [2014-09-21 19:56:38,531: warning/worker-1] c:\python33\lib\site-packages\celery-3.1.15- py3.3.egg\celery\app\trace.py:364: runtimewarning: exception raised outside body: oserror(connectionrefusederror(10061, 'no connection made because target machine actively refused it', none, 10061),): traceback (most recent call last): file "c:\python33\lib\site-packages\kombu-3.0.23-py3.3.egg\kombu\utils\__init__.py", line 420, in __call__ return self.__value__ attributeerror: 'channelpromise' object has no attribute '__value__' during handling of above exception, exception occurred: traceback (most recent call last): file "c:\python33\lib\site-packages\kombu-3.0.23-py3.3.egg\kombu\connection.py", line 436, in _ensured return fun(*args, **kwargs) file "c:\python33\lib\site-packages\kombu-3.

Get month from data stored as string in sqlite android -

i'm getting date user , storing sting in database. example date in database looks "22/09/2014". want month(september) date. how can that? my code is public arraylist<string> getmonths(){ string select_mon = "select strftime('%m'," + diary_dbhandler.personal_date + ") " + diary_dbhandler.table_personal + ";"; cursor c = database.rawquery(select_mon, null); c.movetofirst(); arraylist<string> mon=new arraylist<string>(); if (c != null) { while(!c.isafterlast()) { system.out.println(mon); mon.add(c.getstring(0)); c.movetonext(); } c.close(); } return mon; } you can date object simpledateformat . pattern string ("22/09/2014") dd/mm/yyyy date date = new simpledateformat("dd/mm/yyyy", locale.english).parse(string); from date can build calendar object calendar cal = calendar.getinstan

python - How to do JSON handler in Django -

i want , parse json in django view. requst in template: var values = {}; $("input[name^='param']").each(function() { values[$(this).attr("name")] = $(this).val(); }); $.ajax ({ type: "post", url: page, contenttype: 'application/json; charset=utf-8', async: false, processdata: false, data: $.tojson(values), success: function (resp) { console.log(resp); } }); in view: import json ... req = json.loads(request.body) return httpresponse(req) it give me error: the json object must str, not 'bytes' what wrong? most web framework consider string representation utf-8, bytes in python 3 (like django, , pyramid). in python3 needs decode('utf-8') body in: req = json.loads( request.body.decode('utf-8') )

osx - `pg_tblspc` missing after installation of latest version of OS X (Yosemite or El Capitan) -

i use postgres homebrew in os x, when reboot system, postgres doesn't start after reboot, , manually tried start postgres -d /usr/local/var/postgres , error occurred following message: fatal: not open directory "pg_tblspc": no such file or directory . the last time occurred, couldn't original state, decided uninstall whole postgres system , re-installed , created users, tables, datasets, etc... disgusting, occurs on system, once in few months. so why lose pg_tblspc file frequently? , there can avoid loss of file? i haven't upgraded homebrew , postgres latest version (i.e. i've been using same version). also, things did on postgres database delete table , populate new data every day. haven't changed user, password, etc... edit (mbannert): felt need add this, since thread top hit on google issue , many symptom different. homebrewers encounter error message: no such file or directory server running locally , accepting connections on unix doma

hadoop - ParseException in Hive query -

i running below hive query (mapr version 0.12): select a.id, a.amt1, a.amt2 ( select id id, net_amount amt1 test_table date_by >='2012-10-01' , date_by <='2012-10-31') q join ( select id id, net_amount amt2 test_table date_by >='2013-10-01' , date_by <='2013-10-31') r on q.id=r.id ) but getting error: error : failed: parseexception line 2:2 cannot recognize input near '(' 'select' 'id' in subquery source there seems issue query, think should this: select q.id,q.amt1,q.amt2 (select id id, net_amount amt1 test_table date_by >='2012-10-01' , date_by <='2012-10-31') q join (select id id ,net_amount amt2 test_table date_by >='2013-10-01' , date_by <='2013-10-31') r on (q.id=r.id ) but comparing dates, , @antariksha ponited out need cast it. prefer better option, compare date in timestamp format. in case query : select q.id

Mongodb get information to make some stats -

i need information mongodb database, cant realize request actual skill... can me making ? i have : - sum of object attribute {isdone : true} - filter 2 dates - group month concerned thanks advance all need aggregation framework . db.coll_name.aggregate([ {$match: {date_field: {$gt: new date("...")}, date_field: {$lt: new date("...")}}, // date range {$project: {isdone: "$isdone", year: {$year: "$year"}, month: {$month: "$month"}}}, // extract year/month , isdone {$group: {_id: {year: "$year", month: "$month"}, count: {$sum: 1}} ]);

crop - Is there any possibility to retrieve square size images from Wikipedia? -

is there possibility retrieve square size images wikipedia instead of proportional ones, there method out there crop images on fly? example http://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/johann_sebastian_bach.jpg/81px-johann_sebastian_bach.jpg will retrieve 81x100 size image, possible have 100x100 pixel one? no, there not. thumbnails support (down)scaling , conversion png format, generate fast , small previews. not supposed advanced , arbitrary image manipulation operations. if want square images, crop them on fly after downloading.

c++ - Qt4 qwidget after shown event -

i need handle event fired after widget visible after show event. cannot find event in qt4. tried solutions suggested below. none of them worked. my aim: working on embedded system , using qt ui. trying show hardware accelerated camera on ui after customwidget shown. if use showevent, camera shown before customwidget drawn. seems showevent fired before widget drawn. behaves before show event. failure-1 bool customwidget::event(qevent *event) { bool returnvalue = qwidget::event(event); if (event->type() == qevent::polish) { this->camera->show(); } return returnvalue; } polish event called once. when hide , show widget again , again, never fired. failure-2 void customwidget::showevent(qshowevent *event) { qwidget::showevent(event); qtimer::singleshot(0, this, slot(dialogexec)); } void customwidget::dialogexec() { this->camera->show(); } this did not work either. failure-3 void customwidget::paintevent( qpaintevent *ev

xslt - Looking up XML attributes with wildcard values, using XSL -

the task of little piece of xsl go through optionref tags in xml file , print id , displayname attributes optionref tags. id´s looked-up in options section find displayname. and now, problem: of optionref id attributes use wildcards (*) part of values. these id´s cannot looked-up regards displayname, unless first resolved real id´s found in options section. there way extend xsl kind of "globbing"? i print id´s , displaynames of id´s matching wildcard. instance "a01*" match both "a0101" , "a0102" in options section, these id´s , display names should printed. this sample of xml: <?xml version="1.0" encoding="utf-8"?> <optionlist xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <group> <optionref id="a0102"/> <optionref id="a03"/> <optionref id="a04"/> <optionref id=&quo

html - Bootstrap: Responsive not working on phone altough viewport included -

my bootstrap pages designed responsively. viewport stated required: `<meta name="viewport" content="width=device-width, initial-scale=1.0" />` (without backticks) in browsers tested (safari, chrome, firefox), responsivity works well. however, iphones , other smarthphones show desktop view. what doing wrong? test page see (sorry it's still little cluttered): http://zhaw.warnez-services.ch/nakt/stackoverflow.php (link updated) interestingly, using cloaking service, send own head , suppress viewport instructions. thank hints. viewport tag not yet added. add <meta name="viewport" content="width=device-width, initial-scale=1.0" /> inside <head></head> of html/php.

android - ImageView diffrent scale types for orientation -

i use imageview has display after following rules: always show full width landscape , portrait images -this works now if image landscape image center in screen - works if image portrait show top - don't cut top - not work from xml file <imageview android:id="@+id/myimage" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:contentdescription="@null" android:scaletype="centercrop" /> can set properties image show correct if portrait or landscape image? you may subclass imageview , use matrix scaling , override setframe method. depending on image size - whether has portrait or landscape orientation - apply different matrix. please find example implementation here aligns image bottom edge , crops off top. similar requ

javascript - Bootstrap ignore style modifications -

i'm developing simple webpage using twitter bootstrap. at sidebar have 3 buttons. each of buttons calls function show 1 div , hide others. the html code like: <div> <div class="row" id="general" style="display:none"> text1 </div> <div class="row" id="medication" style="display:none"> text2 </div> <div class="row" id="diet" style="display:none"> text3 </div> </div> and 1 of js functions hide/show divs: function showgeneral(){ document.getelementbyid('general').style.display = 'block'; document.getelementbyid('medication').style.display = 'none'; document.getelementbyid('diet').style.display = 'none'; } i update code @chaoticnadirs answer still not work. here code @ bootply the problem function works once finish divs became hi

run jar in php without shell_exec() and exec() -

i have code <?php if (isset($_get['_escaped_fragment_'])) { $url = ' http://'.$_server['server_name'].'/'.escapeshellarg($_get['_escaped_fragment_']); $result = shell_exec('java -jar htmlunit.jar'.$url); echo $result; } ?> when try run it, see error warning: shell_exec() has been disabled security reasons with exec() same warning: exec() has been disabled security reasons my hosting can't change php.ini me. how can ran jar?

java - What is the difference between having a Circle object to a CircleMapObject or CircleShape in Libgdx? -

i don't know if silly question or not because there different types of circle objects in can have, studying libgdx api i've found circlemapobject has more functions relating object such color, visibility etc circle , circleshape objects. question reason declare shape 1 of these type of objects on other? there performance constraints on program depending on type of circle object create or have same effect in terms of performance , it's down personal preference? circlemapobject intended used maps api. holds circle, , few additional properties defined parent class mapobject. circleshape use box2d. circle light weight , general, if don't need map or box2d, that's 1 want.

android - Launch new Hangouts Dialer from an Intent -

with release of new hangouts app (2.3) , hangouts dialer, wondering if knew how trigger dialer intent. when use standard intent.action_call or intent.action_dial don't new hangouts dialer in list. is there different intent type or uri has found allow me start call app on new hangouts dialer directly? thanks in advance. tried hangouts v2.5.8xxxx intent.action_dial intent filter hangouts.

racket - Scheme Beginning Student, Function Body Extra Part -

i attempted follow solution provided in this question , didn't work. essentially, function works so: (define (item-price size normal-addons premium-addons discount) (define price 0) (+ price (* normal-addon-cost normal-addons) (* premium-addon-cost premium-addons) size) (cond .. conditions here [else price])) however, met following error: define: expected 1 expression function body, found 2 parts now, i've tried wrapping body of function in 'begin', when run claims 'begin' not defined. using beginner student language version oppose straight-up racket. insight on workaround? the problem remains same: in language that's being used, can't write more 1 expression inside function body, can't use begin pack more 1 expression, , both let , lambda (which have allowed create local bindings) forbidden. that's lot of restrictions, can around using helper function calculates price each time: (define normal-addon-cost

php - .htaccess preventing subdirectory access -

i have drupal site , needed second site coded purely in html/css/js up. created folder second site , subdomain point it. however, .htaccess file causing 403 forbidden error while trying access subdomain. if delete or rename file .htaccess.old, subsite work drupal site won't. mean, home page loads, links redirect 404 not found. i know nothing .htaccess , not sure how troubleshoot. here's file: # # apache/php/drupal settings: # # protect files , directories prying eyes. # don't show directory listings urls map directory. options -indexes # follow symbolic links in directory. options +followsymlinks # make drupal handle 404 errors. errordocument 404 /index.php # force simple error message requests non-existent favicon.ico. <files favicon.ico> # there no end quote below, compatibility apache 1.3. errordocument 404 "the requested file favicon.ico not found. </files> # set default handler. directoryindex index.php # override php settings. mo

specifying multiple random effects in R lmer (translating from HLM model) -

i'm attempting "translate" model run in hlm7 software r lmer syntax. this now-ubiquitous "math achievement" dataset. outcome math achievement score, , in dataset there various student-level predictors (such minority status, ses, , whether or not student female) , various school level predictors (such catholic vs. public). the predictors in model want fit student-level predictors, have been group-mean centered deal dummy variables (aside: contrast codes better). students nested in schools, should (i think) have random effects specified of components of model. here hlm model: level-1 model (note: predictors @ level 1 group mean centered) mathachij = β0j + β1j*(minorityij) + β2j*(femaleij) + β3j*(sesij) + rij level-2 models β0j = γ00 + u0j β1j = γ10 + u1j β2j = γ20 + u2j β3j = γ30 + u3j mixed model mathachij = γ00 + γ10*minorityij + γ20*femaleij + γ30*sesij + u0j + u1j*minorityij + u2j*femaleij + u3j*sesij + rij translating lmer sy

php - Laravel Eloquent Join vs Inner Join? -

so having trouble figuring out how feed style mysql call, , don't know if eloquent issue or mysql issue. sure possible in both , in need of help. so have user , go feed page, on page shows stuff friends (friends votes, friends comments, friends status updates). have tom, tim , taylor friends , need of votes, comments, status updates. how go this? have list of friends id number, , have tables each of events (votes, comments, status updates) have id stored in link user. how can of information @ once can display in feed in form of. tim commented "cool" taylor said "woot first status update~!" taylor voted on "best competition ever" edit @damiani after doing model changes have code this, , return correct rows $friends_votes = $user->friends()->join('votes', 'votes.userid', '=', 'friend.friendid')->orderby('created_at', 'desc')->get(['votes.*']); $friends_comments = $user-&g

c# - Get list of email and select top email with desired title/subject and click it -

i trying automated password recovery onto test script. trying email malinator.com, , looks like. <li class="row-fluid message ng-scope" ng-repeat="email in emails"> <a style="cursor: pointer;" onclick="showmail('1411426607-6188591-xapncvfk501')"> <div class="from ng-binding" style="width:223px;float:left;"> mentor support </div> <div class="subject ng-binding" style="width:473px;float: left;"> recovered password </div> <div class="time ng-binding" style="text-align: right;float:left;width:144px;padding: 0 5px 0 5px;margin:0;"> 16 minutes ago </div> </a> </li> <li class="row-fluid message ng-scope" ng-repeat="email in emails"> <a style="cursor: pointer;" onclick="showmail('1411426524-6185292-xapncvfk501')"> <div class="from ng-binding" style=&q

c# - Bring window to front with Xamarin.Mac -

i have window uses filesystemwatcher pop when new file created. how can display / become foreground window? makekeyandorderfront doesn't make pop infront of other windows. to make window appear front, centered , focused have had success following: nsapplication app = nsapplication.sharedapplication; app.activateignoringotherapps(true); var win = new preferenceswindowcontroller().window; win.center(); win.makekeyandorderfront(this);

javafx 8 - how to chage media soures by using sceentap gesture? -

i want change media source , restart mediaplayer in javafx using leap motion gesture. how decribe screentap gesture case in leaplistener restart mediaplayer? hot change media source using swipe gesture? and there fix plz (i'm beginner in java & first time of programming) here code public class leaptest extends application{ private final leaplistener listener = new leaplistener(); private final controller leapcontroller = new controller(); private media media = new media("file:///c:/users/halim.shin/workspace/movie/flower.mp4"); private mediaplayer player = new mediaplayer(media); private mediaview view = new mediaview(player); @override public void start(stage stage) throws exception { leapcontroller.addlistener(listener); borderpane root = new borderpane(); int key_move_delta = 10; double size_delta = 1.05; root.setcenter(view); scene scene = new scene(root,500,500,color.black); scene.getstylesheets().add(getclas

regex - How to have a good output in bash when printing? -

i have command here, , have problem achieving format. in lines, date*2014*09*23 val*0001*abc n3*sample val*0002*xyz my desired output here this: ["abc", "xyc"] i tried code: perl -nle 'print $& if /val\*[0-9]*\*\k.*/' file | awk '{ printf "\"%s\",", $0 }' resulting only: "abc","xyz", another thing when printing 1 value. if happens file this: date*2014*09*23 val*0001*abc n3*sample my desired output (ignoring output of having []): "abc" you can awk: #!/usr/bin/awk -f begin {fs="*"; i=0; ors=""} $1=="val" {a[i++]=$3} end { if (i>1) { print "[\"" a[0] (j = 1; j < i; j++) print "\",\"" a[j] print "\"]" } if (i==1) print "\"" a[0] "\"" }

Correctly using collections in a meteor package? -

i trying create package uses collection. in normal application, same code works fine without issues. collectiontest.js (package code) // why need set global property manually? var globals = || window; testcol = new meteor.collection('test'); globals.testcol = testcol; console.log('defined'); if(meteor.isserver){ meteor.publish('test', function(){ return testcol.find(); }); meteor.startup(function(){ console.log('wtf'); testcol.remove({}); testcol.insert({test: 'a document'}); }); }; if(meteor.isclient){ meteor.subscribe('test'); }; test passes on client , server: tinytest.add('example', function (test) { console.log('here'); var doc = testcol.findone(); test.equal(doc.test, 'a document'); console.log(doc); }); but if open developer tools on client , run: testcol.find().count() the result 0. why? also, why have have line globals.testcol = testcol; tests run

.net - Quickbooks API / tool to Integrate custom app with Quickbooks Desktop & Quickbooks Online -

we trying find quickbooks api integrate our custom app quickbooks desktop , quickbooks online without having write them both separately. seems best approach write quickbooks online services, desktop data sync'd using quickbooks sync manager, , allows access customers using qbo. is there sync both qbd , qbo? our app written in .net using c# we trying find quickbooks api integrate our custom app quickbooks desktop , quickbooks online without having write them both separately. there isn't one. where desktop data sync'd using quickbooks sync manager, sync manager deprecated - relevant blog post . is there sync both qbd , qbo no. realistically, data models between qbo , qbd similar. still have customers, , invoices, , invoice lines, , items, , etc. so, you're not looking @ 100% code duplication here - data format/protocol you're submitting stuff quickbooks different. so you're looking @ upwards of 60%+ code re-use though ha

ios - Resizing UITextView in custom UITableViewCell -

Image
i have custom uitableviewcell , i'm trying resize uitextview inside based on content size. i'm on ios7 , using autolayout. i've tried using following: [cell.question setscrollenabled:yes]; [cell.question sizetofit]; [cell.question setscrollenabled:no]; and - (cgrect)textviewheightforattributedtext: (nsattributedstring*)text andwidth: (cgfloat)width { uitextview *calculationview = [[uitextview alloc] init]; [calculationview setattributedtext:text]; cgsize size = [calculationview sizethatfits:cgsizemake(width, flt_max)]; cgrect finalframe = cgrectmake(0, 0, width, size.height); return finalframe; } from different posts. i'm able resize frame. issue i'm not able see change visibly. in sense, when log it, can see change. uitextview doesnt resize. cant find autolayout dependencies either. when disabled autolayout, seems work. how do this, enabling autolayout? thanks. edit here's uitextview constraints you have

asp.net mvc - MVC DropDownList with Enum Text & Value -

i want set values of dropdownlist 1, 2, 3, 4 , etc. & text january, february, etc. following code:- public enum inputmonths { january = 1, february = 2, march = 3, april = 4, may = 5, june = 6, july = 7, august = 8, september = 9, october = 10, november = 11, december = 12 } @html.dropdownlistfor(model => model.applymonth, enum.getnames(typeof(models.inputmonths)).select(e => new selectlistitem { text = e, value = e }), "-- select month --", new { @class = "form-control", @id = "applymonth" }) what should put in place of value = e values of dropdown list should show 1, 2, 3... currently dropdown values show january, february, march.

bash - Ux modify timestamp -

i'm trying write ux script change timestamp (add 10years). working on debian no idea how on solaris (-d , + 10 years not working) find directory -print | while read filename; touch -d "$(date -r "$filename") + 10 years" "$filename" done it adds ten years in terms of 10*365*24*3600 seconds, find directory -print|perl -mfile::stat -lne 'utime((stat($_)->mtime +10*365*24*3600) x2, $_)' in case file::stat not available, find directory -print|perl -lne 'utime(((stat($_))[9] +10*365*24*3600) x2, $_)'

objective c - View/API for rendering office documents doc,docx, ppt, pptx, xls, xlsx in cocoa application (Mac OSX) -

currently developing cocoa application viewing office documents inside our application. "intention behind load documents in-memory , within our app only". in ios application, able render such files using standard uiwebview class provided uikit framework. hence tried same approach webview class in mac osx application. however, doesn’t work me. sample code used render files below – nsurl *url = [nsurl urlwithstring: filepath]; nsstring *mimetype = “mime type of document”; nsdata *filedata = [nsdata datawithcontentsoffile: filepath]; [[webview.mainframe] loaddata: filedata mimetype: mimetype textencodingname: @”utf-16” baseurl: url]; it displays raw data on screen , not proper view. also tried approach - qlpreviewpanel . displays above formats, there no support passing nsdata input. provides options sharing , open document in third party apps. don't require these options , don't allow document open in third party apps. suggest me better approach this.

Getting list elements from Prolog in a C interface -

i try implement c interface using prolog script based on gnu prolog. problem single elements of nested prolog list. actually c code looks like ... int func; plterm arg[10]; plterm *sol_gb; plbool res; int nmb; char *strhead; char *strtail; pllong nummero; plterm pl_nummero; pl_start_prolog(argc, argv); pl_query_begin(pl_true); arg[0] = pl_mk_string(strrname); arg[1] = pl_mk_variable(); arg[2] = pl_mk_variable(); arg[3] = pl_mk_string("true"); res = pl_query_call(func, 4, arg); sol_gb = pl_rd_list(arg[2]); nmb = pl_list_length(sol_gb[0]); strhead = pl_write_to_string(sol_gb[0]); printf("strhead = %s\n",strhead); strtail = pl_write_to_string(sol_gb[1]); printf("strtail = %s\n",strtail); ... the prolog list returned in arg[2] looks like [ [ spezial bolognese, [2, ,zwiebeln,300,gramm,hackfleisch,10, ,tomaten, 100,ml,sahne,500,gramm,spaghetti] ], [ spaghetti bolognese, [2, ,zwiebeln gehackt,300,gramm,hackfleisch

c# - Cant Access Value of spinner contol WPF -

i have tried following access value spinner control. spinner part of microsoft service manager wpf controls dll giving me following routerdpropertychangedeventargs'1[system.decimal]. question how retrieve value self. i attached event in winforms following event handler indexedorderspincontrol.valuechanged += spinvaluechanged; private void spinvaluechanged(object sender, routedpropertychangedeventargs<decimal> e) { messagebox.show("this should value of spin control " + convert.tostring(e.newvalue)); } sorry should have explained trying use value in linq query retrieve description of column such private void spinvaluechanged(object sender, routedpropertychangedeventargs<decimal> e) { observablecollection<customcolumnsmodel> columnslist = this.wizarddata.concretecustomcolumnsproxy; var q = columnslist.where(a => a.columnindex == (double)e.newvalue).firstordefault()) ; }

VBA Excel - Macscript causing problems on windows when using IIF -

i'm creating macro opens file has on computer , in order must know person's username / work id. person's work id i've tried using following: sso = iif(instr(application.operatingsystem, "windows") = 1, environ("username"), _ 'macscript("(user name string)")) running on windows returns error because of macscript (i think) , i'd assume same happen vice versa, though error part of iif never accessed i'm guessing seeing whole line executed why there problem, on error resume next not here. i know can overcome using if , else statement want know if i'm right / why problem occurs , if there other more sophisticated ways of achieving want. thanks the iif function evaluates both true , false parts, or rather attempts so. there no short-circuit. assumption why it's failing (and can't use oern ) correct. may take @ conditional compilation logic, if parts of code not compile on windows (or mac, respective

Magento mini-cart not updating on product pages -

i having issue in magento mini cart . when go product page , click on add cart , mini cart not update , show product items on product page products added cart once go cart page. i creating local.xml file theme , having code here <block type="checkout/cart_sidebar" name="custom_mini_cart" template="checkout/cart/mini.phtml" before="-"> <action method="additemrender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action> <action method="additemrender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action> <action method="additemrender"><type>configurable</type><block>checkout/cart_item_renderer_confi

java - update text field using servlet -

i'm newbie in java , i'm trying update textfield using servlet.insert , delete done update not work.i'm working html , servlet. here servlet computercontroller.java protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8"); printwriter out = response.getwriter(); computerdao comdao = new computerdao(); //get service string service = request.getparameter("service"); if (service == null || service == "") { service = "listallcomputer"; } if (service.equals("addcomputer")) { //get parameter string name = request.getparameter("cname"); string quan = request.getparameter("quantity"); string price = request.getparameter("price"); string func = request.getparameter("functions");