Posts

Python Pandas join aggregated tables -

i have data frame 2 columns: product_id , rating. i'm trying join 2 tables. 1 obtained from a = data.groupby('product_id').count() the other one b = data.groupby('product_id').mean() i'd have table has on columns the product_id count mean try: data.groupby('product_id').agg(['mean', 'count'])

c# - Bluetooth LE CanUpdate Characteristic property -

i building xamarin.forms cross platform mobile app, uses monkey.robotics bluetoth low energy functionality. connecting mbed based implimentation of custom gatt service . in xamarin c#, triggers characteristic. canupdate property in monkey.robotics? this standard example c# based on: if (characteristic.canupdate) { characteristic.valueupdated += (s, e) => { debug.writeline("characteristic.valueupdated"); device.begininvokeonmainthread( () => { updatedisplay(characteristic); }); isbusy = false; // spin until first result received }; isbusy = true; characteristic.startupdates(); } this has been working, since changed own custom gatt service connecting to, canupdate property false. property , how triggered? me debugging gatt service code. thanks monkey.robotics open sour...

JavaScript - Replace variable from string in all occurrences -

ok, know if have character '-' , want remove in places in string javascript, ... someword = someword.replace(/-/g, ''); but, when applying array of characters, s not working ... const badchars = ('\/:*?"<>|').split(''); let filename = title.replace(/ /g, '-').tolocalelowercase(); (let item = 0; item < badchars.length; item++) { // below not work global '/ /g' filename = filename.replace(/badchars[item]/g, ''); } any ideas? /badchars[item]/g looks badchars , literally, followed i , t , e , or m . if you're trying use character badchars[item] , you'll need use regexp constructor, , you'll need escape regex-specific characters. escaping regular expression has been well-covered . using that: filename = filename.replace(new regexp(regexp.quote(badchars[item]), 'g'), ''); but , don't want that. want character class: let filename = title.replac...

java - Static nested class instance -

this question has answer here: java inner class , static nested class 23 answers i came across in java, know static nested class why create instance of 'static'. isn't whole idea of 'static' use without instance? understand concept of inner classes, why (and frankly how possible to) create 'instance' of 'static' member @ ? why this: 1- outerclass.staticnestedclass nestedobject = new outerclass.staticnestedclass(); 2- nestedobject.anestedclassmethod(); and not this: 1- outerclass outerinstance=new outerclass(); 2- outerinstance.staticnestedclass.anestedclassmethod(); use on inner classes, keyword static indicates can access inner class without instance of outer class. for example: public class outer { public static class inner { /* code here. */ } } with construction, can create instance of inn...

process - Python What is the difference between a Pool of worker processes and just running multiple Processes? -

i not sure when use pool of workers vs multiple processes. processes = [] m in range(1,5): p = process(target=some_function) p.start() processes.append(p) p in processes: p.join() vs if __name__ == '__main__': # start 4 worker processes pool(processes=4) pool: pool_outputs = pool.map(another_function, inputs) as says on pymotw : the pool class can used manage fixed number of workers simple cases work done can broken , distributed between workers independently. the return values jobs collected , returned list. the pool arguments include number of processes , function run when starting task process (invoked once per child). please have @ examples given there better understand application, functionalities , parameters. basically pool helper, easing management of processes (workers) in cases need consume common input data, process in parallel , produce joint output. the pool quite few thi...

javascript - How to use force Jquery mouseenter fadein over again? -

i'm trying set menu, hover on photo show person name , links underneath image-menu. used mouseenter , fadein hover effect, coupled css class has background color set white (so new item cover old one). when try hover menu item has been shown, nothing happens. also, hover not work on items. when hover left, hover not function on 3 items. when hover right side, first 2 items work. please suggest issues be, , how these resolved? please note need have menu shows when mouseover shown, user can click links provided there. script: $(document).ready(function() { $("#pau").mouseenter(function(){ $("#paup").fadein(600); }); $("#red").mouseenter(function(){ $("#redp").fadein(600); }); $("#aesthet").mouseenter(function(){ $("#aesthetp").fadein(600); }); $("#danny").mouseenter(function(){ $("#dannyp").fadein(600); }); $("#kisic").m...

java - How to access payload from REST 404 response in Camel cxfrs? -

i have camel route accesses rest service. things work ok if rest response 200 ok. however, if response 404, rest service returns additional info in payload, cannot find way access. this part of debug log running it: [camel (rraacamelcontext) thread #2 - seda://from_rraa] info org.apache.cxf.interceptor.loggingininterceptor - inbound message ---------------------------- id: 2 response-code: 404 encoding: iso-8859-1 content-type: application/json headers: {accept=[application/json], breadcrumbid=[id-steves-macbook-pro-local-53701-1446241733043-1-7], content-type=[application/json], originalheader=[{name=verifyemployeerequest, version=1, scac=rraa, timesent=null, uuid=abcd-1234}], pin=[1234], reason=[init], server=[jetty(9.2.11.v20150529)], transfer-encoding=[chunked], user-agent=[apache cxf 3.1.2]} payload: { "employeeid": "bad-name", "message": "id not found" } my route set as: <route id="rraaiss"> <from uri="...

mysql - Find all kids born on Friday -

how can find dates in 1 table - fridays - can show information in table? i taking information ads.date . look @ mysql function dayofweek() select * ads dayofweek(ads.date)=6 dayofweek() returns weekdaynumber 1-7 1 sunday. if want born on friday have filter on dayofweek() = 6

Arduino + RealTime camera for controlling the arduino robot .Possible? -

so problem need work out solution real time camera controlled arduino robot . hardware should use ? if possible have have multiple cameras on board realtime image transmiting on protocol than ideas :) arduino bad idea kind of project. it's memory not enough hold single image of decent resolution. you did not specify how input cameras going control it's movement, keep in mind microcontroller can not real time image processing algorithms.

Is there a way to globally define a type in typescript? Interested in using bluebird instead of ES6 Promise -

i'm ts beginner. see if compile typescript code --target es6 , knows promise type globally. i want use bluebird instead, , have global promise type represented bluebird. how accomplish this? specifically, want avoid importing bluebird everywhere promise<t> mentioned. use typings npm install typings typings install dt~bluebird --global --save make sure tsconfig.json , typings folder in same directory.

javascript - Node sends data back multiple times everytime a user adds new data -

first of all, apologize horribly worded title; have been trying think of 1 past 20 minutes not know succinct way describe problem having. if has better suggestion, please let me know or edit title if able to. background : in order learn nodejs, creating chat server. when user clicks createroombtn , event created containing name of room user created, , sent socket.js module in app.js , app.js appends room array of rooms (these rooms displayed list in browser), , creates broadcast event users including active user. problem : let's there empty list, , user adds new room, titled "nodejs", display room on screen, , fine , dandy. now, if add room, socket.io, example, browser renders following result: socket.io, nodejs, nodejs . if add "javascript", result javascript, socket.io, nodejs, socket.io, node.js . basically, browser renders list on , on again, , each time list shrinks one. not have slightest idea of why happening. weird thing if press refresh, ...

Why Rest Api in Sharepoint -

what main reason go rest api in sharepoint 2013. have client object model implementing application. can please guide me. the client side object model built upon rest api 1 reason exist. javascript developers may simplicity of rest api. people trying keep page size minimum, may appreciate forgoing size of csom , dependencies. lastly, in mash scenarios other tools, having easy way address content via rest urls makes better interoperability other tools instead of relying on product specific api (i.e. csom).

Get group names in java regex -

i'm trying receive both pattern & string , return map of group name -> matched result. example: (?<user>.*) i return map containing "user" key , whatever matches value. the problem can't seem group name java regex api. can matched values name or index. don't have list of group names , neither pattern nor matcher seem expose information. have checked source , seems if information there - it's not exposed user. i tried both java's java.util.regex , jregex. (and don't care if suggested other library good, supported & high in terms performance supports feature). there no api in java obtain names of named capturing groups. think missing feature. the easy way out pick out candidate named capturing groups pattern, try access named group from match . in other words, don't know exact names of named capturing groups, until plug in string matches whole pattern. the pattern capture names of named capturing group \(\...

