Skip to content

Instantly share code, notes, and snippets.

View nad2000's full-sized avatar
🇳🇿
Working from New Zealand

Radomirs Cirskis nad2000

🇳🇿
Working from New Zealand
View GitHub Profile
@nad2000
nad2000 / gaps.r
Created June 9, 2013 02:12
Distribution of sample counts per gap value between the current sample and the previous one
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="6", user="postgres", host="192.168.132.111")
# dbListConnections(drv)
# dbGetInfo(drv)
# summary(con)
rs <- dbSendQuery(con,"
SELECT
delta, delta_cnt ,
@nad2000
nad2000 / fsvsbs.r
Created June 9, 2013 02:11
Relative Error of Bandwidth Estimate Based On Flow Sample
fsvsbs <- read.csv("~/fsvsbs.csv", sep=";")
fsvsbs$rel_err = fsvsbs$rel_err*100
plot(
fsvsbs$rel_err ~ fsvsbs$delta,
xlab="Step / Sub-range Length (sec)",
ylab="Relative Error (%)",
main="Relative Error of Bandwidth Estimate Based On Flow Sample")
nls_fit <- nls(rel_err ~ a + b * delta^(-c), fsvsbs, start = list(a = 43, b = 4, c = 0.2))
lines(fsvsbs$delta, predict(nls_fit), col="red",lwd=3)
@nad2000
nad2000 / flow_counts.r
Last active December 18, 2015 06:08
flow count with exponential moving average data comes from Postgres DB
# install.packages("RPostgreSQL")
# install.packages("zoo")
# Notes: EMA - Exponential moving average with alpha=0.05
library(RPostgreSQL)
library(TTR)
drv <- dbDriver("PostgreSQL")
##con <- dbConnect(drv, dbname="probedb", user="postgres", host="192.168.132.111")
con <- dbConnect(drv, dbname="1", user="postgres", host="192.168.132.111")
def straddr2int(addr):
"""
converts IPv4 address inot an integer
>>> str2int('192.168.129.43')
3232268587
"""
return reduce( lambda a,b: a<<8|b, map(int,addr.split('.')) )
@nad2000
nad2000 / gist:5705543
Last active December 18, 2015 01:39 — forked from anonymous/gist:5705535
# Include the Dropbox SDK libraries
from dropbox import client, rest, session
# Get your app key and secret from the Dropbox developer website
APP_KEY = 'KEYKEYKEY'
APP_SECRET = 'SECRET'
# ACCESS_TYPE should be 'dropbox' or 'app_folder' as configured for your app
ACCESS_TYPE = 'dropbox' ### 'app_folder'