Posts

Showing posts from July, 2013

kineticjs drag & drop - no release inconsistency -

first of drag , drop works correctly in stages in version 4.3.0, want understand why following problem 4.3.3. i have 3 stages. 1 sits in container in document in iframe. others sit in containers in iframe's parent document, 1 displaying complex layout of shapes , other single simple shape testing. document in iframe controls action has viewfinder overlay drags , drops correctly. shapes in layout , test stages not release on mouseup. any idea what's going on appreciated ... try , keep date. well, since can't see of code can much, try doing following. for each shape have, add attribute: dragontop: false example: kinetic.rect({ fill: 'blue', dragontop: false });

jquery - Having trouble getting to the JSON response after promises resolve -

i'm sorry, guys. hate having ask question; promise, i've been through many other questions tangentially related patience allow. following code following questions: jquery when each completed, trigger function jquery ajax solution inside each() loop how return response asynchronous call? i've got following: var xhr = []; //this parses selections on screen, which, in turn, informs url inside loop. $("#list > input:checkbox:checked").each(function(){ result = []; var list = $(this).val(); xhr.push($.ajax({ type:'get', url:"https://a-place.com/subsite/webapp/_api/web/lists/getbytitle('"+list+"')/items?$select=" + select + "&$filter=" + filter + "&$expand=" + expand + "&$top=10000", datatype: "json", headers: {accept:"application/json;odata=verbose"}, complete:function(data){} })); }); $.when(xhr...

c++ - Why does an overloaded assignment operator not get inherited? -

this question has answer here: trouble inheritance of operator= in c++ 5 answers operator= , functions not inherited in c++? 3 answers why code: class x { public: x& operator=(int p) { return *this; } x& operator+(int p) { return *this; } }; class y : public x { }; int main() { x x; y y; x + 2; y + 3; x = 2; y = 3; } give error: prog.cpp: in function ‘int main()’: prog.cpp:14:9: error: no match ‘operator=’ in ‘y = 3’ prog.cpp:14:9: note: candidates are: prog.cpp:8:7: note: y& y::operator=(const y&) prog.cpp:8:7: note: no known conversion argument 1 ‘int’ ‘const y&’ prog.cpp:8:7: note: y& y::operator=(y&&) prog.cpp:8:7: note: no known conversion argument 1 ‘int’ ‘y&&’ wh...

linux - Root Account Compromised In Unknown Fashion -

