Skip to content

Instantly share code, notes, and snippets.

View kgorman's full-sized avatar

Kenny Gorman kgorman

View GitHub Profile
@kgorman
kgorman / pyscript.py
Created April 13, 2016 21:29 — forked from nhoffman/pyscript.py
Python script template
#!/usr/bin/env python
"""A simple python script template.
"""
import os
import sys
import argparse
-- here is my stream
drop stream test_stream cascade;
create stream test_stream (speed int, ts int, tail char(10));
create continuous view v1 as select ts, tail, speed from test_stream;
create continuous view v2 as select tail, keyed_max(ts, speed) from test_stream group by tail;
-- put some data into it
insert into test_stream values (100, 1, 'YY');
@kgorman
kgorman / setup_kafka.sh
Created October 14, 2015 16:40 — forked from ekampf/setup_kafka.sh
Setup Kafka (0.8.0) on OSX
brew install sbt
cd /tmp
wget http://apache.spd.co.il/kafka/0.8.0/kafka_2.8.0-0.8.0.tar.gz
tar -zxvf kafka_2.8.0-0.8.0.tar.gz -C /usr/local/
cd /usr/local/kafka_2.8.0-0.8.0
sbt update
sbt package
@kgorman
kgorman / gist:6748eb47422c804412b5
Last active August 29, 2015 14:27
hillary_sentiment2
hour,avg_neg,avg_neutral,avg_pos
0,0.489045047812703,0.572904921392379,0.510954952187297
1,0.45979209657117,0.55928348584548,0.54020790342883
2,0.452954920632673,0.564895009665459,0.547045079367327
3,0.4886087921913,0.473499704794948,0.5113912078087
4,0.486929135727515,0.470766998533493,0.513070864272485
5,0.516430239594934,0.633499700744954,0.483569760405066
6,0.476850687564712,0.605231004647229,0.523149312435288
7,0.485249046873756,0.504506815590507,0.514750953126244
8,0.485469075837924,0.53258626109772,0.514530924162076
hour,avg_neg,avg_neutral,avg_pos
0,0.489045047812703,0.572904921392379,0.510954952187297
1,0.45979209657117,0.55928348584548,0.54020790342883
2,0.452954920632673,0.564895009665459,0.547045079367327
3,0.4886087921913,0.473499704794948,0.5113912078087
4,0.486929135727515,0.470766998533493,0.513070864272485
5,0.516430239594934,0.633499700744954,0.483569760405066
6,0.476850687564712,0.605231004647229,0.523149312435288
7,0.485249046873756,0.504506815590507,0.514750953126244
8,0.485469075837924,0.53258626109772,0.514530924162076
@kgorman
kgorman / gist:1c39f6dce753bb6703e5
Last active August 29, 2015 14:23
Compaction/Fragmentation example
// mongodb 2.4.8
// fragmented
// initial setting of random rand of 5000
> use sbtest
switched to db sbtest
> db.stats()
{
"db" : "sbtest",
@kgorman
kgorman / gist:4e0e0d933d9fae4571e8
Created February 24, 2015 03:12
Ipython plus Spark
import sys
import os
sys.path.append("/usr/lib/spark-yarn/python")
os.environ["SPARK_HOME"]="/usr/lib/spark-yarn/"
from pyspark import SparkContext
@kgorman
kgorman / gist:50f256c1c328efe576b7
Last active August 29, 2015 14:15
install_jupyterhub
# this script installs jupyter on Rackspace CBD
# 2015 kcg
# the trick here is to install python 3.3 with pip and not ruin the default python install
# then simply run jupyterhub
# this is designed to be run as a postinstall script when provisioning a cluster.
if [ $HOSTNAME == "GATEWAY-1" ]
then
# pre-requisites
{
"metadata": {
"name": "",
"signature": "sha256:a90804b68c0c02c405e62b261bc333673f0be01d2a735136d4799cd5e506f42d"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@kgorman
kgorman / gist:134896c7414fde8e090b
Last active May 7, 2024 13:34
MongoDB Profiler Cheat Sheet
// a list of useful queries for profiler analysis. Starting with the most basic.
// 2.4 compatible
//
// output explained:
//
{
"ts" : ISODate("2012-09-14T16:34:00.010Z"), // date it occurred
"op" : "query", // the operation type
"ns" : "game.players", // the db and collection