Posts

Showing posts from June, 2011

php - Am I using Domain Object correctly? -

according article here you can think of them [services] "higher level domain objects", instead of business logic, services responsible interaction between domain objects , mappers. these structures end creating "public" interface interacting domain business logic. can avoid them, @ penalty of leaking domain logic controllers. i have been reading on mvc, , ive split m part services, domain objects , data mappers. services , data mappers easy figure out, dont understand reason domain objects, can please give me examples? here code: memberservice class memberservice extends service { public function authenticate() { $domainobject = $this->domainobjectfactory->getdomainobject('member'); $datamapper = $this->databasefactory->getmapper('member'); $_temp_sess_id = 0; $_temp_sess_password = ""; $member = $datamapper->fetch( $_temp_sess_id ); $authenticationre...

r - How do I delete rows from a data frame when the DF only has one column -

this question has answer here: in r, why selecting rows data frame return data vector if data frame has 1 column? 1 answer this sort of duplicate of this question , emphasis different, i'm posting it. i have data.frame 1 column. if attempt delete row using "df[-1, ]" r returns list. how return data.frame? the problem r trying "helpful", , simplifying data you. solution following (note 2 commas, not one): df[-1,, drop = false] this remove specified row, , leave data.frame otherwise untouched.

Rails app gives error only when running via Unicorn -

i in unfortunate position of having configure machine run multiple rails applications. machine set nginx , rvm , passenger. appears pretty painful have configure multiple standalone passengers, , feels hack. want application , running, i'm going run through different port (8080) unicorn. hav? no experience with. my application has little helper checks see if site being accessed mobile device, serves different set of views. helper has little puts statement in debug line. when running through unicorn, puts line barfs with: errno::eio (input/output error - <stdout>): all can think of is unable write stdout. have never seen rails app bail @ puts line before. sure should use logger, problem line in unicorn when doesn't have problem elsewhere. the eio error indicates process trying write tty, tty gone. started unicorn terminal, let daemonize , exited terminal. setting stderr_path helps because redirects stderr (and maybe stdout too?) file. but phusion ...

node.js - Glob / minimatch: how to gulp.src() everything, then exclude folder but keep one file in it -

i have project this: root |-incl1 |-incl2 |- ... |-excl1 |-excl2 |- .gitignore <-- keep 1 |- (other files) <-- exclude them i need write gulp.src() include folders except excl1 , excl2 but keep .gitignore file. this code doesn't work: gulp.src([ basedir + '/**', '!' + basedir + '/{excl1, excl1/**}' '!' + basedir + '/excl2/{**, !.gitignore}' // <-- doesn't work ], {dot: true}) this seems work: gulp.src([ basedir + '/**', // include '!' + basedir + '/excl1{,/**}', // exclude excl1 dir '!' + basedir + '/excl2/**/!(.gitignore)', // exclude excl2 dir, except .gitignore ], { dot: true }); excluding single file glob match tricky because there's no similar examples in minimatch docs. https://github.com/isaacs/minimatch "if pattern starts ! character, negated". ...

multiple assignments with a comma in python -

i tried find explanation of this , gotcha part: b = "1984" = b, c = "ab" print(a, b, c) returns: ('ab', 'a', 'b') i understand happens multiple equals: a = b = 1 but using comma, cannot understand behaviour, ideas in why works way? the answer a = b, c ="ab" acts like: a = (b, c) = "ab" this why: a = "ab" , b = "a" , c = "b"

javascript - Change input value loaded inside HTML Object Tag, is it possible? -

i have simple html webpage loads webpage using html object tag, , know if possible change content of input loaded inside object tag. my code: <html lang="en"> <head> <script> function fill(){ document.getelementbyid('uri').value = "hola"; } </script> </head> <body> <button type="button" id="fill" onclick="fill()">fill</button> <object style="width:800px;height:600px;" data="http://validator.w3.org/" /> </body> inside loaded object, there's input id 'uri', change value. error give "cannot set property 'value' of null", means javascript isn't seeing input. so, there anyway can accomplished? <object> not have "value" attribute. can assume want change value of whatever loaded object, looks of it, hosted on vali...

powershell - Getting Contents of Txt file into output -

i trying list of specific adsite servers dc's. have dc's saved txt file , running foreach against it. dc name within text file part of output. so far have $servers = gc dclist.txt foreach ($server in $servers){ get-adreplicationsite somecity -server $server |select intersitetopologygenerator } and output looks like: cn=ntds settings,cn=domaincontrollerx,cn=servers,cn=somecity,cn=sites,cn=configuration,dc=domain,dc=com cn=ntds settings,cn=domaincontrollerx,cn=servers,cn=somecity,cn=sites,cn=configuration,dc=domain,dc=com cn=ntds settings,cn=domaincontrollerx,cn=servers,cn=somecity,cn=sites,cn=configuration,dc=domain,dc=com cn=ntds settings,cn=domaincontrollerx,cn=servers,cn=somecity,cn=sites,cn=configuration,dc=domain,dc=com how can corresponding server @ front of output, ideally like: domaincontrollera cn=ntds settings,cn=domaincontrollerx,cn=servers,cn=somecity,cn=sites,cn=configuration,dc=domain,dc=com domaincontrollerb cn=ntds settings,cn=domaincontr...

java - Split around character with regex and conditions -

i try split string following conditions keep characters split around = if preceding character not % or ! split around != example : test=45 -> [test, =, 45] test!=45 -> [test, !=, 45] test%=45 -> [test%=45] code : private static final map<string[], string> tests = new hashmap<>(); static { tests.put(new string[]{"test", "=", "45"}, "test=45"); tests.put(new string[]{"test", "!=", "45"}, "test!=45"); tests.put(new string[]{"test%=45"}, "test%=45"); tests.put(new string[]{"test", "=", "%=45"}, "test=%=45"); tests.put(new string[]{"test%=", "=", "%=45"}, "test%==%=45"); } @org.junit.test public void simpletest() { string regex = "(?=!=)|(?<=!=)|(?<![!%])((?<==)|(?==))"; (map.entry<string[], string> ent...

How to change a string delimiter in Ab Initio? -

in ab initio graph have input file has pipe-delimited values in rows. use similar dml file parse it: record decimal("|",0, maximum_length=19, sign_reserved) v1 = null(""); utf8 string("|", maximum_length=10) v2 = ""; utf8 string("|", maximum_length=10) v3 = ""; utf8 string("|", maximum_length=40) v4 = ""; utf8 string("|", maximum_length=255) v5 = ""; utf8 string("\n", maximum_length=40) v6 = ""; end for use in later equality comparisons other data want make strings pipe-delimited, need change v6 value. i tried simple reformat changing output dml one, , leaving transform function empty: record decimal("|",0, maximum_length=19, sign_reserved) v1 = null(""); utf8 string("|", maximum_length=10) v2 = ""; utf8 string("|", maximum_length=10) v3 = ""; utf8 string("|", maximu...

jsp - Remove last three columns of Handsontable -

i have simple handsontable displays data mysql table. unfortunately i'm retrieving data , need remove or hide added columns. i've searched on internet , seem possible, every example have found doesn't seem work. results.jsp <script> var data = ${jsonproducts}; var ht = new handsontable(datatable, { data: data, startrows: data.length, readonly: true, maxcols: 7, colheaders: true, colheaders: ["id", "problem", "solution", "deadline", "type", "status", "developer"], }); </script> i tried maxcols: 7 doesn't work. this how i'm retrieving data (not that's it's relevant question) @requestmapping(value = "/result", method = requestmethod.get) public string defaultview(model model) { iterable<request> request = requestrepository.findall(); model.addattribute("reques...

Android GUI issues in the tablet with changedButton.getBackground().setColorFilter(color, mode); -

Image
how in title, app work in smartphones (samsung s2 , samsung s3), have gui bug in tablet (samsung galaxy tab s android 5.0.2). this activity can changed user. can touch 1 button , change text , color this but in tablet if user switch orientation or close , open activity, appear problem! all button s take color of first inputed color! , if user swap orientation or close , re-open activity returns normal state! here code change button s user has changed in past! static string clickedbuttonviewid; private list<materievoti> materie; mysqlitehelper db = new mysqlitehelper(this); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_set_table); //get materie inside database list<materia> materia = db.getallmaterie(); //change textview inputed user if(materia.isempty()){ //do nothing }else { (materia mat : materia) { //chang...

in python, how to check if list is not empty, and empty it if so? -

i've seen several answers how check if list empty, didn't find excatly need. shortly - in python, need way check if list full, , empty it, need check start after fill list. i'm define list call class - packet() class packet(object): """description of class""" def __init__(self): self.newpacket = [] newpacket = packet() i have menu, 1 of options call function in class fill list. but, if function chose again, need empty instance, , start new one. i've tried that: if newpacket: del newpacket newpacket.makepacket() but don't let me start list call function.. if disable if newpacket: del newpacket the function works fine. you appear confusing particular packet instance have created , chosen name newpacket , attribute of same name. rather delete instance, or delete list, sounds want empty list. because you've given 2 different things same name, list in question accessible command-line newpac...

ensembles - How to execute the cdeconvert app from OS X or XCode7? -

i found cdeconvert app, got clean build , error not passing file path. sorry lame question, have never built/run os x app xcode directly. question is: how execute (either xcode or os x directly) cdeconvert passing cdeevent file path? cdeconvert command line tool. once built, can locate executable file (in products), , use via command line. there no app.

php - Couchbase JSON structure model -

i want work couchbase json-document oriented. don't know what's best way store , structure data , retrieve later. is there somehow tutorial started (the learing resources on couchbase.com did not help)? i'm using php access couchbase. i've got following sample: (new document) user1 { "uid":1, "name":"marius" } (new document) planet1 { "pid":1, "user_uid":1, "name":"earth" } (new document) user2 { "uid":2, "name":"anyone" } (new document) planet2 { "pid":2, "user_uid":2, "name":"saturn" } now smartest way set (insert) these documents database , how can (select) documents selection. to in sql want -> select * user,planet user.uid=1 , planet.user_uid=1 couchbase stores data differently relational database. there 2 main ways data out of couchbase: key/value . means give document 1 key query on , value go...

data structures - Why does java complain about raw types in my variable declaration? -

this question has answer here: what raw type , why shouldn't use it? 12 answers public class table<key extends comparable<key>, value> { /* * purpose of entry glue key , value * * class use key has implement comparable * */ private class entry<key extends comparable<key>, value> implements comparable<entry> { key key; value value; public entry(key k, value v) { key = k; value = v; } public int compareto(entry<key,value> entry) { return key.compareto(entry.key); } } private bst<table.entry<key, value>> tree = new bst<table.entry<key, value>>(); //must supply public methods 3 operations public value lookup(key key) { entry<key, value> e = new entry<key, value>(key, null); return tree.search(e).value; } public boolean insert...

javascript - How to delete angular generated element in DOM -

i have ran wall this. delete function maincontroller. $scope.delete = function($posts) { $http.delete('/api/posts/' + $posts._id) .success(function(data) { // delete element dom // on success want delete post i'm clicking on. }); and here template load data angular. <div id="post-stream"> <h4>chirp feed</h4> <div class="post" ng-repeat="post in posts.results | orderby:'created_at':true" ng-class-odd="'odd'" ng-class-even="'even'"> <button ng-click="delete(post)" ng-show="authenticated" class="btn btn-danger btn-xs pull-right remove">x</button> <p>{{post.text}}</p> <small>posted @{{post.created_by}}</small> <small class="pull-right">{{post.created_at | date:"h:mma 'on' mmm d, y"}}</sma...

json - Searching for and updating a dictionary in a list of dictionaries in python -

so know this: python list of dictionaries search answers first part of question. however, issue such: want update searched dictionary directly, not retrieve it. more specifically, have list of dictionaries. dictionaries each have "list" key value list. want update list once find dictionary. the structure each dictionary such: {"name": "whatever", "display":"whoever", "list": [x, y, z]} so example list be: [ {"name": "whatever", "display":"whoever", "list": [x, y, z]}, {"name": "whatever2", "display":"whoever2", "list": [x2, y2, z2]}, {"name": "whatever3", "display":"whoever3", "list": [x3, y3, z3]} ] i want retrieve, say, dictionary name "whatever2" , add a2 "list". what best way this? "best" can weigh "...

sql server - Defining type as a variable - DATEADD(type, value, date) - SQL -

i had change date in 1 of column of sql table (datetime field), increment year 1. simple way perform action (unless knows better way) update table , set column dateadd() -- sample 1 -- dateadd(type, value, date) select dateadd(year, 1, getdate()) since i'm lazy programmer, don't want keep updating tables every time run in such situation. decided write small script (function) gets type, value user , perform operation. ran situation can't use type variable. -- sample 2 -- error in code declare @type varchar(10) = 'year' ,@increment int = 1 select dateadd(@type, @increment, getdate()) i can write case statement based on 'type' value can select update statement. -- sample 3 declare @type varchar(10) = 'year' ,@increment int = 1 update table_name set column_date = case @type when 'year' dateadd(year, @increment, column_date) when 'month' dateadd(month, @increment, col...

Angular 2 - understanding bidings and pipes -

i'm trying understand how angular 2 works. i'm reading pipes documentation: https://angular.io/docs/ts/latest/guide/pipes.html , there following example: import {component} 'angular2/core' @component({ selector: 'hero-birthday', template: ` <p>the hero's birthday {{ birthday | date:format }}</p> <button (click)="toggleformat()">toggle format</button> ` }) export class herobirthday { birthday = new date(1988,3,15); // april 15, 1988 toggle = true; // start true == shortdate format() { return this.toggle ? 'shortdate' : 'fulldate'} toggleformat() { this.toggle = !this.toggle; } } what puzzles me why birthday updated when user clicks on button? so... when click button , toggleformat() function called, changes this.toggle variable. there "something" checks if this.toggle changed , therefore format changed updates birthday ? can explain how working? thanks ...

java - if statement not finding condition -

this question has answer here: how compare strings in java? 23 answers i building basic tic tac toe app project , trying add basic ai (just random number) player play against. it should pick random number based on length of arraylist of each value represents button or square on board. idea that integer value converted string , used select button matching tag, using, gettag() . the problem looping through button in layout, statement unable find button tag , skips necessary logic contains ai play turn. should then, fill relevant button x , set inactive , return. i have added system.out.println(""); statements aid debugging , can see point @ stops working expected. the problem in aiplayerpick() method. mainactivity.java package com.example.richardcurteis.connect3; import android.os.bundle; import android.support.design.widget.floatingactionbut...

c# - Asp.net password encryption and decryption with salt -

i trying pull encrypted password table receiving error: system.data.sqlclient.sqlexception: conversion failed when converting nvarchar value '84p37u29dna08xhudv+bhq==' data type int. where value encrypted password. don't understand why there error. code breaks @ line: dataadapter.fill(dataset); protected bool attemptlogin(string username, string password) { bool validlogin = false; string sql = "select users.username, passwords.password " + "from users inner join passwords on users.userid = passwords.password " + "where users.username = @username"; sqlcommand command = new sqlcommand(sql, dbconnection); command.parameters.addwithvalue("@username", username); sqldataadapter dataadapter = new sqldataadapter(command); // set of tables (in instance, one) dataset dataset = new dataset(); dataadapter.fill(dataset); ...

javascript - why can't I load mydomain.com/public url directly? -

note: added apache , spring tags because user commented below thinks apache , spring issue. i learning angularjs reading tutorials , experimenting sample apps. code below allows person type in mydomain.com , click around public links without being authenticated. however, whenever, type in mydomain.com/public1 directly in browser, browser responds popup window requesting username , password interpreted on server. angularjs app making decision force authentication calls server instead of letting unauthenticated users view public routes. not acceptable behavior. what can fix code below mydomain.com/public1 (or public url) can accessed directly typing url in browser? here route provider in hello.js : angular .module('hello', [ 'ngroute', 'auth', 'home', 'message', 'public1', 'navigation' ]) .config( function($routeprovider, $httpprovider, $locationprovider) { $locationprovide...

mysql - Failed opening required mysqli_connect.php -

i 'm trying connect mysql database in php script. keep getting following error: warning: require(mysqli_connect.php): failed open stream: no such file or directory in c:\xampp\htdocs\simpleidb\register-page.php on line 52 fatal error: require(): failed opening required 'mysqli_connect.php' (include_path='.;c:\xampp\php\pear') in c:\xampp\htdocs\simpleidb\register-page.php on line 52 i 'm running xampp 5.5.30 on windows 10. line 52 is: require('mysqli_connect.php'); and following mysqli_connect.php: define ('db_user', 'horatio'); define ('db_password','hmsvictory'); define('db_host', 'localhost'); define('db_name', 'simpleidb'); $dbcon = @mysqli_connect (db_host, db_user, db_password, db_name) or die ('could not connect mysql:'.mysql_connect_error()); mysql_set_charset($dbcon, 'utf-8'); my include path in php.i...

javascript - concrete example for Promises and nodejs (and no solution) -

so i'd learn more promises (i arbitrarily chose bluebird, despite 'succinct' documentation) attempting implement common use case, using nodejs: i have bunch of 9000 or urls in file, empty lines well. to: filter out empty lines (url.length <= 0) filter out no longer respond (via head request using request module) map ipv4 address via dns.resolve() map use ipv4 address , http://ipinfo.io/xx.xx.xx.xx/geo geo data (ok, yes, there daily api limit, let's assume could) write resulting information array of json objects in new file and of course profit fact run in parallel , therefore faster doing sequentially the first filter easy it's returning (here using bluebird): promise.each(urls, function(value, index, length) { return value.length > 0; }).then( console.log(urls); ); but how can feed result of asynchronous head request promise? here another, more complete example of i'm hitting wall (see comments inline): <pre class=...

Why is Google App Engine Making --set-default a default parameter? -

so, in past, when i've used google app engine, i've utilized wonderful version system create integration, staging, , production environment. when we're ready go live, set production environment default, , starts receiving traffic @ standard appspot url ( myapp.appspot.com ), if it's not default have manually go version ( dev.myapp.appspot.com ) testing. awesome system pre-prod deployment full test. however, went app engine deployment today , got warning: warning: soon, deployments set deployed version receive traffic default. keep current behavior (where new deployments not receive traffic), use `--no-promote` flag or run following command: $ gcloud config set app/promote_by_default false adopt new behavior early, use `--promote` flag or run following command: $ gcloud config set app/promote_by_default true either passing 1 of new flags or setting 1 of these properties silence message. so, apparently, google make every deploy of version, automatically...

python - Get row count in MySQLdb -

is there better way row count doing following? cursor.execute("select distinct(provider_id) main_iteminstance") num_items = len(cursor.fetchall()) is there shorthand in mysqldb above? you execute following sql directly on cursor.execute rather depending on mysqldb: cursor.execute("select count(distinct provider_id) main_iteminstance") then result query.

go - Making a post request in golang -

i'm trying automate following using golang generate password (done) push notification devices (done using pushbullet) change wifi router password @ 192.168.0.1 (needs done) wifi router page @ 192.168.0.1 wifi router page here raw data captured using fiddler . (when manually changed) post http://192.168.0.1/goform/form2wlanbasicsetup.cgi http/1.1 host: 192.168.0.1 user-agent: mozilla/5.0 (windows nt 6.3; wow64; rv:43.0) gecko/20100101 firefox/43.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate referer: http://192.168.0.1/d_wlan_basic.asp cookie: curshow= x-skyzip-mode: high connection: keep-alive content-type: application/x-www-form-urlencoded content-length: 233 domain=1&hiddenssid=0&ssid=home&band=9&chan=0&chanwid=1&txrate=0&method_cur=0&method=6&authtype=2&length=1&format=1&defaulttxkeyid=1&key1=&pskformat=0&pskvalu...

java - Android create a new Object from findViewById vs casting a findViewById -

i try set text textview in java: first created object this: //property info textview propertyinfo = (textview) info.findviewbyid(r.id.info); propertyinfo.settext(getinfo()); //production textview production = (textview) info.findviewbyid(r.id.production); production.settext(getproduction()); later tried same thing time casted instead of creating new object: //property info ((textview) info.findviewbyid(r.id.info)).settext(getinfo()); //production ((textview) info.findviewbyid(r.id.production)).settext(getproduction()); in test found out second method used less memory when called it. know why, however, want know correct way or how it? the 2 methods doing same thing. if need make repeated use of textview setting multiple properties or events first method better avoid multiple calls findviewbyid . necessary if need keep reference view update later in other method. if using view once in case prefer option 2 since more concise. it worth noting in first method...

jquery - Getting JavaScript to create a full li -

function loadfamily() { var family = ["kelly", "paul", "jason", "jessica", "mat"]; var ulelement = document.getelementbyid("namelist"); (var name in family); { var listitem = ulelement.appendchild(document.createelement("li")); listitem.appendchild(document.createtextnode(family[name])); } } i trying code create ul in html. have been able make work; place last name of array when page loaded. first time working javascript , i'm sure simple problem, appreciated! you stopping for loop here: for (var name in family); //----------------------^ remove this. it runs , index in last, executes last 1 now. change code to: function loadfamily() { var family = ["kelly", "paul", "jason", "jessica", "mat"]; var ulelement = document.getelementbyid("namelist"); (var name in family) { var listitem = ulelement.appen...

c# - Reference a generated dataset -

how reference , pull data out of generated dataset? i have 2 projects in same solution. (1) myuiproject (2) mydatasetproject ->mygenerateddataset.xsd -->-->mynamestable (in dataset) all want reference mynamestable , loop through names in table , put them in list box. i'm having trouble getting records out of generated dataset. i'm trying like: foreach (var name in mydatasetproject.generateddataset.mynamestable) { mydropdownlist.items.add(new listitem(name)); } thanks thoughts. first thing make sure references correct between projects. right click on myuiproject , click add reference . go projects tab , add mydatasetproject entry. if gives error have been added, it's added. second, need access dll project classes website. let's in website have page called default.aspx , , in dll project have class called datasetaccessor , looks following: public class datasetacessor { public dataset getdataset(<arguments>) { ...

android - Issue with Relative Layout -

i working on first android app , 1 issue have not been able find solution relative layout , footer bar. i have set relative layout button bar @ bottom. works find if there enough content in other linear layout; however, when there not enough content fill out page, content aligned @ bottom on top of button bar. aligned @ top button bar remaining on bottom. have tried every align top option can find , setting content height fill_parent/match_parent, of cause items inside of linear layout disappear. how can fix this? <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/viewpost" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#c9c9c9" > <linearlayout android:id="@+id/bottom_control_bar" android:layout_width="match_parent" ...

maven - java.lang.NoClassDefFoundError:org/apache/commons/fileupload/FileItemFactoryin Spring MVC -

i trying build simple spring mvc web app functionality of file uploading.i got following error: java.lang.noclassdeffounderror: org/apache/commons/fileupload/fileitemfactory after quick search,all answers pointed missing of dependencies,but seems not true in case: i have included following code in pom.xml: <dependencies> <dependency> <groupid>commons-fileupload</groupid> <artifactid>commons-fileupload</artifactid> <version>1.3.1</version> </dependency> <dependency> <groupid>commons-io</groupid> <artifactid>commons-io</artifactid> <version>2.4</version> </dependency> </dependencies> commons.io-2.4.jar , commons.fileupload-1.3.1.jar added lib folder. one interesting thing found whenever deleted code: <bean id="multipartresolver" class...

javascript - Phantomjs renders wrong snapshot size -

we try make snapshot different webpages using phantomjs (both resizable , fixed pages). when try on wikipedia (page resizable), viewport dimensions client ignored. problem in render, define viewport width , height. seems phantomjs first stretches page (snapshot has bit bigger text original wikipedia), crops right margin, , adds large margin in bottom. here code: var owebpage = webpage.create(); owebpage.viewportsize = { width : nviewportwidth, height : nviewportheight }; owebpage.onloadfinished = function() { if (owebpage.injectjs('inject.js')) { // nothing being done affect page size in inject.js try { owebpage.evaluate(function() { // nothing being done affect page size here either }); owebpage.render(simagepath, {format: 'png', quality: '100'}); phantom.exit(); } catch (oerror) { phantom.exit(1); } } else { phantom.ex...