Posts

Showing posts from June, 2014

warnings - PMD Class definition inside method -

i use local class inside method , pmd triggers 2 warnings headercommentrequirement class , publicmethodcommentrequirement method inside class, write comments on both if normal class doesn't work. ideas on this? help. code looks this: /** * * @author me * */ class myclass{ void thismethod(){ if(condition){ /** * * @author me * local class */ class localclass implements otherclass{ /** * method comment */ public boolean boolmethod(){ //do } } } } } correct javadoc should have second , following lines indented addtional space, , description should before tags: /** * description. * @author me */

FTP Files Upload Error in VB6 -

i'm developing project in required communicate mitsubishi m70 cnc (an ftp server) through vb6. though initial communication successful, when try upload or download file ,following error occurs : error 120003 200 type set 200 port command successful 500 cannot copy file/directory. permission denied. i'm able copy , paste files in folder manually. when try same through vb , showing error. my project vb exe installed on same pc ftp server . my code follows option explicit private m_gettingdir boolean private sub addmessage(byval msg string) txtresults.text = txtresults.text & vbcrlf & msg txtresults.selstart = len(txtresults.text) end sub private sub cmdupload_click() dim host_name string dim cmd2 string enabled = false mousepointer = vbhourglass txtresults.text = "working" txtresults.selstart = len(txtresults.text) doevents ' must set url before user name , ' password. otherwise control cannot verif...

c# - Where do I register IMemoryCache in my ASP.NET application? -

Image
i have asp.net web application created visual studio 2015 community edition. .net framework 4.6.1. i have no idea version of asp.net web application using asp.net mvc 4? asp.net mvc 5? it's not mentioned anywhere. i'm trying register imemorycache service (from microsoft.extensions.caching.memory ) microsoft unity container. however, found on google refers adding services.addcaching() in startup.cs file. i don't have startup.cs file. see global.asax . furthermor, custom dependencies registered within unityconfig.cs provided when installing nuget package unity.mvc microsoft unity bootstrapper asp.net microsoft. any appreciated. edit: here's screenshot of project: the things referring part of asp.net core (asp.net 5) in new version no longer have global.asax file, have new startup processed defined in startup class. also, di standard, things work in different way now. either upgrade latest version of asp.net or apply use di solutions olde...

python - How to rank DataFrame by subgroup -

if have dataframe such col1 col2 col3 0 x1 typea 3 1 x2 typeb 13 2 x3 typeb 3 3 x4 typea 5 4 x5 typeb 1 5 x6 typea 1 is there way of ranking rows col3 each type in col2? example solution like col1 col2 col3 rank 0 x1 typea 3 2 1 x2 typeb 13 1 2 x3 typeb 3 2 3 x4 typea 5 1 4 x5 typeb 1 3 5 x6 typea 1 3 transform keeps same shape original dataframe. use lambda function rank col3 based on groupings col2 .. df['col4'] = df.groupby('col2').col3.transform(lambda group: group.rank()) >>> df col1 col2 col3 col4 0 x1 typea 3 2 1 x2 typeb 13 3 2 x3 typeb 3 2 3 x4 typea 5 3 4 x5 typeb 1 1 5 x6 typea 1 1

mmenu - Why isn't my jquery main menu header not sliding with the nav in IE edge and 10? -

i trying jquery main menu header slide nav when user clicks on hamburger button. in chrome, safari , ff, works fine, in ie edge , 10, header stays in place while rest of content slides right, top section of nav cut off. knows why? thanks my code: <nav id="my-menu" class="visible-xs"> <ul> <li class="selected"><a href="index-privacy-1.html">privacy & security</a></li> <li><a href="#">privacy policy</a></li> <li><a href="#">cookies, ads & more</a></li> <li><a href="#">resume security</a></li> <li><a href="#">email scams</a></li> <li><a href="#">faqs</a> <ul class="vertical"> <li><a href="faq...

how iMacros can extract the data without having attribute on element? -

