Skip to content

Instantly share code, notes, and snippets.

View thearchduke's full-sized avatar

Tynan Burke thearchduke

View GitHub Profile
#!/usr/bin/env ruby
# please use 2.4.0+
# Recursively searches your directory of repos to find the specified regex in commit messages,
# and produces a histogram by author.
# e.g. "./commitsearch.rb 'fu*ck'"
authors = []
Dir.glob('*').select { |f| File.directory? f } .sort .each do |d|
@thearchduke
thearchduke / comment_linter.js
Created October 4, 2017 18:20
Simple jQuery script for letting users check Wordpress comment for banned words & mismatched formatting
$(function(){
var LINTER_BUTTON_TEXT = 'Lint comment';
var BAD_WORDS = [];
var LINTER_MEMO = {};
function memoized(input) {
if (input in LINTER_MEMO === true) {
return LINTER_MEMO[input];
}
LINTER_MEMO[input] = checkWord(input);
@thearchduke
thearchduke / knn.py
Created August 14, 2017 23:42
Basic K-nearest neighbor classifier in standard-library python
'''
Example python implementation of K-nearest neighbor machine learning algorithm
'''
from collections import Counter
import random
class KNNClassifier(object):
'''
@thearchduke
thearchduke / data.csv
Last active August 3, 2017 18:59
Donald Trump Gallup approval rating weighted by party identification
from to weighted_rep weighted_ind weighted_dem unweighted_rep unweighted_ind unweighted_dem
1/20/17 1/29/17 0.2492 0.1848 0.0325 0.89 0.42 0.13
1/30/17 2/5/17 0.2666 0.1517 0.0248 0.86 0.41 0.08
2/6/17 2/12/17 0.2697 0.1295 0.0341 0.87 0.35 0.11
2/13/17 2/19/17 0.2666 0.1369 0.0217 0.86 0.37 0.07
2/20/17 2/26/17 0.2728 0.1406 0.031 0.88 0.38 0.1
2/27/17 3/5/17 0.2288 0.1638 0.03 0.88 0.39 0.1
3/6/17 3/12/17 0.2288 0.1512 0.027 0.88 0.36 0.09
3/13/17 3/19/17 0.2236 0.147 0.03 0.86 0.35 0.1
3/20/17 3/26/17 0.2184 0.1386 0.024 0.84 0.33 0.08
@thearchduke
thearchduke / index.html
Last active April 4, 2017 23:44
Blog category co-occurrence edge bundle graph
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
background: black;
}
.node {
font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
$.ajax({
url: "evening.html",
}).done(function(data) {
var post = $(data);
window.graph.nodes.push({
"id": "front-page post",
"user": "front-page post"
})
post.find('.comment').each(function() {
var cmt = $(this);
try:
import cPickle as pickle
except:
import pickle
from twitter import *
import datetime
token = ''
token_key = ''