Posts

Showing posts from June, 2011

postgresql - PostgresSQL - Loop through daily Select statement for end of month reporting -

postgresql 9.4.5 the following select statement run every night @ 11:55 pm. want run monthly query (or function) loops through following query based on hard-coded start_date , end_date. query must process results on day-by-day basis. want see how many lost sheep have in given month. purpose: lost sheep- looking users attempt login mysoftware , unsuccessful entire day. *the ip address compared against other login attempts may successful rest of day. in event of login failure, query should ip address , verify no successful logins happened same ip address within day. select distinct l.username, l.ip login l l.ip not in (select l.ip login l date_trunc('day', l."time") = current_date , l.succeeded = 'true') , date_trunc('day'

parse.com - Parse Cloud Code: beforeDelete not called for Installation on reinstallation -

i noticed @ point(?) parse update behavior of installations if user deletes app , reinstalls it, old installation associated device gets deleted. however, when parse delete old installation automatically, doesn't seem parse.cloud.beforedelete(parse.installation, function(request, response) {}) called. is there way trigger code either when installation deleted parse or upon reinstallation of app? (unsurprisingly, doesn't seem there's way detect when app in uninstalled.)

user interface - Qt Creator Application Output pane Stop button: "The program has unexpectedly finished." when running a simple QML app -

in qt creator, run dummy qml app simple following: import qtquick 2.0 item { } go application output pane. press stop button (a tiny red square). error message appear. following log: starting <path>/qtbase/bin/qmlscene... **the program has unexpectedly finished.** <path>/qtbase/bin/qmlscene crashed this bit confusing or misleading, no crash has been observed. contrast, not happen when qmlscene window closed clicking close (x) button, nor happen when running qmlscene using command line on terminal. i'm using qt 5.5.0 on linux ubuntu. appears happen other versions of qt. was designed way, or improved? thanks! i have dived qt creator source code. when stop button clicked, function applicationlauncher::stop() called. function tries kill or terminate process qmlscene , leading above-mentioned messages. so stop means "kill" or "terminate" process. it if label renamed accordingly.

Azure: connecting to a Windows VM from Linux -

i using azure create windows vm. able create vms, able see port 3389 open unable connect using rdesktop . $ rdesktop 40.xx.xx.xx error: recv: connection reset peer the server created following urn: microsoftwindowsserver:windowsserver:2012-r2-datacenter:4.0.20150916 any idea how connect windows server in azure after have created vm ? edit: installations must performed automated , using xplat create vm: azure vm quick-create testrgcentral testvm westus windows microsoftwindowsserver:windowsserver:2012-r2-datacenter:4.0.20150916 username mysafepassword i can confirm port open scanning nmap nmap 40.xxx.xxx.xxx -pn if have made vm using "quick create" option, won't have port 3389 remote desktop endpoint security point of view. go "virtual machines", select vm, "endpoints" -remote desktop - port listed here "public port" port @ rdp should working, port mapped private port 3389 (which usual rdp port)

mysql - How to limit the query pattern in Tableau -

all, i using tableau 9.0 data analysis , want other users run permitted pattern of queries. how configure tableau run special pattern of queries? use template regex or custom sql query that? e.g. have 1 table named 't1', fields '_id', 'name', 'age','grade'.. want other users run queries contains field '_id', such 'select name t1 id=1;', 'select count(*) t1 group _id;', 'select grade t1 _id in (1, 2, 3)...' thanks in advance. the filtering capabilities in tableau focused on contents of data, rather query (indeed, tableau modeled you're abstracted away underlying queries in cases). can used data source filters define permitted records users can use, enforcing security restrictions on data retrieval. being said, i've found it's easier/more robust provide filtering within upstream data repository (rbac in ms-sql, instance). here's section on data source filtering. http://onlinehelp

mysql - adding columns with alter table error -

ok i'm trying add these columns table says have syntax error, please let me know whats wrong alter table equipomulti add marca varchar(45) null , serie varchar(45) null , modelo varchar(45) null , fechaad date null , costo double null , observacion varchar(500) null ; i believe need wrap multiple columns in parens, try: alter table equipomulti add (marca varchar(45), serie varchar(45), modelo varchar(45), fechaad date, costo double, observacion varchar(500)) ;

gulp - How to deal with dependencies when deploying a node.js app? -

i'm setting gulp build file node.js project , don't have experience either of them. so i'm doing copying code deployment directory, i'm unsure of how handle dependencies stored in node_modules . copy of them well, or there more preferred way of doing it? gulp.task('deliver', function() { gulp.src('src/*.html').pipe(gulp.dest('deployment/')); gulp.src('src/*.js').pipe(gulp.dest('deployment/')); gulp.src('src/games/').pipe(gulp.dest('deployment/')); }); the standard way have package.json file lists dependencies. part of deployment process run npm install go through package.json , install necessary packages in node_modules folder.

c# - ASP.Net MySqlDatabase Null Value -

i have below code in asp.net web forms page c#, protected void page_load(object sender, eventargs e) { conn.open(); string selecttruckquery = "select * truck truck_id='" + truckid + "'"; mysqlcommand cmd = new mysqlcommand(selecttruckquery, conn); foreach (dbdatarecord rowdata in cmd.executereader()) { if (!rowdata.isdbnull(rowdata.getordinal("truck_id"))) idno.text = rowdata.getstring(rowdata.getordinal("truck_id")); if (!rowdata.isdbnull(rowdata.getordinal("registration_no"))) registrationno.text = rowdata.getstring(rowdata.getordinal("registration_no")); if (!rowdata.isdbnull(rowdata.getordinal("make"))) tmake.text = rowdata.getstring(rowdata.getordinal("make")); if (!rowdata.isdbnull(rowdata.geto

javascript - React-redux store updates but React does not -

bear me here question pertains first test app using either react, redux or react-redux. docs have gotten me far , have mock banking app works. state object looks this: { activepageid: "checking", accounts: [ checking: { balance: 123, transactions: [ {date, amount, description, balance} ] } ] } i have 2 actions: 1. change_hash (as in url hash). action works expected , reducer update state.activepageid (yes, i'm cloning state object , not modifying it). after action, can see state has changed in redux store , can see react has updated. function changehash(id) { return { type: "change_hash", id: id } } 2. add_transaction (form submission). action never updates react, updates redux store. reducer action updating state.accounts[0].balance , it's adding transaction object array state.accounts[0].transactions. don't receive errors, react doesn't update. however, if dispatch cha

ios - How to change value of variable inside of Void function? -

i have function public func lastactivityfor(username: string) -> string { var lastseeninfo = "date" onelastactivity.sendlastactivityquerytojid((username), sender: onechat.sharedinstance.xmpplastactivity) { (response, forjid, error) -> void in if let timeinseconds = response?.lastactivityseconds() { let time: nsnumber = nsnumber(unsignedlong: timeinseconds) switch timeinseconds { case 0: lastseeninfo = "online" case _ timeinseconds > 0 && timeinseconds < 60: lastseeninfo = "last seen \(timeinseconds) seconds ago" case _ timeinseconds > 59 && timeinseconds < 3600: lastseeninfo = "last seen \(timeinseconds / 60) minutes ago" case _ timeinseconds > 3599 && timeinseconds < 86400: lastseeninfo = "last seen \(timeinseconds / 3600) hours ago&quo

c# - How to select from List of KeyValuePair? -

i have list of keyvaluepair (key string type , value int type). , want return key value pair list matching criteria example : return list key = "a" , value = 10. how select work on , how write expression required result ? you can use linq expression so: ilist<keyvaluepair<string, int>> values = new list<keyvaluepair<string, int>>(); add key values. ilist<keyvaluepair<string, int>> result = values.where(v => v.key == "a" && v.value == 10).tolist();

regex - Regular Expression to replace sub string in last parenthisis to strings between trignometric fun and first right closing parenthesis in Javascript -

i have string pow((sin),(2))(4*x+5)+pow((cos),(3))(4*x+3)/pow((tan),(5))(x) i need as pow(sin(4*x+5),2)+pow(cos(4*x+3),3)/pow(tan(x),5) what tried was 1)split expression based on operators(+,-,/,*) between pow single units. 2)extract expression between last parenthisis 3)insert extracted subexpression between first string after pow , first closing parenthis units. what tried :- re="pow((sin),(2))(4*x+5)+pow((cos),(3))(4*x+3)+pow((tan),(5))(x)"; re.split(+); re.replaceall("^[()]]{3}","\\(\\)]*\\)"); to frank new regular expression. you can use following regex , replacement string: edited regular expression : ([a-z]+)\(\(([a-z]+)\),\(([0-9]+)\)\)\(([a-z0-9\*\+]+)\)([\*\-%\/+]*) replacement expression : $1($2($4),($3))$5 check following code: function cal() { var string = "pow((sin),(2))(4*x+5)+pow((cos),(3))(4*x+3)/pow((tan),(5))(x)"; var regex = /([a-z]+)\(\(([a-z]+)\),\(([0-9]+)\)\)\

Notify user about location updates automatically android -

i'm trying android hive's tutorial understand how track location of user , show them places nearby. want notify user location change , redirect them first screen of app. have tried calling class contains notification code onlocationchanged method, shows null pointer exception @ pendingintent.getactivity().i have added permissions in manifest file here's code: gpstracker.java: this file contain onlocationchanged i'm trying call shownotif(). public class gpstracker extends service implements locationlistener { private final context mcontext; notif n = new notif(); // flag gps status boolean isgpsenabled = false; // flag network status boolean isnetworkenabled = false; // flag gps status boolean cangetlocation = false; location location = null; // location double latitude; // latitude double longitude; // longitude // minimum distance change updates in meters private static final long min_distance_change_for_updates = 0; // minimum time between updates

javascript - Using jquery to submit one form on page that shares element names with other forms -

to give basic view of question, i'm trying create page similar how facebook , twitter's dashboards , comment systems work. have 1 page continuously create form elements (posts) database rows in loop user scrolls down. users able comment on each of these posts. want able use ajax submit comments on each post individually without reloading page. i run problem when try submit comment on form other first 1 loaded on page. in addition ajax posts first form elements on submit (due each form , elements having same name i'm guessing). below comment loading script: [forgive old php, know need update mysqli or pdo] php <?php ... $query = mysql_query("select * `posts`"); while ($row = mysql_fetch_array($query)) { echo " <div name='comment_body'> <form name='comment_form'> <td>user: ".$row['user']."</td> <td>post: ".$row['post']."</td> <textarea name='

android - Chromecast custom selector dialog -

Image
is there way make custom chromecast selector dialog? have been looking through documentation , can't find on how this. you can that: first, extend mediaroutechooserdialogfragment , , call that, say, mychooserdialogfragment . next, extend mediaroutedialogfactory (call that, say, mymediaroutedialogfactory) , override method oncreatechooserdialogfragment() . in there, need return instance of mychooserdialogfragment : public mediaroutechooserdialogfragment oncreatechooserdialogfragment() { return new mychooserdialogfragment(); } finally, set factory on action provider: mediarouteactionprovider.setdialogfactory(new mymediaroutedialogfactory());

javascript - How to make angular child scopes refresh? -

i have template: <div class="oss-object cp-def cp-row" ng-repeat="(key, value) in data" ng-init="viewables = getviewables(value.versions[0].objectinfo);"> <div class="cp-def"> {{value.info.name}} ossstatus: {{value.versions[0].objectinfo.status}} , 3d-viewables: <select ng-change="viewableselected(value.versions[0].urn, viewables, '3d')" ng-model="viewables.selected3d" ng-options="viewable viewable.name viewable in viewables['3d']"> <option value="">---please select---</option> </select> , 2d-viewables: <select ng-change="viewableselected(value.versions[0].urn, viewables, '2d')" ng-model="viewables.selected2d" ng-options="viewable viewable.name viewable in viewables['2d']">

python - return a new list from a list stopped at certain location -

i can't code make work life of me. in exercise function receive 1 parameter, list of strings. function make , return new list includes copies of strings parameter to, not including string kahn . kahn in list. expected result: words_up_to_kahn(["kirk", "spock", "luke", "charlie", "kahn", "bob"]) -> ["kirk", "spock", "luke", "charlie"] words_up_to_kahn(["ernie", "kahn", "bert", "teal'c"]) -> ["ernie"] examples: this? return words[0:kahn] or this: def words_up_to_kahn(words): new = "" c = 0 while words[c] != "kahn": new = new + words[c] c = c + 1 return new or else? this simplest solution believe. conditional statements , .index("kahn") friends: def up_to_kahn(lst): return lst if ("kahn" not in lst) else lst

php - Email sending is failed in Opencart using Gmail -

Image
email sending failed in opencart. while add order history admin, have send order status customer. when click add history button, following error alert. error.password not accepted server! my mail settings is: in cases mail not sending me. please me ...how can make working.. opencart version 2.0.3.1 finally got solution: allowing less secure apps access account solve problem. login account, @ link https://www.google.com/settings/security/lesssecureapps and choose turn on .

c# - how can I convert this foreach loop to linq? -

i'm new linq. want convert these lines of code linq lambda expression, if makes sense how can achieve? foreach (var type in essay.text) { string text = $"{"here result"}\n{method(type)}"; if (text.length <= 20 && !string.isnullorempty(method(type))) { essay.total += text; } } with of resharper : essay.total = string.concat( essay.text.select(type => new {type, text = $"{"here result"}\n{method(type)}"}) .where(@t => @t.text.length <= 20 && !string.isnullorempty(method(@t.type))) .select(@t => @t.text) );

Unpack nested tuple in Swift closure -

if have: let array = [(1, 2)] you can do: array.map({ first, second in ... }) what if have: let array = [((1, 2), (3, 4))] how can unpacked? array.map({ (first, second), (third, fourth) in ... }) array.map({ ((first, second), (third, fourth)) in ... }) neither of these compile. this works but's it's not pretty let array = [((1, 2), (3, 4))] array.map({ a, b in return a.0 + a.1 + b.0 + b.1 }) this might little bit better it's still nested let array = [((1, 2), (3, 4))] array.map({ (a:(first:int, second:int), b:(first:int, second:int)) in return a.first + a.second + b.first + b.second }) you use map reduce them tuple , assign values array.map{($0.0,$0.1,$1.0,$1.1)}.map { (first:int, second:int, third:int, forth:int) in }

How to display a json array in a textbox using c# -

i know how deserialize json array , display on richtextbox. i'm calling api json array. can me out this. have got list i'm not sure whether i've done properly. form1.cs private void btnstart_click(object sender, eventargs e) { runapi("http://localhost:8080/json_coordinates"); } public void runapi(string api) { try { webrequest request = webrequest.create(api); httpwebresponse response = (httpwebresponse)request.getresponse(); stream datastream = response.getresponsestream(); streamreader reader = new streamreader(datastream); string json = reader.readtoend(); obj.deserializejsondes(json); // me fill display data on richtextbox //richtextbox1.text = responsefromserver; reader.close(); datastream.close(); response.close(); } catch (exception ex) {

ruby on rails - Error occurred while parsing request parameters JSON::ParserError - 795: unexpected token at -

i trying write api methods user sign on spree app. it's working on local machine not on server. here code of user_decorator_controller.rb def sign_up @user = spree::user.find_by_email(params[:user][:email]) if @user.present? render "spree/api/users/user_exists", :status => 401 , return end @user = spree::user.new(user_params) if !@user.save unauthorized return end @user.generate_spree_api_key! end and sign_up.v1.rabl object @user attributes :id, :spree_api_key, :email, :firstname, :lastname, :mobile child(:bill_address => :bill_address) extends "spree/api/addresses/show" end child(:ship_address => :ship_address) extends "spree/api/addresses/show" end when curl server below request curl -v -h 'content-type: application/json' -h 'accept: application/json' -x post -d {"user":{"email":"ml5698

qml - Adjust application resolution for mobile screens -

hello have tried adjust qml app mobile screens. have main screen consists of tab s in tabview : import qtquick 2.5 import qtquick.window 2.1 import qtquick.layouts 1.1 import qtquick.controls 1.1 import qtquick.controls.styles 1.4 tabview { tab{ id: tab1 component: qt.createcomponent("qrc:///loginscreen.qml")} tab{ id: tab1 component: qt.createcomponent("qrc:///afterlogged.qml")}}` in loginscreen.qml in have button s, label s, textfield s data: import qtquick 2.5 import qtquick.window 2.1 import qtquick.layouts 1.1 import qtquick.controls 1.1 import qtquick.controls.styles 1.4 item { label { id: ipaddresslabel text: qstr("address ip:") textfield { id: iptextfield placeholdertext: qstr("insert ip address") button { id: loginbtn onclicked: { connecttoapp(iptextfield.text)}} } how resize app screen on basis of specific mobile screen resolution/density? ju

wordpress - Change post url -

i have web page has blog. has static home page, , can access menu using top menu. when visit site, looks like: www.mysite.com when go blog, looks like: www.mysite.com/blog but when visit post, looks like: www.mysite.com/my-post-name.html and want look: www.mysite.com/blog/my-post-name.html how can achieve this? there way without plugins? or maybe, plugin won't crash anything? thank you! you change in permalink settings : in "custom structure", enter /blog/%postname%/ (or /blog/%postname%.html ).

javascript - ZeroClipboard issue -

i trying copy link of current page using zeroclipboard , don't know further. code until now. how can copy link? function copylink() { document.getelementbyid("copy").value += window.location.href; var link = document.getelementbyid("copy").value; var client = new zeroclipboard(); client.settext(link); } <script src="https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/zeroclipboard.core.min.js"></script> <html> <head> <title>copy</title> </head> <body> <div> <button id="copybtn" onclick="copylink()">copy link</button> <textarea id="copy" style="display: none;"></textarea> </div> </body> </html> thanks !

json - How to access the body after a get request() in nodeJs -

i have tried use json.parse , request.on modules none of examples have seen has helped me much. can send me example of accessing "body" create array (parsing json)? i'm newbie in nodejs. thank in advance! var request = require("request"); var options = { method: 'get', url: 'url credentials , filter', }; request(options, function (error, response, body) { if (error) throw new error(error); console.log(body); });

Set different multiple values to different multiple text boxes using Jquery -

i creating script in admin can add charge domestic regions , can add charge international regions. scenario :- admin clicks add charge button. there can add charge,cost , delivery days. want set value of charge text boxes having name = delivery_charge[<?php echo $addindex; ?>][charge] , set value of cost text boxes having name=delivery_charge[<?php echo $addindex; ?>][cost] , set value of delivery_days text boxes having name=delivery_charge[<?php echo $addindex; ?>][days] . what i've done is function addcharges(type){ var cost = parsefloat($('#modal-cost').val()); var charge = parsefloat($('#modal-charge-box').val()); var days = parseint($('#modal-days').val()); if(isnan(cost)){ cost = 0; } if(isnan(charge)){ charge = 0; } if(isnan(days)){ days = 0; } if(type == 'domestic'){ $('.domesticzones :checkbox').prop("checked", true); $('.domesticzones input').prop("read

Java Annotation Processor, Processing Order -

i'm wondering if there way process annotations top down in class, or @ least in deterministic order. it doesn't seem case because processor class provides: boolean process(set<? extends typeelement> annotations, roundenvironment roundenv); where roundenvironment allows access set of annotated elements, e.g.: set<? extends element> getelementsannotatedwith(typeelement a) everything in terms of unordered collections, , makes order of processing unpredictable. there anyway around this, besides trying sort manually element name or something? as have discovered, there not way force processing of annotations in specified order, using current interfaces. here workaround. suppose wish process every declaration annotation, such annotations on fields , methods. don't register callback declarations. instead, invoke annotation processor every class. annotation processor obtains ast javac, walks in order prefer. example, checker framework

intellij idea - PHPStorm EAP update on Debian: java.io.IOException: No space left on device -

when start phpstorm, screen shows: platform , plugin updates when click on "update , restart", after few seconds screen pops up: no space left on device which silly because brand new computer , have lots of available space: ➜ ~ df -h filesystem size used avail use% mounted on /dev/sda2 6.3g 3.4g 2.6g 57% / udev 10m 0 10m 0% /dev tmpfs 3.2g 9.1m 3.2g 1% /run tmpfs 7.9g 55m 7.8g 1% /dev/shm tmpfs 5.0m 4.0k 5.0m 1% /run/lock tmpfs 7.9g 0 7.9g 0% /sys/fs/cgroup /dev/sda3 2.7g 364m 2.2g 15% /var /dev/sda1 511m 132k 511m 1% /boot/efi /dev/sda6 195g 4.7g 181g 3% /home /dev/sda5 361m 7.4m 331m 3% /tmp tmpfs 1.6g 16k 1.6g 1% /run/user/1000 ➜ ~ df -h /tmp filesystem size used avail use% mounted on /dev/sda5 361m 7.4m 331m 3% /tmp here versions, reference: phpstorm ps-143.129 debian gnu/linux 8 (jessie

c++ - How to get all possible matches of std::regex -

i find possible matches of regex, how possible? regex rx("(2|25)"); string s = "2225"; (sregex_iterator it(s.begin(), s.end(), rx), end; != end; ++it) { cout << it->position() << ": " << it->str() << endl; } gives output: 0: 2 1: 2 2: 25 but can't find third 2: 2 exactly. prefer use regex because of o(n) complexity searching several tokens @ same time. update: maybe split token list non-prefixable lists , create several regexes? example: (2|4|25|45|251|455|267) => (2|4) , (25|45|267) , (251|455) grow complexity o(n log(m)) update 2: please, provide short stl-based algorithm of splitting token vector non-prefixable vectors answer question. i dont think it's possible iterator , single regexp. here's how works. your regexp searches substring either "2" or "25". now, start search sregex_iterator . starts first symbol of string, , tries find match regular ex

javascript - Allow only html break tag with regex -

i have following preg_match statment in php: if(!preg_match("/^[a-za-z\d '-^\",.!?]+$/", $cont)){ //do } in addition want allow br tags no other html tags, how can that? also done same way js? var ccheck = /^[0-9a-za-z '-^\",.!?]+$/; if(!cont.match(ccheck)){ //do }

SQL Server: Sum values from multiple rows into one row -

i trying sum values multiple rows. example: my output is: id value --------- 1 3 1 4 what see is: id value --------- 1 7 this code: select id case sum(cast(value float)) when 0 [other_value] else isnull([value] ,'') end 'value' table1 id = 1 group id i saw solutions online such had include group by in order avoid error: is invalid in select list because not contained in either aggregate function or group clause but, still no sum. note: values varchar , therefore, need cast you trying sum string (even if cast it) query work if isnull goes 0 or numeric value select id, sum(case when cast(value float) = 0 cast([other_value] float) else isnull([value], 0) end) 'value' table1 id = 1 group id

java - Unable to unit test - Unitils, Hibernate -

i'm trying setup unit test application, i'd test unitils datasets, far i'm encountered many problems. i'm convinced have wrong setup can review problems. i have hibernate.cfg.xml <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- database connection settings --> <property name="hibernate.dialect">org.hibernate.dialect.hsqldialect</property> <property name="hibernate.connection.driver_class">org.hsqldb.jdbc.jdbcdriver</property> <property name="hibernate.connection.url">jdbc:hsqldb:mem:testdb</property> <!--<property name="hibernate.hbm2ddl.auto">create</property>--&g

VB6 application vs Java 8u60 for Serial Communication -

i writing java application replace vb6 application. application has poll remote system using 10 byte binary protocol, response 10 byte binary message last byte checksum calculated summing previous bytes. the problem i'm experiencing high number of errors in java application checksum doesn't match. the results quite repeatable. vb6 application has virtually no errors, java application has lots. i've checked port settings, same 19200,n,8,1. in vb6 port set-up serial port set-up follows: cdtimeout = 0 commport = 1 ctstimeout = 0 dsrtimeout = 0 dtrenable = false eofenable = false handshaking = none inbuffercount = 0 inbuffersize = 1024 index = 0 inputlen = 0 inputmode = cominputmodebinary interval = 1000 name = "cominterfaceunit" nulldiscard = false outbuffersize = 512 parityreplace = "?" rthreshold = 10 rtsenable = false settings = "19200,n,8,1" sthr

javascript - Prevent loader from disappearing before all data is retrieved from service angularjs -

i using angularjs ui-router transition state state , loader attached each view. problem when transitioning 1 state , loader initiated, loader disappears before contents web service pulled in , other requests completed.this first time trying implement angularjs's ui-router. i have tried use: app.run(function($rootscope,$cookies){ // fired when transition begins. $rootscope.$on('$statechangestart',function(e, tostate, toparams, fromstate, fromparams){ $rootscope.loading = true; }); // fired once state transition complete $rootscope.$on('$statechangesuccess',function(e, tostate, toparams, fromstate, fromparams){ $rootscope.loading = false; }); }); i have tried utilize resolve method: ... .state('loan-new',{ url: '/loan-new/:id', templateurl: base_url+'js/pages/loan-new.html', controller: 'loancontroller', resolve: { loannew: function($q, client, $stateparams, $http) { var def

javascript - How to push from forEach in prototype to array in constructor? -

this question has answer here: how access correct `this` inside callback? 6 answers if have global array this var arr = [value1, value2...]; i got construcotor this function myfunction() { this.array = []; this.toarray(); } and prototype method this myfunction.prototype.toarray = function() { arr.foreach(function() { if (statement) { // how can if here, want push current value, array in cunstructor function? } }); } as comment says, if comment is, want push current value in foreach function array in constructor function? tried this.array.push(); realized cant use since refers arr array. edit if don't var = this in snippet above can : myfunction.prototype.toarray = function(arr) { arr.foreach((function(item) { if (item%2 ===0) { this.array.push(item); } }).bind(thi

c# - Can I use something else instead of "this" in this code? -

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace event_training { class publisher { public event eventhandler x; public void raise() { x(this, null); } } class subscriber { public void method1(object o, eventargs e) { console.writeline("metod1 called"); } public void method2(object o, eventargs e) { console.writeline("metod2 called"); } } class program { static void main(string[] args) { publisher p = new publisher(); subscriber s = new subscriber(); p.x += s.method1; p.x += s.method2; p.raise(); } } } having hard time understrand "this" keyword. refer "x(this, null);" in here? can use else instead of "this"?

dplyr - Best practices to comment R pipeline %>% -

when writing long pipelines r , dplyr/tidyr, has found way add comments? i know function syntax pretty expressive, multiple actions "grouped" , wonder if better break whole thing in multiple pipelines comments between them or if there way nicely format comments within pipeline. not answer, long comment-- i put comments in between commands in pipe. example: object %>% command1 %>% #* comment command2 %>% command3 %>% #* perhaps #* long #* comment command4 the key, me, indenting comment same level code discusses can visualize part of single block.

ios - UITableView dynamic height cannot satisfy constraints -

i'm trying use autolayout dynamically determine height of table cells using tutorial http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout the problem is, i'm getting these weird automatic constraints set dimensions simulated metrics of custom cell. have done lot of autolayout, , thought simulated metrics weren't supposed affect actual app @ runtime. did change in new sdk? anyway, here method i've been messing with... - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { static jmsocialfeedtableviewcell *sizingcell = nil; static dispatch_once_t oncetoken; dispatch_once(&oncetoken, ^{ sizingcell = [self.tableview dequeuereusablecellwithidentifier:@"cell"]; }); [self configurecell:sizingcell forindexpath:indexpath]; //[sizingcell.contentview addconstraint:[nslayoutconstraint constraintwith

android - PUSH: Unable to get GCM project number, run "ionic config set gcm_key your-gcm-id" -

i cannot send push notifications android. updated latest ionic cli updated latest ionic lib after did: ionic config build and ionic prepare android my io-config.json has {"app_id":"01e6d3ad","api_key":"some_secret_key","gcm_key":"142738311658"} i've made ionic config set gcm_key your-gcm-id several time , replaced 'your-gcm-id' project id. but still message: push: unable gcm project number, run "ionic config set gcm_key your-gcm-id" and when try register ionic notification get: $ionicpush:register_error org.json.jsonobject$1 cannot cast java.lang.string following ionic documentation android, must run command: ionic config set gcm_key <your-gcm-project-number> in order add projectnumber .io-config.json

reflection - How to obtain a class object of a parameterized class in java -

i trying this:- public interface parseable { string execute(); } public interface adaptable<p> { string execute(); } public class parser1 implements parseable{ @override public string execute() { return "parser1"; } } public class parser2 implements parseable{ @override public string execute() { return "parser2"; } } public class adapter1<p extends parseable> implements adaptable<p>{ private p p; public adapter1(class<parseable> clazz){ try { p=(p) clazz.newinstance(); } catch (instantiationexception ex) { logger.getlogger(adapter1.class.getname()).log(level.severe, null, ex); } catch (illegalaccessexception ex) { logger.getlogger(adapter1.class.getname()).log(level.severe, null, ex); } } @override public string execute() { return "adapter1 "+p.execute(); } } public class ad

html - Divs jitter when hovering between them quickly -

i have following html code: <div class="project"> <h3 class="black product">dash</h3> <a href="#" class="black hide">view project</a> </div> <div class="project"> <h3 class="black product">5/3/1</h3> <a href="#" class="black hide">view project</a> </div> and following css code: .hide { display: none; } div.project:hover h3{ line-height: 200px; } div.project:hover .hide { display: inline-block; } div.project { display: inline-block; position: relative; overflow: hidden; width: 300px; height: 300px; border: 2px solid #222; margin: 0px 20px 20px 20px; } h3.product { font-size: 24px; line-height: 300px;} which 2 div buttons side side. when hover on each div product title moves , "view product" text appears. however when hover between 2 divs "jitter"

sql - How to use DataAdapter to call a stored procedure in C# with variable parameters -

i calling following code in c# fill dataadapter given stored procedure "sp1_name" . problem want call different stored procedures different parameters. (all sp's select) let's suppose stored procedure name "sp_somesp" , works fine. let's suppose stored procedure name "sp_somesp @month= 10, @year = 2010" , doesn't work. throws exception cannot find stored procedure. any solutions? thanks! //first connection - sp1 using (sqlconnection con = new sqlconnection(constr)) { using (sqlcommand cmd = new sqlcommand(sp1_name, con)) //sp1_name = name + parameters { cmd.commandtimeout = 3600; cmd.commandtype = commandtype.storedprocedure; using (sqldataadapter dataadapter = new sqldataadapter(cmd)) { dataadapter.fill(results2); } } } first issue: parameters in stored procedure shouldn't in

javascript - Jquery - Animate by scroll positions to work the same on window resize -

hey have annoying issue thats got simple solution life of me cant find away fix it. basically have 2 images both 50% of it's container goal both images slide in (left/right) on basis of scroll position , once top of container both images sit place. now got working point issue when resize page position of both images wrong. did resize() function same logic scroll() function still got nowhere. here's code var page_width = $(document).outerwidth(), page_height = $(document).outerheight(), left_image = $('.split-screen.youth'), right_image = $('.split-screen.elite'), offset = (page_width) / page_height; left_image.css({'left':'0px'}); right_image.css({'right':'0px'}); $(window).on('scroll', null, function(){ var scrolltop = $(window).scrolltop(), calc = -(scrolltop*offset); left_image

Java: append to JTextPanel not working inside ActionListener -

i working on program work queries logs , posts results in textarea box. can append box outside action listener search, not within. i have added system out lines append text , shows being received not posting. internal frame. any pointing me fixing appreciated. package net.fedson; import javax.swing.*; import java.awt.*; class searchframe { private textpanel textpanel; private formpanel formpanel; private string user; private string password; private string logs; public jinternalframe searchframe() { jinternalframe mboxframe = new jinternalframe("search", true, true, true, true); mboxframe.setlayout(new borderlayout()); textpanel = new textpanel(); //btn = new btnpanel(); //toolbar = new toolbar(); formpanel = new formpanel(); formpanel.setformlistener(new formlistener() { @override public void formeventoccured(formevent e) { string email = e.getemail(); string = e.getextra();

Asynchronous JSON Requests in Python -

i'm using api doing http requests return json. calling of api, however, depends on start , end page indicated, such this: def api_request(url): while(true): try: response = requests.get(url) data = response.json() return(data['data']) except exception apierror: print(apierror) continue break def build_orglist(start_page, end_page): apilink = ("http://sc-api.com/?api_source=live&system=organizations&action=" "all_organizations&source=rsi&start_page={0}&end_page={1}&items_" "per_page=500&sort_method=&sort_direction=ascending&expedite=1&f" "ormat=json".format(start_page, end_page)) return(api_request(apilink)) the way know if you're not longer @ existing page when json null, this . if wanted multiple build_orglist going on every single page asyn

java - jaspertreport v.6.1.1: font extension not working for international language -

i'm new jasper report. i'm trying display thai characters in pdf using font extensions reason characters not displayed. i've researched on issue , followed official documentation ( http://jasperreports.sourceforge.net/sample.reference/fonts/ ) didn't work. i use tibco jaspersoft studio design , displayed correctly when preview design via jaspersoft studio. however, when applied generated jrxml file java code thai characters not displayed in pdf file. tried in html file , worked fine. following official documentation generate pdf, i'm recommended export jar file containing ttf files, jasperreports_extension.properties , fonts.xml files. please @ code snippets fontsfamily1445966397265.xml <?xml version="1.0" encoding="utf-8"?> <fontfamilies> <fontfamily name="tahoma"> <normal>fonts/tahoma/tahoma.ttf</normal> <bold>fonts/tahoma/tahomabd.ttf</bold> <pdfencoding>iden