Skip to content

Instantly share code, notes, and snippets.

View blackfist's full-sized avatar

Kevin Thompson blackfist

View GitHub Profile
Book.create(title: "I win", author: "U. Lose")
Book.create(title: "Robots", author: "Anne Droid")
Book.create(title: "Come on in", author: "Doris Open")
Book.create(title: "The Yellow River", author: "I. P. Freely")
def aggregateIndustry(inArray):
returnArray = [{'_id':'31-33','friendly_name':'Manufacturing','count':0},
{'_id':'44-45','friendly_name':'Retail','count':0},
{'_id':'48-49','friendly_name':'Transportation','count':0}]
for eachIndustry in inArray:
if eachIndustry['_id'] in ['31','32','33']:
returnArray[0]['count'] += eachIndustry['count']
continue
if eachIndustry['_id'] in ['44','45']:
returnArray[1]['count'] += eachIndustry['count']
@blackfist
blackfist / simple_bar.R
Last active August 29, 2015 13:56
Simple bar chart of vcdb data using Jay's veris package
library(verisr)
library(ggplot2)
# Load the data
vcdb.dir <- "../vcdb/data/json"
vcdb <- json2veris(vcdb.dir)
# Filter out the Unknowns
filt <- !getfilter(vcdb, list("action.hacking.variety"="Unknown"))
#!/usr/bin/env python
import json
vDict=json.loads(open('verisc-enum.json').read())
def dict_walker(inCollection, pre=None):
pre = pre[:] if pre else []
#print(pre)
if isinstance(inCollection, dict):
{
"type": "text",
"from": {"data": "site"},
"properties": {
"enter": {
"text":"This is some text.",
"align": "center",
"baseline": "bottom",
"fill": {"value": "#000"}
}
@blackfist
blackfist / schema_update.py
Created February 12, 2014 21:01
Add a region code to veris - experimental
# Download https://raw2.github.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all/all.json
# and save as all.json in the same folder
import json
import os
from datetime import datetime
import uuid
# i = getIncident('blahblahblah.json')
def getIncident(inString):
return json.loads(open(inString).read())
@blackfist
blackfist / git.md
Last active August 29, 2015 13:56
Git stuff I don't want to forget

fetch a remote branch

git checkout --track origin/daves_branch

Undo a commit from a few commits ago that was pushed up to github. Be warned that if you do this everyone will have to basically blow away their local copy of the repo and do a fresh git pull.

git rebase -i HEAD~4 
git push --force

That will show all the commits going back 4 and let you pick which ones you want to keep. A better way might be to delete the files, then you wont be rewriting history

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import simplejson as sj
import os
from jsonschema import validate, ValidationError
sk = sj.loads(open('verisc.json').read())
enum = sj.loads(open('verisc-enum.json').read())
os.chdir('/Documents/development/python/vcdb/data/json')
# All of the action enumerations