Skip to content

Instantly share code, notes, and snippets.

View kafka399's full-sized avatar

Dzidas Martinaitis kafka399

View GitHub Profile
@kafka399
kafka399 / spot.r
Created July 16, 2017 13:18
R script to fetch spot prices from AWS
#aws ec2 describe-spot-price-history --instance-types m4.xlarge --start-time 2017-05-16T01:08:09 --end-time 2017-07-16T12:09:10 --product-descriptions "Linux/UNIX" >dump.txt
require(jsonlite)
require(ggplot2)
require(dplyr)
prices = fromJSON('/projects/dump.txt')
prices = data.frame(prices$SpotPriceHistory)
prices$Timestamp = strptime(prices$Timestamp, '%Y-%m-%dT%H:%M:%S')
prices$Timestamp = as.POSIXct(prices$Timestamp)
@kafka399
kafka399 / gist:4046903
Created November 9, 2012 17:11
How to replace text in bunch of files
find . -name "*.jsp" -print | xargs sed -i 's/old_stuff/new_one/g'
@kafka399
kafka399 / gist:3169371
Created July 24, 2012 10:53
tracking slidify
Title
========================================================
This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the **MD** toolbar button for help on Markdown).
When you click the **Knit HTML** button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r}
summary(cars)
```
@kafka399
kafka399 / gist:3047501
Created July 4, 2012 13:59
summary of the network data
sudo tshark -T fields -E separator=, -E quote=d -e ip.src -e ip.dst -e tcp.srcport -e tcp.dstport -e udp.srcport -e upd.dstport -e tcp.len -e ip.len -e eth.type -e frame.time_epoch -e frame.len
@kafka399
kafka399 / gitdata.md
Created May 15, 2012 14:24
Data analysis of GitHub timeline

First graph below shows how GitHub users actions are spread over time during the day. The X axis on the graph is labeled with the hours of the day (GMT) and the Y axis represent median values of the actions for each hour. From it, we can make a deduction, that highest load for GitHub can be expected between 15:00 and 17:00 GMT and lowest to be expected between 05:00 and 07:00 GMT. The color of the line indicates how busy was the day based on quantiles: green are calm days (20% of days), blue – normal days (50% quantile) and red are busy days (80% quantile). I should to mention, that auto-correlation or serial correlation is high (70% for following hour), which means, that busy hours tend to be followed by busy hours and calm hours tend to be followed by calm hours. Moreover, busy days tend happen after busy days.

Second graph below shows median of actions divided by weekdays. There is not big surprise – weekends are more slow than

@kafka399
kafka399 / gist:2479226
Created April 24, 2012 12:26
rsi blotter
rsi2Vix<-function(ticker,vix)
{
getSymbols(c('SPY','VIX'),from='1995-01-01',index.class=c("POSIXt","POSIXct"))
rsi2<-RSI(Cl(SPY),2)
signal<-ifelse(rsi2>90,-1,0)
temp<-ifelse(rsi2<10,1,0)