Posts

Showing posts from February, 2012

javascript - Angular $httpBackend.expectGET - respond with 409 status & custom statusText -

trying create $httpbackend.expectget in unit test return status of 409 , custom statustext of 'testphrase'. looking @ angular docs ( https://docs.angularjs.org/api/ngmock/service/$httpbackend ) gives following example of returned: {function([status,] data[, headers, statustext]) | function(function(method, url, data, headers)} having trouble understanding how interpret above example. my current code is: $httpbackend .expectget('/example/url') .respond(function () { return ['409', ['testphrase'], {}]; }); the code i'm testing is: $http.get('/example/url').then(function (response) { console.log('success, status ' + response.status); console.log('success, statustext ' + response.statustext); }, function(response) { console.log('error, status ' + response.status); console.log('error, statustext ' + response.statustext); ...

android - Make bounce animation -

i bounce animation of layer. i have done layer comes right center, move little , center. create bounce effect. i thinking can translate this: <translate android:duration="900" android:fromxdelta="100%p" android:toxdelta="0%p" /> <translate android:duration="900" android:fromxdelta="0%p" android:toxdelta="100%p" /> <translate android:duration="900" android:fromxdelta="70%p" android:toxdelta="0%p" /> well code not working, thing can achieve layer comes left center, , animation stops. i can not use code: because not achieve want setinterpolator(animationutils.loadinterpolator(this, android.r.anim.bounce_interpolator)); any appreciated. you can use bounceinterpolator have effect. docs contain description how use in xml. have animation xml this: <?xml version="1.0" encoding=...

Groovy -- What is the difference between this and owner -

according this this , owner seem have same meaning. reading further find owner can refer enclosing class or closure. difference? if so, why reserve entire word that? this refers enclosing class instance. owner refers directly enclosing object, may or may not enclosing class instance. example: def x = { def y = { println this; println owner }; y() } x() here this refers instance of script class, , owner refers x .

javascript - .bind paste (ctrl+v) handler in jQuery -

this works great in chrome: $('body').bind({ paste : function() { if(!$('input, textarea').is(':focus')) { alert('you used ctrl/cmd + v'); } } }); however doesn't seem work in firefox esr (haven't tested latest version). adjustments need made? jsfiddle

maven - mavenize eclipse wtp project (Dynamic web module) for openshift -

managed publish project in openshift - scp 'ing war correct location detailed here . here .project file: <?xml version="1.0" encoding="utf-8"?> <projectdescription> <name>datacollectionservlet</name> <comment></comment> <projects></projects> <buildspec> <buildcommand> <name>org.eclipse.wst.jsdt.core.javascriptvalidator</name> <arguments></arguments> </buildcommand> <buildcommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments></arguments> </buildcommand> <buildcommand> <name>org.eclipse.wst.common.project.facet.core.builder</name> <arguments></arguments> </buildcommand> <buildcommand> <name>org.eclipse.wst.validation.vali...

node.js - Uninstalling bower installed with a different version of npm -

i have ubuntu 14.04 system. had installed npm , installed bower using sudo npm install -g bower some time after realized using node , npm came fromt ubuntu repositories, use latest one, added repository: $ sudo add-apt-repository ppa:chris-lea/node.js and update packages. now trying uninstall bower system, guess what? this: $ sudo npm remove -g bower npm warn uninstall not installed in /usr/lib/node_modules: "bower" so, wait, what? cant find bower? try make which bower and output here is: /usr/local/bin/bower i dont understand going on. suspect have problem different versions of npm , nodejs not playing nice together, since installed bower different version of npm 1 have installed now. idea of how uninstall bower now? (or @ least come clean state, can begin beginning?) sudo npm uninstall bower -g --prefix=/usr/local

html - limit td width that has span elements -

