Posts

Showing posts from July, 2014

netbeans - How does javafx compares colors? -

for school need make game called memory, mine isn't working fine. have cards , can turn around don't know how can javafx compares colors , turning cards if colors not mach or let cards dissapear if colors mach. can guys please me? little part of code: d = rectangle { width: bind 150 height: bind 150 x: bind 500 y: bind 20 arcwidth: 20 archeight: 20 fill: color.green stroke: color.black strokewidth: 1.0 onmouseclicked:function(a: mouseevent) { if(d.fill == color.green) d.fill = color1.yellow else d.fill = color.green } } if(color1.equals("yellow")) && (color2.equals("yellow")) { d.setvisible(false); j.setvisible(false); } versions 2.x javafx obiously partly open source ( stack overflow reference ). link found source code equals() method in color class versions 2.x : /** * indicates whether other object "equal to" one. * @param obj refere...

amazon web services - How to ensure to update Docker image on AWS ECS? -

i use docker hub store private docker image, repository has webhook once image updated calls service built to: update ecs task definition update ecs service deregister old ecs task definition the service running accordingly. after runs ecs creates new task new task definition, stops task old task definition , service come new definition. the point docker image not updated, once service starts in new task definition remains old image. am doing wrong? how o ensure docker image updated? after analysing aws ecs logs found out problem in ecs docker authentication. to solve i've added following data file /etc/ecs/ecs.config ecs_cluster=default ecs_engine_auth_type=dockercfg ecs_engine_auth_data={"https://index.docker.io/v1/":{"auth":"your_docker_hub_auth","email":"your_docker_hub_email"}} just replace your_docker_hub_auth , your_docker_hub_email own information , shall work properly. to find information ...

Ruby: undefined method `include?' for nil:NilClass (NoMethodError) -

i can't find proper fix delete conditional expression error, 'include?' when "delete" puts "please type verbatim task delete:" target_task = gets.chomp if @all_tasks.include?("target_task") @all_tasks.delete("target_task") puts "#{target_task} removed list" end full code linked here @ github. line 70. i've tried proper include? format linked here , tried every combination of parenthesis , quotations target_task , , tried including my_list.@all_tasks.include? too. no dice. the problem @all_tasks instance variable of list class , try access outside class. that, add attr_reader :all_tasks inside definition of list class , call if my_list.all_tasks.include?("target_task") instead.

c# - design a usercontrol for different scenario -

now working on registration system, there 3 different scenario users' personal information (name, address e.g.) 1. prepopulate data table1 2. prepopulate data table2 3. empty new user i trying make personal information usercontrol these 3 situation, in case guess need switch determine table go. question worth this? because not sure if client add more scenario in future. thanks yes, in general it's idea follow dry (don't repeat yourself) principle. if you're going present same user interface in 2 (or more) places should attempt code/design once , reuse it. even if presented 1 data source though should attempt decouple presentation model , business logic. it makes code maintenance , testing easier.

dart - What does the pubspec.yaml's environment mean in this context? -

i notice environment variable in intl package's pubspec.yaml says supports between sdk '1.4.0 2.0.0' i found description of environment variable here but, particular version's numer_format.dart has null aware operators not introduced until 1.12.0. am understanding definition of pubspec's environment variable correctly? thanks you correct sdk constraint should modified >=1.12.0 <2.0.0 . can file issue (or better submit pull-request).

.net - C# - Does DataTable.Merge() add duplicates or update? -

i have 2 datatables. 1 current rows in table sqlserver , 1 new rows want add. i want like: datatable1.merge(datatable2); i trying figure out, if duplicates between these 2 tables exist, duplicate added datatable1, or update values in datatable1? i need duplicates updated in datatable1, , non-duplicates added datatable1. iv searched msdn , cant find distinct answer. from last paragraph merge documentaton when merging new source datatable target, source rows datarowstate value of unchanged, modified, or deleted, matched target rows same primary key values. source rows datarowstate value of added matched new target rows same primary key values new source rows. it update row has same primary key. primary key set datatable.primarykey property

r - What is the difference between following lines of code? -

here's code levels(data[,7]) ## output levels of column in vector levels(data[,7])[data[,7]] ## not 100% sure i think second 1 gives vector of non-duplicate values (as far got). clarification appreciated. the first line shows levels of factor variable in data[,7] - is, unique values of factor. the second line uses values in data[,7] index unique levels. which, in case, gives data[,7]. it's useful construct if instead of levels have vector of colors want use different points in plot. > levels(data[,2])[data[,2]] [1] "a" "b" "b" "b" "c" "b" "a" "a" "b" "b" "c" "b" "a" "c" "a" "c" "a" "a" "a" "a" > c("red", "blue", "green")[data[,2]] [1] "red" "blue" "blue" "blue" "...

How to get Facebook Friends Age in Android -

i writing app in fetching list of facebook friends along names, profile pics , birthdays , using below query: string query = "select name, birthday, uid, pic_square user uid in (select uid2 friend uid1=me()) order birthday_date asc"; and have given these permissions : string[] facebook_permissions = { "user_photos", "user_birthday", "friends_birthday", "friends_photos", "read_stream", "offline_access" }; but want show age of facebook friend, , guess should use age_range i trying age of facebook friends using below query getting null in place of age : string query = "select name, birthday, uid, pic_square, age_range user uid in (select uid2 friend uid1=me()) order birthday_date asc"; age range not how old person, but, facebook documentation says: containing min , max age range; possible age ranges 13-17, 18-20, , 21+; max not set if age 21+ why do...

javascript - Embedded HTML5 player refuses fullscreen requests -

this whole page <html> <head> <script type="text/javascript" src="//bitmovin-a.akamaihd.net/bitdash/latest/bitdash.min.js"></script> </head> <body> <div id="player"></div> <script type="text/javascript"> var conf = { key: "xxxxxxx", playback: { autoplay: true }, source: { dash: 'http://xxxxxx', poster: 'https://i.ytimg.com/vi/y5qyusmznhg/maxresdefault.jpg' } }; var player = bitdash('player'); if (player.requestfullscreen) { player.requestfullscreen(); } player.setup(conf).then(function(value) { // success console.log('successfully created bitdash player instance'); }, function(reason) { // error! console.log('error while creating bitdash player instance'); }); </script> </body> </html...

raspberry pi2 - Trouble lighting and extinguishing an LED based on the contents of a variable in Python 2 -

i'm working on weather station draws environment canada data toronto. if wind speed , wind chill results exceeds or falls below numbers, want light leds on breadboard. the wind speed warning works correctly using following code: if ((cityobject.get_quantity(wind)) > windmax: gpio.output(13,gpio.high) else: gpio.output(13,gpio.low) the wind chill warning proving more complex. environment canada returns "none" when there no discernible wind chill. but, eventually, return negative integer instead. following code lights wind chill warning led when, really, should off: chillzero = "none" if (cityobject.get_quantity(chill)) == chillzero: gpio.output(11,gpio.low) if (cityobject.get_quantity(chill)) < chillmax: gpio.output(11,gpio.high) else: gpio.output(11,gpio.low) at time of writing, following returns none print cityobject.get_quantity(chill) any idea why code causing led stay illuminated? want come on when wind chill below -15c . i...

osx - Python OSError: [Errno 24] Too many open files -

i use ipython notebook on mac os 10.11.2. run python 3.5.1 , matplotlib 1.5.1 , seaborn version 0.6.0: %matplotlib inline import matplotlib.pyplot plt import seaborn sns i started having issues when plotting using matplotlib/seaborn. after generating few plots within same notebook, notebook cell latest plot being generated crashes error: oserror: [errno 24] many open files: '/library/fonts/arial.ttf' i still able run other cells same error raised every time try plot within notebook until restart it. i tried increasing files limit running: sudo launchctl limit maxfiles 10000000 10000000 it seems have helped bit issue persists. suggestion on how solve issue once , appreciated. ! below exact output of error: oserror traceback (most recent call last) /users/spfraib/anaconda/lib/python3.5/site-packages/ipython/core/formatters.py in __call__(self, obj) /users/spfraib/anaconda/lib/python3.5/site-packages/ipython/core/pylabto...

What is the best way of handling return in CakePhp Models? -

i'm researching coding standards cakephp 2.8 project. i'm looking way of handling return values in models. for example in model want return data queried database. want say, "hey found data want , here is" or "sorry couldn't find anything" or "i encountered error while looking data want" so there 3 types of return, data found without error no data found without error an error has occured while looking data any appriciated. why need that? built in a) $data contains data b) empty array (no data found obviously) c) exception being thrown, can either catch or not. so problem doesnt exist in first place imo :)

Get KeyDown messages as they happen from SoftKeyboard in Delphi on Android -

hiyas. i'm wanting know keys user pressing, press them in delphi app on android (from soft/virtual keyboard). i've got bit of code show keyboard in form's onshow event , wired other code in onkeydown event onkeydown event fired when user presses enter not press each key. do using addtextlistener on jfmxtexteditorproxy of jfmxnativeactivity? work, if have no views/edit controls (just form on i'm rendering image). can assist? tia. daniel. oh dear, long haul. i have code working now. there may still bugs in odd corner cases i've done best test them. in example code, place keys pressed (including enter , delete key presses) tqueue in form , display them in label (one one). adapt code produce events instead. beware of threading issues. to code working, you'll need blank firemonkey application targeting android. place 3 labels on form , name "testkeydownmainform". name unit "formtestkeydownmain". place timer. ...

d3.js - adding class names to arcs from data in d3.layout.pie() -

i'm creating pie chart json file. wonder if there way can take names json file , assign them class names of arcs created d3.layout.pie(). here example created: http://blockbuilder.org/jinlong25/532d889e01d02cef2d24 essentially, want last line of code below: var data = [ { 'name': 'apple', 'value': 250 }, { 'name': 'banana', 'value': 100 }, { 'name': 'orange', 'value': 150 } ]; var arcs = svg.selectall('g.arc') .data(pie(data.map(function(d) { return d.value; }))) .enter().append('g') .attr('transform', 'translate(70, 70)') .attr('class', function(d) { return d.name; }; but since data has been transformed pie(), wonder if there anyway add class names data generated pie(). thanks! some d3 layouts mutate original dataset others create new dataset (like voronoi...

javascript - Using Ajax to submit form from jQuery tabs -

i having problems submitting form on second tab, the page reloading , submitting first tab. understand can solved using ajax. have read other posts haven't quite grasped explanation great. i form load different page same way 'action' works within html form. the code below shows part of html , jquery. what ajax , need placed in order second , on going tabs post data inputted in particular tab. <div class="tabs"> <ul class="tab-links" style= "margin-top: 50px; width:700px;"> <li class="active"><a href="#tab1"><p>advert space</p></a></li> <li><a href="#tab2"><p>vouchers</p></a></li> <li><a href="#tab3"><p>business 2 business</p></a></li> <li><a href="#tab4"><p>search space ads</p></a></li> <...

Stop meteor iron-router auto rendering template -

my route: router.route('/profile/:_id', { layout: 'apptabs', template: 'appprofile', autorender: false }); my layout: <template name="apptabs"> ... <a href="/profile/{{getuserid}}"> ... <section> {{> yield}} </section> ... </template> my template: <template name="appprofile"> <section> <div>my profile</div> </section> </template> trouble route automatically renders. have link in template, want wait clicked before template rendered. how achieve this?

java - Why does my ApplicationContext fail to load when I enable web security? -

i have spring boot application add spring security too. i've added following configuration, starts , runs fine: @configuration @enablewebsecurity public class securityconfiguration extends websecurityconfigureradapter { @resource private environment environment; @bean public passwordencoder passwordencoder(){ return new bcryptpasswordencoder(); } @override protected void configure(httpsecurity http) throws exception { if(environment.acceptsprofiles("live")) { http.requireschannel().anyrequest().requiressecure(); } http.csrf().disable(); } } the problem functional tests fail load application context. functional tests extend following configuration: @contextconfiguration(loader = springapplicationcontextloader.class, classes = myconfiguration.class) @webappconfiguration @integrationtest class contextinitializer extends gebreportingspec { } when tests attempts load application, throws ...

c# - Should I re-use a Struct? -

i know structs value types , live on stack, unless declared field in reference type, , contain values in memory @ location. i'm wondering whether or not efficient or worthwhile re-use declared struct in iterated loop rather creating new 1 each time. how costly stack instantiate variables, if @ all? also, related question, if instantiate struct inside method call create local copy of struct or create first parameter of method when executes? about declarations: // worth doing... mystruct ms = new mystruct(0); (int = 0; i< 10000; i++) { ms.num = i; // ms } // ...over this: (int = 0; i< 10000; i++) { mystruct ms = new mystruct(i); // ms } public struct mystruct { public int num; public mystruct(int mynum) { num = mynum; } } and instantiation: for (int = 0; i< 10000; i++) { mymethod(new mystruct(i)); // mystruct live in scope? }

java - How to get long from byte array returned by jmrtd's sendGetChallenge (used to get passport random number) -

i'm using jmrtd library on android , process passport information. the first step send challenge passport responds random 64 bit number byte array (8 bytes). the function sendgetchallenge returns byte array. i need print out byte array number make analysis i'm having trouble converting byte array returned long, because i'm not sure if array big endian or little endian. so far i've used following methods: public static long bytearraytolong(byte[] bytes){ long value = 0; value += (long) (bytes[7] & 0x000000ff) << 56; value += (long) (bytes[6] & 0x000000ff) << 48; value += (long) (bytes[5] & 0x000000ff) << 40; value += (long) (bytes[4] & 0x000000ff) << 32; value += (bytes[3] & 0x000000ff) << 24; value += (bytes[2] & 0x000000ff) << 16; value += (bytes[1] & 0x000000ff) << 8; value += (bytes[0] & 0x000000ff); return value; } or private long bytea...

iphone - Not able to display anything on table view Swift -

this history view, have tableview inside view controller. reason can't output anything, trying hardcode , not displaying @ all. 1 thing know need make tableview functions override , if error. import uikit class history: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet var tableview: uitableview! override func viewdidload() { super.viewdidload() tableview.delegate = self tableview.datasource = self self.view.backgroundcolor = uicolor(patternimage: uiimage(named: "newbackground.jpg")!) } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return 1 } func numberofsectionsintableview(tableview: uitableview) -> int { return 1 } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("h...

java - I want the full verision of my website to appear in mobile browsers -

how can make without scaling down? want people have zoom in. possible? website not mobile friendly atm :( as long don't include viewport meta tag, you'll experience you're looking for.

html - SVG Path Clipping issue in Chrome -

Image
i'm experience clipping issue seems affect chrome not firefox. firefox: chrome: this svg tag definitions: <svg width="0" height="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <g> <clippath id="c3"> <polygon points="64.405,221.5 1.207,111.5 64.405,1.5 190.802,1.5 254,111.5 190.802,221.5"/> </clippath> </g> <defs> <g id="fullhex"> <polyline points="64.405,221.5 1.207,111.5 64.405,1.5 190.802,1.5 254,111.5 190.802,221.5 64.405,221.5" style="fill:none; stroke:rgba(60,158,194,.9); stroke-width:10" /> </g> </defs> </svg> this html hexagon containers: <div id="heximagecontainer"> <div id="profileimg1container" class="profileimgcontainer...

php - Maximum function nesting level in Yii -

i know there duplicates question, tried of them, none of them worked. @ last commented out zend_extension in php.ini, browser keeps on processing endlessly. what have i'm calling simple widget view echo \sintret\chat\chatroom::widget([ 'url' => \yii\helpers\url::to(['/site/send-chat']), 'usermodel'=> \common\models\user::classname(), 'userfield' => 'avatarimage' ]); in controller: public function actionsendchat() { if (!empty($_post)) { echo \sintret\chat\chatroom::sendchat($_post); } } here github link chatroom.php contains main widget, has 2 main functions init() , run(). sendchat calling in our controller. any thoughts resolve error welcome.

Swift Property Encapsulation -

i'm wondering "standard" way of declaring property in swift is. in particular, seems of apple's swift example code doesn't encapsulate properties (you can freely , set property without having go through getter , setter methods). (i'm used java have trouble believing that's how apple expects developers write code.) right now, have: private var x: int private var xlistener: xlistener? public func getx() -> int { return x } public func setx(newvalue: int) { x = newvalue if (let listener = xlistener) { listener.onxset(x) } } but feel there must simpler way this. saw mention of computed properties seems don't store value, use them you'd have do: private storedx: int public var x: int { { return storedx } set { storedx = newvalue } didset { if (let listener = xlistener) { listener.onxset(storedx) } } } i have trouble believing either of these meth...

javascript - Jquery.ajax requesting a 'Get' to Web API 2 backend is not working -

i have web api 2 project, , trying write front-end jquery. having issues, , quite frankly, confusing behaviors, when trying user (login). backend: using system; using system.collections.generic; using system.data; using system.data.entity; using system.data.entity.infrastructure; using system.linq; using system.net; using system.net.http; using system.threading.tasks; using system.web.http; using system.web.http.description; using angularjswebapiempty.models; using system.web.script.serialization; namespace angularjswebapiempty.controllers { public class artistscontroller : apicontroller { private bandioappentities db = new bandioappentities(); public artistscontroller() { db.configuration.proxycreationenabled = false; } // get: api/artists public iqueryable<artist> getartists() { return db.artists; } // get: api/artists/5 [responsetype(typeof(artist))] public artist get(string username, string password) ...

Prolog more than one argument or a list as a comparison for a query? -

i'm new prolog , struggling queries. want allow user input number of arguments query. right can work 1 argument aminofor(x) :- aminoname(x,_,z), aminoclass(z,'hydropathy',a), print('hydropathy'), print(a). with if enter valid input x , it'll output 'hydropathy' , value of a . however, want make enter multiple inputs x , have give me hydropathy . e.g. right if enter aminofor(g) . tell me hydropathy neutral if enter aminofor(g,h) . error: undefined procedure: aminofor/2 error: however, there definitions for: error: aminofor/1 false. how solve this, apologies in advance problem explanation appreciated.

javascript - Add each image to text area on click -

i able answer original question here , had change way doing , not working. changed too: foreach ($image_data $key => $row) { //print_r($row); echo '<div class="item image-link" id="img_link" onclick="myfunction()"> <img src="'.$row['s3_link'].'" class="img-responsive img-post" /> <div class="after"> <span class="zoom"> <i class="fa fa-check text-success"></i> </span> </div> </div>'; } this 1 of many different ways have tried it: function myfunction() { var $this = $('.image-link'); var myimg = document.getelementsbyclassname('img-post')[0]; var mysrc = '<div class="col-xs-3 col-...

java - How can I make a link redirect to a servlet? -

this question has answer here: call servlet on click of hyperlink 4 answers i have html file following link: <li><a class="active" href="personalinfooutput.java">view personal information</a></li> when clicks on "view personal information", want redirect servlet, why put: href="personalinfooutput.java but not working. returning: http status 404 - /payroll/personalinfooutput.java here personalinfooutput.java servlet import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class personalinfooutput extends httpservlet { protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8"); printwriter out = response...

unix - Slow, word-by-word terminal printing in Python? -

this question has answer here: how print 1 character @ time on 1 line? 3 answers i'm writing python app involving database. hell of it, i'm including easter egg. if user decides nuke database, terminal, he'll prompted confirm simple (y/n). if types dlg2209tvx instead, lines scene of wargames print. doubt ever find unless through source, that's okay. the problem printing lines plays scene way fast , ruins it. implemented timer between each character's lines slow things down, , it's better, still seems unnatural. there standardized way print each word or character out instead of doing lines @ time? or should start adding timers between words? standardized? not know of. try this: import random import sys import time def slowprint(s): c in s + '\n': sys.stdout.write(c) sys.stdout.flush() # defeat bufferi...

html - AngularJS ng-repeat in div tag issue -

Image
i can't able loop array in div tag. my javascript source code is <script type="text/javascript"> var app = angular.module('drag-and-drop', ['ngdragdrop']); app.controller('onectrl', function($scope, $timeout) { $scope.list1 = []; $scope.list2 = []; $scope.list3 = []; $scope.list4 = []; $scope.list5 = [ { 'title': 'item 1', 'drag': true }, { 'title': 'item 2', 'drag': true }, { 'title': 'item 3', 'drag': true }, { 'title': 'item 4', 'drag': true }, { 'title': 'item 5', 'drag': true }, { 'title': 'item 6', 'drag': true }, { 'title': 'item 7', 'drag': true }, { 'title': 'item 8', 'drag': true } ]; // ...

javascript - ngrepeat Edit in line with form -

Image
i trying allow renaming of item in line. aware of using $scope.editmode etc, realized when use ng-repeats getting of entries in list edditable rather specific index. here have in html: <li ng-repeat="playlist in myplaylist"> <a href="" data-ng-hide="editplaylist">{{playlist.name}}</a> <form data-ng-show="editplaylist" data-ng-submit="renameplaylist()"> <input data-ng-model="editableplaylistname"> </form> </li> my controller uses context menu setting so: $scope.editplaylist =false; $scope.menuoptions = [ ['rename', function ($itemscope) { $scope.editplaylist = true; $scope.editableplaylistname = $itemscope.playlist.name; }] etc. when want rename, setting hide , shows true/false accordingly, issue of items in list true resulting number of input fields each item. how go around show input field corresp...

nginx - Lumen in a subfolder trailing slashes issue -

in public/index.php have changed $app->run() $app->run($app['request']) , resulted in lumen working in sub-folder, works: http://local.dev/app/ http://local.dev/app/test however if there's slash @ end of route notfoundhttpexception . example: http://local.dev/app/test/ i'm using nginx , rewrite rule folder is: location /app/ { try_files $uri $uri/ /app/index.php?$query_string; } am doing wrong?

php - MagicSuggest dependent multiple dropdowns not working -

i using magicsuggest custom dropdown, have 2 dropdowns category , sub category.. sub categories should populated based on category selection. when select category, , subcategory, work first time, if change category sub categories not change , shows same list. here jquery.. var cat = $('#category').magicsuggest({ maxselection:1, data: site+'project/getcats/', valuefield: 'id', displayfield: 'title', mode: 'remote', renderer: function(data){ return '<div>' + '<div class="title">' + data.title + '</div>' + '</div>'; }, resultasstring: true, selectionrenderer: function(data){ return '<div class="name">' + data.title + '</div>'; } }); $(cat).bind('selectionchange', function(event, combo, selection){ cat_id = cat.getvalue(); src = site+'proje...

javascript - Mootools getElements("input[type=radio]") returns Object not Array -

can shed light why getelements("input[type=radio]") or getelements("input[name=radioname]") return object rather array specified in docs? in case, not returning objects, key value index string ("0", "1"...) , last value of key "length" , value of int n. any ideas? which documentation referring to? according : http://mootools.net/docs/core/element/element#element:getelements , return array. and way describe object, looks array me.

ios - Drawing on an image causes the photo to expand -

hi build in app allow users use finger draw line on top of image, issue when user touches screen start drawing images expands make image distorted. here code of viewcontroller: update: code updated try use second image view suggestion maile import uikit import mobilecoreservices class newautographviewcontroler: uiviewcontroller, uinavigationcontrollerdelegate, uiimagepickercontrollerdelegate, uigesturerecognizerdelegate {          var signeditmode: bool = false          @iboutlet var btnedit: uibarbuttonitem!     @iboutlet var textfieldalbum: uitextfield!     @iboutlet var imageview: uiimageview!          @iboutlet var signimageview: uiimageview!     @ibaction func btnbackclick(sender: anyobject) {         self.navigationcontroller?.popviewcontrolleranimated(true)              }          @ibaction func btneditclick(sender: anyobject) {         if signeditmode {             signeditmode = false             signimageview.backgroundcolor = nil             btnedit.title = ...