i want extract data: name, email, phone, date, city here html sample code: <tbody> <tr class="grid-row"> <td>jimmy shark</td> <td>jshark@gmail.com</td> <td>082166883333</td> <td>07/13/15, 07:23 am</td> <td></td> </tr> <tr class="odd grid-row"> <td>denny large</td> <td>large.denny@gmail.com</td> <td>08575510121</td> <td>07/09/16, 11:55 pm</td> <td></td> </tr> <more , repeated> </tbody> start following macro , correct meet goal: set !errorignore yes set !timeout_step 0 set !extract_test_popup no tag xpath="//tr[@class='grid-row'][{{!loop}}]/td[1]" extract=txt tag xpath="//tr[@class='grid-row'][{{!loop}}]/td[2]" ex...

sum - OpenERP V7 multi sale orders to invoice -

is there way join ( sum ) same product ( product qty ) different sale orders when invoicing one invoice (from sale orders tree view , select orders invoice -> more drop down menu -> option make invoices -> on wizard select group invoices , hit button create invoices )?

c# - Initializing a log object for all classes -

i have winforms application lot's of classes, , in every class need write log if goes wrong. today made logger function initialize in every class object using inside. for example have main logic class have log , 1 more class that's running different logic should have log. today using: initialize log object in class contractor working it. passing log object contractor. what best architecture initialize 1 time , use in every class (not doing static). my logger class: namespace mylogger { public class logger : imessagelogger { imessagelogger _messagelogger; public logger(imessagelogger messagelogger) { _messagelogger = messagelogger; } public void log(string message) { _messagelogger.log(message); } } public interface imessagelogger { void log(string message); } public class filelogger : imessagelogger { string _filepath = environ...

reporting services - SSRS report shared data source wont render -

ssrs report wont work shared data source . report works fine if use embedded data source. moment switch shared data source report goes blank again, no error shown. trying preview report in visual studio 2013. 1 got similar problem? suggested fix this? sql server bi plugin update fixed rendering issue

Palindrome of string in c without using library functions -

i created code palindrome of string using reverse , copy of strings without library function.but still shows palindrome.what mistake have done.and prints palindrome regardless whether give palindrome or not.i checked internet code want know mistake made in code please help. #include <stdio.h> #include <string.h> int main() { char s[1000]; char t[1000],temp; int i,j,flag=0; gets(s); for(i=0;i<strlen(s);i++) { t[i]=s[i]; } printf("%s",t); int n=strlen(s)-1; for(j=0,i=n;i>=0;j++,i--) { t[j]=s[i]; } printf("%s",t); for(i=0,j=0;i<=n,j<=n;i++,j++) { //for(j=0;j<n;j++){ if(t[j]==t[i]) { flag=1; break; } } if(flag==1) { printf(" palindrome"); } else { printf("else palindrome"); } return 0; } not preventing using library functions, mi...

python - Repeating strings in pandas DF -- want to return list of unique strings -

i have bunch of rows of data in pandas df contain inconsistently offsetting string characters. each game id (another column), 2 string characters unique game id, not switch off in predicatble pattern. regardless, i'm trying write helper function takes each unique game id , gets 2 team names associated it. for example... index game_id 0 400827888 1 400827888 2 400827888 3 400827888 4 400827888 ... 555622 400829117 555623 400829117 555624 400829117 555625 400829117 index team 0 atl 1 det 2 atl 3 det 4 atl ... 555622 por 555623 den 555624 por 555625 por here woeful attempt, not working. def get_teams(df): in df['gameid']: both_teams = [df['team'].astype(str)] return(both_teams) i'd return ['atl', 'det] game id 400827888 , ['por', 'den'] game id 400829117. instead, returning team name associat...

Android: How can I launch shortcut of a certain app in my own application? -

thanks click question. i'm developing kinds of beginner-level apps, , wondering possible launch shortcut(not app. itself) in own application. actually, found way launch apps package names, need start shortcuts(which located in homescreen) when touch special button in app. is there way said? best regards. may useful, how classes manifest, i'd know http://www.tutorialforandroid.com/2009/10/launching-other-application-using-code.html say want open fuelgauge, this. final intent intent = new intent(intent.action_main, null); intent.addcategory(intent.category_launcher); final componentname cn = new componentname("com.android.settings","com.android.settings.fuelgauge.powerusagesummary"); intent.setcomponent(cn); intent.setflags(intent.flag_activity_new_task); startactivity( intent); explanation open other people's application, need make sure in manifest file, author specify class have android.intent.action.main intent-filter added ...

swift - WatchKit 2 Complication Text Only Shows Up in Preview -

Image
i'm trying develop simple complication watchkit 2 says "hi" simple text provider. i've managed achieve strange behavior; can see text when complication clicked or when previewing customize watchface screen, not when watchface displayed. have look: any ideas might causing this? my text provider looks this var textprovider: clksimpletextprovider override init() { textprovider = clksimpletextprovider() textprovider.text = "hi" textprovider.shorttext = "hi" textprovider.tintcolor = uicolor.whitecolor() super.init() } and getplaceholdertemplateforcomplication looks like func getplaceholdertemplateforcomplication(complication: clkcomplication, withhandler handler: (clkcomplicationtemplate?) -> void) { // method called once per supported complication, , results cached switch complication.family { case .modularsmall: let stemplate = clkcomplicationtemplatemodularsmallsimpletext() st...

Exclude folder from Recurse in Powershell -

i've written following script move mp4 file in particular folder root folder, want script ignore 1 particular folder called "camera". i'm using exclude command no avail. can help? $ignore = ("*camera*"); get-childitem "c:\root" -exclude $ignore -recurse -include *.mp4 | move-item -dest "c:\root\" -exclude filter filename or extension dont think can use filter directories. can try : gci c:\root\*.mp4 -recurse |where {$_.fullname -notmatch "camera"}

Android Wear: DataItem API vs Channel API -

i need collect sensor data on android wear device , want stream on android smartphone. is, have regular set of values want send on phone on extended period of time. data rate not high, say, 100 samples per second, 20 bytes per measurement sample. seems either implemented series of dataitems (for dataitem api) or series of small blobs (for channelapi). both dataitem , channel apis work. there reason choose 1 or other? other questions: 1) i've read android docs , looks dataitem protocol allows caching , retransmission in case of dodgy wireless transport. channelapi also? 2) push each sample measurement on separate item (or blob) , expect these accumulate on time. makes sense once phone receives data (and copies local storage) should remove dataitem (or blob). affect data on wear device? thanks! okay, i'm answering own question. after several months working datalayer api, can works , surprisingly robust. have 3 wear devices each pushing 100hz sensor data co...

variables - How to modify a python script to call an external file during a batch process? -

i have long series of files need analyze, in batch, using python script, e.g.,: all_transcriptomes.fasta ofas000003-ra_rbh.fasta ofas000101-ra_rbh.fasta ofas000115-ra_rbh.fasta ofas000119-ra_rbh.fasta and on. need query each *rbh.fasta against all_transcriptomes.fasta . here beginning section of script i'm using perform analysis (up specifying variables): #!/usr/bin/env python usage = """this program entire reciprocal blast search. nomenclature follows: sequences vs sequences b blast search step 1 = seqs vs blast database of seqs b step 2 (this step) = seqs b vs blast database of seqs columns of results table must follows: column 1: query id column 2: query length column 3: subject id column 4: subject length column 5: bitscore column 6: e-value column 7 onwards can like. """ #import modules needed import subprocess #give information required print "\na program run full reciprocal blast program. \n\ if having problems, worth rea...

escaping - How to identify a special character in a file using java -

i have .doc file contains header before ÐÏ , need remove characters exist before ÐÏ. example : asdfasdfasdfasfasdfasfÐÏ9asjdfkj i have used below code. inputstream = new fileinputstream("d:\\users\\vinoth\\workspace\\testing\\testing_2.doc"); datainputstream dis = new datainputstream(is); outputstream os = new fileoutputstream("d:\\users\\vinoth\\workspace\\testing\\testing_3.doc"); dataoutputstream dos = new dataoutputstream(os); byte[] buff = new byte[dis.available()]; dis.readfully(buff); char temp = 0; boolean start = false; try{ for(byte b:buff){ char c = (char)b; if(temp == 'Ð' && c == 'Ï' ){ start = true; } if(start){ dos.write(c); } temp = c; } however , not writing in file first if condition not getting satisfied. please advise how can perform . there wrong when use char c = (char)b; refer byte...

google maps - Zoom beyond 21 zoom level with googlemaps api Android -

is possible zoom beyond 21 max zoom level provide googlemaps api on android ? have own pictures tileoverlay, zoom on 21 on own pictures on map. thanks ! the maximum zoom level 21 , there no indicated way surpass this. as proof, i'm going give example using javascript same concept holds true android well. this map zoom level set 21: click here demo var map = new google.maps.map(document.getelementbyid('map'), { zoom: 21, center: mylatlng }); this map zoom level set 23: click here demo var map = new google.maps.map(document.getelementbyid('map'), { zoom: 23, center: mylatlng }); you notice between 2 nothing has changed, there no way go beyond limit.

javascript - ajax is working without event.preventDefault(); - but breaks if added event.preventDefault(); -

i've built ajax request insert new row mysql , updated database array. works without event.preventdefault(); (and redirects php file) - breaks when added event.preventdefault(); prevent redirect. any ideas? $("#upload-form").submit(function() { //event.preventdefault(); window.alert(paintscatlg.length); document.queryselector("#upload-form #id").value = paintscatlg.length; document.queryselector("#upload-form #src").value = "paintings//" + document.queryselector("#upload-form #exhibition_en").value + "//" + filename; window.alert(document.queryselector("#upload-form #id").value); window.alert(document.queryselector("#upload-form #src").value); var uploadform = new formdata(); uploadform.append("id", $('#id').val()); uploadform.append("src", $('#src').val()); uploadform.append("title_en", $('#title_en...

haskell - Avoid repetition in lexing when using parsec -

the parsec documentation has example of using maketokenparser build lexer: module main import text.parsec import qualified text.parsec.token p import text.parsec.language (haskelldef) -- parser ... expr = parens expr <|> identifier <|> ... -- lexer lexer = p.maketokenparser haskelldef parens = p.parens lexer braces = p.braces lexer identifier = p.identifier lexer reserved = p.reserved lexer ... in "the lexer" block, every p.* applied lexer 1 can avoid repeating in "the parser" block. repeating every token still tedious. there way avoid repetition more? thinking implicitly apply lexer everywhere in "the parser", @ lost how to. there general syntax pattern matching on records in haskell (i started noticing of p.parens , p.braces , etc. record projection functions - can see looking @ docs .) . can use here p.tokenparser { p.parens = parens , p.brac...

scala - get hdfs file path in spark -

i wonder whether have elegant way directory under path. example, have path on hfs /a/b/c/d/e/f, , given a/b/c, there straight-forward way path /a/b/c/d/e ? think can of regex. still hope find whether there easier way make code cleaner. evn: spark 1.6, language: scala for several days investigation, think there may no such easy way(integrated api)to extract work. write regex pattern wise choice. welcome suggestion.

Email verification using Firebase 3.0 on Android -

Image
i knew can verify users email firebase auth 3.0. i'm not able find documentation regarding email verification on android. i'm able find same ios web not android. link documentation helpful. from image, clear once user signs in, intimated regarding on email confirm subscription. i've subscribed myself , verified in users section in auth tab , able see mail id , firebase generated unique user id. what's missing here confirmation email email id. did 1 try or trying this? help. update email verification available in version 9.6 , higher of firebase sdk android . original answer email verification not available android yet. answered here more context.

android - 0 devices supported google play store -

i'm having trouble uploading new app. upload work fine says 0 devices supported. have tried removing libaries (dependencies gradle ) , uses permissions can't seem work. manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.southtune.smicker"> <uses-permission android:name="com.southtune.smicker.permission.maps_recieve" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.vibrate"/> <uses-permission android:name="com.south...

java - BigQuery - decyphering 'quota exceeded' message -

im running message , im not clear of many quotas im exceeding. process has: 80 threads (spread on 8 machines) < 50 records / insert ~5k / record 1 sec delay / insert inserting ~100 different tables (depending on specific record - records same table grouped together) to me is: < max row size (1mb) < max rows / second (100k / table , 1m / project) < max rows / request (~500) < max bytes / second (100mb) im looking @ output of: bq --project <proj name> ls -j -a . gives me jobs , success/fail. here @ results using bq --project <proj name> show -j <jobid> error output has these lines: "status": { "errorresult": { "location": "load_job", "message": "quota exceeded: project exceeded quota imports per project. more information, see https://cloud.google.com/bigquery/troubleshooting-errors", "reason": "quotaexceeded" }, "errors...

html - How to change the height of a numeric textbox input -

does know how change height of numeric textbook input css? i'm finding using simple style - height="20px" resize input not input wrapper. tried applying style parent div , doesn't work. i'm relatively new kendo ui i'm not hugely experienced did not find useful within documentation. suggestions useful. you can try style: .k-numeric-wrap input { height: 50px !important; } and fixing decrease arrow(but i'm not sure if idea use since uses position: absolute ): .k-numeric-wrap .k-link:last-child { position: absolute; bottom: 0; margin-left: 7px; } demo . you have fix font size too.

javascript - Can't link js file to html file in flask template -

in project there folder named mine 2 subfolders (static folder & templates folder) , 1 app.py file init. i have put jquery script file inside static folder , shop.html file in templates folder. want link html file js file. i put inside html file: <script type=text/javascript src="{{url_for('static', filename='/static/hide.js') }}"></script> but not work? problem? you have duplicate 'static' in there: url_for('static', filename='hide.js') the first 'static' automatically populate url points static folder, therefore putting 'static' in filename field redundant. url_for('static', filename='static/hide.js') # '/static/static/hide.js' url_for('static', filename='hide.js') # '/static/hide.js'

powershell - How to run an Event (FileSystemWatcher) through Task Scheduler -

i have pretty simple powershell script creates io.filesystemwatcher object, , calls executable upon event being triggered. i can run script without issue administrator powershell on 2012 windows server, seems run issues when have script being run task scheduler . i've attempted running task while logged on, , on trigger while i'm logged off , in both instances event status reads: "running" when check. interacting folder should watched produces no results. i've added log file document parts of code functioning , script create event, event triggering seems issue. has heard of issue creating events through task scheduler? i've read forums might domain user issue hkey_local_machine\system\currentcontrolset\control\lsa change ‘reg_dword’ valuename ‘disabledomaincreds’ value “0 although case, , i've tried multiple variations of settings in task properties per scripting guy , spiceworks . general consensus i've found needs ran -noexi...

Represent data from json file in rating stars without jquery!! pure javaScript -

i trying load data json file using javascript , need represent hotel2show.rating in form of stars, represent them dependig on value 'hotels.json' here javascript function gethotels(i){ var xhr = new xmlhttprequest(); xhr.onreadystatechange = function() { if (xhr.readystate === xmlhttprequest.done) { if (xhr.status === 200) { hotel=json.parse(xhr.responsetext); var hotel2show = hotel.hotels[i]; document.getelementbyid("img-container").innerhtml = "<img src='"+hotel2show.imgurl+"'>"+ "<p id='name'><strong>"+ hotel2show.name +"</strong></p>" +"<br/>" + "<p id='rating'><strong>"+ hotel2show.rating +"</strong></p>" +"<br/>" + "<br/>" +"<p id='price'><strong>"+ '...

annotations - Java: run custom code on field access -

my use-case following: have class member field, accessed of methods. able run custom code modifying member field each time accessed methods see modified value. initial idea use custom annotation. so wanted have this: class myclass { ... @myannotation myfieldtype myfield; ... public void mymethod() { ... smth = myfield.getsomething(); ... } } such when run method mymethod() (or other class method), code executed before modifying myfield: void myannotationprocessor() { ... myfield.change(); } so when access myfield in mymethod, see changed myfield , not 1 before method call. basically, in aspect, @myannotation should @before in junit. i tried implement @myannotation custom constraint, but, unfortunately, did not work planned, constraint validator never called when methods accessed field. is there way annotations? or fighting lost struggle? any appreciated. update i have solved problem in entirely different ...

css - Bootstrap 3 complex layout -

Image
haven't found complex layout question one, here goes. question 1 - need layout like: +----------------------------------------+ +--------------------+ | | | | | | | 2 | | | +--------------------+ | | | | +--------------------+ | | | | | | | | | 1 | | | | | | 3 | | | | | | | | | | | +--------------------+ | ...

Excel vba MsgBox to display message when duplicate is found -

i trying remove duplicates table in excel, have piece of code removes duplicates without problem, wondering if make prompt message box when duplicate found saying along lines "this entry duplicate entry" suggestions? got far: sub accesstransfer() range("a1:f1").select selection.copy sheets("sheet2").select activesheet.paste activecell.offset(0, 6).value = "oven" range("a65536").end(xlup).offset(1, 0).select call godupe sheets("sheet1").select application.cutcopymode = false end sub sub godupe() cells.removeduplicates columns:=array(1), header:=xlno range("a65536").end(xlup).offset(1, 0).select end sub rather looping through, identifying , prompting each duplicate, highlight duplicates , prompt user once. godupe() sub this: sub godupe() cells.formatconditions.adduniquevalues cells.formatconditions(cells.formatconditions.count) .dupeunique = xld...

c# - How to use LINQ to assign while selecting to new object -

i have data contract called gameimage , gametone . trying join 2 entities, , assign unique random position between 0-11 image/tone association. able join tables unsure if there way assign position while creating object in linq lambda expression. // need random positions 0-11 to associated image/tone var positions = enumerable.range(0, 11).shuffle().tolist(); // associate image/tones imagetonedata = game.gameimages.shuffle() .join(game.gametones, gi => gi.gameid, gt => gt.gameid, (gi, gt) => new imagetonedata { image = new imagedata() { imagefilename = gi.image.imagefilename, imageid = gi.imageid }, tone = new tonedata() { tonefilename = gt.tone.tonefilename, toneid = gt.toneid }...

python - Pandas crash when multiplying dataframe column with another -

on server running python script (apache2, flask, debian config), i'm having crash without error output when trying multiply or divide dataframes columns (ex: df[col] = df[col] * or / df[another_column] ). on local computer, works once running on server, execution stops without kind of indication @ lines divide or multiply. this error occurred after tried upgrade pandas on sever. here pip freeze of config. cython==0.23.4 flask==0.10.1 flask-excel==0.0.4 flask-login==0.3.2 flask-sqlalchemy==2.1 flask-wtf==0.12 flask-whooshalchemy==0.56 jinja2==2.8 markupsafe==0.23 pillow==3.3.0 pygments==2.1.3 sqlalchemy==1.0.14 tempita==0.5.2 wtforms==2.1 werkzeug==0.11.10 whoosh==2.7.4 xlsxwriter==0.8.4 backports-abc==0.4 blinker==1.4 cycler==0.10.0 dask==0.10.1 decorator==4.0.10 et-xmlfile==1.0.1 ipython==5.0.0 ipython-genutils==0.1.0 itsdangerous==0.24 jdcal==1.2 jsonschema==2.5.1 matplotlib==1.5.1 mpmath==0.19 networkx==1.11 numexpr==2.6.1 numpy==1.10.4 openpyxl==2.3.5 pandas==0.17.1 p...

ios - GameplayKit GKPolygonObstacle Not Working With GKGoal -

similarly question have posted here , realizing problem more trivial anticipated, works elements of gameplaykit not others.. i have obstacle, sknode , trying define gkpolygonobstacle can used agent, gkagent2d , obstacle avoid when moving in skscene have set up. i have looked apple's agentscatalog see how use gkobstacle agent in gameplaykit method: goaltoavoidobstacles:(nonnull nsarray<gkobstacle *> *) maxpredictiontime:(nstimeinterval) when use following code in own project create gkcircleobstacle objects, find agent quite nicely navigates around , avoids these circular obstacles quite nicely depending on weight give (importance level). here code using: nsarray<gkobstacle *> *obstacles2 = @[ [self addobstacleatpoint:cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame) + 150)], [self addobstacleatpoint:cgpointmake(cgrectgetmidx(self.frame) - 200, cgrectgetmidy(self.frame...

html - How can I explore Body Labs' Blue with my API key before embedding into our production-level site? -

i use api key begin prototyping blue before embedding our production-level site. how do this? the easiest way sample blue before embedding make practice html page on local machine. embed blue simple html page, make sure origin account settings include localhost, , use http-server (or similar) run on localhost (http-server -a localhost) . can explore blue local machine opening html file browser (most url localhost:8080 - tell when run http-server port use on). just sure remove localhost account settings before using app in production! be sure check out documentation more information: http://developer.bodylabs.com/blue_reference.html

Python UDP socket resend data if no data recieved -

i want send data sensor , if python script doesn't receive data want receive function timeout , resend data. def subscribe(): udp_ip = "192.168.1.166" udp_port = 10000 message = '6864001e636caccf2393730420202020202004739323cfac202020202020'.decode('hex') print "udp target ip:", udp_ip print "udp target port:", udp_port print "message:", message sock = socket.socket(socket.af_inet, socket.sock_dgram) sock.sendto(message, (udp_ip, udp_port)) recieve_data = recieve() if recieve_data == subscribe_recieve_on or recieve_data == subscribe_recieve_off: logging.info('subscribition light successful') else: logging.info('subscribition light unsuccessful') def recieve(): udp_ip = "192.168.1.118" udp_port = 10000 sock = socket.socket(socket.af_inet, socket.sock_dgram) # udp sock.bind((udp_ip, udp_port)) data, addr = sock.recvfrom(1024) ret...

r: conditionally replace values in a subset of columns -

i have dataframe so: sport contract start contract end visits spends purchases basket 2013-10-01 2014-10-01 12 14 23 basket 2014-02-12 2015-03-03 23 11 7 football 2015-02-12 2016-03-03 23 11 7 basket 2016-07-17 2013-09-09 12 7 13 i conditionally replace columns [4:6] nas, based on variables "sport" , "contract start". instance: i1 <- which(df$sport =="basket" & df$contract_start>="2014-01-01") will index rows in conditions met. there easy piece of code add above, replace df[4:6] nas given above conditions? end that: sport contract start contract end visits spends purchases basket 2013-10-01 2014-10-01 12 14 23 basket 2014-02-12 2015-03-03 na na na football 2015-02-12 2016-03-03 23 11 7 basket 2016-07-17 2013-09-09 na na na thanks! a. you can specify rows , columns repla...

python - Doing calculations on Pandas DataFrame with groupby and then passing it back into a DataFrame? -

i have data frame want group 2 variables, , perform calculation within variables. there easy way , put information dataframe when i'm done, i.e. this: df=pd.dataframe({'a':[1,1,1,2,2,2,30,12,122,345], 'b':[1,1,1,2,3,3,3,2,3,4], 'c':[101,230,12,122,345,23,943,83,923,10]}) total = [] avg = [] aid = [] bid = [] name, group in df.groupby(['a', 'b']): total.append(group.c.sum()) avg.append(group.c.sum()/group.c.nunique()) aid.append(name[0]) bid.append(name[1]) x = pd.dataframe({'total':total,'avg':avg,'aid':aid,'bid':bid}) but more efficiently? you can use pandas aggregate function after groupby : import pandas pd import numpy np df.groupby(['a', 'b'])['c'].agg({'total': np.sum, 'avg': np.mean}).reset_index() # b total avg # 0 1 1 343 114.333333 # 1 2 2 122 122.000000 # 2 2 3 368 184...

What are some machine learning algorithms -

i'm kinda confused machine learning classification in machine learning algorithm amd suprivied , unsupervised algorithms or type of ml? machine learning algorithms? didnt understand question, ml algorithms are: linear regression logistic regression neural networks support vector machines desicion trees k-nearest neighbor k-means principal component analysis and more....

SSH to jump host, to final host, then tmux -

in ssh config, have host jumphostnick hostname jumphost.com user username host finalhostnick user username proxycommand ssh jumphostnick nc finalhosturl 22 i supplement having run tmux attach -d when gets final host. possible? use -w rather netcat : host jumphostnick hostname jumphost.com user username host finalhostnick user username proxycommand ssh -w finalhosturl:22 jumphostnick if want run tmux attach -d , should add finalhostnick : requesttty yes and connect using ssh finalhostnick -t tmux attach -d , or setup bash alias: alias ssh-final='ssh finalhostnick -t tmux attach -d' in ~/.bashrc

sql server - creating summation in a sql table in SSIS for Tableau -

i want sum hours daily dates month in ssis package. wrote following sql code this: the below query calculates sum of forecasthoursend , groups date month select year(forecastdate) y, month(forecastdate) m,sum(forecasthrsend) p rpt_histsnapeng group year(forecastdate), month(forecastdate) and, below query calculates sum of actual hours , groups date month select year(actualsdate) y, month(actualsdate) m, sum(actualhrs) p rpt_histsnapeng group year(actualsdate), month(actualsdate) now trying write code in ssis pass them variable/column can use column in tableau create chart, how that? i referencing following links purpose: sql needed: sum on values month , sql query sum-up amounts month/year first, there no reason @ can't use tableau perform aggregations @ year , month grain - without having pre-aggregate data. however, if insist on preparing data in sql first, have couple of options: 1. union this more normalized structure allow use t ("type...

swift2 - AVFoundation: Creating an AVAsset from NSData Without Saving to Device. Is it possible? -

in app video recorded user. when user finishes recording, video compressed using compression algorithm returns video nsdata. writing data file , saving server. i retrieving saved videos , displaying them on tableview . in theory there dozens of videos on feed. when retrieve video server , decompress it, stuck nsdata object. i looking turning object avasset without saving file device. any appreciated

python - Adding a related object as a context value back to a rendered view in Django -

i have query can run in shell , right answer given models , way relations work: # , let's see each business's employees: employees=employee.objects.filter(business_locations__business=business).distinct() this works great, can set employees , have employees work business. trouble not sure clean way figure out when trying use model , render list view it. if see list.html code (last snippet) can see trying provide number of employees working business in list , ideally provide link edit employees using <-- --> arrow widget thingy . i know have in view right below, wasn't sure cleanest way. best come involved loop , map of ids? i have view method: in views.py: def business_list(request): object_list = business.objects.all() paginator = paginator(object_list, 25) # 3 posts in each page page = request.get.get('page') #make map object list how can have data @ end... try: business = paginator.page(page) except pagenot...

amazon web services - Multiple AWS Lambda functions on a Single DynamoDB Stream -

i have lambda function multiple dynamodb streams configured event sources , part of bigger pipeline. while doing checks, found missing data in 1 of downstream components. want write simpler lambda function configured event source 1 of earlier mentioned dynamodb streams. cause 1 of dynamodb streams have 2 lambda functions reading it. wondering if ok? both lamdba functions guaranteed receive records placed in stream , there resource (read/write throughput) limits need aware of. couldn't find relevant documentation on aws website, did find regarding processing of shards to access stream , process stream records within, must following: determine unique amazon resource name (arn) of stream want access. determine shard(s) in stream contain stream records interested in. access shard(s) , retrieve stream records want. note no more 2 processes @ should reading same streams shard @ same time. having more 2 readers per shard may result in throttling. ...

node.js - Node how to make dependency analysis and remove unused module dependecies -

my node modules simple module have few dependencies , makes use of built-in modules. given that, module has dependency of module declares dependencies "dependencies": { "events": "^1.1.1", "geocoder": "^0.2.2", "gpsoauthnode": "^0.0.5", "istanbul": "^0.4.4", "protobufjs": "^5.0.1", "request": "^2.73.0", "s2geometry-node": "^1.3.0", "tape": "^4.6.0" } running npm install end in following node_submodules tree ├─┬ body-parser@1.15.2 │ ├── bytes@2.4.0 │ ├── content-type@1.0.2 │ ├─┬ debug@2.2.0 │ │ └── ms@0.7.1 │ ├── depd@1.1.0 │ ├─┬ http-errors@1.5.0 │ │ ├── inherits@2.0.1 │ │ ├── setprototypeof@1.0.1 │ │ └── statuses@1.3.0 │ ├── iconv-lite@0.4.13 │ ├─┬ on-finished@2.3.0 │ │ └── ee-first@1.1.1 │ ├── qs@6.2.0 │ ├─┬ raw-body@2.1.7 │ │ └── unpipe@1.0.0 │ └─┬ type-i...