React native redux and ListView -

i have seen @ least 1 similar question . however interested in pattern redux usage in react native application having listview . should reducers create new listview.datasource every time? cause performance problems etc., asked question pointed out? or should take deviation , call setstate({datasource : new listview.datasource()}) componentwillreceiveprops() of component has listview ? i went componentwillrecieveprops route. given clonewithrows needs new object each time updated (depending on how use rowhaschanged ), 1 needs pass new set of data it. luckily redux reducers, kind of pattern expected anyways in terms of data return. here's how did in app of mine: componentwillreceiveprops(newprops) { let days = newprops.days; if (newprops.viewingdayuuid !== this.props.viewingdayuuid) { days = days.map((day) => { if (day.uuid === newprops.viewingdayuuid || day.uuid === this.props.viewingdayuuid) { return object.assign({}, day); } else ...

firefox addon sdk - Mozilla JetPack Invalid Filename -

i'm trying create simple mozilla add-on using external js file; folders & files /var/www/html/add-ons/hello /var/www/html/add-ons/hello/index.js /var/www/html/add-ons/hello/package.json /var/www/html/add-ons/hello/script/data/test.js /var/www/html/add-ons/hello/index.js // import page-mod api var pagemod = require("sdk/page-mod"); // create page-mod pagemod.pagemod({ include : "*", contentscriptfile : "./test.js", contentscript: 'window.alert("loaded");' }); /var/www/html/add-ons/hello/package.json { "title": "my jetpack addon", "name": "test", "version": "0.0.1", "description": "a basic add-on", "main": "index.js", "author": "", "engines": { "firefox": ">=38.0a1", "fennec": ">=38.0a1" }, ...

