Skip to content

Instantly share code, notes, and snippets.

kevincolten / RockPaperScissors.js
Last active August 29, 2015 02:35
Rock Paper Scissors
'use strict';
var prompt = require('prompt');
function compareHands(hand1, hand2) {
if (hand1 === hand2) {
return "It's a tie!";
kevincolten / gist:8853141
Created February 6, 2014 21:46
listing all (mysql) processes and killing them
$ ps aux | grep mysql
$ sudo kill -9 629 513 #1, 5, 9 (varying levels of process killing)
class ApplicationController < ActionController::Base
before_filter :cor
def cor
headers["Access-Control-Allow-Origin"] = "http://localhost:8000"
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",")
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",")
head(:ok) if request.request_method == "OPTIONS"
kevincolten /
Last active August 29, 2015 14:00
Launch Sublime Text from terminal
sudo ln -s /Applications/Sublime\ /usr/bin/subl
kevincolten /
Last active August 29, 2015 14:07
When Setting Up a New Mac
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL"
# Update homebrew recipes
brew update
kevincolten /
Created January 27, 2015 22:16
Run PHP_CodeSniffer on files with uncommitted changes
if [ "$(git diff --name-only master --diff-filter=AMR | grep -Ei "^.*app\/(models|controllers)\/.*\.php$")" ]; then vendor/bin/phpcs $(git diff --name-only master --diff-filter=AMR | grep -Ei "^.*app\/(models|controllers)\/.*\.php$") --standard=PSR2; fi
kevincolten / sparkMySQL.scala
Created June 7, 2015 20:07
Import MySQL into Spark
SPARK_CLASSPATH=../mysql-connector-java-5.1.35/mysql-connector-java-5.1.35-bin.jar bin/spark-shell
val jdbcDF = sqlContext.load("jdbc", Map(
"url" -> "jdbc:mysql://localhost:8889/employees?user=root&password=root",
"dbtable" -> "(SELECT employees.*, departments.*, salaries.salary, titles.title FROM employees JOIN dept_emp ON dept_emp.emp_no = employees.emp_no JOIN departments ON departments.dept_no = dept_emp.dept_no JOIN dept_manager ON dept_manager.emp_no = employees.emp_no JOIN salaries ON salaries.emp_no = employees.emp_no JOIN titles ON employees.emp_no = titles.emp_no) AS employees",
"driver" -> "com.mysql.jdbc.Driver",
"partitionColumn" -> "emp_no",
"lowerBound" -> "10001",
"upperBound" -> "499999",
"numPartitions" -> "10"
kevincolten /
Last active August 29, 2015 14:23
Download Google Trends
import csv
from collections import deque
with open('weekly_stock_trends.csv', 'rb') as f:
reader = csv.reader(f)
weekly_trends = list(reader)
headers = weekly_trends.pop(0)
new_headers = []
kevincolten /
Last active August 29, 2015 14:24
Ocean Plot
from bokeh.embed import components
from bokeh.models import AjaxDataSource, Callback, Slider
from bokeh.plotting import figure, output_file, show, vplot
from jinja2 import Template
import webbrowser
import os
import six
source = AjaxDataSource(
kevincolten /
Last active August 29, 2015 14:25
@post Backbone + React: or, How I Came to Stop Looking for an Example and Built My Own

This tutorial came out of many frustrating google searches trying to find a decent end-to-end boilerplate example of incorporating React as the view component in Backbone. The three components I wanted in a tutorial were:

  1. Build something more than a single page TODO
  2. Involved routing and controllers
  3. Included a build process using a modern build tool
  4. Optimization and source-mapping
  5. Done in an organized manner with descriptive naming patterns

What we'll be building in this tutorial is a basic blog viewer. The source can be found here and the finished product can be found here. When complete, we'll be able to write the blog post in markdown in a gist with the title starting with a key word (ex. @post Here's My Post Title!) and display it in all its html glory.

So let's get started.