Skip to content

Instantly share code, notes, and snippets.

View madbook's full-sized avatar

Matthew Lee madbook

  • reddit
  • Pittsburgh, PA
View GitHub Profile
@madbook
madbook / test-live-comments.py
Created November 11, 2016 21:11
test-live-comments.py
import random
import time
from r2.lib import websockets
def spew_comments_on_link(link_id36, num_comments=10, delay=.1, start_at_id=1):
"""
Generate a series of fake websocket messages to test live comments
link_id36: id36 of a link, used to namespace the websocket messages
num_comments: how many comments to broadcast
@madbook
madbook / keybase.md
Created February 6, 2016 04:40
keybase.md

Keybase proof

I hereby claim:

  • I am madbook on github.
  • I am madlee (https://keybase.io/madlee) on keybase.
  • I have a public key ASAgcSuEBTjxAx8TdD68uTgzgvvWpM3KkXM6uUEHTgTBTQo

To claim this, I am signing this object:

@madbook
madbook / hack.js
Created May 26, 2015 20:38
js multiline string function hack
function _multiline(fnc) {
return fnc.toString().replace(/^function *\(\) *\{ *\/\* */, '').replace(/ *\*\/ *\} *$/, '');
}
// example
var template = _multiline(function(){/*
<div id="some_id">
<h1>Multiline strings without all the bullshit</h1>
<p>This is a pretty terrible hack, probably don't actually do this ever.</p>
@madbook
madbook / snippet.js
Created December 17, 2014 19:52
clean up github notifications page
$('.octicon-issue-closed, .octicon.type-icon-state-closed, .octicon-git-pull-request.type-icon-state-merged').parent().parent().find('button.delete-note').click();
@madbook
madbook / new-markdown.css
Created November 25, 2014 01:18
old and new markdown styles
.md
{
max-width:60em
}
.md .-headers,
.md h1,
.md h2,
.md h3,
.md h4,
@madbook
madbook / gulpfile.coffee
Created August 7, 2014 16:42
coffescript gulpfile
gulp = require 'gulp'
browserify = require 'gulp-browserify'
react = require 'gulp-react'
gulp.task 'scripts', () ->
gulp.src 'src/jsx/app.jsx'
.pipe browserify()
.pipe react()
.pipe gulp.dest 'build/js'
function* range(begin, end) {
for (let i = begin; i < end; i++)
yield i;
}
let buzzWord = (n) =>
'' + ((n % 3 ? '' : 'fizz') + (n % 5 ? '' : 'buzz') || n)
let fizzBuzz = (max = 100) =>
[for (n of range(1, max)) buzzWord(n)]
@madbook
madbook / Brainluck.js
Created January 19, 2014 19:54
A brainfuck interpreter in javascript. My solution to CodeWars kata "My smallest code interpreter (aka Brainf**k)"
function brainLuck (code, input) {
var interpreter = new BrainLuck(code)
return interpreter.execute(input)
}
function BrainLuck (code) {
// data
this.i = null
this.data = null
// output
@madbook
madbook / git blame all
Created September 17, 2013 17:47
gives you a line count per author, can take a while depending on size of project. modify (php|js|html|css) with whatever file extensions you want to check.
git ls-tree --name-only -r -z HEAD | egrep -z -Z -E '\.(php|js|html|css)$' | xargs -0 -n1 git blame --line-porcelain | grep "^author " | sort | uniq -c | sort -nr
@madbook
madbook / debug-helper.js
Last active December 21, 2015 20:00
replace `obj` with a module object. This wraps every method of that object that dumps nested, collapsible console logs any time those methods are called. logs include arguments, return value, and execution time.
for (i in obj)
if (typeof obj[i] === 'function' && i !== 'toString')
(function (method) {
var fnc = obj[method]
obj[method] = function () {
var x
console.groupCollapsed(this + " -> " + method)
console.dir(this)
console.dir(arguments)
console.time(method + ' time')