Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar
💭
🍒 🍍 🍓 🍊 🍌

Chaz Reid charlesreid1

💭
🍒 🍍 🍓 🍊 🍌
View GitHub Profile
def Trigger_GC():
import serial
import time
GC_Trigger_Port = serial.Serial(12,9600,timeout = 1)
bytesEnable = bytearray([254, 248])
bytesOn = bytearray([254, 1])
bytesOff = bytearray([254, 0])
GC_Trigger_Port.write(bytesEnable)
GC_Trigger_Port.write(bytesOn)
time.sleep(2)
@charlesreid1
charlesreid1 / SingletonWrapper.py
Last active August 29, 2015 14:05
Python Singleton Wrapper (Design Pattern)
class ExpensiveObjectToCreate(object):
'''Insert code here'''
pass
def __init__(self,**kwargs):
self.params = kwargs
def check(self):
print self.params
== Chess Games and Positions in Neo4j
:neo4j-version: 2.0.0
:author: Wes Freeman
:twitter: @wefreema
:tags: chess
The goal is to load a bunch of chess games into Neo4j for further analysis. Scores listed are Stockfish's take on a position after a 25 move horizon (but this number can be deepened as the graph is filled out or as more processing is done). Positions can also be loaded as alternative moves (not connected to a game) based on suggestions from Stockfish. The positions are recorded as link:http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation[FEN], a human-readable/compressed chess board state notation.
=== Schema diagram
@charlesreid1
charlesreid1 / correlation.cpp
Last active August 29, 2015 14:05
Correlation coefficient for two T-dimensional vectors
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <string>
using namespace std;
/// The sums() function computes several sums from vectors x and y,
/// and stores the values in a, b, c, d, and e

NOTE: This how-to was written for the Census API at http://thedataweb.rm.census.gov/ -- it has since been moved to http://api.census.gov/

Mike Stucka, our contact at the Macon Telegraph, sent us a link to the Census's official API which is launching next month. You can skip ahead to the site - http://www.census.gov/developers/ - and get an API key, but also read my notes after using this yesterday:

  1. The datasets

--- The 2010 Census Summary comes from everyone filling out census forms, and you can get stats at state level down to a super-detailed block level. Info from this includes population, age, gender, race, home ownership, members of a household, and various combinations of that. Full list: http://www.census.gov/developers/data/sf1.xml

--- The 2006-2010 American Community Survey is a longer form given to fewer households over 5 years (so its numbers are incompatible with the 2010 Census). You can get stats down only to the block group level. In addition to the standard census stats, you get: educa

"""
Simple web server that listens for Github webhooks to implement push-to-deploy
with Pelican static sites
Settings are loaded from a json file except for SECRET which should be an
environment variable
Example `deployer.json`
{
@charlesreid1
charlesreid1 / xkcd_colors.json
Created April 20, 2015 17:17
Results of the xkcd color survey (https://xkcd.com/color/rgb/) in JSON format
{
"acid green": "#8ffe09",
"adobe": "#bd6c48",
"algae": "#54ac68",
"algae green": "#21c36f",
"almost black": "#070d0d",
"amber": "#feb308",
"amethyst": "#9b5fc0",
"apple": "#6ecb3c",
"apple green": "#76cd26",
@charlesreid1
charlesreid1 / empirical_cdf.py
Last active August 29, 2015 14:19
Compute Empirical CDF in Matplotlib
import numpy as np
import seaborn as sns
import matplotlib.pylab as plt
from numpy.random import weibull
from scipy.stats import cumfreq
Nsamples = 5000
Nsamples_new = 500
# generate a weibull distribution
import seaborn as sns
from numpy.random import weibull
Nsamples = 1e4
# generate a weibull distribution
k=2
x = weibull(k,(Nsamples,))
partition1, binlocs1, _ = hist(x,10);
$ brew install -v svn
==> Downloading http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.7.9.tar.bz2
Already downloaded: /Library/Caches/Homebrew/subversion-1.7.9.tar.bz2
tar xf /Library/Caches/Homebrew/subversion-1.7.9.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/subversion/1.7.9 --with-apr=/usr/local/Library/ENV/4.3 --with-ssl --with-zlib=/usr --with-sqlite=/usr/local/opt/sqlite --with-serf=/usr/local/opt/serf --disable-neon-version-check --disable-mod-activation --disable-nls --without-apache-libexecdir --without-berkeley-db
./configure --disable-debug --prefix=/usr/local/Cellar/subversion/1.7.9 --with-apr=/usr/local/Library/ENV/4.3 --with-ssl --with-zlib=/usr --with-sqlite=/usr/local/opt/sqlite --with-serf=/usr/local/opt/serf --disable-neon-version-check --disable-mod-activation --disable-nls --without-apache-libexecdir --without-berkeley-db
configure: Configuring Subversion 1.7.9
configure: creating config.nice
checking for gcc... cc
checking whether the C compiler wo