Skip to content

Instantly share code, notes, and snippets.

View jason-feng's full-sized avatar

Jason Feng jason-feng

View GitHub Profile
@jason-feng
jason-feng / CopyDrawView
Created March 30, 2015 01:24
Refactored Objective C code into Swift for easier integration with parse
//
// CopyDrawView.swift
// eyeTrainTest2
//
// Created by Jason Feng on 2/25/15.
// Copyright (c) 2015 edu.dartmouth.dali. All rights reserved.
//
import Foundation
import QuartzCore
@jason-feng
jason-feng / tictactoe.py
Created September 17, 2015 14:54
A simple python command line tic tac toe game
import pprint
# Returns a row in a given column
def column(matrix, i):
return [row[i] for row in matrix]
# Checks if a given row or column has all of the same value
def check(list):
if len(set(list)) <= 1:
if list[0] != 0:
@jason-feng
jason-feng / format_email.py
Created March 29, 2017 01:23
Formats emails nicely for slack
## Turns list of dartmouth emails into formatted emails with first and last name
f = open("names.txt")
o = open("names_edit.txt", 'w')
for email in f.readlines():
email = email.strip()
email = email[:-1] # Remove semicolon
bracket_email = "<" + email + ">" # Now its like <jason.s.feng.17@dartmouth.edu>
at_index = email.rfind("@")
name = email[0:at_index-3] # get just the jason.s.feng
@jason-feng
jason-feng / pre-push-hook
Created May 8, 2017 20:02
Prevent pushing to master
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
@jason-feng
jason-feng / pre-push-hook-lint
Created May 8, 2017 20:04
Lints your code before you push
#!/bin/bash
npm run lint:all
# This command could look something like this: `eslint **.js`