i've following code: <td> <span class='label label-success'>text1</span> <span class='label label-success'>text2</span> <span class='label label-success'>text3</span> <span class='label label-success'>text4</span> <span class='label label-success'>text5</span> </td> i want limit width of can line breaks between spans when max width reached, this: text1 text2 text3 text4 text5 assuming text4 exceeded max width. ideas? add table-layout:fixed table tag in css, add width of td want, this: html: <table> <td> <span class='label label-success'>text1</span> <span class='label label-success'>text2</span> <span class='label label-success'>text3</span> <span class='label label-success'>text4</span> <span class=...

python - Unable to plot worldmap with Vincent in iPython notebook -

this question related unable plot vincent in ipython , although think it's not same problem. i can plot bar chart using vincent 0.4.4 in ipython 0.13.1 notebook in following example (found in docs ): import vincent vincent.core.initialize_notebook() bar = vincent.bar(multi_iter1['y1']) bar.axis_titles(x='index', y='value') bar.display() however, i'm unable same thing worldmap representation in data mapping example : import vincent geo_data = [{'name': 'countries', 'url': world_topo, 'feature': 'world-countries'}] vis = vincent.map(geo_data=geo_data, scale=200) vis.to_json('vega.json') i've replaced value 'world_topo' path topojson file (world-countries.topo.json) downloaded here . no errors shown , nothing happens. i'm not using https, way. simplest map chart example, guess should work smoothly... any ideas? following webpage of vincent...

datastep - SAS - Compare observation to previous observations? -

i have following data: acct date 11111 01/01/2014 11111 01/01/2014 11111 02/02/2014 22222 01/01/2014 22222 01/01/2014 33333 01/01/2013 33333 03/03/2014 44444 01/01/2014 44444 01/01/2014 44444 01/01/2014 what best way accomplish following in sas? want compare dates each acct number , return records accts there @ least 1 date doesn't match. so dataset above, want end following: acct date 11111 01/01/2014 11111 01/01/2014 11111 02/02/2014 33333 01/01/2013 33333 03/03/2014 something work. sort data acct/date if not already, check each last.date row. if first last.date row not last.acct , set of rows respondent needs output. here output 1 row per date/acct combination: data want; set have; acct date; if (last.date) , not (last.acct) do; flg=1; output; end; else if last.date , flg=1 output; else if first.acct flg=0; run; if need rows, need either take ...

angularjs - How to correctly manage fonts with bower / grunt -

on project added bower.json projects use fonts: fontawesome bootstrap roboto-fontface grunt file generated "yo angular" custom edits. fonts work fine in "grunt serve" development mode don't work when dist build "grunt". the problem fonts aren't copied dist folder. fix manually changed gruntfile copy:dist fonts. this: { expand: true, cwd: "<%= yeoman.app %>/bower_components/bootstrap/dist/fonts", dest: "<%= yeoman.dist %>/fonts", src: ["*.*"] } my problem libraries css expect fonts on specific folder ( roboto-fontface , bootstrap example expect font in different folders). so i'll have change gruntfile replace fonts reference on *.css files target right paths. don't know yet how main itch seems "hacky" bower works css files: automatically added index.html , href correctly replaced when doing dist build. example can upgrade ng-grid project without problem...

android - ImageViews in a ScrollView causing lag -

i have problem application creating android. known problem imageview s? should use other scrollview ? there kind of caching should do? looked around , there seems lot of solutions listview , none scrollview . first create bitmap of image , make it's memory smaller using these methods below setsize bitmapfactory.options samplesize after that, add bitmap imageview also see displaying bitmaps efficiently .

wordpress - jquery swap variable images -

i using wordpress , acf create image gallery when user hovers on image swaps image that's in database. can't seem swap original image. i'm receiving error: bkgd_bl not defined html <li class="carousel-img" data-alt-src="<?php the_sub_field('carousel_image_hover');?>" style="background-image:url( <?php the_sub_field('carousel_image');?> )" > jquery jquery(document).ready(function(e) { jquery('#carousel li').hover(function() { var bkgd = "url('" + jquery(this).attr('data-alt-src') + "')"; var bkgd_bl = jquery(this).css('background-image'); jquery(this).css("background-image", bkgd); //alert(bkgd_bl); }, function() { jquery(this).css("background-image", bkgd_bl); }); }); the bkgd_bl local function; move out below : jquery(document).ready(function(e)...

