Posts

Showing posts from April, 2014

sorting - Sort a list i java with two elements (type string and double) in Java -

i writing pension program , stuck. the program looks this: first read in file every line has name of person, age, , first deposit. use method called readfile that. inside method call upon class called class savings which in separate file calculate pension. have following problem: sort names according pensions (highest lowest) don't know how that. here method in readfile class: @suppresswarnings("resource") public void readfile(double rate) { while(scan1.hasnextline()) { string input = scan1.nextline(); scan2 = new scanner(input).usedelimiter("/"); string = scan2.next(); int b = scan2.nextint(); int c = scan2.nextint(); // calculate savings savings s = new savings(); s.totalsavings(a, b, c, rate); // add savings array } } 1st, create class person : class person{ private string name; private int age; private bigdecimal firstdeposit; private bigdecimal pensio

bootstrap-3 tooltip doesn't flash accordingly to the js - if - condition -

this code use register users mysql db. , i'm using twitter bootstrap tooltips, obtain following: initially, when user hover on textboxes, string wrote in title attribute displayd. if write 2 letters (fe, firstname), , presses submit button, form won't submitted, , new tooltip message should flash , show: "please use @ least 3 letters!". the same algorithm every input in form. if user fills in correctly textboxes, form submitted register.php , process data. <form id="form"> <div class="form-group"> <input type="text" class="form-control" id="firstname" placeholder="first name" style="width:48%;float:left;" title="the first name mandatory! please use @ least 3 letters!"/> <input type="text" class="form-control" id="lastname" placeholder="last name" style="width:48%;float:right;" title="the last n

java - Starting Another Activity - Activity not showing my message -