Image
i have server running ubuntu 14.04-64 running openssh 5.9 started acting strangely on last few days. ssh , http connections timing out. in addition, ssh key no longer working. having use password login. got notice our hosting provider server had used 400% of allotted bandwidth month (5 days month) when go on 10%. suspected server had been compromised. i saw no strange cpu activity in htop. saw no strange network activity in iftop. however, there strange executable set service in of rc.xd directories: s90.777{1452022308. called executable in / directory called .777{1452022308. process running high priority , causing other connections time out. file binary executable. i examined server logs , found this: jan 3 09:08:32 dev1 sshd[19757]: accepted publickey root x.x.x.x port 41394 ssh2: rsa 31:1c:bd:a0:d0:56:1b:e0:fd:a3:05:cc:9e:96:4e:8c we've never put public keys on of our servers root , never would. user on server approximately 8 minutes , disappeared. auth...

regex - MySQL REGEXP string not followed by another -

in mysql, need select registers table containing string in field not followed string. have tried using: select * table field regexp "(desired_string(?non_desired_follow_up))" however, get: got error 'repetition-operator operand invalid' regexp can right sentence doing that?

mysql - Inserting data into table SQL server -

if have 2 tables , table 1 has primary key(userid) autoincrement , table 2 has foreign key(userid) table 1's (userid) when insert new row table 1 first row have userid = 1 then if insert again, userid = 2. so how go keeping table 2's userid same when inserting in table 1. instance, in table 2, adding password table. my question should add autoincrement table 2(userid) , insert new value both tables when create user or there way? you have manually insert data correct id in table2. there no such built-in functionality in mysql. the algorithm follows: insert row in table1. get id of new row. insert row new id in table2.

C# .Net framework strings encoding from utf-8 bytes -

Image
i have application wrote in c#, , application receives data through network server using sockets (udp libenet). in application have function process raw bytes sent in packet. 1 of functions reading string, delimited \0. my problem i'm sending utf-8 encoded string server c# application, when use these strings display them in controls, gibberish instead of polish letters. function reads strings buffer: public override string readstring() { stringbuilder sb = new stringbuilder(); while (true) { byte b; if (remaining > 0) b = readbyte(); else b = 0; if (b == 0) break; // here problem. checked other encodings etc., still same sb.append(encoding.utf8.getstring(new byte[] { b }, 0, 1)); } return sb.tostring(); } function overrides, 1 from: public class bitreader : binaryreader in application get: you can't read utf-8 byte wise single character might take mo...

Sorting list of lists based on a given string in Python -

i have list of lists following: list_of_lists = [ ('test_ss', 'test 1'), ('test_2_ss', 'test 2'), ('test_3_ss', 'test 3'), ('test_ss', 'test 4') ] i need sort list of lists first item in each list based on given variable string. as example, want sort 'test_ss' resulting list of lists be: sorted_list_of_lists = [ ('test_ss', 'test 1'), ('test_ss', 'test 4'), ('test_2_ss', 'test 2'), ('test_3_ss', 'test 3'), ] i've tried number of examples off , others ( sorting list of lists based on list of strings , sorting lists based on particular element - python , sorting multiple lists based on single list in python , etc) haven't found right approach (or i've not been following examples correctly. any pointers? you can use simple key function this: in [59]: def compare(element): ....: return e...

How to fire mouse click event on a JavaFX ListView? -

how fire single , double mouse click events on first (or other) item of javafx.scene.control.listview ? i want receive event this: getlistview().setonmouseclicked(mouseevent -> { switch (mouseevent.getclickcount()) { case 1: break; case 2: break; } }); there seems misunderstanding. events not fired on items of listview , on listcell s display items. listcell s may constructed dynamically , reused, there may not event target corresponding particular item. if hands on correct node, fire event using event.fireevent : node target = ... mouseevent mouseevent = new mouseevent(mouseevent.mouse_clicked, ...); event.fireevent(target, mouseevent); you find listcell s using lookupall : set<node> listcells = listview.lookupall(".list-cell"); and use listcell.getitem , listcell.getindex determine correct one. but since event listener added listview finding correct listcell may not necessary.

objective c - Can't draw completely using Open GL ES 2.0 in cocos 2d 2.0 in a game tutorial -

Image
i working on tutorial http://www.raywenderlich.com/3888/how-to-create-a-game-like-tiny-wings-part-1 , trying hills correctly drawn. however, tutorial have been written before cocos 2.0 , therefore doesnt involve shaders. so, im trying convert it. far, have not succeeded , getting images these: as can seen, doesn't draw hills , colors of hills wrong too. stops drawing them after 2 or 3 seconds. here part of code, draw them. - (void) draw { [self.shaderprogram use]; [self.shaderprogram setuniformformodelviewprojectionmatrix]; ccglblendfunc( cc_blend_src, cc_blend_dst ); ccglbindtexture2d(_stripes.texture.name); glvertexattribpointer(kccvertexattrib_position, 2, gl_float, gl_false, 0, _hillvertices); glenablevertexattribarray(kccvertexattrib_position); glvertexattribpointer(kccvertexattrib_texcoords, 2, gl_float, gl_false, 0, _hilltexcoords); glenablevertexattribarray(kccvertexattrib_texcoords); gldrawarrays(gl_triangle_strip, 0,...

java - Can't hand an ArrayList to out of an AsyncTask into an Activity (Android) -

i try on give arraylist out of asynctask activity. result nullpointerexception. here ist code the async task arraylist<string> liststring = new arraylist<string>(); private class gettingevents extends asynctask<string, void, string>{ protected string doinbackground(string... urls) { string tablename = maketablename(); try { string url = "jdbc:mysql://"+server+":"+port+"/"+dbname; connection = drivermanager.getconnection(url, username, password); statement statement = null; string sqlcommand = null; databasemetadata md = (databasemetadata) connection.getmetadata(); resultset rsdb = md.gettables(dbname,null,null,null); while (rsdb.next()){ arraylist<player> players = new arraylist<player>(); string currtablename = rsdb.getstring("table_name"); stateme...

Bosun: How to handle empty number sets with ungroup? -

i'm trying setup bosun , graphite alert on error ratio, compiled 2 different sources: api traffic , web app traffic. here's have now: $web_rate = avg(graphite("sumseries(collectd.*.statsd.web.*.rate)", "5m", "", "")) $api_rate = avg(graphite("sumseries(collectd.*.statsd.api.*.rate)", "5m", "", "")) $web_error_rate = avg(graphite("sumseries(collectd.*.statsd.web.*.errorrate)", "5m", "", "")) $api_error_rate = avg(graphite("sumseries(collectd.*.statsd.api.*.errorrate)", "5m", "", "")) $total_rate = ungroup($web_rate) + ungroup($api_rate) $total_error_rate = ungroup($web_error_rate) + ungroup(api_error_rate) $error_ratio = $total_error_rate / $total_rate our counters don't exist in graphite until non-zero, our pre-production environment, above fails following: ungroup: requires 1 group when in expression ...

javascript - Time Range on Bootstrap 3 or jquery -

i use control 1 bootstrap-datetimepicker , if view totally different enables functionality described bellow not problem. but have format hh:mm:ss , without ("pm"or "am"). without, unlimited number of hourse ( hh ) , accept time range, example: time acceptable between " 11:12:02 " , " 11:30:20 " other time wouldn't possible select. jon thornton created timepicker in jquery type of time selection: $('#example1').timepicker({ 'timeformat': 'h:i:s', 'mintime': '11:12:02am', 'maxtime': '11:30:20am' }); http://jonthornton.github.io/jquery-timepicker/

c# - Calling a method that expects an array of objects -

i'm learning c# , have written console program save an array of high scores file. although program works, how have got work making me feel uneasy , feels more of hack solution looking guidance on how should have written it. what doing within main method is: declaring array of highscore objects initialising them assigning values array. i happy have done until now, it's following 2 steps make me uneasy i declare highscore object i use object pass array of highscores savehighscores method. here code: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.io; namespace highscore { class highscore { public string name { get; set; } public int score { get; set; } public void savehighscores(highscore[] highscores) { string allhighscorestext = ""; foreach (highscore score in highscores) { ...

react native - Can't access this.props.navigator -

i've been creating views way: var settingsview = react.createclass({ render: function() { return ( <view> <touchablehighlight onpress={this.donepressed}> //left out styling code simplicity </touchablehighlight> </view> ); }, donepressed: function() { this.props.navigator.pop(); }, }); this working fine. donepressed event handler that's hooked touchablehighlight in render (not shown). today tried refactor this: class settingsview extend react.component { render() { //same stuff above } donepressed() { this.props.navigator.pop(); } } this rendered settings screen normal. when donepressed triggered, screen turned red saying can't find this.props.navigator . i'm not sure going on here, please me out! edit: this screen brought via touch event handler different page via method: settingstapped: function() { this.props.navigator.push({ name: 's...

java - Passing mouse events from Jframe glass to menu bar? -

based on previous stack questions have written following code capture mouse input glass pane push series of panels underneath. mousemotionlistener mml = new mousemotionlistener() { private void dispatchmouseevent(mouseevent e) { point glasspanepoint = e.getpoint(); container container = jf.getcontentpane(); point containerpoint = swingutilities.convertpoint( glass, glasspanepoint, container); if (containerpoint.y >= 0) { (component ml : mouselisteners) { point componentpoint = swingutilities .convertpoint( glass, glasspanepoint, ml); ml.dispatchevent(new mouseevent(ml, e.getid(), e.getwhen(), e.getmodifiers(), componentpoint.x, componentpoint.y, e.getclickcount(), e.ispopuptrigger())); } } } @override public void mousedragged(mouseevent me) { dispatchmouseevent(me); } @override ...

c# - Fetch rows from database using ExecuteStoreQuery, without knowing the number of columns in the table -

i'm trying manual sql queries against sqlite database using executestorequery method on objectcontext . the catch don't know how many columns in table i'm querying. ideally, each fetched row string[] object. i've looked @ example 2 here: http://msdn.microsoft.com/en-us/library/vstudio/dd487208(v=vs.100).aspx it's close want do, except don't know structure of telement i'm fetching, can't define struct in example. below of code (not compiling due ???? telement ). code below trying fetch table info, in case know structure of rows, in general don't. is there way executestorequery ? or there different way of doing it, while still using existing connection of objectcontext (rather opening new sql connection db)? public void printcolumnheaders(nwrevaldatabaseentities entities, string tablename) { string columnlistquery = string.format("pragma table_info({0})", tablename); var result = entities.executestorequery<???...

node.js - Matching all urls using router.all() method of Express and using Angular ui-router in the same time -

problem solved. see answer details. i've written authentication part of app long ago (there few jquery ajax calls), moved away jquery angular, won't using express.js routing anymore. i used match "/" (localhost) that. router.get('/', csrfprotection, indexonly, indexcontroller.index); i'll using ui-router, serve 1 index.html file , angular handle rest. don't want rewrite in index page, want make exception that. if user visits homepage, check whether they're logged in or not. if aren't, regular login page gets rendered, (frontend/index) . if logged in , try visit main page (localhost), redirected /feed . indexonly checks , csrfprotection , know, protects csrf. need 2 of these work on index if user not logged in. here's indexcontroller.js exports.index = function(req, res) { res.render('frontend/index', { csrftoken: req.csrftoken() }); }; how can that? tried little couldn't it. turned unlimited loop, g...

python - DataError: unterminated CSV quoted field -

i'm trying import huge (~2 gb) csv file postgres. below query wrote (in python) this: q= ("copy {db} '{d}\\{file}' (format csv, null 'null', header) ;").format(d = directory, db = db_name, file =fname) now somewhere on line 17632150 there integer field starts quotation, not closed: "2195961,12855,628,no i wonder options @ point? constraint should possible psycopg2 .

dc unix : preserving initial value even after storing new value at the same array index -

i'm unable understand example given in manpage of dc : $ dc 1 0:a 0sa 2 0:a la 0;ap 1 to me answer should 2 because: 1 0:a here store 1 @ 0th position of array a . 0sa push 0 stack of register a . 2 0:a here again store 2 @ 0th position of array a thereby overwriting previous 1 stored @ location. la pop 0 stored on stack of register a , push main stack. 0;a again push 0 main stack , pop use array index , push 2 stored @ 0th location of array a main stack. p print top of main stack 2. answer should 2. what missing? edit : $ dc -v dc (gnu bc 1.06.95) 1.3.95 the explanation given before example in man page: note each stacked instance of register has own array associated it. in other words, when use array commands , stack commands on same register, create 2-dimensional structure. array commands operate on entries within top row, , stack commands operate on whole rows. also, "scalar" value of stack entry retri...

javascript - socket.io websocket is closed before the connection is established -

console in browser prints me messege when connect server. i'm still able emit events server side , cach them on client side, unable emit them client side. server side: var express = require('express'); var http = require('http'); var app = express(); var server = http.createserver(app); var io = require('socket.io').listen(server); server.listen(8080); app.get("/", function(req, res) { res.sendfile(__dirname + '/index.html'); }); io.on('connection', function(socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); client side: <!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> </head> <body> <h1 id ="id">tutaj jestem</h1> <...

c++ - Error with insert and reverse_iterator -

this question has answer here: how insert reverse_iterator 2 answers i have error in code void f(list<cclass*> mylist,cp* database,string namepoi){ //some code list <cclass*>::reverse_iterator ite; (ite=mylist.rbegin(); ite!= mylist.rend(); ite++) { mylist.insert(++ite,database->getpointer(namepoi));//compiler error } } the error : no matching function call 'std::list::insert(std::list::reverse_iterator&, cpoi*)' line database->getpointer(namepoi) giving right output think m not using right insert command because when use normal iterator(not reverse_iterator), works perfect. thanks list::insert takes iterator s, not reverse_iterator s. can convert reverse_iterator iterator calling base on it: mylist.insert((++ite).base(), database->getpointer(namepoi));

javascript - ng-messages is not working -

<!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="login.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-messages.min.js"></script> </head> <body ng-app="loginapp"> <div class="container"> <div class="login_logo"></div> </div> <div class="form_container"> <div ng-messages="form_login.username.$error"> <div class="alertmsg" ng-message="required">your username required</div> </div> ...

How do I use LIKE in a postgresql function for loop query -

having view named jap.lots_name_view products names name name flame 19#pouch acosta produce ctn b flame 19#pouch acosta produce ctn b flame 19#pouch so2 j.a.p. black 5l styro b red globe 21#plainso chelan starr 7l sty red globe 21#plainso chelan starr 7l sty sugraone 19#pouch free bird ctn b summer royal 19#pouch so2 sf white od 5l styro summer royal 19#pouch top gun cnt and having list of categories this: select inid inventory type ='variety' , list below: invid -------------- sugraone autumn royal flame summer royal red globe now question how loop through list out category list using on function counting out on list of inventory items , result below invid | count sugraone | 1 autumn royal | 2 flame | 3 summer royal | 2 red globe | 2 so far tried: create or replace function jap.category_lookup() returns table(variety text, count bigint) $func$ declare category...

Docker compose not exposing port for application container -

i have exposed port 80 in application container's dockerfile.yml mapping "80:80" in docker-compose.yml "connection refused" after "docker-compose up" , try http on port 80 on docker-machine's ip address. docker hub provided rethinkdb instance's admin panel gets mapped fine through same dockerfile.yml ("expose 8080") , docker-compose.yml (ports "8080:8080") , when start application on local development machine port 80 gets exposed expected. what going wrong here? grateful quick insight more docker experience! so in case, service containers both bound localhost (127.0.0.1) , therefore seemingly exposed ports never picked via docker-compose port mapping. configured services bind 0.0.0.0 respectively , works flawlessly. thank @creack pointing me in right direction.

c# - How to allow an object to move within a collider? -

i trying have block can pushed inside of rectangular collider. player has able move through collider in order push block. have tried affect mass upon block being pushed edge collider, drag, angular drag, velocity, iskinematic nothing stop cube moving when hits collider. confusing, appreciated...here code: public class pushblock2 : monobehaviour { public rigidbody2d pblock2; void ontriggerenter2d(collider2d col) { if (col.tag == "edge") { debug.log ("pushblock2 touched edge"); pblock2.iskinematic = true; pblock2.iskinematic = false; } } void ontriggerstay2d(collider2d col) { if (col.tag == "edge") { pblock2.iskinematic = true; } } why don't try , create 4 colliders around area want move block within? way you'll have stop block entering easier task trying prevent item leaving collider. i pretty sure able pull off without cod...

Java JodaTime Period Formatting -

in joda time, need find difference between 2 periods: periodformatter formatter = new periodformatterbuilder() .printzeroalways().minimumprinteddigits(2) .appendhours().appendsuffix(":").appendminutes().appendsuffix(":").appendseconds() .toformatter(); period period1 = formatter.parseperiod("11:20:50"); period period2 = formatter.parseperiod("13:40:00"); period difference1 = period1.minus(period2).normalizedstandard(); system.out.println(formatter.print(difference1)); //shows -02:-19:-10 the result -02:-19:-10 want show -02:19:10 . there formatting can in jodatime achieve that? i don't think can configure periodformatter itself. can check if normalized period has negative length. if so, add minus sign yourself, , append formatted version of negated period (so in case, negating period makes positive) periodformatter formatter = new periodformatterbuilder() .printzeroal...

Java long calculations without freezes GUI (in single thread) -

Image
at interview, me asked question: "how perform many calculations in single thread without freezes gui component progress bar or able check user input? (can execute 1 thread)" i asked can write event loop node.js. me java have mechanism it. java can use hardware parallelization of operation. classes or special words can used task? so, assuming can't use either swingworker or swing timer , create second thread support operations, choice you're left use swingutilities#invokelater repeatedly call method, performs small subset of work , updates ui before calling again (using swingutilities#invokelater ) import java.awt.eventqueue; import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.jprogressbar; import javax.swing.swingutilities; import javax.swing.uimanager; import ...

rubygems - Rubocop: Ignore all cops that are boilerplate from a new rails app -

when run rubocop in app directory, long list of cops stem default boiler-plate rails app generated. i don't want rubocop @ these files since i'm not author of files , don't want mess around them. i see can add files exclude: section rubocop/config/default.yml i'm not sure configs , files should adding ignore built in files while not ignoring files create. you can run rubocop --auto-gen-config , create todo file can disable cops in. can selectively turn ones want on. alternatively can create boiler plate rails app , run rubocop , files need add excludes list.

Is it possible to update an AngularJS expression via an API call through a Service? -

i'm looking way (and not sure if possible) update angular expression on html page when data sent api. for example, have $scope.message on .html page. there way can send message api (e.g. http://...?message=foo ) , have page update message sent? also, need $scope.message updated in angular service available multiple pages within website. i wanting live update, if not, happy code executing on timer or similar. any suggestions appreciated. update i'm guessing may not possible, in case haven't explained correctly, i'll try , simplify it. i can find information using angularjs send commands out url , receive data back. need send json string to angular site update variable. field updates in database, want server application send alert angular site update status of value live. don't want run constant check of database if don't have to. i open other suggestions on how achieve this. if don't care old school browsers, can try using...

java - Extra *(astericks) is displayed when entering encrypted password on cmd prompt -

i have below code encrypt user password, when user enter password * symbol displayed on cmd prompt. in below code, asterisks displaced when run command. please let me know doing wrong. public static string readpassword(string prompt) { system.out.print(prompt); eraserthread et = new eraserthread(prompt); thread mask = new thread(et); mask.start(); bufferedreader in = new bufferedreader(new inputstreamreader(system.in)); string password = ""; try { password = in.readline(); } catch (ioexception ioe) { ioe.printstacktrace(); } et.stopmasking(); return password; } class eraserthread implements runnable { private boolean stop; public eraserthread(string prompt) { system.out.print(prompt); } @override public void run() { stop = true; while (stop) { system.out.print("\010*"); try { thread.currentthread(); ...

javascript - How to remove hyphen in span? (jQuery) -

i have breadcrumbs generate hyphen inside specific link. <div class="breadcrumbs"> <span class="home"> <a href="#"><span property="name">home</span></a> </span> <span> <a href="#" class="post post-vehicle-archive"><span property="name">books-for-sale</span></a> </span> <span> <a href="#" class="book-name"><span property="name">soup sould</span></a> </span> </div> i want remove hypens inside class="post post-vehicle-archive". this code tried far: <script type="text/javascript"> var j = jquery.noconflict(); j(function() { var gettermname = j('.breadcrumbs .post.post-type-archeive > span'); j(gettermname ).text(value.replace(/\-/g, " ")); }); ...

ServiceStack OrmLite PUT deletes all the fields except those are passed -

servicestack ormlite put deletes fields except passed you can use ormlite's updatenondefaults api , if want update fields have non-default values, still updating fields puts, if want update partial fields use patch. whilst post's typically used creating (inserting) resources or other non-idempotent requests.

jquery - How do I get this AJAX request to work in my Ruby on Rails Table Reservation App? -

Image
okay guys, lengthy question, going try , keep condensed possible. i have table reservation app i'm trying create, looks this: when click on of booths or tables in map, "table id" field fills number of table selected (i.e table number "a1", etc). afterwards, once hit "create reservation" table turns yellow signify user signed in reserving table. the app works fine, able table highlight in yellow (to show successful reservation) , user's email become associated table upon making reservation. there's problem though. there 2 types accounts, "users" (the customer), , "owners" (the actual owner of restaurant trying make reservation for). on users side, can see table reserved, want owner see user made reservation (i want update dynamically, moment user creates reservation , table highlights in yellow show reservation go, owner). i told ajax way go this, have never used ajax before in life, , tutorials looking @ are...