Random error 80020009 accesing an Access 2000 database from a classic asp webpage -

i running query classic asp webpage microsoft access 2000 database table return query of names , perform calculation. database has been running years, , queries in past have been succesful. of sudden past few months, of names , calculations displayed, following error appears: error 80020009. on bottom of displayed query, person's name displayed, calculation field not displayed; blank. calculation feild using count option in classic asp, , text data type in microsoft access. error message never appeared until last few months, strange. able find records in microsoft access table (in development environment) causing errors specific month, don't want have delete records in production environment. if run sql query in microsoft access, of records in given month in table (where issues apepars) fine, , no errors appear. have exported , imported access table, 8002009 error still appears. has experienced issue this? sound classic asp coding issue, or issue microsoft access 2000 dat...

svn - NuGet Versioning Auto Increment Pre-Release -

we have 3 hosted source control management repositories (subversion) , 3 nuget repositories each environment: development qa trunk code: library x (version 1.0.0) application a i have set-up post build event on library x create nuget package , push development repository. because these changes not yet stable, want these packages pre-release packages. from understanding , reading, should follow format of x.1.0.1-alpha001. i've included version number in assemblyinfo.cs file: [assembly: assemblyinformationalversion("1.0.1-alpha001")] my problem have no idea on how auto-increment value 001 002. not know how auto increment these within ci server jenkins. want make seamless possible developers. you may use .targets files solution, can configured increment assemblyinformationalversion each build. http://msdn.microsoft.com/en-us/library/ms366724.aspx

excel - delete duplicate data on 2 columns with more than 10k each -

painting picture... i work in shoe industry , i'm using excel spreadsheets improve records. i'm planning expanding amazon . problem statement: i have 2 columns more 10000 cells each. 1 own record , other online inventory. need delete duplicate values in both columns in order common record can update inventory. have ms access, i've tried queries nothing happened guess doing wrong wizard. summary: how import .xls microsoft access , remove duplicate entries? basically solve many many ways...here couple solutions. migrate access , remove duplicates: migrate excel access : click here delete duplicate entries in access : click here remove duplicates in excel how remove duplicates in excel : click here

cmd - Cordova doesn't work anymore : "unexpected end" -

i'm getting error when trying run cordova command. c:\users\james\desktop\dev\neptunus>cordova prepare -d cordova library "android" exists. no need download. continuing. generating config.xml defaults platform "android" calling plugman.prepare platform "android" preparing android project processing configuration changes plugins. iterating on installed plugins: [] writing out cordova_plugins.js... wrote out android application name "neptunus" [error: unexpected end line: 0 column: 0 char: ] the same goes "cordova run" . i've tried restarting, debugging, in vain. know wrong? thanks! i ran error after updating cordova version. removing , readding platform resolved me: cordova platform rm android cordova platform add android hope helps runs this.

batch file - How do I pass a username to an FTP command from the command line? -

i attempting script file upload using winscp using batch script. problem is, cannot figure out how pass ftp username/password prompt. here script: @echo off "..\..\..\program files (x86)\winscp\winscp.com" /command "option batch abort" "option confirm off" "open ftp://**.***.***.*" "put boom.txt /test/" "exit" echo domain\ftp_user set /p dummy=press enter close currently echo command isn't working, , command prompt still shows: prompting credentials.... username: how pass username/password thing? the syntax specifying credential in ftp url is: ftp://username:password@hostname/

asp.net mvc - MVC 4 Null Data on Post -