android - Find all child views for given root view recursively -

i want find child views given root view. public list<view> getallchildviews(view rootview) { //return child views given rootview recursively } consumer of method pass rootview follows //client has custom view list<view> childviews = getallchildviews(customview.getrootview()); //get root view of custom view i can type cast rootview particular layout , children ( @ leaf level ) not sure type of root view. can scrollview or different layout private list<view> getallchildren(view v) { if (!(v instanceof viewgroup)) { arraylist<view> viewarraylist = new arraylist<view>(); viewarraylist.add(v); return viewarraylist; } arraylist<view> result = new arraylist<view>(); viewgroup viewgroup = (viewgroup) v; (int = 0; < viewgroup.getchildcount(); i++) { view child = viewgroup.getchildat(i); //do not add parents, add child e...

javascript - google autocomplete setComponentRestrictions -

is there restriction on setting setcomponentrestrictions value ? because not working while setting dynamic values. scenario 1 (works fine) in scenario hard coded county value search specific cities in country.so works fine when use hard coded value. var input = document.getelementbyid('searchcity'); var options = { types: ['(cities)'],componentrestrictions: {country: 'us' }}; var autocomplete = new google.maps.places.autocomplete(cityinput,options);` scenario 2 (not working) in this, have text field using find country using autcomplete , storing short_code value in shortnamecountry id.but not working when passing dynamic value. var input = document.getelementbyid('searchcity'); var countryopt = $("#shortnamecountry").val().tolowercase(); var options = {types: ['(cities)'], componentrestrictions: {country: countryopt }}; var autocomplete = new google.maps.places.autocomplete(input,options); (i have added scenarios. don...

javascript - image is not show in json page -

the images database not coming out in json page , html page image source name outputted. how make images show on html page? thank precious time. linejson.php page <?php header("access-control-allow-origin: *"); header("content-type: application/json; charset=utf-8"); $conn = new mysqli("localhost", "db_user", "db_pwd", "db_name"); $result = $conn->query("select tbl_users.image, tbl_users.firstname, tbl_users.lastname, tbl_users.username, tbl_posts.post, tbl_posts.post_date tbl_posts inner join tbl_users on tbl_users.id=tbl_posts.user_id tbl_posts.user_id=3"); $outp = "["; while($rs = $result->fetch_array(mysqli_assoc)) { if ($outp != "[") {$outp .= ",";} $outp .= '{"image":"' . $rs["image"] . '",'; $outp .= '"firstname":"' . $rs["firstname"]...

java - Apache Flink Streaming window WordCount -

i have following code count words sockettextstream. both cumulate word counts , time windowed word counts needed. program has issue cumulatecounts same windowed counts. why issue occurs? correct way calculate cumulate counts base on windowed counts? streamexecutionenvironment env = streamexecutionenvironment.getexecutionenvironment(); final hashmap<string, integer> cumulatecounts = new hashmap<string, integer>(); final datastream<tuple2<string, integer>> counts = env .sockettextstream("localhost", 9999) .flatmap(new splitter()) .window(time.of(5, timeunit.seconds)) .groupby(0).sum(1) .flatten(); counts.print(); counts.addsink(new sinkfunction<tuple2<string, integer>>() { @override public void invoke(tuple2<string, integer> value) throws exception { string word = value.f0; integer delta_count = value.f1; integer count = cumulatecounts.g...

javascript - node.js & mysql - How to get the last inserted ID? -

db.query("insert `chat_entries`(`author`, `authorrank`, `receiver`, `timestamp`, `message`) values (" + db.escape(getusername(connection)) + ", " + getuserdata(getusername(connection), "rank") + ", '-', " + math.round(new date().gettime() / 1000) + ", '" + db.escape(messagedata.message) + "')", function(result, rows){ console.log(result.insertid); }); the console told me: cannot read property 'insertid' of null after had searched solution found page: https://github.com/mysqljs/mysql#getting-the-id-of-an-inserted-row according documentation, must work. where's mistake? in advance. you need replace console.log(result.insertid); with console.log(rows.insertid); since it's varibale you're passing callback function.