Skip to content

Instantly share code, notes, and snippets.

View davidski's full-sized avatar
🔬
Dance card is pretty full.

David F. Severski davidski

🔬
Dance card is pretty full.
View GitHub Profile
@davidski
davidski / openFairSim.R
Last active October 3, 2022 07:02
Sample OpenFAIR model
# for *pert functons
library('mc2d')
# given the number of loss events, calculate the sum of losses for the number of events
sample_LM <- function(N, L, ML, H, CONF){
# Calculate the aggregate loss
#
# ARGS:
# N - number of threat events to evaluate
# L - low boundary
@davidski
davidski / output
Created April 23, 2014 03:22
simpleKMeans problems
> simpleKMeans()
[,1] [,2]
[1,] -0.0520000 -1.8500000
[2,] -2.0040000 -0.8500000
[3,] 0.1413699 0.1849315
@davidski
davidski / gist:aeab819368419d38f608
Last active August 29, 2015 14:01
IP Aggregration Query
{
"size": 0,
"query": { },
"aggregations": {
"ip_ranges": {
"ip_range":{
"field": "srcip",
"ranges" : [
{ "from" : "10.0.0.0" },
{ "to" : "10.0.0.255" }
@davidski
davidski / marxports-video.R
Last active August 29, 2015 14:02
ports ~ country + time visualizaton code as stolen from @jayjacobs
# Inbound port movie maker
# Adopted nearly wholesale from @jayjacobs at DataDrivenSecurity.info
# mangled by @davidski
# which weeks should we look at?
#whichweek <- c(27, 28, 29, 30)
# how many countries to show?
numcountry <- 25 # 20 at first
#!/bin/bash
#debian R upgrade
echo "deb http://streaming.stat.iastate.edu/CRAN/bin/linux/debian lenny-cran/" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get -t lenny-cran install --yes --force-yes r-base r-base-dev
@davidski
davidski / extract_traffic.py
Created July 16, 2014 20:14
Sample Elasticsearch Scroll Query
from elasticsearch import Elasticsearch, helpers
import csv
import logging
logging.basicConfig()
target_file = "traffic.csv"
es=Elasticsearch("your.es.host.example.tld", timeout=480)
@davidski
davidski / es_sample.pig
Last active August 29, 2015 14:05
Sample ES PIG Query
/*es_sample.pig
Silly little proof of concept query to pull ES data into Apache Pig
*/
REGISTER s3://log-inbox.elk.sch/bin/elasticsearch-hadoop-2.1.0.Beta1.jar;
/*
Either use the full class name (ugh) or use a define will _all_ parameters
specified. You can't parameterize DEFINES in pig. (More ugh)
*/
library(httr)
library(magrittr)
library(dplyr)
library(ggplot2)
# data retrieval ----------------------------------------------------------
pg <- GET("http://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.txt",
user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"))
@davidski
davidski / blackcat.R
Created February 13, 2015 13:43
Triskaidekaphillia
library(dplyr)
# thanks to http://www.math-aids.com/ for the shape points
shape1 <- list(c(0,0), c(1,-1.5), c(1.5,-3), c(2,-5), c(2,-6), c(1.5,-7), c(3,-7.5), c(4,-7.5), c(5.5,-7), c(5,-6.5),
c(3,-6), c(3,-5), c(4,-2.5), c(5,-1), c(6,0), c(7,1), c(8.5,2), c(10,2.5), c(11,3), c(10,3.5),
c(9,4.5), c(9.5,6.5), c(8,5), c(6,5), c(5,5.5), c(4,7), c(3.5,4), c(2.5,3.5), c(4,2), c(3,1.5),
c(2,2.5), c(1.5,4), c(1,6), c(0,7), c(-2,7.5), c(-4,7), c(-5,6.5), c(-6,5), c(-7,4), c(-7.5,3.5),
c(-8.5,4), c(-8.5,9), c(-9.5,10), c(-11,10.5), c(-13,10), c(-14,9), c(-13.5,8), c(-13,7.5), c(-11.5,8),
c(-10,4.5), c(-9,2), c(-8,0), c(-7,-2.5), c(-6.5,-5), c(-5.5,-6), c(-4.5,-7.5), c(-1.5,-7.5),
@davidski
davidski / poweR.R
Created February 22, 2015 18:50
Poll residential power rates for Top 50 Metro regions
library(dplyr)
library(tidyr)
library(magrittr)
library(httr)
library(ggplot2)
library(ggvis)
#Inspired by original utility rate API post at
#http://www.numbrcrunch.com/blog/using-the-httr-package-to-retrieve-data-from-apis-in-r