i missing here, , can't life of me figure out what. can populate model fine , send view, on post, of data null or default. i'm force feeding create /test/create?a1=5&a2=6&shell=7 works fine initialize test entity. post has name , catid other properties null. any appreciated. model namespace myapp.models { public partial class testentity { [displayname("entity id")] [required] public int? entityid { get; set; } [required] [displayname("entity name")] public string entityname { get; set; } [displayname("category id")] [required] public int? catid { get; set; } [displayname("attribute 1")] public int? attribute1 { get; set; } [displayname("attribute 2")] public int? attribute2 { get; set; } } } view @model myapp.models.testentity <h2>test</h2> @using (html.beginform()) ...

javascript - Using createDocumentFragment to replace an existing column in a table -

i've read createdocumentfragment way more faster appending elements 1 one dom in for-loop, e.g. see here . what want do: create table column in document fragment. column should contain numbers array (for example "ratings"). after want replace existing column new 1 (the "fragment" one). can put whole column dom @ once. my problem: i can't figure out how replace existing column if there one. appending on other hand no problem. my jsfiddle: http://jsfiddle.net/leqg9/2/ helpful links, here , here html <table id = "table"> <tr> <th>name</th> <th>rating</th> </tr> <tr> <td>a.h.hattray </td> <td id = "row0"></td> </tr> <tr> <td>icke_eben </td> <td id = "row1"></td> </tr> <tr> <td>john_doe123 </td> ...

asp.net - How to fix forms authentication with 51degrees detection library? -

i have existing asp.net mvc app uses custom forms-based authentication, creating formsauthenticationticket , writing auth cookie per example @ http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket(v=vs.110).aspx . now, when add reference 51degrees mobile device detection framework, i'm stuck in auth loop, context.request.isauthenticated permanently reporting false . i've tracked down fact context.request.browser.cookies reporting false , explains why auth cookie isn't having effect. cause library think desktop browser (chrome in case, if makes difference) didn't support cookies? bug in detection library? misconfiguration or code error on end? else? i upgraded 51degrees v3 using nuget , ran same problem. you correct - context.request.browser.cookies false authentication cookie doesn't set , if 1 there doesn't read. tried manually setting using formsauthentication.getauthcookie() followed response.cookies.add...

python - Is there a simple way to add a border to Kivy Labels, Buttons, Widgets etc. with-out images? -

