Posts

Showing posts from April, 2015

javascript - $scope doesnt update on change -

i trying update view on button click, doing wrong. console showing array want be, ng-repeat list not updating. html: <body ng-app="myapp"> <div layout="row" ng-controller="lekovicontroller"> <md-content md-scroll-y flex class="lista_lekova_layout"> <md-list> <md-list-item ng-repeat="lek in lekovi | filter:search"> <p ng-click="prikaz(lek)">{{lek.naziv}}</p> </md-list-item> </md-list> <button ng-click="loadmore()">ucitaj jos</button> </md-content> </div> </body> js: var app = angular.module('myapp', [ 'lbservices', 'ui.router', 'ngresource', 'ngmaterial', 'ngmdicons', 'ngroute' ]); app.controller('lekovicontroller', ['$scope', ...

java - MySQL error - incorrect DOUBLE value: 'chests' -

i trying add value specific user called chests when execute method: public void addamm(player player, int amount, datatype type) { try { statement sql = mysql.getconnection().createstatement(); sql.executeupdate("update `playerinfo` set `chests`= '" + amount + "' + 'chests' username='" + player.getname() + "';"); sql.close(); } catch (sqlexception e) { e.printstacktrace(); } } it gives me error: [12:26:14 warn]: com.mysql.jdbc.mysqldatatruncation: data truncation: truncated incorrect double value: 'chests' let's assume amount 5 , player.getname() paul . is: "update `playerinfo` set `chests`= '5' + 'chests' username='paul';" so assign '5' + 'chests' `chests` . if column of type double, assigned value has converted (truncated). may wanted rather following: "update `playerinfo` set `chest...

git - Cloning a private Github repo as a collaborator when I have multiple accounts -

i have 2 github accounts: account1 account2 in account2 i'm added collaborator of repo: account_notmine/repo_xyz i've created , added new ssh key second account, , added on github. host github.com hostname github.com user git identityfile ~/.ssh/id_rsa host github-new hostname github.com user git identityfile ~/.ssh/id_rsa_new now, if try work on 1 of personal repositories of account2, works fine. when try clone repo of i'm collaborator, doesn't work. basically, i'm doing trying execute command: git clone --bare git@github-new:account_notmine/repo_xyz.git and error gives me is: cloning bare repository 'repo_xyz.git'... warning: permanently added 'github.com,xxx.xxx.xxx.xxx' (rsa) list of known hosts. error: repository not found. fatal: not read remote repository. please make sure have correct access rights , repository exists. what doing wrong? i had problem in past tried solve: error: repository n...

java - Declaring variable and assignment -

i practicing java program in eclispe following code: import java.util.*; class problem7 { public static void main(string args[]){ int num,sum=0,mod_num,count;//syntax error on token ";", { expected after //this token. ques=why? system.out.println("enter 5 digit number"); try(scanner n1 = new scanner(system.in)) { num = n1.nextint(); } for(count = 0; count <= 4; count=count+1) { mod_num = num%10; num=num/10; sum = sum+mod_num; } system.out.println("the sum off digits "+sum); } } ========================================================================== above code runs correctly without error. if wanted use different class "class sum_of_digits" following code. starts shows error in class "sum_of_digits" before create object.following code: import java.util.*; class sum_of_digits { int num,sum=0,mod_num,count;//syntax error on token ";", { expect...

javascript - CKEditor what to get cursor position and set again after replacing text -

i want set cursor position manually specific position in ckeditor . have implemented short keys on key press adding text using set data in ckeditor (e.g. if type "rnd+space", replace "research , development "). problem after set data cursor set last @ end of text. i want cursor there, text replaced. possible?

mysql - Why does the query execute so much slower when all the columns involved are the same and only the where condition changes? -

i have query: select 1 inputindex, if(trim(deviceinput1name = '', 0, if(instr(deviceinput1name, '|') > 0, 2, 1)) inputtype, (select value1_1 devicevalues deviceid = devices.deviceid order valuetime desc limit 1) inputvalueleft, (select value1_2 devicevalues deviceid = devices.deviceid order valuetime desc limit 1) inputvalueright devices deviceimei = 'some_search_value'; this completes (in 0.01 seconds). however, running same query where clause such deviceimei = 'some_other_search_value'; makes run upwards of 14 seconds! search values finish quickly, while others run way long. if run explain on either query, following: +----+--------------------+--------------+-------+---------------+------------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | | +----+--------------------+--------------+-------+-------------...

composer php - Laravel 5 - "laravel new" command -

help guys in installing laravel 5, i'm using windows 7 home premium i'm using git bash terminal i run command composer global require "laravel/installer=~1.1" and installed but when ran laravel new blog it shows message below: crafting application... 'composer' not recognized internal or external command, operable program or batch file. application ready! build amazing. there's error message "'composer' not recognized....". why happening me? composer command working fine. :( i've added path ";c:\users\username\appdata\roaming\composer\vendor\bin" system variables run command install laravel: composer create-project laravel/laravel --prefer-dist http://laravel.com/docs/5.0/installation

lint - Unsuppress Android Studio warnings -

Image
in order off back, suppressed few warnings in android studio -- warnings regarding formatting issues font size , button styles. in retrospect, i'd rather hadn't, since i'm @ point i'd ensure code complies relevant styling guidelines. so, how unsuppress these warnings? thanks. in android studio, open preferences , select editor -> inspections side menu. should see large, collapsible list can change potential problems indicated , severity. screenshot below shows example of window in android studio 2.0. if remember settings want revert, can search them , re-check box. can select gear icon above list reset default settings. if have warnings relatively sure can ignore don't want hidden completely, change severity lower level. changing 'warning' 'weak warning' or 'info' cause indicator little less annoying , if using built-in version control tools, allow pass pre-commit code analysis. jetbrains has pretty support articl...

Convert CLLocationCoordinate2D to double or int swift -

how convert cllocationcoordiante double can perorrm arithmetic on , compare coordinates using size? in (swift ios) cllocationcoordinate2d struct of latitude , longitude both defined cllocationdegrees typealias of double . the following code creates location in code, supplied mapkit function: var location = cllocationcoordinate2d(latitude: 10.30, longitude: 44.34) you can access values calling location.latitude , location.longitude .

python - Starting celery worker from multiprocessing -

i'm new celery. of examples i've seen start celery worker command line. e.g: $ celery -a proj worker -l info i'm starting project on elastic beanstalk , thought nice have worker subprocess of web app. tried using multiprocessing , seems work. i'm wondering if idea, or if there might disadvantages. import celery import multiprocessing class workerprocess(multiprocessing.process): def __init__(self): super().__init__(name='celery_worker_process') def run(self): argv = [ 'worker', '--loglevel=warning', '--hostname=local', ] app.worker_main(argv) def start_celery(): global worker_process worker_process = workerprocess() worker_process.start() def stop_celery(): global worker_process if worker_process: worker_process.terminate() worker_process = none worker_name = 'celery@local' worker_process = none a...

java - GUI not updating after a remove, revalidate, and repaint -

Image
in program i'm creating, i'm showing local queue on gui, , letting user have option click button remove top element of queue, removing queue , panel. when try remove panel , "refresh" panel, works once. screenshot of panel: example of situation: 1) queue of 5 elements created , shown on panel 2) user clicks button remove top of queue top of queue deleted , removed screen 3) user clicks button remove top of queue again top of queue deleted not remove screen (side note: adds resolvedtickets_ panel once well) here code snippet; can provide more if need be: public void actionperformed(actionevent evt) { if("removefromqueue".equals(evt.getactioncommand())){ system.out.println("removefromqueue button clicked"); if(empty()){ joptionpane.showmessagedialog(null, "queue empty! work."); return; } // removes top of queue screen mainframe.activeque...

c# - NBitcoin throws InvalidOperationException with the message: "Mac HMACSHA256 not recognised." -

i got message when try sign transaction: transaction payment = new transaction(); bitcoinsecret paymentsecret = new bitcoinsecret("1sxcvdpxz...uqkxw9mvt"); ... payment.sign(container.paymentsecret, false); i dig opensource nbitcoin api , figured out these lines give me error message. can do? ( https://github.com/nicolasdorier/nbitcoin/blob/master/nbitcoin/crypto/deterministicecdsa.cs ) try { hmac = macutilities.getmac(macname); } catch(securityutilityexception nsae) { throw new invalidoperationexception(nsae.message, nsae); } if figure out happening exactly, here's code snippet that'll cause bug: string mechanism = "hmacsha256"; if (mechanism.startswith("hmac")) { console.writeline("good"); } else { console.writeline("bad"); } console.readline(); if set mechanism = "hmac-sha256", bug won't happen. if use mechanism.startswith("hmac...

How to download a file using php? -

i want download file server using php. searched google , found stackoverflow answer here . answer shows have write these codes purpose. $file_url = 'http://www.myremoteserver.com/file.exe'; header('content-type: application/octet-stream'); header("content-transfer-encoding: binary"); header("content-disposition: attachment; filename=\"" . basename($file_url) . "\""); readfile($file_url); but able merely these 2 lines: header("content-disposition:attachment; filename=uploads1/efl1.5_setup.exe"); readfile("uploads1/efl1.5_setup.exe"); so why should write few more lines codes above? header('content-type: application/octet-stream'); the content-type should whatever known be, if know it. application/octet-stream defined "arbitrary binary data" in rfc 2046, , there's definite overlap here of being appropriate entities sole intended purpose saved disk, , point on out...

access vba - Opening a combo box from another object -

i know if possible open combo box , see it's elements listed object on form. not 'down arrow' on combo box , create more 'stylish' if possible. wondering if there routine 1 write , put on object upon 'on click' event, user see elements listed within combo box , have opportunity select 1 of them. for can use dropdown method of combobox object. example: dim cmb1 combobox: set cmb1 = me.combo1 cmb1.setfocus ' necessary cmb1.dropdown note: control needs have focus have set programmatically first.

Clarification on skeleton code for C graphics library -

Image
i'm studying c , i've been given code draws single line of pixels: void draw_line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2) { // insert algorithm here. if (x1 == x2) { //draw horizontal line unsigned char i; (i = y1; <= y2; i++){ set_pixel(x1, i, 1); } } else if (y1 == y2){ //draw vertical line unsigned char i; (i = x1; <= x2; i++){ set_pixel(i, y1, 1); } i understand how works, not how implement it. provide example of how use it? hope you: algorithm: 1)get x , y co-ordinates of start , end points of line. 2)find difference in x , y co-ordinates values dx , dy. 3)check if dx greater of dy greater , assign greater value ‘steps’. 4)increment x , y values @ regular intervals dividing corresponding axes difference steps. 5)plot initial point using “putpixel” syntax. 6)repeat step 4 ‘steps’ number of times , mark end point using “putpixel” syntax. 7)end prog...

sockets - Haunted by KillerService.exe while attempting to get C# server & client programs to communicate (from same machine) -

i made client & server programs in c# based on this example code . server program: tcplistener tcplistener = new tcplistener(8080); tcplistener.start(); first time ran this, windows firewall popped , asked me if should allowed network access. client program: iphostentry ip = dns.gethostentry(tbserver.text);//"mycomputer-msi" string addr = ip.addresslist[0].tostring(); tcpclient clientsocket = new tcpclient(addr, 8080); at last line above, got message: an unhandled exception of type 'system.net.sockets.socketexception' occurred in system.dll additional information: no connection made because target machine actively refused it i made sure both programs (client.exe , server.exe) allowed windows firewall. no other antivirus enabled (as far know). checked conflicts command netstat -a -b : [killerservice.exe] tcp 127.0.0.1:8080 mycomputer-msi:0 listening the strange thing killerservice.exe (which can...

html - Div not centering as expected -

i'm trying center inner divs setting margins on outer div, not appear working. so html looks this: <div id="outer"> <div class="inner"><span>h</span></div> <div class="inner"><span>i</span></div> </div> my css looks this: #outer { display: block; width: 100%; margin: 0 auto; /* not working reason */ } #outer .inner { display: inline-block; /* used put boxes side side */ margin: 0 0 0 1%; width: 5%; } i can't figured out wrong css code. if set fixed width, still won't center. just use text-align: center css property in #outer div center .inner divs (as display ed inline elements). #outer { text-align:center; } #outer .inner { display: inline-block;width: 5%; } <div id="outer"> <div class="inner"><span>h</span></div> <div class="inner"><span>i</span><...

python - How to get an index for an element in numpy array? -

if have: a = np.array(['a','b','c','d']) how index letter 'c'? np.where find positions: > np.where(a == 'c')[0][0] 2

html - Is it possible to have Inline text with carriage returns after each element? -

question: how can have elements display:inline but still have carriage return @ end of each span or a element? caveats: no br tag must use display: inline undetermined width of elements html: ... <hgroup> <span>{{splash.title}}</span> <span>{{splash.desc}}</span> <a ui-sref="principle" class="btn-primary">enter</a> </hgroup> css: hgroup { max-width: 360px; } span { font-weight: 300; color: $base-black; font-size: 3.75rem; display: inline; } while other answer featuring white-space here’s option: instead of using pseudo-class style hgroup with white-space: pre-line;

c# - Avoid that a word be deselected -

i'm working in application going measure speed of typing. i want select word writing @ moment. have fragment of code in form load event: string line; filestream fs = new filestream("text.txt", filemode.open, fileaccess.read); streamreader fr = new streamreader(fs); while ((line = fr.readline()) != null) { textbox1.appendtext(line); } string texto = textbox1.text; string[] split = texto.split(new char[] { ' ' }); textbox1.selectionstart = 0; textbox1.selectionlength = split[0].length; that works correctly, when change focus textbox begin type, selected word disappears. is there way avoid happening ? to prevent textbox losing selection when loses focus, can (when form created). textbox1.hideselection = false; refer textboxbase.hideselection property : gets or sets value indicating whether selected text in text box control remains highlighted when control loses focus.

php - Wordpress Core Data Validation Functions not working -

i'm developing custom theme wordpress site , want use wordpress core data validation functions validate info forms. every time try use sanitize_text_field() function error: fatal error: call undefined function sanitize_text_field(). i've read many posts similar issues, specially using $wpdb , none of them seem work. the file in i'm trying use sanitation functions inside theme directory, in case piece of info helps solve mystery. i've seen posts talking including wp-load.php , formatting.php files none of attempts has worked yet. ok, kept searching , found solution, adding next line of code beginning of file solved problem: require_once( explode( "wp-content" , __file__ )[0] . "wp-load.php" ); i hope helps else too.

javascript - Make Navigation Bar that Shrinks when Scrolling Begins -

i designing website have navigation bar sticks top of page, gets smaller whenever user scrolls down. example of https://www.endgame.com/ . if possible, solely css, if necessary, willing javascript. after research , looking @ endgame's source code, unable figure out how this. how achieved? use css transitions , little jquery (4 lines): $(document).scroll(function() { if ($(this).scrolltop() > 10) { //adjust 150 $('#head').addclass('shrinked'); } else { $('#head').removeclass('shrinked'); } }); body { height: 9999px; margin: 0; background: url(http://webdesignledger.com/wp-content/uploads/2009/09/pattern_places_8.jpg) repeat;/* added sense of scrok=lling */ } #head { background-color: red; height: 100px; width: 100%; position: fixed; top: 0; } #head, #head * { transition: 0.3s ease; } #head.shrinked { height: 30px; } #head.shrinked span { color: blue; } <scr...

javascript - Getting musicmetadata to work in the browser -

here library i'm trying use: https://github.com/leetreveil/musicmetadata there docs showhow use it, docs uses function called fs.createreadstream open file. functionality users of node, , believe not avilable (or not applicable) in browser enviornment. assume need use filereader ? file in case going come <input> field. here example library's docs: var parser = mm(fs.createreadstream('sample.mp3'), function (err, metadata) { if (err) throw err; console.log(metadata); }); i tried using didn't work: $("input[type=file]").change(function(event) { var reader = new filereader(); reader.onload = function(e) { var blob = reader.result; var parser = new musicmetadata(blob); parser.on('metadata', function (result) { console.log("mp3 tags!!!", result); }); } reader.readasbinarystring($(this)[0].files[0]); }); edit: discovered browser example: https://gi...

'wdm' Gem on Windows 8.1 x64 Ruby 2.1.5 -

i trying learn how testing rspec, capybara & guard. requires me install wdm gem work guard listener on windows. for reason failing. can tell me happening here? bit out of league. wdm gem reason not installing: gemfile: source 'https://rubygems.org' ruby '2.1.5' # bundle edge rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.1' # use sqlite3 database active record gem 'sqlite3' # use scss stylesheets gem 'sass-rails', '~> 5.0' # use uglifier compressor javascript assets gem 'uglifier', '>= 1.3.0' # use coffeescript .coffee assets , views gem 'coffee-rails', '~> 4.1.0' # see https://github.com/rails/execjs#readme more supported runtimes # gem 'therubyracer', platforms: :ruby # use jquery javascript library gem 'jquery-rails' # turbolinks makes following links in web application faster. read more: https://github.com/rails/turb...

java - Adding Two Large Numbers Using Stacks -

i'm trying make program can add large numbers out of ordinary 8,330,103,343,234 , 5,123,342,345,231 or numbers based on user input. radical example. issues aside implementing stack class i'm not entirely sure on how user input numbers stack string . know i'll have make use of 2 stacks , possibly third 1 hold remainder of numbers. i'm not entirely sure how handling user input, following might started in simple linear fashion (just example): stack<biginteger> stack = new stack<biginteger>(); scanner scan = new scanner(system.in); system.out.print("enter number: "); biginteger bi = new biginteger(scan.next().trim()); stack.push(bi); system.out.print("enter number: "); bi = new biginteger(scan.next().trim()); stack.push(bi); system.out.println(stack.pop().add(stack.pop()));

javascript - Return a value from AngularJS API service to controller -

if have service looks this: app.factory('user', function($http, user) { var user = function(data) { angular.extend(this, data); }; user.prototype.create = function() { var user = this; return $http.post(api, user.getproperties()).success(function(response) { user.uid = response.data.uid; }).error(function(response) { }); }; user.get = function(id) { return $http.get(url).success(function(response) { return new user(response.data); }); }; return user; }); how i, in controller, user created in get() function? currently have is: app.controller('userctrl', function($scope, user) { $scope.user = null; user.get($routeparams.rid).success(function(u) { $scope.user = new user(u.data); }); }); the issue userctrl getting api response, not value returned success() in factory. i'd prefer making new user in factory, opposed passing...

types - Expected pointer to struct slice -

i'm working on server in golang. i have auth-helper authenticates user secure token (its test) . error comes when make query (i'm using dep ) in authusingcredentials function, outputs following error: "expected pointer struct slice *[]struct" if change var result *entities.user var result []entities.user , print result[0] works outputs: "cannot use result[0] (type entities.user) type *entities.user in argument ah.userentitytomodel" the auth helper code: auth.go package helpers import ( "fmt" "server/data/entities" "server/data/models" "server/interfaces" ) var authhelper *authhelper type authhelper struct{} func init() { authhelper = &authhelper{} } func (ah *authhelper) userentitytomodel(_entity *entities.user) (*models.user, error) { u := models.newuser(_entity, db) u.username = _entity.username return u, nil } func (ah *authhelper) authenticateusingcrede...

dummy variables to single categorical variable (factor) in R -

i have set of variables coded binomial. pre value_1 value_2 value_3 value_4 value_5 value_6 value_7 value_8 1 1 0 0 0 0 0 1 0 0 2 1 0 0 0 0 1 0 0 0 3 1 0 0 0 0 1 0 0 0 4 1 0 0 0 0 1 0 0 0 i merge variables (value_1, value_2...value_8) 1 single ordered factor, while conserving column (pre) is, duch data this: pre value 1 1 value_6 2 1 value_5 3 1 value_5 or better: pre value 1 1 6 2 1 5 3 1 5 i aware exists: recoding dummy variable ordered factor but when try code used in post, receive following error: pa2$factor = factor(apply(pa2, 1, function(x) which(x == 1)), labels = colnames(pa2)) error in sort.list(y) : 'x' must atomic 'sort.list' have called 'sort' on list? any appreciated a ...

c++ - What level are fread thread locks on? What level do they need to be on? -

visual studio's fread "locks out other threads." there alternate version _fread_nolock, reads "without locking other threads", should used "in thread-safe contexts such single-threaded applications or calling scope handles thread isolation." even after reading other relevant discussions on two, i'm confused if locking fread implements on specific file struct, specific actual file, or on fread calls on totally different files. if use nolock versions, level of locking need provide? can multiple threads in parallel reading separate files without locking? can multiple threads in parallel writing separate files without locking? or there global or static variables involved corrupted? so, using nolock versions, able potentially achieve better i/o throughput (if aren't needlessly moving heads, reading off separate drives, or ssd drive), or potential gain reducing redundant locks single lock (which should negligible.) does vs' ifstre...

functional programming - How to use swift flatMap to filter out optionals from an array -

i'm little confused around flatmap (added swift 1.2) say have array of optional type e.g. let possibles:[int?] = [nil, 1, 2, 3, nil, nil, 4, 5] in swift 1.1 i'd filter followed map this: let filtermap = possibles.filter({ return $0 != nil }).map({ return $0! }) // filtermap = [1, 2, 3, 4, 5] i've been trying using flatmap couple ways: var flatmap1 = possibles.flatmap({ return $0 == nil ? [] : [$0!] }) and var flatmap2:[int] = possibles.flatmap({ if let exercise = $0 { return [exercise] } return [] }) i prefer last approach (because don't have forced unwrap $0! ... i'm terrified these , avoid them @ costs) except need specify array type. is there alternative away figures out type context, doesn't have forced unwrap? with swift 2 b1, can do let possibles:[int?] = [nil, 1, 2, 3, nil, nil, 4, 5] let actuals = possibles.flatmap { $0 } for earlier versions, can shim following extension: extension array { func flat...

linux - Bash like management in windows environment -

i have worked in bash on linux couple of years. moved windows. in bash, run couple of .cpp files, take output 1 , give in smooth way. want same .bat files too, find no tutorial on that. please guide me through process. dos, written microsoft unix heads, has syntax similar unix. first thing added dos when bought it. & separates commands on line. && executes command if previous command's errorlevel 0. || (not used above) executes command if previous command's errorlevel not 0 > output file >> append output file < input file | output of 1 command input of command ^ escapes of above, including itself, if needed passed program " parameters spaces must enclosed in quotes + used copy concatenate files. e.g. copy file1+file2 newfile , used copy indicate missing parameters. updates files modified date. e.g. copy /b file1,, %variablename% inbuilt or user-set environment variable !variablename! user-set e...

java - how to group all of the characters of String into a 2d char array? -

i'd know how group of characters of string char [][] . suppose have string m = "x b \n"+ "s d w \n"+ "d e f" how can group characters of above string 2d char? method should group characters are, i.e.: x b s d w d e f public void groupchars (string lines) { char [][]temp = new char [3][3]; } one way of doing way [though have used string array] public class test1 { public static void main(string args[]) { string s = "x b \n"+ "s d w \n"+ "d e f"; string[] splitparts = s.split(" "); string[][] newarray = new string[splitparts.length/3][3]; (int = 0, = 0; < newarray.length; a++) { newarray[a][0] = splitparts[i++]; newarray[a][1] = splitparts[i++]; newarray[a][2] = splitparts[i++]; } system...

c# - How to Use a Tag to Change the Properties of Multiple Items With That Tag? -

i have multiple 6 buttons, when click on each button, change properties, , deactivate other properties in others of same tag. the code have @ moment doesn't use tags , long winded doing every button click: private void buttonbritishgas_click(object sender, eventargs e) { buttonbritishgas.flatstyle = flatstyle.flat; buttonbritishgas.flatappearance.bordersize = 3; buttonbritishgas.flatappearance.bordercolor = color.blue; buttonedf.flatstyle = flatstyle.standard; buttonedf.flatappearance.bordersize = 1; buttonedf.flatappearance.bordercolor = color.white; buttoneon.flatstyle = flatstyle.standard; buttoneon.flatappearance.bordersize = 1; buttoneon.flatappearance.bordercolor = color.white; buttonnpower.flatstyle = flatstyle.standard; buttonnpower.flatappearance.bordersize = 1; buttonnpower.flatappearance.bordercolor = color.white; buttonscottishpower.flatstyle = flatsty...

java - passing multiple JTextFields to a boolean method -

method fourofakind supposed test 4 jtextfields , check if equal each other. each jtextfield excepts 1 number. when press buttonlistener boolean method fourofakind doesn't respond, if returns false, when enter numbers 5555 ex. import java.awt.*; import java.awt.event.*; import javax.swing.*; /** */ public class mypanel extends jpanel { private jlabel inputlabel, outputlabel; private jbutton button; private jtextfield digit1, digit2, digit3, digit4; public mypanel() { inputlabel = new jlabel ("enter 4 1 digit numbers between 0 , 9"); button = new jbutton ("result"); outputlabel = new jlabel ("---"); digit1 = new jtextfield(1); digit1.addactionlistener (new buttonlistener()); digit2 = new jtextfield(1); digit2.addactionlistener (new buttonlistener()); digit3 = new jtextfield(1); digit3.addactionlistener (new buttonlistener()); digit4 = new jtext...

c++ - Constructor gets ignored -

my constructor gets ignored somehow. here code: my class: class field { private: char playfield[5][5]; public: char o = 'o'; field() { char playfield[5][5] = { { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o } }; } void settile(int x_val, int y_val) { playfield[x_val][y_val] = 'x'; } char gettile(int x_val, int y_val) { return playfield[x_val][y_val]; } /*field::~field();*/ }; the constructor field() should initalize 4 wins field 'o's , if want add tile x mark tile is. if do int main() { char x; field fourwins; //fourwins.settile(3, 2); x = fourwins.gettile(3, 2); std::cout << x << std::endl; return 0; } the constructor ignored , weired sign @ i'm looking. position finding works, becouse if first set , x (3,2) print me x. any ideas? ideone example here the initialization...

symfony - Symfony2 embedded forms with the "child" entity assigned in a dynamic way -

i have project entity tied tolerance entity. on surface project has 1 tolerance seems one-to-one, in practice want keep track of changes in tolerance entity. so, every time project saved, if tolerance entity fields changed want save new "version" of tolerance, recording timestamp , did change. in visualization, every time user sees project, or edit it, see last version of tolerance attached. the problem have no clue how manage thing point of view of form. as tolerance entity can referred other stuff other project, have projecttolerance extending tolerance. this project entity: /** * @orm\entity(repositoryclass="appbundle\entity\projectrepository") * @orm\table(name="projects") */ class project { /** * @orm\column(type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @orm\column(type="string", length=100) */ protected $name; ...

javascript - setInterval in member function of object error -

i'm trying create throttling queue of sorts in nodejs module. i'm getting error back: timers.js:265 callback.apply(this, args); ^ typeerror: cannot read property 'apply' of undefined @ wrapper [as _ontimeout] (timers.js:265:13) @ timer.listontimeout (timers.js:110:15) i'm guessing i'm doing stupid, usual, there reason loses closure scope or when second interval runs? var queuesvc = function(settings){ var queue = ['bob', 'is', 'name', 'my', 'hi']; var svc = {}; var runtime; svc.addquery = function(queueentry){ queue.push(queueentry); }; svc.stopqueue = function(){ clearinterval(runtime); }; svc.startqueue = function(){ runtime = setinterval(runqueue(queue), settings.queueinterval); }; svc.emptyqueue = function(){ //this method of emptying array needs change //if decide make queue public property ...

java - my proxy server doesn't work as expected -

i developed simple, multi-threaded proxy server. note program proxy 1 specific server. here code : public class proxy { int remoteport; inetaddress remotehost; public proxy(inetaddress remotehost, int remoteport) { this.remoteport = remoteport; this.remotehost = remotehost; } public void go() { executorservice pool = executors.newcachedthreadpool(); try (serversocket server = new serversocket(2015);) { system.out.println("proxy running....!"); while (true) { socket socketclient = server.accept(); system.out.println("client connected...!"); socket socketserver = new socket(remotehost, remoteport); system.out.println("connection established server...!"); worker p1 = new worker(socketclient, socketserver); worker p2 = new worker(socketserver, socketclient); po...

javascript - How can i get the multiple apple/s to fall? -

i creating game (using html5 canvas) involves catching falling apples, know, how original! having trouble finding way make multiple apples fall? here code in jsfiddle: https://jsfiddle.net/pgkl09j7/12/ var apple_x = 100; var apple_y = 0; var basket_x = 100; var basket_y = 100; var points = 0; var basket_img = new image(); basket_img.src = "http://s18.postimg.org/h0oe1vj91/basket.png"; var countable = function () {} //background colour of canvas var c = document.getelementbyid("c"); var ctx = c.getcontext("2d"); ctx.fillstyle = "#000"; ctx.fillrect(0, 0, 500, 500); //here event listener c.addeventlistener("mousemove", seenmotion, false); ////////////////////// function seenmotion(e) { //this code mouse //moving on canvas. var bounding_box = c.getboundingclientrect(); basket_x = (e.clientx - bounding_box.left) * (c.width / bounding_box.width) - basket_img.width / 2; basket_y = (e.clienty - boundin...

ios - Updating Random Integers (swift, spritekit) -

i have random integer needs update every second, issue random int cannot defined outside of function because random int range of 0 screen size var randomx = uint32(self.size.width) i cannot use self.size.width outside of function. @ first thought maybe not updating because 1. declared in function didmovetoview() , 2. declared using "let" instead of "var". if declare in function updates every second, variable cannot used outside of function huge problem. you can declare var instance variable of class (outside method), update in method, , use anywhere else in instance of class. class rtest { var randomx: uint32 init() { self.randomx = 2; } func rx5()->uint32 { return self.randomx * 5 } }

css - Make div to stay in the container -

i want put button on image, if image have < height id="addgravity" top:-300px, button go out container. <div class="item"> <img src=""/><hr style="position: relative;top:-20px;"/> <div id="addgravity" style="position:relative;top:-300px;background:white; height:56px;color:white;opacity:0.9;"class="item">button</div> </div> you're making difficult using negative margins position things. why not position 'button' absolutely stays aligned in middle regardless of image size? .item { display:inline-block; position:relative; } #addgravity { position:absolute; top:0; right:0; bottom:0; left:0; background:white; height:56px; color:black; opacity:0.9; margin:auto; } <div class="item"> <img src="http://www.placehold.it/300" /> <div id="addgravity...

angularjs - Refresh Events In Angular Calendar UI (Fullcalendar) With Laravel As A Backend -

i trying make automated refresh calendar. using calendar ui , getting data backend in way /**calendar config***/ //config object $scope.uiconfig = { calendar:{ height: 500, width: 800, editable: false, //first hour firsthour: 8, //devide half hour slotminutes: 30, //default duration 01:30 defaulteventminutes: 90, axisformat: 'hh:mm', timeformat: { agenda: 'h:mm{ - h:mm}' }, header:{ //buttons center: 'month agendaweek agendaday', left: 'title', right: 'today prev,next' ...

c# - Find occurrences of each value of a datagridview column in a text and display each occurrence to the next column -

i having problem here. trying display how many times each 1 of strings in datagridview column "values" appear. trying display each occurrence next each value(for example want this: 71->4, 83 ->7 , 0b->6 etc.). here code. i'm taking result first one. in advance. private void button4_click(object sender, eventargs e) { string text = richtextbox1.text; string[] words = text.split(' '); foreach (string word in words) { datagridview1.rows.add(word); } string searchterm = " " ; foreach (datagridviewrow r in datagridview1.rows ) { if (searchterm == null || searchterm == string.empty || searchterm.trim().length == 0) { searchterm = r.cells["value_detected"].value.tostring(); var matchquery = wor in words wor.toupperinvariant() == searchterm.toupperinvariant() ...

javascript - Jquery, get values from <li> tag -

i have list id myid . can values li values $('#' + i).text() . using $( '#myid' ).sortable() . how can values in displayed order? demo here . need implement function in stop: <ul id='myid'> <li id='1'>value 1</li> <li id='2'>value 2</li> <li id='3'>value 3</li> <li id='4'>value 4</li> <li id='5'>value 5</li> </ul> use .each() .text() : updated fiddle stop:function(){ $('li',this).each(function(){ alert($(this).text()) }); } or map() them array. stop:function(){ var $li= $('li',this).map(function(){ return $(this).text() }); alert($li) }

memory - How to dispose of multimaterial objects? -

i use multimaterial objects in scene, , wondering best way remove , dispose of them? i've read questions on how dispose of regular objects, , can use .dispose() on object, there no method multimaterial objects or regular objects(it's not listed in object3d document page). is enough dispose geometry , materials? do after that, set object null? free memory? (this concern since use lot of objects , want make sure memory released). . edit: after experimenting, appears if way dispose objects follows sequence: scene.remove(mesh); mesh.geometry.dispose(); if want remove geometry (looping through children of multimaterial object , disposing of geometry seems okay) mesh.geometry = undefined; mesh = undefined; if want remove materials used in multimaterial object, can remove each 1 material.dispose(); so if initialize material var material = new three.meshbasicmaterial(); material.dispose(); remove it. then material = undefined; textures disposed similarly. i...

Python asyncio: return vs set_result -

hello asyncio experts, how correctly return results coroutine? need use return or future.set_result? for example: @coroutine def do_something() result = yield some_function() return result or @coroutine def do_something() future = asyncio.future() result = yield some_function() future.set_result(result) you should use return result . second example end returning none , rather result . here's complete example demonstrating that: from asyncio import coroutine import asyncio @asyncio.coroutine def some_function(): yield asyncio.sleep(.5) return 5 @coroutine def do_something(): result = yield some_function() return result @coroutine def do_something_else(): future = asyncio.future() result = yield some_function() future.set_result(result) @coroutine def main(): print((yield do_something())) print((yield do_something_else())) loop = asyncio.get_event_loop() loop.run_until_complete(main()) output: ...