Skip to content

Instantly share code, notes, and snippets.

View rossgoodwin's full-sized avatar
💭
I may be slow to respond.

Ross Goodwin rossgoodwin

💭
I may be slow to respond.
View GitHub Profile
import random
import time
import collections
import itertools
import numpy as np
from pprint import pprint
from PIL import Image
@rossgoodwin
rossgoodwin / dsklfj
Created June 12, 2014 00:02 — forked from 1328/dsklfj
import random
import time
import collections
import itertools
import numpy as np
from pprint import pprint
from PIL import Image
@rossgoodwin
rossgoodwin / gist:21bf9a56daa246970db2
Created September 29, 2014 18:19
Piece and Pawn Classes from Che55
import java.util.*;
char[] files = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
char[] ranks = {'1', '2', '3', '4', '5', '6', '7', '8'};
boolean enpassantOp = false;
Piece enpassantable;
Piece selected;
Piece[] pieces;
float[] position(char[] square) {
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,
@rossgoodwin
rossgoodwin / index.html
Last active August 29, 2015 14:23
d3-dendrogram-troubleshoot
<html>
<head></head>
<body>
<div id="foo"></div>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
@rossgoodwin
rossgoodwin / webm.md
Last active August 29, 2015 14:24 — forked from ndarville/webm.md

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@rossgoodwin
rossgoodwin / split_to_lines.py
Created March 26, 2016 20:38
Function to format text for a variable maximum line length
import string
def split_to_lines(text, ll=80):
text_list = filter(
lambda x: x in string.printable,
list(text.strip())
)
char_count = 0
ws_indexes = list()
cur_line = list()
for i,d in enumerate([1]*999999):import random;d*=random.randint(-1,1);l=list('\\|/');print ' '*(i/64+d)+l[d]+''.join(random.sample([l[d],'_']*64,32))+l[d];sum(range(8**7));
import re
with open('faulkner.txt', 'r') as infile:
complete_lines = infile.read().split('\n')
stripped_lines = map(lambda x: x.strip(), complete_lines)
lines = filter(lambda x: x and not x.isdigit(), stripped_lines)
print len(lines)