Image
i'm trying add border kivy buttons doesn't work expected. labels implementation seems ok buttons overrides/clears standard of button. how can draw border above button with-out changing normal behavior? i'd implement buttonbehavior can add border every kivy object canvas. i've called borderbehavior. styling dashed, dotted works line width of 1 because there bug in kivy (see https://github.com/kivy/kivy/issues/2037 ) (need figure out what's wrong here later.) i know drawing border possible borderimage i'd add simple borders with-out image. here how looks @ moment: you can find source code here (the labels can dragged testing purposes see border correctly positioned): https://gist.github.com/awolf81/c6796dc2049d9872b2df ok, i've found fix. naming conflict. in console log saw there problem @ unpacking border tuple in borderimage of button. of course, that's not working because border implemented differently. maybe can add list (to...

insert - Keep getting a seg fault with my binary search (working in C) -

i'm having trouble getting binary tree work. 1 weird thing when try print node data repeatedly, seg fault. i'm taking red flag i'm doing wrong. test program made struct definition , insertion function. notice issue? #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include <stdbool.h> typedef struct tnode{ char *name; int value; struct tnode *left; struct tnode *right; } tnode; tnode *insert(tnode *node, char *name, int value){ if(node==null){ tnode *temp = malloc(sizeof(struct tnode)); temp->name = strdup(name); temp->value = value; temp->left = null; temp->right = null; return temp; } else if(strcmp(name,node->name)<0) { node->left = insert(node->left, name, value); } else ...

sql - Incorrect data when run as subquery -

i have query takes data given media table joins user table : select media.id, media.user_id,@rownum := @rownum + 1 position inner join users on media.user_id = users.id media_table order media.distance asc, media.media_likes_count desc, media.media_views_count desc; this query produces nice looking table follows: media_id, user_id, position 39199 , 3949 , 1 39299 , 3149 , 2 39359 , 3944 , 3 39369 , 3349 , 4 39379 , 3149 , 5 39389 , 3449 , 6 from derived table, want position of media_id = 39389. however if include query in subquery this: select position (select media.id, media.user_id,@rownum := @rownum + 1 position inner join users on media.user_id = users.id media_table order media.distance asc, media.media_likes_count desc, media.media_views_count desc;) media_id = 39389 then columns 'shuffle' , 39389 not have position 6 anymore. not withstanding errors in query, assuming typos, perhaps you're issue not initializing u...

excel - OpenOffice saves empty cells in xlsx -

i'm processing xlsx files in php. when create xlsx file using openoffice 1 filled cell, spreadsheet has 65536 rows itself. looks openoffice stores cells if empty. there solution can save many rows/columns filled? because every library parsing xlsx produces wrong number of rows i'm not able process correctly. solution achieve directly inside openoffice, or use external tool/script (*nix based) clean such xlsx file if possible. here 1 solution: use opentbs open xlsx , save or without modifications. opentbs pure php tools purpose merge data libreoffice , ms office documents using technique of templates. since version 1.9.0, opentbs can handle xlsx workbooks made libreoffice. such xlsx workbooks may have row definition contains repetition attribute extends upon maximum limit of row number. opentbs reduce extended row single row. opentbs download page opentbs demo opentbs doc

html - Push divs down in containing div with CSS -

Image
i build sort of "stack" of divs (with class .inner) within containing div (#container) each inner pushed far down in container possible without overlapping inner. i've included illustrations of 1 , 3 inners, respectively: i know result on left setting... #container { position: relative; } .inner { position: absolute; bottom: 0; } ...but solution not scale example on right - instead cause of inners overlap 1 another. there way accomplish want through css alone arbitrary number of inners? know hacky javascript. you use additional container inner containers , use trick suggested. <style> div{border:1px solid red} #container{height:1000px;} #inner-container{position:absolute;bottom:0px;} .inner {height:200px;width:200px;margin:5px;; </style> <div id="container"> <div id="inner-container"> <div class="inner"></div> <div class="inner"></div> ...

What is the purpose of &environment in Common Lisp? -

i confused &environment parameter in common lisp. in particular, useful for, , why parameter, rather special variable? edit: nice see concrete example of how &environment used in code. doc macro lambda lists : &environment followed single variable bound environment representing lexical environment in macro call interpreted. environment should used macro-function , get-setf-expansion , compiler-macro-function , , macroexpand (for example) in computing expansion of macro, ensure lexical bindings or definitions established in compilation environment taken account. explanation operators define macros (local or global) have define how code expanded before being evaluation or compiled, , may need expand existing macros, expansion may depend on environment - macro definitions need environment. not special variable special variables more dangerous because user might rebind them , because harder handle correctly in multi-threaded code. ...

ember.js - Ember: ArrayController computed property based on array item properties -

i have arraycontoller on want set boolean property based on properties of contents. plain-language description of logic: if array contains any items property of isretired equal true , set retiredshoes property of arraycontroller true , otherwise, set arraycontroller retiredshoes property false . it seems should simple matter, haven't found solution anywhere, , i'm still pretty new @ this. i'll put jsfiddle if necessary. here controllers array , object: app.applicationcontroller = ember.arraycontroller.extend({ sortproperties: ['title'], itemcontroller: 'shoe', retiredshoes: function() { //how compute sucker? } }); app.shoecontroller = ember.objectcontroller.extend({ needs: ['application'], actions: { delete: function() { var shoe = this.get('model'), runs = shoe.get('runs'); shoe.deleterecord(); shoe.save(); }, ...

generics - c# - Store a collection of handlers mapped to the concrete type they operate on -

i adding metrics tracking application. each concrete metric object there specific metricstracker responsible parsing data , sending off server. wanted use generics each metricstracker, ran issue during design, , cannot figure out elegant solution. i've created simplified model illustrate stuck. lets pretend running a zoo, when notice 1 of animals sick, need find zoo keeper specializes in caring animal. here animal class. contains zoocode used zoo identify it. (note "zoocode" necessary in real model because identifies metric type on server) public abstract class animal { //the zoo code of animal. public abstract int zoocode { get; } //other things specific animal. } here example of concrete animal. public class elephant : animal { //an elephant has zoo code of 1 public override string zoocode { { return 1; } } } here base class zookeeper, zookeeper knows how care specific type of animal. public abstract class zookeeper { //the z...

ios - UIView won't move to a new position -

i'm having little trouble here moving uiview up. here codes. -(void)viewwillappear { if ([self.expensetoshowdetail.recurring intvalue] == 1) { //something... } else { [self.recurringview sethidden:yes]; self.noteuiview.layer.position = cgpointmake(160, 200); } } i'm trying hide 1 view , move other bit. doing wrong here? thanks. do this: self.noteuiview.center = cgpointmake(160, 200); you accessing self.noteuiview 's layer property, may not have been looking do. also, code not visibly move view, put 160, 200.

java - How do you add keyboard commands to a preexisting javafx scene? -

i have been trying find out how add keyboard commands preexisting javafx scene , can not seem find answer anywhere. want have keyboard method run key pressed. add keyboard commands/controls to. import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.stage.stage; public class main extends application { public void start(stage primarystage) { try { parent root = fxmlloader.load(getclass().getresource("/fxml/main.fxml")); scene scene = new scene(root,600,400); scene.getstylesheets().add(getclass().getresource("application.css").toexternalform()); primarystage.setresizable(false); primarystage.setscene(scene); primarystage.settitle("keyboard test app"); primarystage.show(); } catch(exception e) { e.printstacktrace(); } } public static void main(string[] args) { lau...

java - Class Cannot Be Resolved To A Variable -

i trying cast component custom class name (outerspace) , says cannot this. doing in class inherits jframe. //add game jframe add(new outerspace()); (outerspace)(getcomponents()[0]).start(); it cannot resolved however, other class name. here error- outerspace cannot resolved variable. this looks wrong: (outerspace)(getcomponents()[0]).start(); it done: ((outerspace)getcomponents()[0]).start(); having said this, regardless of right or wrong, code looks fragile , dangerous kludge. if project, i'd try hold more secure class-specific reference outerspace field, 1 not require casting, or require component in specific component array position.

c++ - How to declare a new class in the header and define it in the source file without this errors? -

i'm on situation want create new class , use in created class (c++), without using different header or source files: both classes shall in same place, 1 way or another. main class shall contain pointer "child" class. now know in many cases possible define class in header file. in fact, if 1 wants not set pointer "child class", use 1 of methods in header file (e.g., inline methods), 1 have define in source file: class childclass { public: bool myfunctions() { return true; } } class mainclass { private: childclass* pochildclass; inline bool getresult() { return pochildclass->myfunctions(); } } but let's suppose want have pointer there, without call childclass' methods, should able declare childclass , later define in same .cpp file mainclass defined: //in .hpp class childclass; class mainclass { private: childclass* pochildclass; } //in .cpp class childclass { public: bool myfunction...

ssis - Not able to configure WMI Connection for remote server -

i trying configure ssis package read values(like disc free space , total space) remote server. need configure wmi connection manager. i have entered ip address (\\ip address\) of server in "server name:" text box , user credentials server. when try test connection clicking on test button, gives me message: failed connect specified server following message: "user credentials can not used local connections". server name may invalid.

python - Solving tic-tac-toe through brute force -

i have been struggling problem while. need solve tic tac toe through brute force - is, having computer "learn" playing few million times. right now, "setup" works - i'll briefly describe it. computer plays generating random moves, until 1 side or other has won. stores list represents game, , associates list 1, 0, or -1 win, draw, or loss. the algorithm i'm using simple one; find move on board associated wins , least losses, out of games can result current board, , move there. this works ever case; except important ones: forks. in situation this: o - - o - x o - x - x - > - x - > - x - - - o - - o o - o where computer has next move, computer invariably goes in corner, , later gets forked. is there way solve tic tac toe through "brute force" (without using min/max, heuristics, hard coding forks, etc.)? a few million times may excessive. think there 362,880 possible "games" (stat...

Sorting Combinations according to the price prestashop -

i new prestashop facing problem while sorting product combinations according price. until came know manually want dynamic i.e if changes price should automatically sort in order.how can achieve this?? there modules provides functionality or else. any or suggestions great. i got , quite simple, foolishness making difficult. whatever order of combination in backend, combination in frontend displayed according sort order of attribute. sort according cost of combination attribute need sort attribute in "attributes , values".the way sort attributes in "attributes , values" reflects sorting in frontend display.hence fulfilling requirement.

matlab - Implementation of GUIDE GUI buttons -

i have question implementation of buttons inside guide framework. have 2 buttons created , drop down menu not seen in below code (referenced in numc line). way program meant run select drop down menu, generate button takes directly drop down menu. third button, optimize, needs numc variable , cities matrix. possible reference them directly in optimize function, or first have use output feature in generate button make 2 usable. numc easy enough recapture using same line in generate, need cities matrix it's generated. function optimize_callback(hobject, eventdata, handles) % hobject handle optimize (see gcbo) % eventdata reserved - defined in future version of matlab % handles structure handles , user data (see guidata) % --- executes on button press in generate. function generate_callback(hobject, eventdata, handles) % hobject handle generate (see gcbo) % eventdata reserved - defined in future version of matlab % handles structure handles , user data (see guidat...

r - Use Predict on data.table with Linear Regression -

regrad post , have created example play linear regression on data.table package follows: ## rm(list=ls()) # anti-social library(data.table) set.seed(1011) dt = data.table(group=c("b","b","b","a","a","a"), v1=rnorm(6),v2=rnorm(6), y=rnorm(6)) setkey(dt, group) ans <- dt[,as.list(coef(lm(y~v1+v2))), = group] return, group (intercept) v1 v2 1: 1.374942 -2.151953 -1.355995 2: b -2.292529 3.029726 -9.894993 i able obtain coefficients of lm function. my question is: how can directly use predict new observations ? if have new observations follows: new <- data.table(group=c("b","b","b","a","a","a"),v1=rnorm(6),v2=rnorm(6)) i have tried: setkey(new, group) dt[,predict(lm(y~v1+v2), new), = group] but returns me strange answers: group v1 1: -2.525502 2: 3.319445 3: 4...

Python multiprocessing redirect stdout of a child process to a Tkinter Text -

i'm trying use tkinter gui launch child process , display stdout/stderr output text widget. initially, thought sys.stdout can redirected text widget setting "sys.stdout = text_widget" seems not. comes error: "text instance has no attribute 'flush'". i checked online , got solutions, using queue communicate child process. however, none of them fit case because of special requirement: the child process should better launched "multiprocessing.process" because easier use shared variables, makes subprocess solutions usable. the codes of child process there quite lot "print" inside, don't want modify them "queue.put()" or else. in case, come solution of getting "multiprocessing.process"'s "print" output , display tkinter text? many thanks! an example code of case follows: import sys import time multiprocessing import process tkinter import * def test_child(): print 'child runni...

javascript - How to read html form contents using jquery? -

i have html form in can add input element dynamically using jquery. @ end want submit/read data on form. used serialize method gives me data of elements on form , not if dynamically added elements. here work: <html> <head> <title></title> <script type="text/javascript" src="jquery-1.11.1.min.js"></script> <script type="text/javascript"> function call(class_name) { console.log(class_name); $("#new_append_pass").append('<input type="password" class="username_' + class_name + '" name="pass">'); } $(document).ready(function () { var count = 0; var alt, str; $(".user_pass ").click(function () { $("#append_me").append('<input type="password" class="' + $("#append_me").attr("alt...

java - javax.el.PropertyNotFoundException IN SHOPPING CART -

i working on shopping cart when try display contents of cart gives me error called http status 500 - javax.el.propertynotfoundexception: property 'idnumber' not found on type cart.cartitembean – using bean on jsp diplay contents of cart. shoppingcart.jsp <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html> <head> <title>shopping cart</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <p><font face="verdana, arial, helvetica, sans-serif"><strong>shopping cart</strong></font></p> <p><a href="modellist.jsp" mce_href="modellist.jsp...

c# - Remembering SQL connection state in .net? -

beside's old known fact connection.close() vs connection.dispose() same - except running close() on disposed connection raises exception while running close() on closed connection - ok - still have question : assuming connection pooling on , (default) - why important remember state of connection ? i've read this question here shows - avoiding opening , closing connection saves performance . this seems logic , problem connection never closed ! marked close. even if use under using scope - dispose closes connection , put in pool. even if wanted , couldn't leave open ( because i'd want others use it) . had close/dispose it. looking @ dapper implements behavior: public static async task<ienumerable<t>> queryasync<t>(this...) { //... bool wasclosed = cnn.state == connectionstate.closed; using (var cmd = (dbcommand)command.setupcommand(cnn, info.paramreader)) { ...

xsl fo - left and center aligning in same line using XSL FO -

i saw in post , <fo:block text-align-last="justify"> left text <fo:leader leader-pattern="space" /> right text </fo:block> but want right text aligned center of same line. using apache fop generate pdf xml. appreciated! use 1 row, 3 column table column widths 30-40-30 or whatever need accommodate text widths. put content in first 2 cells , set alignment on them left , center respectively.

Get Data From XML by Livecode -

i learn livecode , try few tutorials data xml format. confuse. here xml code: <current><city id="1642911" name="london"><coord lon="106.83" lat="-6.17"/><country>indonesia</country><sun rise="2014-05-29t22:56:30" set="2014-05-30t10:43:59"/></city><temperature value="302.254" min="302.254" max="302.254" unit="kelvin"/><humidity value="76" unit="%"/><pressure value="971.07" unit="hpa"/><wind><speed value="1.24" name="calm"/><direction value="20.5019" code="nne" name="north-northeast"/></wind><clouds value="20" name="few clouds"/><precipitation mode="no"/><weather number="801" value="few clouds" icon="02d"/><lastupdate value="2...

python - Entry Points in setup.py -

i making cli in python using click. entry point script: entry_points=''' [console_scripts] noo=noo.noodle:downloader ''', i have made package, have added import noodle in __init__.py file import file noodle contains function downloader() - needs executed entry_point script. when install setup.py , error: importerror: no module named noo.noodle when run noodle --help in terminal? directly documentation on click.pocoo.org : yourscript.py : import click @click.command() def cli(): """example script.""" click.echo('hello world!') setup.py : from setuptools import setup setup( name='yourscript', version='0.1', py_modules=['yourscript'], install_requires=[ 'click', ], entry_points=''' [console_scripts] yourscript=yourscript:cli ''', ) while if have multiple commands in cli a...

angularjs - ng-click inside bs-tooltip not working -

i'm using angular-strap tooltip , inside have link should react ng-click , instead it's not responding. .html <span class="add-on input-group-addon" data-title="{{tooltips.date}}" bs-tooltip> <i class="glyphicon glyphicon-calendar fa fa-calendar"></i> dates </span> .js $scope.tooltips = { date: '<a class="btn btn-default" ng-click="select()">select date</a>' }; $scope.select = function() { //doing , works fine outside tooltip } in app .config() there html set true . angular.extend($tooltipprovider.defaults, { template: "static/lib/angular-strap/tooltip.tpl.html", trigger: 'click', html: true, placement: 'bottom-left' }); by using data-title along html: true passing html, not compiled angular. if want use angular directives , data binding in tooltip, use 'contenttemplate'; here working plunker: http://plnkr.co/...