Posts

Showing posts from May, 2013

turning nightwatch.js test (using jquery function) into custom assertion or command -

i running jquery function many times through test suite in order validate whether elements visible in viewport (nightwatch's current commands visible, present, etc not factor in). seems valuable have reusable command or assertion, fighting uphill battle understand how translate current code new reusable code, , have spent many hours trying different things. i have other custom commands work well, not work on validating result of function, perform repeatable commands. leads me believe should custom assertion? documentation on custom assertions sparse, , has not helped me in piecing own custom assertion. this run in test files: browser.execute(function () { $.fn.isonscreen = function(){ var win = $(window); var viewport = { top : win.scrolltop(), left : win.scrollleft() }; viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); var bounds = this.offset();

neo4j - How to write a Cypher query to check commutativity between nodes -

Image
i need check commutativity between nodes. there 3 relationships across node tracked following: aabbca, aabcba, aacbba. seen every b , c node placed commute. below use query on how generate graph. here graph: create (x1:node {title:'a'}) create (x2:node {title:'a'}) create (x3:node {title:'b'}) create (x4:node {title:'b'}) create (x5:node {title:'c'}) create (x6:node {title:'a'}) create (x1) - [:transition {id:[1]}] -> (x2) create (x2) - [:transition {id:[1]}] -> (x3) create (x3) - [:transition {id:[1]}] -> (x4) create (x4) - [:transition {id:[1]}] -> (x5) create (x5) - [:transition {id:[1]}] -> (x6) create (x1) - [:transition {id:[2]}] -> (x2) create (x2) - [:transition {id:[2]}] -> (x3) create (x3) - [:transition {id:[2]}] -> (x5) create (x5) - [:transition {id:[2]}] -> (x4) create (x4) - [:transition {id:[2]}] -> (x6) create (x1) - [:transition {id:[3]}] -> (x2) create (x2) - [:

MySQL: To exclude some results based on specified conditions -

i stuck @ problem. problem has 2 tables, namely hackers , challenges. here schema: hackers(hacker_id: int, name string) challenges(challenge_id: int, hacker_id int) i trying write query print hacker_id, name, , total number of challenges created each student. sort results total number of challenges in descending order. if more 1 student created same number of challenges, sort result hacker_id. if more 1 student created same number of challenges , count less maximum number of challenges created, exclude students result. here query: select hackers.hacker_id , hackers.name , count(challenges.challenge_id) challenges_created hackers left join challenges on hackers.hacker_id = challenges.hacker_id having count(challenges_created) >= max(challenges_created) order challenges_created desc, hackers.hacker_id asc i getting wrong output! please tell me getting wrong! sample input : hackers table: imag

javascript - Gulp not creating CSS folder on production build -

i have static site uses 2 gulpfiles compile. 1 gulpfile.dev.js compiles files correctly , uses static server served browsersync. gulpfile.prod.js the exact same dev file, without browsersync server. when compile file using deployhq move files on server doesn't compile necessary css folder. my gulpfile.prod.js file: //dh var gulp = require('gulp'), //task runner uglify = require('gulp-uglify'), //minimizies js sass = require('gulp-ruby-sass'), //compiles css imagemin = require('gulp-imagemin'), // minimize images concat = require('gulp-concat'), concatcss = require('gulp-concat-css'), gutil = require('gulp-util'), autoprefixer = require('gulp-autoprefixer'), cssnano = require('gulp-cssnano'), pug = require('gulp-pug'), htmlmin = require('gulp-htmlmin'); /

c# - Why does my FormLoad event handler call the custom class' default constructor instead of the one with arguments? -

i making basic multiclass gui program assignment have created 3 custom classes inherit form abstract class (readingmaterial) , interface. problem running when run information should passed each class's constructor (i've included class online example) not being passed , classes calling default constructor instead, gui components showing zeros , blank spaces instead of populating other information passed constructors. why isn't calling correct constructor instead of default? (gui form partial class) public partial class presentationgui : form { private book book; private magazine magazine; private online online; public presentationgui() { initializecomponent(); } private void rdbtnonline_checkedchanged(object sender, eventargs e) { txtbxpagecount.text = online.pagecount.tostring(); txtbxtitle.text = online.title; txtbxauthor.text = online.author; txtbxurl.text = online.websiteurl; txtbxp

css - Dropdown Menu get cut off -

i have drop down menu , seems cut of due parent div i.e if increase height of parent div, drop down menu seems come visible. please help. , below code: markup <div id="main-navigation" class="container"> <div class="menu rounded"> <ul id="navigation" class="l_tinynav1"> <select id="tinynav1" class="tinynav tinynav1"> </div> </div> css #main-navigation .menu ul { background: none repeat scroll 0 0 #ffffff; border-bottom: 1px solid #d51386; border-left: 1px solid #d51386; border-radius: 0 0 5px 5px; border-right: 1px solid #d51386; margin: 0 auto; min-height: 38px; overflow: visible; width: 98%; } #main-navigation .menu li { border-left: 1px solid #e1e1e1; border-right: 1px solid #c1c1c1; float: left; height: 38px; position: relative; top: 0; } it may have overflow

node.js - Undefine globals in particular files -

i working on plugin system sails.js application. security reasons need rid of sails global variable, holds data config files' content, etc. don't want undefine globally, since break application. plugin's entry point following: module.exports = function (pluginmanager) { return { ... } } where pluginmanager allowed reference application's code. is possible execute plugin's code in sandbox-like isolated environment? considered using child_process api, don't know how affect performance , stability of application. in globals.js set sails instance false, like: sails: true still, still access globals via req._sails.

Open pdf in .apk with native android application using phonegap -

i coding app ios , android using phonegap (version: 2.7.0). pdf file file:///android_asset/www/test.pdf (compressed in .apk). i try open pdf native pdf viewer like: window.open('file:///android_asset/www/test.pdf', '_system', 'location=yes'); the command above works on browsers , ios (you have use _blank instead of _system ) i tried load file phonegap file api sdcard, read not possible access files in android_asset/www. is possible open pdf directly android_asset/www path? possible copy file sdcard end open there? maybe possible android install scripts? edit: i added .java file in /src/com/...etc .java file: if (android.os.build.version.sdk_int >= android.os.build.version_codes.jelly_bean) { super.appview.getsettings().setallowuniversalaccessfromfileurls(true); } but there still same problem... i have output adb -d logcat happens when start app , click pdf link: i/activitymanager(22040): displayed com.company.appname/.

swift - app crash on iphone not on simulator -

whenever tap on last row in column, app crashes on iphone, not on simulator. else works fine. not error message. code working fine along simulator. import uikit class earthvc: uiviewcontroller { @iboutlet var slideshow1: uiimageview! override func viewdidload() { super.viewdidload() // additional setup after loading view. slideshow1.animationimages = [ uiimage(named: "earth1.jpg")!, uiimage(named: "earth2.jpg")!, uiimage(named: "earth3.jpg")!, uiimage(named: "earth4.jpg")!, uiimage(named: "earth5.jpg")!, uiimage(named: "earth6.jpg")!, uiimage(named: "earth7.jpg")!, uiimage(named: "earth8.jpg")!, uiimage(named: "earth9.jpg")!, uiimage(named: "earth10.jpg")!, uiimage(named: "earth11.jpg")!, uiim

Making shapes with linux shell script -

Image
for assignment, i'm trying make shell script print triangle looks following: + | \ | \ | \ | \ +----- here code in vim: echo'+ | \ | \ | \ | \ +----- ' however, instead of getting output when run script, outputs following: can tell me i'm doing wrong? try this #!/bin/bash echo ' + | \ | \ | \ | \ +----- ' just start on next line since need spaces before "+"

solr - Filter on fields only if present on a document -

is possible filter document value provided if document has field. for context, i have document types a,b,c have field. i have document types d , e don't. i define query such filter applies first subset, might later add new document type first set invalidate filter. you'll have combine query match against documents, except have value in field : myfield:foobar or (*:* not myfield:*) .. should want. being said, i'd wait introduce these additional queries until see it's needed, make each query more expensive without possibly being necessary in future - that's judgement.

hadoop - How to save Iterable[String] to hdfs in spark-scala -

val ordersrdd = sc.textfile("/user/cloudera/sqoop_import/orders"); val ordersrddstatus = ordersrdd.map( rec => (rec.split(",")(3), 1)); val countordersstatus = ordersrddstatus.countbykey(); val output = countordersstatus.map(input => input._1 + "\t" + input._2); how save output iterable[string] hdfs in spark-scala. iterable[string] note: ouput not rdd (i cannot use output.saveastextfile("hdfs-path") one way write simple hdfs file (same way in vanilla scala or java). has nothing spark. another way convert output rdd , save that. val output = countordersstatus.map(input => input._1 + "\t" + input._2) sc.makerdd(output.tolist).saveastextfile("hdfs-path")

html - Animated 'X' icon for bootstrap toggle -

i attempting animate horizontal lines in navbar 'x' when page reduced in size. my navbar code follows: <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.html">company<

python - Pyomo: How to use the final data point in an abstract model's objective? -

i have pyomo model has form: from pyomo.environ import * pyomo.dae import * m = abstractmodel() m.t = continuousset(bounds=(0,120)) m.t = param(default=120) m.s = var(m.t, bounds=(0,none)) m.sdot = derivativevar(m.s) m.obj = objective(expr=m.s[120],sense=maximize) note objective m.obj relies on parameter m.t . attempting run gives error: typeerror: unhashable type: 'simpleparam' using value, such expr=m.s[120] gives error: valueerror: error retrieving component s[120]: component has not been constructed. in both cases, goal same: optimize largest possible value of s @ horizon. how can create abstract model expresses this? you hitting on 2 separate issues: typeerror: unhashable type: 'simpleparam' is due bug in pyomo 4.3 cannot directly use simple param s indexes other components. said, fix particular problem not fix example model. the trick fixing objective declaration encapsulate objective expression within rule:

java - JPA Sample Spring Boot app throws BeanCreationException -

i'm trying simple spring project work, downloaded starter project here (maven, jpa dependency want use hibernate): https://start.spring.io/ i ran: mvn clean install which threw lot of errors: --- exec-maven-plugin:1.2.1:exec (default-cli) @ project --- . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: spring boot :: (v1.3.5.release) 2016-06-11 11:52:57.644 info 20700 --- [ main] com.app.projectapplication : starting projectapplication on jameswmac.local pid 20700 (started james in /users/james/downloads/project 2) 2016-06-11 11:52:57.647 info 20700 --- [ main] com.app.projectapplication : no active profile set, falling default profiles: default 2016-06-11 11:52:57.679 info 20700 --- [

javascript - set focus to a div when any of it's content elements are clicked -

i use following set focus div when clicked or tabbed into. it works when click padding area inside div. clicking on of child elements not activate div:focus. please how can fix this? css .sidebar-message:link { } .sidebar-message:visited { } .sidebar-message:hover { background-color: lightyellow !important; outline-width: 0 !important; } .sidebar-message:focus { background-color: khaki !important; outline-width: 0 !important; } html <div class="sidebar-message" tabindex="-1"> <a href="#" id="pending_{{id}}" data-id="{{id}}"> <div class="pull-left text-center"> <img alt="image" class="img-circle message-avatar" src="media/profile-pics/{{uid}}.jpg"> </div> <div class="media-body"> <strong>{{{contact_name}}}</strong> <span class="badge {{color}} pull-

java - junit testing -- how to comparing two ArrayList<Double> using assertEquals(), is there an better alternative? -

i'm writing junit test use assertequals() compare value of 2 arraylist. @test public void test(){ quadraticformula 1 = new quadraticformula(3, 4, -4); list<double> results = new arraylist<>(); results.add(0.66666); results.add(-2.0); assertequals(results, one.getroots()); } however, junit prints out following failure message: expected:<[0.66666, -2.0]> was:<[0.6666666666666666, -2.0]> junit.framework.assertionfailederror is there anyway can specify how many decimal places want test compare? know how test equality of 2 double values accuracy, there anyway can achieved when comparing 2 arraylist of doubles? in advance suggestions or help! you can use numberformat or bigdecimal below round-of double d = 0.66666666; numberformat format = new decimalformat("#.##"); system.out.println(format.format(d)); // 0.67 bigdecimal bigdecimal = new bigdecimal(d); bigdecimal

android - How to edit already present file in SD CARD using SAF(storage access framework)? -

i have doubt read these tutorials clear understanding of saf introduced in kitkat in higher version of android how use new sd card access api presented android 5.0 (lollipop)? how persist permission in android api 19 (kitkat)? android api below 19 equivalent contentresolver takepersistableuripermission android gallery on kitkat returns different uri intent.action_get_content now have question when intent fired , select sd card uritree intent getting root tree have iterate through uri specific file uri. question have mp3 files in phone , want edit specific file selected how can selected files uri tree , edit it?i tried editing directly using file makes mp3 file disappear , dont want fire saf intent again n again how check user has given permission sd card or not? p.s. using jaudio tagger editing tags of mp3 files. thank you!! have got answers of in question issue if using jaudio tagger library tagging mp3 files takes file objects android 4.4 , above wont let u modify file ob

python - How can i add a level 2 in my game? -

i making space invaders-like game. have finished first first level has 4 rows of 10 aliens. want add level there 4 rows of 17 aliens make difficult , reduce time limit. have made separate module name 'level2' have tried import , run after level 1 completed. can please me figure out. thanks in advance main game(level 1): import pygame, random, sys time import sleep pygame.locals import * import subprocess import level2 black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) blue = (0, 0, 255) navyblue = (0,0,45) grey = (128,128,128) screen_width = 900 screen_height = 650 pygame.init() openscreen = pygame.display.set_mode([screen_width, screen_height]) screen = pygame.display.set_mode([screen_width, screen_height]) class block(pygame.sprite.sprite): def __init__(self, image): aliens = pygame.image.load('aliens.png') aliens = pygame.transform.scale(aliens, (20,20)) super(block, self).__init__() self.image = aliens

java - Dynamically updating a fragment -

i have mainactivity has multiple tabs. each tab showlistfragment , extends fragment. now, each tab contains data fetch database. have move-button moves data 1 tab in each fragment: @override public void onclick(dialoginterface dialog, int listindex) { database.add(listindex,object); database.remove(listindex,object); } the fragment not update directly, after few swipes in between tabs (3 exactly). how force fragment update instantaneous after clicked button? don't want manage through onpageselected in viewpager, since not update fragment i'm on, after i've swiped next fragment. , don't want update data after each swipe. i know maybe need use kind of observer pattern this: how make class extend observable when has extended class too? still, i'm still not sure how update fragment directly, , how apply observer/event pattern in application. since fragments can access activity enough getactivity() , make activity central hub dispatching upda

github - How to maintain up-to-date version of git repository for non-git collaborators -

i have private git repository multiple contributors. have up-to-date version of repository's master branch in network drive (including ones doesn't use git) have access tools in repo. i have understood possible git hooks, i'm not sure how or best practice so. directory in network drive should clone of git repository's master , if accidentally modified, should cleaned whenever commits master next time. edit: of contributors , collaborators work windows. you need hook on push event (see here ). whenever receive request hook, can do git fetch origin git reset --hard origin/master this fetch updates 'origin' repository , change local 'master' branch same state remote 'master'.

JVM (Java Virtual Machine) is an abstract machine. -

i java beginner. read line " jvm (java virtual machine) abstract machine." can please me understand term abstract machine. abstract machine. an abstract machine machine not have physical existence. abstractness a bicycle has physical existence. can touch it. not abstract. a computer chip has physical existence. can touch it. not abstract. a jvm executing program ... , has no physical existence. cannot touch it. abstract. machine-ness: a bicycle machine transporting people. a computer chip machine executing programs ... coded in instruction set of chip; e.g. intel x86 machine code. a jvm machine executing programs ... coded in instruction set of jvms; i.e. java bytecodes.

javascript - Open a popup using on_sent_ok using Contact Form 7 and Ninja Popups? -

i using wordpress contact form 7 , ninja popups. open popup when form sent using cf7's additional settings. have tried: on_sent_ok: "snp_open_popup(’’,’’,’snppopup-content-popupid’,’content’);" (where popupid id of ninja popup want open) not working. some javascript examples call popup using ninja popups: popup_id=’25’ ;snp_open_popup(’’, ’’, ‘snppopup-content-’ + popup_id, ‘content’); or jquery(“selector”).click(function(){ return snp_open_popup(’’,’’,’snppopup-content-popupidhere’,’content’); }); this used ninja popup shortcode inside page/post content: [ninja-popup id=xx] or onclick=”return snp_open_popup(’’,’’,’snppopup-content-popupidhere’,’content’); ” and [ninja-popup id=xx] in page content. i figure this, there has way call popup using on_sent_ok haven't been able figure out. any appreciated - thanks!

java - Save the information in a RealmList locally -

i'm trying create list of objects using realm.io. i've managed create realmlist of objects extend realm objects , convert recycler view displays of objects in realmlist. i've added ability add objects list. however, whenever close , re-open app, of items added realmlist gone , list started scratch. how can save realmlist locally of items added list remain when app closed , opened again? if modify realm objects definition , have deleterealmifmigrationneeded() in realm initialization realm data cleared. if don't have option or don't modify definitions data has same between application restarts.

ios - drop pin with long touch in google maps -

i can't add marker long touch in google maps in swift have try lots of codes doesn't work me should !? override func viewdidload() { super.viewdidload() gmsservices.provideapikey("aizasybw95wehcsisbmpwuykik0_ibnzqk-lm7i") locationmanager.delegate = self locationmanager.requestwheninuseauthorization() locationmanager.desiredaccuracy = kcllocationaccuracybest locationmanager.startupdatinglocation() } func locationmanager(manager: cllocationmanager, didfailwitherror error: nserror) { print("error" + error.description) } func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) { let userlocation = locations.last let center = cllocationcoordinate2d(latitude: userlocation!.coordinate.latitude, longitude: userlocation!.coordinate.longitude) let camera = gmscameraposition.camerawithlatitude(userlocation!.coordinate.latitude,

Login failed for user (Microsoft SQL Server, Error:18456) SQL Server 2005 -

i using sql server 2005. tcp/ip enabled. windows authentication being used. while trying connect server database engine server type, getting error message "login failed user 'name-pc\account 2'(microsoft sql server, error:18456)" . this error means given windows user 'name-pc\account 2' not have access given instance. can login 'sa'(if enabled otherwise login other sysadmin account) , check if 'name-pc\account 2' exists , enabled. you can read more error , gain more information here please read comments too, important tips , points reached in comments

c - Why can't auto, static keyword be used in formal parameter in function definitions? -

compiler - mingw gcc os - windows 10 statement 1: void fun(auto int a){} // statement 1 - error! statement 2: void fun(static int a){} // statement 2- error! statement 3: static void fun(auto int a){} //statement 3- error! statement 4: void fun(register int a){} // statement 4-no error(valid) why statements 1,2 , 3 generate compile time errors statement 4 not? what problem while using auto in formal parameters in function? here error output: error: storage class specified parameter 'a' void fun(auto int a) because standard says so. see 6.7.6.3p2 : the storage-class specifier shall occur in parameter declaration register . storage class specifiers don't make sense function parameters.

python - Vim-plug plugin manager unable to use post-update hooks on YouCompleteMe plugin -

Image
i using vim-plug plugin manager , worked great until tried install youcompleteme plugin it. tried putting plug 'valloric/youcompleteme', { 'do': './install.py' } on .vimrc , tried pluginstall! , plugupdate! without success. read documentation github , thought should work that. althought unsure if should done running ~/.vim/plugged/youcompleteme/install.py --all in command line , not using vundle. ps. computer using arch linux, don't think relates problem. if need more info please let me know! it might timing out while downloading. you can clone valloric/youcompleteme .vim/plugged , installation . you can still keep plug 'valloric/youcompleteme' in .vimrc, update when plugin gets updated.

javascript - ajax get Excel form php -

i tryinh excel form php through ajax call when load url of specific php gives me output when same php called via ajax ajax value nothing shows up.. not sure do ajax: var fromdate= $("#fromdate").val(); var todate= $("#todate").val(); var year= $('#year').val(); var category=$('#category_1').val(); $.ajax({ url: "http://localhost/demo.php", type: "post", data: { fromdate:fromdate,todate:todate,year:year,category:category }, success: function(responsecon) { window.open('http://your_url','_blank' ); } }); php: <?php $conn=mysqli_connect('localhost','root','0

jquery - scroll to anchor not working on Wordpress page -

from this answer , found code animate scroll anchors here . the site in question wordpress, replaced $ jquery : jquery(document).ready(function() { jquery('a[href^="#"]').on('click', function(event) { var target = $(this.href); if( target.length ) { event.preventdefault(); jquery('window').animate({ scrolltop: target.offset().top }, 1000); } } }); edited wolff. however, clicking anchors @ top of content on this page not scroll movement anchor, still moves instantly on click. e.g. links don't scroll anchors: personal assistants after sales service etc. assistance appreciated. this work! jquery('a[href^="#"]').on('click', function(event) { event.preventdefault(); var anch = this.href.match(/#[a-za-z0-9-_]+/i), target = jquery(anch[0]); if( target.length ) { jquery('html, bod

javascript - Spawn process on remote host in NodeJS -

i have simple node server serves page button. on click button needs execute command on remote host. when command finishes, output should given response of function , shown in html. currently server code: app.use(logger("combined")); app.use(bodyparser.urlencoded({ extended: true })); app.use(bodyparser.json()); app.get('/index.html', function (req, res) { res.sendfile( __dirname + "/" + "index.html" ); }) app.post('/connect', function (req, res) { var spawn = require('cross-spawn-async'); var mpiproc = spawn('ssh','pi@raspi2','"ls"', { stdio: ['pipe','pipe',2,'pipe'] }); var grid = "...8.1..........435............7.8........1...2..3....6......75..34........2..6.."; str = ""; mpiproc.stdout.on('data', function(data) { console.log(data); str = data.tostring(); res.write('data: ' + jso

networking - UDP load balancing using customised balancing method with session id inside UDP body -

i trying set load balancing solution able load balance udp traffic. in case, have several different servers send udp package load-balancer. inside each udp package body, there msg-id field. ideally, want load-balance udp traffic set of servers based on msg-id. in other words, 2 udp packages same msg-id should sent same server (because want assemble 2 udp packages same msg-id form complete package further processing). if it's not possible, solution based on source/sender ip might sufficient. haproxy doesn't support udp checking nginx. seems nginx-plus (not free solution) allows load-balance based on ip_hash method? i wish know: what best open-source solution me handle load-balance based on custom msg-id inside udp body. does nginx (free/open-source) version support @ least udp load-balance based on ip_hash method. is there anyway can spoof udp source/sender ip. basically, if have server (such server a) receive udp package multiple server (server d) , forward set of