i'm new android developing have experience python , java, decided want make apps, began tutorial developer.android.com. i'm in build first app > starting activity section. i made final step without errors, message type in not showing in second activity created when press send button! ( https://developer.android.com/training/basics/firstapp/starting-activity.html#displaymessage ) if click link see tutorial, , scroll down bottom, should see message type should pop up, , bigger font size. message find when type small font, default "hello world!" here's myactivity.java package com.example.android.myfirstapp; import android.app.fragment; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.content.intent; import android.view.view; import android.widget.edittext; public class myactivity extends appcompatactivity { public final static string extra_mess

Is it possible to tap into Windows 10's Cortana API for Python? -

i working on home automation project. when windows 10 released speech recognition api became incompatible. there openly available api use cortana, if not possible tap speech recognition api? python 2.7 windows 10 dragonfly speech api no longer working, used windows voice recognition. my ultimate goal not use launch phrase, want ai listen say. if randomly ask question want answer. have ai part covered voice input biggest problem. thanks help, looking forward answers! (note: not duplicate question due windows 10 complications.) i visited 1 of microsoft's offices in germany , asked of cortana evangelists if cortana open-sourced, or if planning on developing speech recognition api. told me possibility of launching foreground apps cortana, said open api not in pipeline now. it may better google speech recognition api: https://progfruits.wordpress.com/2014/05/31/using-google-speech-api-from-python/ it limited 50 requests day, accuracy good.

c# - changing activation function from Sigmoid to Tanh? -

Image
i'm trying change neural net using sigmoid activation hidden , output layer tanh function. i'm confused should change. output calculation neurons or error calculation propagation? output calculation: public void calcoutput() { if (!isbias) { float sum = 0; float bias = 0; //system.out.println("looking through " + connections.size() + " connections"); (int = 0; < connections.count; i++) { connection c = (connection) connections[i]; node = c.getfrom(); node = c.getto(); // connection moving forward // ignore connections send our output if (to == this) { // isn't necessary // treating bias individually in case need @ point if (from.isbias) bias = from.getoutput()*c.getweight(); else sum += from.getoutput()*c.getweight(); } }

php - call a helper function in controller in codeigniter -

i created helper visit hits , contains function inserts data in database: hits_counter_helper.php : function count_hits($options = array()) { //determine whether user agent browsing site web browser, mobile device, or robot. if ($this->agent->is_browser()) { $agent = $this->agent->browser() . ' ' . $this->agent->version() . ' - ' . $this->agent->platform(); } elseif ($this->agent->is_robot()) { $agent = $this->agent->robot(); } elseif ($this->agent->is_mobile()) { $agent = $this->agent->mobile(); } else { $agent = 'unidentified user agent'; } //detect if user referred page if ($this->agent->is_referral()) { $referrer = $this->agent->referrer(); } // correcting date time difference adding 563 it. $date = date('y-m-j h:i:s', strtotime(date('y-m-j h:i:s')) + 563);

javascript - Event when image size is known - JS/jQuery -

i'm looking event when appended js image has known height (not image loaded). event should occurs between $('img').ready() , $('img').load() . you can find example in fiddle - i'm simulating event in setinterval loop (when height known). example results fiddle (image should not cached browser): time after append: 6ms, height: unknown. (ready event) time in loop: 259ms, height: known. (??? event) time on load event: 3884ms, height: known (load event). ps. i'm appending form ajax bunch of html content , want animate - height essential it. best solution when: have event on outside container firing when images have known height (it not change size in time).

swift - How to filter JSON dictionary in SwiftyJSON -

i'm using swiftyjson list , printing out tableview. issue can't filter dictionary, tried make loop remove unwanted elements (or pushing new element), couldn't find way remove or pushing element json type swiftyjson provides. var filteredtriplist:json = tripslist (key: string, trip: json) in tripslist { if string(stringinterpolationsegment: trip["tripfrom"]) != searchfilter["from"]! || string(stringinterpolationsegment: trip["tripto"]) != searchfilter["to"]! { // i'm hoping line below // filteredtriplist[key.toint()!].remove() } } } i don't know swifty json, because use native way nsjsonserialization... have guess please change line filteredtriplist[key.toint()!].remove() to line filteredtriplist.removevalueforkey(key) and write me happened

php - SQL Data & JavaScript - Best Practice -

let's website needs pull information specific table in database based on user's menu selection. table's data fed js equations , thrown onto page. what best way go pulling table's information? i've read trying access sql database via javascript bad practice, there way this? know php's json_encode , guess i'm not entirely sure what syntax if i'm calling php js script, and if that's 'best' practice. still relatively new this, i'd right. another option far i'm concerned attempting pull of possible tables (not security concern) @ once on page load. expect that'd introduce deal of latency, though. it looks me not sure technique use. here options. i'm not going type them here because, there enough find each one: plain php: w3schools pure ajax call: stackoverflow jquery: jquery ajax calls more user friendly , many times more efficient because, don't have refresh page. information @ once( long mysql da

Adding text to javascript items -

is there way me add text sprites in javascript each can given it's own number instead of having edit picture? i'm working simple matching game described here . have number shown, image resource must changed. <!doctype html> <html> <head> <title>bakerice</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type ="text/javascript" src ="simplegame.js"></script> <script type="text/javascript"> var game; var ic; var ib; function cone() { tic = new sprite(game,"ice-cream-cone.png",150,150); tic.setspeed(0); tic.setboundaction(continue); tic.setposition(200,400); tic.checkdrag = function(){ if(tic.ismousedown()){ tic.setx(document.mouse

javascript - Inject custom JS file in ionic project -

i'm new ionic/angularjs. need display image carousel in single view, need load in view corresponding js (carousel.js). don't want put js file index.html file, cause loaded in pages , need use in particular one. my question how can load js in particular view? thanks in advance add following code in onload of page want load js file <template onload="onload()"></template> function onload(){ var script = document.createelement("script"); script.src = "https://somejavascript file url"; document.getelementsbytagname("head")[0].appendchild(script); } it called when particular page or template loaded. regards.

sql - how to get current row value in plpgsql function -

i need create plpgsql methods use current row value without passing in parameter in update command. i tried create temp table test ( test text, result text ) on commit drop; insert test values ('1',''); create or replace function public.gettest() returns text $$ declare comp text := null; begin execute 'select ''current row '' ||test.test' comp; return comp; end; $$ language plpgsql strict stable; update test set result = 'result: ' || gettest(); but got exception error: missing from-clause entry table "test" line 1: select 'current row ' ||test.test ^ query: select 'current row ' ||test.test context: pl/pgsql function gettest() line 6 @ execute statement ********** error ********** error: missing from-clause entry table "test" sql state: 42p01 context: pl/pgsql function gettest() line 6 @ execute statement how fix ? how fix without passing vaue

arrays - Minimum elements in all contiguous subarrays -

i saw question asked find minimum of contiguous subarrays. eg. array a=[1,2,3], answer array b containing [1,2,3,1,2,1]. how - b[0] = 1 subarray a[0] b[1] = 2 subarray a[1] b[2] = 3 subarray a[2] b[3] = 1 subarray a[0,1] b[4] = 2 subarray a[1,2] b[5] = 1 subarray a[0,1,2] what did, is, constructed segment tree, doesn't contains minimum of contiguous subarrays. don't think can use "dequeues" either, because don't have find min in subarray of particular length. so, how can min. of contiguous subarrays(that b array)? here implementation using segment tree: #include <stdio.h> #include <math.h> #include <limits.h> #include <iostream> using namespace std; int mid(int s, int e) { return s + (e -s)/2; } int rmqutil(int *st, int ss, int se, int qs, int qe, int index) { if (qs <= ss && qe >= se) return st[index]; if (se < qs || ss > qe) return int_max; int mid = mi

python - I can't find a simple filter for my pyth triples filter -

i want filter down primitive triples ([3,4,5], [7,24,25], etc.) nothing non-primitive [6,8,10] , can't seem figure out, in code took out attempts @ filter, , displays primitive , non-primitive triples. import tkinter import sys fractions import gcd def func(event): x = int(e1.get()) # max number result = [] in range(1, x): # loops each value in range of x b in range(a, x): c in range(b, x): if a**2 + b**2 == c**2 , gcd(a, b) == 1: # if primitive pyth triple, append result result += ['[',a,',',b,',',c,']'] # add group of triples list l = tkinter.message(root, text=result).grid(ipadx=5, ipady=5, sticky='w''e') # display each group of triples root l0 = tkinter.label(root, text="non-primitive , primitive triples").grid(ipadx=5, ipady=5, sticky='w''e') root.bind('<return>', close) # hit enter exit, temp debu

php - How can I get US State from GeoIP2? -

is there way, how state abbr. (ca, vi, ..) ip? the library return me metro code , postal code, there lookup table state convertor? or how extract state? you need in subdivisions section, generic container states, provinces, etc. depending on country. if you're using web api, here docs , , relevant chunk output example: "subdivisions": [ { "confidence": 50, "geoname_id": 5332921, "iso_code": "ca", "names": { "de": "kalifornien", "en": "california", "es": "california", "fr": "californie", "ja": "カリフォルニア", "ru": "Калифорния", "zh-cn": "加州" } } ] the php client using downloaded ip db has mostspecificsubdivision :

javascript - $scope.$watch not catching the value modified by directive -

my directive give focus span , assigns boolean value i.e, focustospan true whenever press shifttab ,however, change not reflected in controller , in template . checked $scope.$watch on focustospan variable below directive (function() { 'use strict'; angular.module("my.page").directive('getfocustospan', function() { return { link: function(scope, elem, attr, ctrl) { elem.bind("keydown keypress", function(event) { if (event.which === 16) { $('.iconclass').attr("tabindex", -1).focus(); scope.focustospan = true; } }); } }; }); })(); controller $scope.$watch('focustospan', function(newvalue) { if (angular.isdefined(newvalue)) { alert(newvalue); } }); which not getting called.may know how change made controller variab

c++ - Are Linux programs as portable as Windows programs? -

maybe dumm question, it's 1 of these 1 learns people talking here , there, , i'd happy if pro described situation correctly. talking standard desktop computers, see windows programs portable can get. compile 32-bit software static library linking, , put software on flash-drive, , it'll work on computer in world that's 32-bit or 64-bit. have programs on 10 years old, , still work without single problem. now program linux too, don't have picture in mind when doing linux programs. have picture should compiled in every system program has used. colleague told me 1 it's wrong run same software on 2 computers blindly among 2 linux computers. but... on windows static executables. can in linux two? so summarize question : limitations creating portable software on linux, people on windows? of course, assuming target computer has no libraries @ other glibc of arbitrary version. libraries should static in model have in mind. in linux world, binary compat

vba - Excel. Worksheet Change to Worksheet Calculate -

i have code runs on "worksheet_change" event. the value in cell "a1" changes live feed. i need adapt code event work "worksheet_calculate" event. every time cell value a1 changes, automatically old value must shown in a2. a1 new value a2 old value here code: private sub worksheet_change(byval target range) dim newvalue, oldvalue if target.address <> "$a$1" exit sub application.enableevents = false target newvalue = .value application.undo oldvalue = .value .value = newvalue end range("a2").value = oldvalue application.enableevents = true end sub for 1 sheet place code in sheet module (initial old value empty) option explicit private oldval string private sub worksheet_calculate() updateoldvalue me.range("a1") end sub private sub worksheet_change(byval target range) updateoldvalue target end sub '--------------

express - oauth2orize redirect_uri issue -

i'm attempting customize oauth2orize all-grants example use. can run all-grants as-is , works (as expect), when run customized version, end error: error: unable issue redirect oauth 2.0 transaction @ object.response [as handle] (c:\dev\expy\api\node_modules\oauth2orize\lib\grant\code.js:122:41) i've been digging bit , seems there property of txn variable within function should named redirecturi , should populated redirect_uri query string of initial request /dialog/authorize page. reason doesn't happen on example app. caused express version difference? biggest difference see between example code , customizations. all-grants uses express 2.* , app use express 4.*. if isn't express version issue, should start looking in code issue? for reference, see in app txn object: txn: { "transactionid": "evlud2q4", "client": { ... }, "req": { "type": "code", "clientid":

angularjs - Clear button in AutoComplete of Angular Material blocks all the DOM elements -

Image
yes, rare situation somehow, if use autocomplete follows, dom elements blocked , cant interact anymore element page. this html-part: <md-autocomplete style="background-color:white; height:10px;" md-selected-item="selecteditem" md-search-text-change="searchtextchange(searchtext)" md-search-text="searchtext" md-selected-item-change="selecteditemchange(item)" md-items="item in querysearch(searchtext) | orderby:'text'" md-item-text="item.text" md-min-length="0" placeholder="filteren op tag" md-menu-class="autocomplete-custom-template"> <md-item-template style="background-color:white;"> <span class="select-title"> <!--<

html - Can I use CSS to add a bullet point to any element? -

pretty simple question, not sure if possible. want add image act bullet in <h1> elements. know can achieve by: <span class='bullet'></span><h1>my h1 text here</h1> with css: .bullet{ background: url('bullet.png') no-repeat; display:inline-block; vertical-align: middle; background-size:100%; height:25px; width:25px; margin-right: 5px; } but there automatic way same thing? thinking like: h1{ list-style-image: url('bullet.png'); } but seems work <ul> elements. don't want have paste <span> element everywhere before <h1> element. ideas? while can use :before pseudo-selector add "-" or "•" character in front of element, doesn't make element behave bullet point. element may bullet point, that's dirty hack, really, , should avoided! to make element both (1) bullet point , (2) behave bullet point, should set display , list-s

c# - Add Days methods -

i have create class includes 3 methods. 1st - shows current date 2nd - current date + 7days 3rd - current date - 7days. i had dealing dates in c # created sth : public class date { private datetime date = datetime.now; public datetime now() { return date; } public datetime aktuplusone () { datetime date = datetime.now.adddays(7); return date; } public datetime aktuminusone() { datetime date = datetime.now.adddays(-7); return date; } } is ok or not ? works fine, care habits . no need create additional method framework provides functionality out of box datetime.now.adddays(numberofdays) . however, if want create generic method requirement, create 1 instead of 3 methods. public datetime adddaystotoday(int days) { return datetime.now.adddays(days); } datetime today = adddaystotoday(0); datetime todayplu

Microsoft Office 14.0 access database engine ole db provider in visual studio 2015 -

this first attempt @ writing visual basic app using visual studio. using access 2013 database source , going fine until decided add calculated fields 1 of tables. vs telling me need "microsoft office 14.0 access database engine ole db provider" read tables. i've been searching , searching can't find version 14.0 of engine. missing simple, or can not access calculated fields in db , have pull data , calculations in app? i working on machine win7 64bit, office 2013 pro, , visual studio 2015 community. thanks! edit: calculated fields this: " http://travellermap.com/api/jumpmap?sector= "+left([sector],4)+"&hex="+[hex]+"&style=print&jump=3" where [sector] , [hex] fields in same database. added fields database vs2015 throw error. if tired use dataset wizard tell me there fields in database missing or not read without v14 of engine. then after removed calculated fields still not read data. have revert backup copy of

java - How to find root of "Could not find or load main class" error when running JAR -

i have seen question asked many times, there no precise answer problem. story simple - downloaded legitimate jar file, functioning , advertised application, here: https://github.com/kamilfb/mqtt-spy/wiki/downloads . the application brings obvious instruction start java -jar mqtt-spy-0.2.0-jar-with-dependencies.jar results in known error, being in case error: not find or load main class pl.baczkowicz.mqttspy.main my system ubuntu 15.04, java version openjdk version "1.8.0_45-internal" openjdk runtime environment (build 1.8.0_45-internal-b14) openjdk 64-bit server vm (build 25.45-b02, mixed mode) i don't have computer test elsewhere. did checks , jar file looks pretty normal. tried de-compressing , running class directly, won't budge, same error message. tried online .class analysis tools, nothing caught attention. reviewed dozen of pages referring "could not find or load" problem. no luck far. not sure if bothers, did java programmers certificati

Need Assistance with This Simple Python Code -

here code & error : attributeerror: type object 'datetime.datetime' has no attribute 'strptime #trying calculate how many days until project due import datetime project = input('when project due please specify mm/dd/yyyy ') deadline = datetime.datetime.strptime(project, '%m/%d/y').date() days = project - deadline print(days) print(days.days) thank in advance #koh looks need this: import datetime project = input('when project due for. please specify mm/dd/yyyy ') deadline = datetime.datetime.strptime(project, '%m/%d/%y').date() delta = deadline - datetime.datetime.now().date() print(delta.days) using python3 there no errors datetime: >>> datetime.datetime.strptime("08/11/2015", "%m/%d/%y").date() datetime.date(2015, 8, 11)

ios - Parse switching view controller on sucessful login -

after user logs in sucessfully, need switch view controllers timeline section of app, going tab bar view controller 5 different tabs @ bottom. here code have far, works , connected parse database have setup. import uikit import parse class loginviewcontroller: uiviewcontroller { @iboutlet var usernamefield: uitextfield! @iboutlet var passwordfield: uitextfield! override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func logintapped(sender: anyobject) { let username = usernamefield.text let password = passwordfield.text pfuser.loginwithusernameinbackground(username, password:password) { (user: pfuser?, error: nserror?) -> void in if user != nil { println("success") } else { var loginerror:uialertview = uialertview(title:

php - Get users liked photos list on Instagram -

i searched on here, github , instagram api couldn't find answer. need this: (user1: authenticated user - user2: un-authenticated user) user1 login instagram access. user1 enter user2's id , see photos user2 liked or commented. on instagram api, gives photos authenticated user liked. need other users liked photos. possible? (php btw) it not possible instagram api. although don't literally, can deduce here can't: see list of media liked authenticated user. private media returned long authenticated user has permission view media. liked media lists available authenticated user. if building big application, can store info people logging in, or storing likes while load pictures, can't updated "live" , have doubts if legal or not.

android - Settings the background of a CanvasView in layout xml not working -

i have canvasview found open source online. see below link. <com.brettrosen.atls.canvas.canvasview android:id="@+id/margin_canvas" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/loose_leaf"/> i have image called loose_leaf.png in drawable folder. however, when set image background canvasview, not take effect. have canvasview functionality (as in doesn't support it) or doing wrong? there add make work? canvasview github

asp.net - Call a specific functionality before each function returns in a c# class -

i writing class returns urls generated web project. i have around 200 functions return urls. @ end of each of these 200 functions, have call specific function process , validate url. can automated? don't want miss in of 200 functions. you can automate using programming technique known aspect oriented programming (aop) . there couple of aop tools out there, , 1 of known c# postsharp , there edition can use free (note have no affiliation postsharp). basically happens add attribute class in question , postsharp takes attribute , class , generates new class during compilation phase performs both actions. powerful technique can simplify things validation , logging greatly.

python - How to call a form.py in another application -

i have model named namemodel in app named customer. wanna reuse model's 1 of choices in app's model or forms.py. how can that. following code of form in customer app. genderchoices = ( ( "", ("---")), (6, ("male")), (7, ("female")), (8, ("notknown")), ) please help. remember genderchoices either class member of namemodel or tuple defined @ customer app models.py just import , use would, in models.py file: from customer.models import namemodel examplemodel(models.model): type = models.charfield(max_length=1,choices=namemodel.genderchoices) or ... from customer.models import genderchoices examplemodel(models.model): type = models.charfield(max_length=1,choices=genderchoices) if tuple not defined inside namemodel class. cheers. edit to edit tuple have convert list append , convert tuple: l = list(genderchoices) l.append(((9,("something else"))) g

ios - How can I attach an object with another object in CoreData using a one to many relationship? -

Image
i'm pretty @ working core data when using entities themselves, since i've started playing relationships i've hit few walls can't seem climb on after trying find solution many days. i've got entity called "entityone" -for simplicity reasons- second "entitytwo" entity. entityone has one-to-many relationship entitytwo. i'm trying attach 1 or more entitytwo objects entityone when saving managedobjectcontext, without saving entityone first attaching entitytwo objects after fetching results. how can attach both of them when saving persistent store? this declaration of both entity descriptions , managedobjects. let firstentity = nsentitydescription.entityforname("entityone", inmanagedobjectcontext: managedobjectcontext!) let firstitem = nsmanagedobject(entity: firstentity!, insertintomanagedobjectcontext: managedobjectcontext!) let secondentity = nsentitydescription.entityforname("entitytwo", inmanagedobjectcontext: ma

javascript - How to use cordova-diagnostic-plugin with meteor? -

i using cordova diagnostic plugin- https://github.com/dpa99c/cordova-diagnostic-plugin , added using meteor add cordova:cordova.plugins.diagnostic@1.1.0 , wrote code below mentioned in plugin github readme if (meteor.iscordova) { document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready(){ cordova.plugins.diagnostic.islocationenabled(function(enabled){ console.log("location " + (enabled ? "enabled" : "disabled")); }, function(error){ console.error("the following error occurred: "+error); }); } } but getting error shown below uncaught typeerror:cannot read property 'diagnostic' of undefined any on how use plugin in meteor.

java - Time complexity analysis of minimum set cover solution -

for question there n persons , k different type of dishes. each person has preference each dish. either likes or not. need feed people. every person should atleast 1 dish of chioce. minimum number of different type of dishes can order? one of solution is, public class optimumdish { private set<integer> result = new hashset<integer>(); public void print(){ for(int r:result) system.out.print(r + " "); } // find optimum dish navigating available options public void find(int[][] m, int r, int c, int mr, int mc, stack<integer> dishes) { dishes.push(c); if (r == mr) { // reached last person. unique dishes set<integer> d = new hashset<>(dishes); if(result.size() == 0 || result.size() > d.size()) result = d; } else if (r < mr) { // check next person's preferred dish (int = 0; <= mc; i++) { if (m[r + 1][i] == 1) { find(m, r

javascript - Using info from GET request in jQuery to display transformed result through Flask -

i'm trying send client info based on selection make. i'd use request since i'm not changing info on server. however, don't know how access info request; i've been researching using querystrings flask haven't had luck. need manipulation result after comes javascript, i'd keep response in success function have below rather use sort of templating. the things afford change how data gets sent (if needs json or besides string) , how gets accessed in flask. possible , how it? app.py from flask import flask, render_template, request, jsonify app = flask(__name__) def myfunc(s): return str(s) + "!" @app.route("/") def index(): # resp = myfunc(selectedoption) # return resp if __name__ == '__main__': app.run(debug=true) index.html <!doctype html> <html> <head> <title>gettest</title> <!-- latest compiled , minified css --> <link rel="stylesheet" hre

How to return new field from cakephp beforeMarshal -

so have rest api expecting json string containing field, eg, 'status'. need relate string id , have obtained id using beforemarshal in table model: $query = $status->find() ->where (['status' => 'new']); $id = $query->first(); $data['status_id'] .= $id->id; problem above, $data['status_id'] not work because 'status_id' not in incoming fields. how can add 'status_id' $data field, or return beforemarshal, such replaces 'status' string value ? ie, incoming: {"status": "new"} , before saving entity, need {"status_id": "2"} this cakephp v3

javascript - JQuery Calculation drops cents -

i have block, pulls current amount paid on item firebase , amount being paid @ moment. supposed add 2 make third variable. for reason code drops cents off total. singleref.once("value", function(snapshot) { var = parseint(snapshot.val().amounts.paid); // amount paid var b = parseint(invoice.payment.amount); // amount being applied var c = + b; console.log(c); }); let's following happening: a = 0; b = 10.86; the result in code be: c = 10; // should 10.86 let's following happening: a = 10.00; b = 10.86; the result in code be: c = 20; // should 20.86 it doesn't matter cents are, rounds rid of them. i've tried adding .tofixed('2') of variables, , b, , c. result in same no cent totals. how!? i've been trying past few hours, it's simple can't figure out. it's driving me nuts! i'm using angularjs , firebase. the function parseint() specifically parsing integers so, if give 3.14159 , g

Python - loop a dictionary? -

i have dict below , not sure how loop through correct data want, py_dict = {'age': {0: 10, 1: 30.0, 2: 19.0}, 'name': {0: u'michael', 1: u'andy', 2: u'justin'}} item in py_dict: print("name:",item[0]) print("age:", item[1]) print("") result, ('name:', 'a') ('age:', 'g') ('name:', 'n') ('age:', 'a') but want is, name: michael age: 10 name: andy age: 30 , on.... edit: py_dict = pandas_df.to_dict() print py_dict age name 0 nan michael 1 30 andy 2 19 justin you thinking looping through dictionaries wrongly, when - for in dict: i key in dictionary , not value. example - >>> d = {1:2,3:4} >>> in d: ... print(i) ... 1 3 as can see , printed keys not values. if need keys values, iterate on iteritems() (for python 2.x) , or items() (for python 3.x) . both return lis

How to download the source code from Ionic View -

i have app on ionic view app, means on ionic.io. there way download source code? unfortunately, feature not possible. don't think ever possible. what can do, if it's application , can prove it. come ionic official forum, post message kindly asking admins (not moderators, i'm 1 of them , know can't you) if can mail app. or can mail them here: help@ionic.io

openoffice base - database structure with multiple bank statements -

okay, designing database hold transactions , types, receipts received , bank account statements. first step receipts input , transaction type created (cash/food/clothes/ect). receipt has multiple trans type records. second step match transactions in bank statements (unless cash) receipts (if any) , existing transaction type or create new one. i going upload statements multiple accounts in multiple banks csv's , import them db. my problem can't db structure feels right. could: have separate table each acct/bank feels wrong. combine csvs 1 acct/bank unique id. combine csvs single. this should simple design problem can't seem work out. i'm using openoffice base + other apache apps. any appreciated. perhaps below table names in caps column names below each table (top column name each table primary key). statements statementid bank statementdate statement_details sdetailid statementid detaildate store amount ttypes typei

powershell - How to extract lines between index 1 and index 2 to another csv variable? -

instead of outputting file set-content in how remove first , last line in powershell $csv = import-csv in.csv -header date,time,o,h,l,c,v | select * -excludeproperty time | foreach {$_.date = [datetime]::parseexact($_.date,"yyyy.mm.dd",$null).tostring("yymmdd");$_.v=1;$_} | convertto-csv -notypeinformation ($i = 1; $i -lt ($csv.length - 1); $i++ { $csv[$i] -replace '"' | set-content out.csv -encoding ascii } i want put these lines in $csv2 var instead of out.csv. set-content not work var. how (i don't have powershell 5 ) ? the issue code every time call set-content rewrite file , replace content file have. consider adding -append switch set-content. add file instead of overwriting it. remember make sure file empty befor begin writing it. i consider using more simple way of getting "mid" content of file. check following sample. might not cover of requirements, simple way

java - FileNotFoundException when loading textfile into android project -

i've been working on android bid page app class , can't seem find out why program throws filenotfoundexception when path correct (relative path). i'm using class read in file contains string values of item objects , create items put temporary hashmap , return it. in advance!! public class fileloader { private file path = new file("items"); private static file textfile; //filename called "allitems.txt" public fileloader(string filename) { textfile = new file(path, filename); } public map<integer, item> getitems() { //item custom object map<integer, item> items = new hashmap<integer, item>(); int = 1; try (bufferedreader bf = new bufferedreader(new filereader(textfile));) { string itemtoparse; while((itemtoparse = bf.readline()) != null) {

c# - How to autofocus textbox on TrayPopup in WPF? -

i working on application taskbaricon hardcodet . when activate customtraypopup , have customtextbox focused. normal way within xaml doesn't seem work. here's code: <usercontrol [...]> <grid x:name="grid"> <border [...]> [...] </border> <textbox [...] focusmanager.focusedelement="{binding relativesource={relativesource self}}" > [...] <textbox.template> [...] </textbox.template> </textbox> <listbox [...]>[...] </listbox> </grid> </usercontrol> is there way make textbox autofocus when calling traypopup ? doesn't matter if xaml or code behind. update 1: customtextbox consists of button , textfield . here's whats inside of textbox.template <controltemplate> <border [...]> <visualstatemanag

sql server - SQL Joins . One to many relationship -

i have 2 tables below table 1 ----------------------------------- userid | username | age | salary ----------------------------------- 1 | foo | 22 | 33000 ----------------------------------- table 2 ------------------------------------------------ userid | age | salary | createddate ------------------------------------------------ 1 | null | 35000 | 2015-01-01 ------------------------------------------------ 1 | 28 | null | 2015-02-01 ------------------------------------------------ 1 | null | 28000 | 2015-03-01 ------------------------------------------------ i need result this. result ----------------------------------- userid | username | age | salary ----------------------------------- 1 | foo | 28 | 28000 ----------------------------------- this example. in real project have around 6 columns age , salary in above tables. in table 2 , each record have have 1 value

How to create session with php curl in mediawiki api -

i working on mediawiki api , want create user login api . referred link . not able create session . here code first step i have created session id session_start(); $data = "action=login&lgname=wiki&lgpassword=gjnlt&lgtoken=5ae555656110dd20a2b0504e4d7e35e0"; // login $result=call($data); // session id function call($data=null) { $ch = curl_init('http://192.168.1.32/eb_new/mediawiki/api.php?format=json'); curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_httpheader, array( 'accept: application/json', 'content-length: ' . strlen($data)) ); $result = curl_exec($ch); return $result=json_decode($result); } the response got . {"login":{"result":"success","lguser

How can we move linux process to different memory area than one it is created -

here requirement 1 of project. need move entire linux process different memory location after process creation. quite confused start either @ end of dofork in fork.c or somewhere else. , thinking process still work same way if moved other memory location. expecting task. thanks

Ansible docker module missing CP command? -

the docker client offers cp sub-command explained here , handy when 1 needs copy file container (note: analogous dockerfile add instruction in image building). in docker 1.8 cp command has been expanded bit. however, reading ansible docker module documentation , appears missing? here 2 questions: did misunderstand ansible documentation? if ansible missing cp thing, has found workaround? can think of using ansible copy module transport files remote machine first, , run there native docker client cp , ideally ansible's docker module have done in single shot part of docker module? thanks in advance. you can use synchronize command ~ examples provided in link: http://opensolitude.com/2015/05/26/building-docker-images-with-ansible.html