Posts

Showing posts from July, 2011

android - Replace fragment in host activity from fragment -

i have container activity has framelayout storing fragment inside it. example have activity initial framgent login page. theare 2 buttons login , register. user can click register , in case need change current fragment fragment registration fields. have idea make host activity implement callback interface , pass activity fragment, , when user clicks register callback method called , host activity replacing fragment. question if there other better way this, maybe more correclty. please leave suggestions , how deal problem.thanks you can replace fragments follows , fragmenttransaction transaction = getfragmentmanager().begintransaction(); transaction.replace(<container id>, new registerfragment()); transaction.commit(); //if using support library, make sure use getsupportfragmentmanager()

javascript - Calling a RESTful web service using SSIS -

i need call restful web service using ssis. the web service accepts json object parameter - can call service constructing json object using javascript: data = { customerkey: "demo", apikey: " 9999aa99-999a-9a9a-99a9-99999999a999", registrationno: "reg n02", insuranceref: "ins ref", vehicletype: "lorry", carmake: "car make", carmodel: "car model", chassisno: "chassisno", grossplatedweight: "gp weight", manufactureyear: 1999, vehiclestatus: "hired", deliverydate: null, transferdate: new date(2004, 4, 1, 0, 0, 0).tomsdate(), lastmotdate: new date(2013, 12, 1, 0, 0, 0).tomsdate(), lastinspectiondate: new date(2013, 1, 11, 0, 0, 0).tomsdate(), lastservicedate: new date(2014, 2, 2, 0, 0, 0).tomsdate(), informationlog: "information log , more information", vehiclenotes: "vehicle notes", entit

java - boolean not holding value when method is executed -

i have method having problem with. second method below, promptforpinnumber(), calls first method, canconverttointeger(), , carries out action, dependent on whether value of boolean variable, pinvalid, true or false. when execute method canconverttointeger() on own, functions fine, , value of pinvalid correct. when execute promptforpinnumber(), , enter string throws , exception, value of pinvalid stays true, else section of if else block isn't executed, however, value of pintry 0, exception must have been caught , dealt with. why boolean pinvalid true when should false? what should happen if invalid entry made oudialog.request box, pinvalid should set false, should change value of pintry 0, , public boolean canconverttointeger() { string pinattempt; { pinattempt = oudialog.request("enter pin number"); try { this.pintry=integer.parseint(pinattempt); this.pinvalid = true; } cat

python 3.x - PyQt - Event Binding (calling a function when the QCloseEvent occurs) - Procedural Style -

i know how can done oop style, interested in understanding pyqt seeing how gui toolkit can programmed in both object orientated , procedural way. my question how can bind application closing event (click app cross) function in code below? how can called when application quit? import sys pyqt5.qtwidgets import (qwidget, qtooltip, qpushbutton, qapplication, qmessagebox) pyqt5.qtgui import qfont def closeevent(event): reply = qmessagebox.question(w, 'message', "are sure quit?", qmessagebox.yes | qmessagebox.no, qmessagebox.no) if reply == qmessagebox.yes: event.accept() else: event.ignore() app = qapplication(sys.argv) w = qwidget() w.setgeometry(300, 300, 300, 200) w.setwindowtitle('procedural event binding - pyqt') w.show() sys.exit(app.exec_()) thanks time. you overwrite existing closeevent of widget: w.closeevent = closeevent and work in example. if want bound method, can do: i

node.js - How to increase connection timeout for Mongolab while connecting from loopback mongodb driver -

i have hosted mongodb in mongolab. have created odm in loopback , made connection mongolab. connection gets established other times due bad connection gets timedout. want increase timeout connected everytime. did not find solution on strongloop site. i tried adding query string param in connection string mongolab: ?connecttimeoutms=1000000 did not help. use connectiontimeout setting in datasources.json file. { "yourmongodb": { "name": "yourmongodb", "connector": "mongodb", "connectiontimeout": 1000000 } }

c++ - How to use QProgressDialog along with QDomDocument save function -

to make long story short have program uses qdomdocument class create xml file , uses save() function save text stream object. its qdomdocument somedoc; //create xml file, elements, etc. qfile io(filename); qtextstream out(&io); doc.save(out,4); io.close(); i want able show progress of save using qprogressdialog class, i'm having hard time figuring out. there way can incrementally check see if file through processing , update progress? suggestions? thanks. firstly, thought can find answer in qt source code, not simple, found easier solution, use tostring() method , write usual file. example: qstringlist = doc.tostring(4).split('\n');//4 intent int numfiles = all.size(); qprogressdialog *progress = new qprogressdialog("copying files...", "abort copy", 0, numfiles, this); progress->setwindowmodality(qt::windowmodal); qfile file("path"); file.open(qiodevice::writeonly); progress->show(); qtextstream stream(&

unable to read struct from a binary file using C when file is not 100% filled as expected -

i have file try read contacts simple contactbook using structure. typedef struct contact{ char name[80]; char surname[80]; char cellnumber[20]; float length; int contactid; }contact; i use function , call reads 200 times ( const int maxcontact = 200; ). for(i2=0;i2<maxcontact;i2++) person[i2]=load(i2); this function given id (the variabile i ), returns contact has same i: contact load(int i){ struct contact person; file *data; data=fopen("data.bin","rb"); do{ fread(&person,sizeof(contact),1,data); }while(person.contactid!=i); fclose(data); return person; } the problem kind of code is, when there no 200 contacts, function not return contact because contact id can't found. i had solutions in mind rather complex , wanted know if done better. make installer creates files real installer , create 200 undeclared contacts variabiles equal null. check if program being ran first time

.htaccess - How do I rewrite /projects/* to /content/projects/* -

how rewrite /projects/* /content/projects/* i don't know how this. you can use rule: rewriterule ^(projects/.*)$ /content/$1 [l,nc]

ns 3 - Enabling ns-3 logging under Eclipse -

there link available on how configure eclipse waf run ndnsim programs. https://www.nsnam.org/wiki/howto_configure_eclipse_with_ns-3 however, did not understand how specify module names print info/debug/err/wrn logs. right now, not able see logs when run eclipse. an equivalent command command line program run command line below. ns_log=ndn.consumer:ndn.producer ./waf --run=ndn-grid-topo-plugin i tried export ns_log variable in eclipse's debug/run configuration settings, value "ndn.consumer:ndn.producer" did not work. can please tell how achieve same in eclipse?

javascript - AngularJS Not Loading on Other Paths -

i sure has been answered before, have no idea how phrase this, not able find on google. i writing website using node.js, express, , angular. angular app loads when visit home page 127.0.0.1:8080 . when click link review (say 127.0.0.1:8080/review/8ja9d8kkjnmd ), route next controller , next page in angular app. however, if manually enter url , press enter, node.js api serves me json serve angular app. so angular app takes json , renders view. how still load angular page manually entering url , not ping node api? i feel common problem, , again apologize because sure has been answered time , time again. this structure angular app public/js ├── app.js ├── approutes.js ├── controllers │   ├── mainctrl.js │   └── reviewctrl.js ├── views │   ├── index.html │   ├── home.html │   └── review.html └── services ├── mainservice.js └── reviewservice.js app.js is: // public/js/app.js angular.module('sampleapp', ['ngroute', 'approutes', 'main

c# - Different Kendo grid Datasource when grouping applied -

i have kendo grid, following decleration: @(html.kendo().grid<agencyautomation.domainlayer.viewmodels.invoicedetailviewmodel>() .name("invoicedetailgrid") .bindto((ienumerable<agencyautomation.domainlayer.viewmodels.invoicedetailviewmodel>)@viewbag.invoicedetails) .columns(columns => { // columns.bound(p => p.accountid).hidden(); columns.bound(p => p.stakeholderid).hidden(); columns.bound(p => p.commissiontypeid).hidden(); columns.bound(p => p.billdescription).hidden(); columns.bound(p => p.groupno).hidden().clientgroupheadertemplate("<span style='float:right'><button id='btngroupedit' onclick='showgroupedit(#=value#)' class='btn btn-primary round_blue'><i class='fa fa-edit'></i>&nbsp;edit</button>&l

r - Rolling means and applying means at beginning of a series of data -

i want rolling mean of the previous 4 values in dataset. however, beginning, since there not 4 values, want rolling mean of 1/2/3 observations. how do this? library(zoo) df= data.frame(a=c(1,2,3,4,5)) df$answer = rollapply(df$a, 4,mean) #help for example, row 1 have value of 1, row 2 have value of (1+2)/2=1.5, row 3 have value of 6/3=2. i want rolling means of 4 periods in periods fewer months, want mean of maximum periods allowed. use right aligment partial=true , i.e. rollapplyr(..., partial=true) or rollapply(..., align = "right", partial=true ). here use rollapplyr : rollapplyr(df$a, 4, mean, partial = true)

python - How to return "already exists" error in Flask-restless? -

i handler exception. i'm using combination of flask-restless , sqlalchemy in python. my problem: when send request api object exists in db, sqlalchemy shows exception: integrityerror: (integrityerror) column <column_name> not unique u'insert ... so have tried add attribute validation_exceptions create_api method: manager.create_api( ... , validation_exceptions=[integrityerror]) but response json contains: { "validation_errors": "could not determine specific validation errors" } and server api shows exception : traceback (most recent call last): file "c:\python27\lib\site-packages\flask_restless\views.py", line 797, in _extract_error_messages left, right = str(exception).rsplit(':', 1) valueerror: need more 1 value unpack exception validation in flask-restless doesn't work type of exception (integrityerror) what should do? possible create handler exception , return own error message in json?

Dynamically instantiate, add polymer elements dart -

trying dynamically add polymer elements on click event not able add element tried using initpolymer (resulting in stack error :element initialized) 4 files. item.html <polymer-element name="init-item" > <template> <input type="image" src="button_minus_red.gif" on-click="{{remove}}"> {{name}} </template> <script type="application/dart" src="item.dart"></script> </polymer-element> item.dart: import 'package:polymer/polymer.dart'; @customtag('init-item') class item extends polymerelement{ @observable string name='hello'; void remove(){ name=''; } playeritem.created(): super.created(){} } index.dart: import 'package:polymer/polymer.dart'; import 'item.dart' // getting unused warning item.dart main() async{.... //init moved main initpolymer().then((_) {}

java - get Nullpointerexception while insert records -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i trying insert data database using prepare statements nullpointerexception my database connection code public class dbconnect { connection conn=null; public static connection connecrdb(){ try{ class.forname("org.sqlite.jdbc"); connection conn = drivermanager.getconnection("jdbc:sqlite:e:\\netbeansprojects\\abdo`s project\\project.sqlite"); system.out.println("connection success"); conn.setautocommit(false); return conn; } catch(exception e){ joptionpane.showmessagedialog(null, e); return null; } } } and code in main class public class items extends javax.swing.jframe { connection conn =null; re

c# - How do I save a file to my Phone's Internal Storage or SD Card? -

due several bugs in frameworks, have resort manually copying , pasting apk file local machine phone when connected machine via usb. this extremely tedious , it's getting on nerves. thought create console app, watches file system changes file , when necessary, copy file machine directory on phone. i have full file access phone using file explorer in windows. it's android phone (htc 1 m8). , when browse root directory in file explorer, "file path" in address bar location of file explorer says: this pc\htc one_m8\internal storage or location: this pc\htc one_m8\sd card but when do: file.copy(source, "this pc\htc one_m8\internal storage\notes.apk", true); i following exception: could not find part of path 'this pc\htc one_m8\internal storage\notes.apk'. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internalcopy(string sourcefilename, string destfilename, boolean over

How to merge array of arrays by key in php? -

so questions of nature have been asked 1000 times on stack overflow, none of them i've searched through far address issue i'm having. have 2 arrays this: $cupcake_sales = [ ['date' => '05/09/1992', 'num_cupcakes_sold' => 30 ], ['date' => '05/11/1992', 'num_cupcakes_sold' => 25 ], ]; and array this: $cupcake_revenue = [ ['date' => '05/10/1992', 'revenue' => '$40'], ['date' => '05/11/1992', 'revenue' => '$100'], ]; what need array this: $cupcake_sales_revenue = [ ['date' => '05/09/1992', 'num_cupcakes_sold' => 30], ['date' => '05/10/1992', 'num_cupcakes_sold' => 25, 'revenue' => '$40'], ['date' => '05/11/1992', 'revenue' => '$100'], ]; any way of doing this? this should work you:

rust - How do I sum a vector using fold? -

this rust tutorial explains fold() mechanism well, , example code: let sum = (1..4).fold(0, |sum, x| sum + x); works expected. i'd run on vector, based on example, first wrote this: let sum: u32 = vec![1,2,3,4,5,6].iter().fold(0, |sum, val| sum += val); which throwed error: error: binary assignment operation `+=` cannot applied types `_` , `&u32` [e0368] let sum = ratings.values().fold(0, |sum, val| sum += val); ^~~~~~~~~~ i guessed might reference-related error reason, changed fold(0, |sum, &val| sum += val) , resulted with error: mismatched types: expected `u32`, found `()` hm, maybe something's wrong closure? using {sum += x; sum } , got binary assignment operation `+=` cannot applied types `_` , `&u32` again. after further trials , errors, adding mut sum worked: let sum = vec![1,2,3,4,5,6].iter().fold(0, |mut sum, &x| {sum += x; sum}); could explain reason why fold() vector

html - Hide first x characters -

is possible hide first x character of h4 element via css? for example: <h4>data: random data.</h4> "data: " shall not shown. i tried overflow , moving div contains h4, works, isn't solution me. maybe there's command don't know helps. know javascript , strreplace work well, i'm looking pure css solution. sadly, css can't calculate width of strings , has no access textual content... if using monospace fonts, you'd able calculate width manually, based on font size, still bad solution. negative margins, indents, etc. unreliable have no idea how fonts rendered, meaning break , ugly in different browsers, under different zoom levels, etc... bottom line: css alone can't it

javascript - Return anonymous object in java -

in javascript can do: function foo() { ... return { attr1 : ... , attr2 : ..., }; } but equivalent in java? because want return custom json object controller after ajax call , want create new bean. as java dictates, should create new class , convert json. also, can use map<string,object> accomplish same thing. generate following json: { "attr1":1, "attr2":2 } you can use following code: map<string,object> map = new hashmap<>(3); map.put("attr1", 1); map.put("attr2", 2); and convert json. p.s.: hashmap in java causes heap increase , unnecessary garbage, specified enough size keep 2 elements.

android - How to download files from other dropbox user -

i've managed create app on dropbox, , turn out app i've created able download own file not file on other user dropbox, there way download file on other user dropbox without them share files? don't use dropbox form of version control/repo sharing, it's best. if want make private repos free, use bitbucket. there strong chance you'll lose files in dropbox exchange (which what's happening here).

https - sonarqube 4.1.2: unable to evict preview database -

after performing successful analysis, seeing failure "unable evict preview database: /batch_bootstrap/evict?project=10020" . followed summary: [error] failed execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project xxx: can not execute sonarqube analysis: unable evict preview database: /batch_bootstrap/evict?project=10020: fail execute request [code=400, url=https://xxx/batch_bootstrap/evict?project=10020]: fail download [https://xxx/batch_bootstrap/evict?project=10020]. response code: 400 -> [help 1] running on sles11sp1, java 1.7, maven 3.3. i've tried increasing memory (maven_opts="-xms4096m -xmx8092m -xx:maxpermsize=4096m") , changing ulimit files (8192) have not seen change in failure. any hints? code 400? you should publish properties files analysis configuration, , log file complete. regards.

php - WP_Query->post_name returns null -

i'm trying post_name attribute wp_query($args) function in wordpress. if i'm using var_dump($wp_query); shows me post_name attribute not empty or null. title of post. but if i'm trying echo using echo $wp_query->post_name; returns empty string. this how define $wp_query : $args = array('posts_per_page' => 5, 'tag' => 'general'); $wp_query = new wp_query( $args ); there posts has tag "general" cannot reason. can please explain behaviour or tell me i'm doing wrong? this because $wp_query isn't single post, posts match query args. means have loop on posts in query result in way. instance, can this: $args = array('posts_per_page' => 5, 'tag' => 'general'); $wp_query = new wp_query( $args ); // posts query $posts = $wp_query->get_posts(); // loop through posts foreach( $posts $post ) { echo $post->post_name; }

functional programming - Please explain me this higher-order function javascript code -

i'm studying higher order functions following eloquent javascript book. haven't been able understand code, why "boolean" passed noisy first argument? this supposed function changes other function, don't how works! function noisy(f) { return function(arg) { console.log("calling with", arg); var val = f(arg); console.log("called with", arg, "- got", val); return val; }; } noisy(boolean)(0); // → calling 0 // → called 0 - got false noisy accepts one-argument function argument. returns new function calls function, displays messages before , after calls it. boolean example function used. converts argument boolean datatype.

html - ng-repeat suprime duplicate and table format -

i have controller this: var myapp = angular.module('myapp',[]); myapp.controller('preguntasctrl', function($scope) { $scope.preguntas = [ { "pregunta_id": "1", "pregunta": "pregunta a", "opcion": "1", }, { "pregunta_id": "1", "pregunta": "pregunta a", "opcion": "2", }, { "pregunta_id": "1", "pregunta": "pregunta a", "opcion": "3", }, { "pregunta_id": "2", "pregunta": "pregunta b", "opcion": "1", }, { "pregunta_id": "2", "pregunta": "pregunta b", "opcion": "2", }, { "pregunta_id": "

c# - New suite of service wrapping earlier endpoints -

we have 10 web api service endpoints. no creating suite of wrapped service endpoint these endpoints, iterative step categorize/segment earlier set of services in respective product areas without breaking underlying functionality. for example: post http://example.com/product would become post http://example.com/internal/v3.5/masterproduct/product (while call endpoint http://example.com/product ) what kind of caveats should approach aware of can take necessary cautionary steps?

oracle - how to handle the text entered from the keyboard pl sql -

how manage text input keyboard using command prompt in pl / sql oracle. want verified if text inserted empty or insert more lines -i use line address retrieve data keyboard set serveroutput on accept my_var varchar(256) prompt 'insert number:', the thing know sql plus can prompt user parameter value.. let user using sqlplus type in text. i'm not sure if that's want meant... you can adding &. so select person.name person age = &age

xamarin.forms - Trying to add OxyPlot to a Xamarin Forms xaml Page -

im trying include oxyplot xamarin.forms-project this xaml.cs file im building plotmodel. private void generateplot() { var points = new list<datapoint> { new datapoint(0, 0), new datapoint(10, 5), new datapoint(20, 10), new datapoint(30, 16), new datapoint(40, 12), new datapoint(50, 19) }; var points2 = new list<datapoint> { new datapoint(0, 0), new datapoint(10, 7), new datapoint(20, 8), new datapoint(30, 8), new datapoint(40, 20), new datapoint(50, 25) }; var m = new plotmodel(); m.plottype = plottype.xy; m.invalidateplot(true); m.title = "hello oxy"; m.resetallaxes(); var ls1 = new lineseries(); var ls2 = new lineseries(); ls1.itemssource = points; ls2.itemssource = points2; m.seri

c++ - Casting from abstract base class pointer to derived class -

i'm trying create state manager game, , have 4 classes: gamestate: // foward declaration avoid circular-referency class statemanager; class gamestate { public: virtual ~gamestate() { } virtual void update(statemanager* gamemanager) = 0; virtual void draw(statemanager* gamemanager) = 0; protected: gamestate() { } }; statemanager: class statemanager { public: statemanager(); virtual ~statemanager(); void addstate(gamestate* gamestate); void update(statemanager* statemanager); void draw(statemanager* statemanager); protected: // store states in unique_ptr avoid memory leak std::vector<std::unique_ptr<gamestate> > states_; }; game: class game : public statemanager { public: void compute() { // call methos of statemanager update(this); draw(this); } } and mainmenu: class mainmenu : public gamestate { public: // override pure vir

javascript - How to modify Google Maps URL to display a set of marked locations? -

is there way modify url display set of locations markers on them? i have latitude , longitude coordinates of places want mark. how construct url? https://www.google.ca/maps/@43.200000,-72.000000,15z do add more @ signs , add more sets of coords? how put markers on them? you can try this: link . change coordinates. note: refering same place: 36°15'56.8"n+92°32'35.7"w/@36.2755246,-92.5637963

c# - How do I update multiple Entity models in one SQL statement? -

i had following: list<message> unreadmessages = this.context.messages .where( x => x.ancestormessage.messageid == ancestormessageid && x.read == false && x.sentto.id == userid ).tolist(); foreach(var unreadmessage in unreadmessages) { unreadmessage.read = true; } this.context.savechanges(); but there must way of doing without having 2 sql queries, 1 selecting items, , 1 updating list. how do this? current idiomatic support in ef as far know, there no direct support "bulk updates" yet in entity framework (there has been ongoing discussion bulk operation support while though, , included @ point). (why) want this? it clear operation that, in native sql, can achieved in single statement, , provides significant advantages on approach followed in question. using single sql statement, small amount of i/o required between client , db server, , statement can executed an

shell - search files in current directory whose name do not contain "txt" in linux -

i know how find files suffix .txt in current directory: find *.txt how invert this? i new linux, please help. thanks! if want current directory, , shell bash: shopt -s extglob ls !(*.txt) reference

c++ - How to completely close the window in qt? -

i creating game using c++ , qt creator. when health gets below zero, want quit current application , show different screen displays quit or play again. i can using hide() method , showing new screen show() method. however, if while game still running in background, can still hear music playing though hidden. main problem when click play again button , loads game again in new window, score , health affected what's still going on in old game have hidden. is there way can close window quits game still loads next window want to? delete window instance , create new 1 next game. or keep , implement proper application states control things music off when game not in running state.

entity framework - Code First design for 3 tables (one-to-one) -

i trying create database tracking parcel being mailed. stuck on trying figure out best way implement relationship between parcel , location @ given time/date. ultimately, need able @ moment in past , tell parcel , @ time/date. when entered location, , when left location. i have 3 tables this. (shortened basics) public class parcel { public int parcelid { get; set; } public virtual location location { get; set; } } public enum locationtype { warehouse, truck } public class location { [key, foreignkey("parcel")] public int parcelid { get; set; } public locationtype locationtype { get; set; } public virtual parcel parcel { get; set; } } locationtimedate { } i not sure how relate locationtimedate location. think should one-to-one relationship. i'd have have locationid. location's key foreignkey (parcel). am going correct way? thoughts/guidance appreciated. this is, me, case many-to-many relationship additional informati

r - Convert date from an unknown factory type -

i had date values in column 2014-08-14 it turned column value 1407992400 when class on column return type factor, not sure how put how before, yyyy-mm-dd format ? dput(date1) structure(c(26l, 14l, 12l, 1l, 20l, 19l), .label = c("1406869200", "1406955600", "1407042000", "1407128400", "1407214800", "1407301200", "1407387600", "1407474000", "1407560400", "1407646800", "1407733200", "1407819600", "1407906000", "1407992400", "1408078800", "1408165200", "1408251600", "1408338000", "1408424400", "1408510800", "1408597200", "1408683600", "1408770000", "1408856400", "1408942800", "1409029200", "1409115600", "1409202000", "1409288400", "140937

C++ declaring a static object in a class -

i'm trying declare static object of class wrote in different class b, this: class // example { int x; public: a(){ x = 4; } int getx() { return x; } }; class b { static obj1; // <- problem happens here public: static void start(); }; int main() { b::start(); } void b::start() { int x = obj1.getx(); } what want achieve int x in b::start() equal int x in class a (4). i tried googling past hour , understood c++ doesn't allow static objects' declarations. correct? if so, here's question. how can same result? available workarounds? keeping in mind rest of code depends on functions in class b static. error error lnk2001: unresolved external symbol "private: static class b::obj1" thanks! you should initialize static var , code: class // example { int x; public: a(){ x = 4; } int getx() { return x; } }; class b { static obj1; // <- problem happens here public: static void

ruby on rails 4 - ActiveAdmin change password inside app -

i went off devise page users can change password inside activeadmin. method 3 doesn't work is, had modify bit activeadmin activeadmin.register_page 'userpassword' def user_params params.required(:user).permit(:password, :password_confirmation) end page_action :update_password, method: :post @user = adminuser.find(current_admin_user.id) if @user.update(params.required(:user).permit(:password, :password_confirmation)) # sign in user passing validation in case password changed sign_in @user, :bypass => true redirect_to admin_root_path, notice: "your password changed" else redirect_to admin_userpassword_path, alert: "your password couldn't changed" end end content render partial: 'edit', locals: {user: current_admin_user} end end i had change if @user.update(params.required(:user).permit(:password, :password_confirmation)) because if (@user.update(user_params)) throw e

excel - Perform a function based on an unknown number of IF statements -

i need following scenario: column contains encounter in department. column b contains date of first administration. column c contains date of last administration. in general, want subtract column b c given a. straightforward. however, column has duplicates. if column has duplicate (meaning same encounter in same department), want subtract b1 c2 (i.e last administration in same first) if b2>=c1, , generate 0 in d1. if not (i.e dates not overlap), subtract b1 c1 , b2 c2. not bad. however, let's column has 3 duplicates , c1 overlaps b2 , c2 overlaps b3. want subtract b1 c3, , generate zeros in d1 , d2. column can have multiple duplicates multiple overlapping dates (let's not infinite five), though don't overlap. i'm pretty sure involves nested ifs (a lot of them), i'm not getting right numbers. last attempt looked like: =if(and(e131<>e130,e131<>e132),(m131-l131)+1,if(and(e131=e126,p131=p126,l131<=m126),(m131-l126)+1,if(and(e131=

ios - Nullability issue on Xcode 6.3 -

i upgraded xcode 6.3 yesterday. since then, have been unable build has parse.framework in it. pfconstants.h errors like nullability specifier '_nullable' cannot applied non-pointer i have never seen error before, , changed nothing other updating 6.3. ideas? parse has implemented new nullability annotations available in xcode 6.3 - see blog post , seems approach in old framework causes these compilation errors. simply update parse frameworks latest api downloads , in business

understanding the java string with add operator -

i trying understand how compiler views following print statements. simple yet bit intriguing. this prints added value. convincing enough. system.out.println(1+2); //output: 3 the output following looks convincing well: system.out.println(1+2+"3");//output: 33 my question (based on behavior above) here. system.out.println("1"+2+3);//should 15 right? no. 123. i tried few other such statements along same lines. able see 1 2 clear behaviors. if integers @ front, without quotes, added , subsequent integers appended suffix added values front. if statement starts string, under quotes, other subsequent elements appended suffix. is somewhere in java api docs? or obvious string or add operator behavior not seeing. of valuable insights appreciated. here code snippet: public static void main(string[] args) { system.out.println(1+2); system.out.println(1+2+"3"); system.out.println("1"+2+3); system.out.

php - Make an oauth2 client with symfony2 -

i made oauth2 server, , want make c client using symfony2 connect (when click login, i'm redirected on site oauth2 server, login, i'm redirected client token). i followed this: http://symfony.com/doc/current/cookbook/security/api_key_authentication.html the problem whem retrieve apikey. if decide use implicit grant oauth2, token sent that: example.com/#token can't retrieve query->get. if send code it's fine, when tried curl server somehow broke (yeah, not specific error, still looking it) so wondering, proper way of doing it? also, when write specific url, why need one, if can check everywhere? thanks :) you can token in php : for known url if have url hash, part after # called fragment. $url=parse_url($yoururl); echo $url["fragment"]; if don't have url in backend, need javascript magic : var token = window.location.hash; then send backend. maybe there other more symfonyc way properly, never used oauth2 yet.. :d

Insert string from file to TextArea Tkinter Python -

def isidatafile(self,namafile): isifile = open(namafile) content = isifile.read().lower() words = re.findall('\w+',content) print words self.textfile.delete('1.0',end) in words: self.textfile.insert('1.0',i+"\n") isifile.close() i wanna print string file .txt textarea (tkinter gui). example, string "ular melingkar, lalu terbang. harimau berjalan di atas air. eh, kenapa hujan atas? bukan sungai mendaki" but, when insert string textarea, result : >>> mendaki, sungai, bukan, atas, hujan, kenapa, eh, air, atas, di, berjalan, harimau, terbang, lalu, melingkar, ular. it look, somehow, reverse. the reason order of words reversing inserting each word @ beginning: self.textfile.insert('1.0',i+"\n") i take words , build single string, example: words = " ".join(words) and insert @ once instead of within for-loop. the other option perform eac

ruby - Rails model if statement -

i'm new rails , app development forgive mistakes. i've got model called product has following (schema): t.string "name" t.integer "cost" t.boolean "in_stock" t.datetime "sold_date" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "quantity" i want in_stock return true if quantity greater 1, otherwise false. wrote following code in product.rb file doesn't seem when enter product quantities through console. i'm not sure if have link database columns (in_stock , quantity) if statement or not. or if right way go things. i'd grateful suggestions. thanks! class product < activerecord::base belongs_to :company def in_stock if quantity >= 1 in_stock true else in_stock false end storing both, quantity , in_stock in database can result in inconsistent data: +----+----------+-------

Randomize related posts in Docpad -

i've installed related plugin docpad , want want display 5 random related posts in sidebar of every blogpost. @ moment have set way in post.html.jade : div h4 related posts: each doc in getrelateddocuments().slice(0,5) a(href=doc.url)= doc.title br so, displays 5 posts, aren't random. how shuffle output of getrelateddocuments() ? have tried variation on question getting random value array ? i created function in docpad.coffee file implement solution: getrandomposts: (howmany) -> items = @getcollection('posts').tojson() output = [] = 0 while < howmany doc = items[math.floor(math.random() * items.length)] output.push(doc) i++ return output you may need step in while loop check if doc value in output array math.floor etc possibly return value used.

rest - Call a Upload API in Java -

there 1 post api in azkaban upload zip file. able upload using curl have given in documentation. curl -k -i -h "content-type: multipart/mixed" -x post --form 'session.id=47cb9240-f8fe-46f9-9cba-1c1a293a0cf3' --form 'ajax=upload' --form 'file=@atest.zip;type=application/zip' --form 'project=aaaa;type=plain' http://localhost:8081/manager http://azkaban.github.io/azkaban/docs/2.5/#api-upload-a-project-zip but want call same api in java. can me how in java? you need use apache httpcomponents framework. create httpclient, httppost request, , multipart entity, , execute request. sample below: httpclient httpclient = httpclientbuilder.create().setdefaultconnectionconfig(config).build(); httppost httppost = new httppost(url); multipartentitybuilder builder = multipartentitybuilder.create(); builder.setmode(httpmultipartmode.browser_compatible); // add parts form here builder.addpart("<param name>", <part>

java - App crashes by opening spinner on popup -

Image
i got massive problem spinner. popup appears without problem , it's showing spinner in closed position. but when open it, app crashes following error message... 04-10 08:34:33.773 1690-1690/com.example.paul_io e/androidruntime﹕ fatal exception: main process: com.example.paul_io, pid: 1690 android.view.windowmanager$badtokenexception: unable add window -- token android.view.viewrootimpl$w@52f02170 not valid; activity running? @ android.view.viewrootimpl.setview(viewrootimpl.java:532) @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:259) @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:69) @ android.widget.popupwindow.invokepopup(popupwindow.java:1019) @ android.widget.popupwindow.showasdropdown(popupwindow.java:925) @ android.widget.listpopupwindow.show(listpopupwindow.java:625) @ android.widget.spinner$dropdownpopup.show(spinner.java:1110) @ android.widget.spinner.performcli

c# - TextBlock GetBindingExpression gets Null when text binded from resource file -

i have text block in text binded resource file,all works fine getbindingexpression return null. there other way of binding <textblock x:name="slide" text="{x:static prop:resources.slidetocollect}"/> slide.getbindingexpression(textblock.textproperty) x:static - not binding, , not creates bindingexpression instances. x:static - it wpf markup extension , allows reference static by-value code entity defined in cls–compliant way. in case - value resource.slidetocollect static property(or field, or constant, etc.) of resource class , assign text property of textblock. if want use binding, need binding markup extension . here example code: <window x:class="wpfapplication66.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:app="clr-namespace:wpfapplication66" title="mainwindow" heigh

puppet - Using old versions of vagrant and puphpet -

i have puppet 3.4.2 , vagrant 1.6.5. configured our puphpet setup on year ago. this working fine on environment, fresh install downloads new version of base box has updated version of puppet , our old configurations don't work. we using box: https://atlas.hashicorp.com/puphpet/boxes/ubuntu1204-x64 . must have v1 new instances download v2.1 i have tried updating puphpet config.yaml, when upload puphpet.com message "the config file provided empty! please recreate manifest manually below.". so see few solutions have blockers on each of them: use old base box. there archive copy of v1 of server somewhere on internet? https://atlas.hashicorp.com/puphpet/boxes/ubuntu1204-x64 use new base box downgrade puppet. how downgrade puppet , it's dependancies? figure out way of importing config.yaml in puphpet.com , start using new versions. there need puphpet.com recognise old file? reconfigure whole file scratch. know can me? thanks advice. it's s

svn - Getting the changed type of files and the previous version in HG -

i collecting information using commit logs generated hg , svn. svn sample: r1667884 | kschenk | 2015-03-20 05:37:55 +0800 (fri, 20 mar 2015) | 1 line #126118# fix malformed if statements in makefile. hg sample: **changeset: 276992:8b564af029aa bookmark: writercompare01 tag: tip parent: 266455:8565218dc235 user: thb@openoffice.org date: fri mar 19 00:16:57 2010 +0100 summary: cws writercompare01: #i110237# changes tzvetelina as-is** i know followings: if above commit infor related diff of 2 revisions, revision displayed revision (in svn 1667884) id , changeset(hg 276992:8b564af029aa) id. revision before committed or revision id after committed? if second 1 how related previous revision in svn , hg? can use hg diff -c changesetid previous version? when considering changeset first numerical portion considered revision id? is there command use changed type (modified, deleted, ignored , etc. ex: " m /openoffice

How to add an application to Apache Brooklyn catalog -

i trying add applications brooklyn catalog. can explain steps add new application catalog.xml? i did try sample catalog provided @ https://brooklyn.incubator.apache.org/v/0.7.0-m1/use/guide/quickstart/policies-and-catalogs.html . application gets listed in catalog tab when try launch it, gets stuck @ 'configuring'. there else needs done ? i tried adding existing application catalog ( https://brooklyn.incubator.apache.org/v/latest/ops/catalog/index.html ) failed. can me ? i'd recommend upgrading 0.7.0-m2-incubating, catalog has improved since 0.7.0-m1. documentation @ https://brooklyn.incubator.apache.org/v/latest/ops/catalog/index.html describes steps 0.7.0-m2-incubating; not work 0.7.0-m1. the link explicit version of docs (rather latest) https://brooklyn.incubator.apache.org/v/0.7.0-m2-incubating/ops/catalog/index.html there more improvements in snapshot (and in existing pull requests), if fancy trying bleeding edge! for 0.7.0-m1 error "gets

objective c - iOS - Unable to Upload media with Twitter/Fabric New SDK -

i want post photo twitter ios app. can post tweet without media when trying attach media throws error. i following twitter documentation , according first need upload media https://upload.twitter.com/1.1/media/upload.json , able attach tweet using media-id. here code uploading media. app crashing @ urlrequestwithmedthod call. help me resolve issue. uiimage *image = [uiimage imagenamed:@"shareit.png"]; nsdata *imagedata = uiimagejpegrepresentation(image, 0.7); nsstring *statusesshowendpoint = @"https://upload.twitter.com/1.1/media/upload.json"; nsdictionary *params = @{@"media" : imagedata}; nserror *clienterror; nsurlrequest *request = [[[twitter sharedinstance] apiclient] urlrequestwithmethod:@"post" url:statusesshowendpoint parameters:params error:&clienterror]; if (request) { [[[twitter sharedinstance] apiclient] se

java - Detect if radio button is checked in webdriver -

i trying validate if radio button checked. have below html code snippet radio button . <span class="jquery-hp-radio jquery-hp-radio-checked" style="-moz-user-select: none;"> <span class="mark"> <img src="http://someurl/images/empty.gif"> </span> </span> tried below code - if(driver.findelement(by.classname("mark")).isselected()){ system.out.println("true"); }else { system.out.println("false"); } } it gives output false - though radio button selected default. i believe radio button's class jquery-hp-radio jquery-hp-radio-checked when checked. so following check if button checked or not if(driver.findelement(by.xpath("//span[@class='mark']/..")).getattribute("class").contains("checked")){ system.out.println("true"); }else { system.out.p

javascript - Best approach to conditionally update nodes in d3.js force graphs -

i working on interactive timeline using d3.js composed of force layout , slider. data encoded json mysql. slider moves, want nodes appear/disappear depending on json values. repeatedly calling database every tick of slider pretty costly , big no-no. i've seen examples of json queries haven't seen 1 implemented in d3.json. what's optimal approach conditionally remove/add nodes on graph? advice appreciated. i think best approach filtered out nodes(i.e. nodes don't want shown based on slider values) , make display:none.

android text to speech 0 supported languages on nexus 7 -

i'm working on little app gives user option "speak" couple of commands app respond. i've got speech recognition working , commands registered. being recognized , means, answer should played. only issue is: doesn't. here's bit of code use determine languages supported google's tts engine (i'm developing older version of android "tts.getavailablelangues()" isn't in there unfortunately): locale[] locales = locale.getavailablelocales(); list<locale> localelist = new arraylist<locale>(); (locale locale : locales) { int res = speaker.islanguageavailable(locale); if (res == texttospeech.lang_country_available) { log.d(tag, "language: " + locale); localelist.add(locale); } } log.d(tag, "languages available: " + localelist.size()); the output of last log always: "languages available: 0" and indeed, if run bit of code: int id

javascript - getting value of my td cells by id in jQuery -

i have following html can see when inspecting element on google chrome. <table id="table_id"> <tr role="row" class="odd"> <td id="aptdate0" class="sorting_1">2015-03-08</td> <td id="aptdateend0" style="display:none;">2015-03-08</td> <td id="start0">10:30:00</td> <td id="end0">11:30:00</td> <td id="duration0">01:00:00</td> <td>john doe</td> <td>jane doe<td> <td id="status0">n/a</td> </tr> <tr role="row" class="odd"> <td id="aptdate1" class="sorting_1">2015-03-08</td> <td id="aptdateend1" style="display:none;">2015-03-08</td> <td id="start1">10:30:00</td>