Skip to content

Instantly share code, notes, and snippets.

@laughinghan
laughinghan / scanner.js
Last active Aug 29, 2015
scan that shit
View scanner.js
var patterns = [];
(function (args) {
for (var i = 0; i < args.length; i++) {
if (!args[i]) continue;
var parts = args[i].source.split('::=');
var name = parts[0].trim();
var pattern = RegExp('^(?:' + parts[1].trim() + ')');
patterns.push([name, pattern]);
}
View gist:51fc8ae91de3b52769de
\hcf
\gcf
\lcm
\mod
\proj
\span
\arcsinh
\asinh
\asin
\arccosh
View test.md
` leading`
`trailing `

leading
trailing

`  leading`
`trailing `
@laughinghan
laughinghan / MathQuill Toolbar
Created Apr 15, 2011
Experimental MathQuill Toolbar
View MathQuill Toolbar
<!DOCTYPE html>
<html>
<head>
<title>MathQuill Toolbar Demo</title>
<!--script type="text/javascript" src="mathquill/vendor/jquery.min.js"></script>
<script type="text/javascript" src="mathquill/build/mathquill.js"></script-->
<link rel="stylesheet" href="http://mathquill.com/mathquill.css">
View gist:1013809
function parseTable(tbl) {
return tbl.find('tbody tr').map(function () {
return $(this).find('td').map(function () {
return $.trim($(this).text());
}).get().join('\t');
}).get().join('\n');
}
var i = 0, page = 1, pages = 1;
(function loop() {
while (!addresses[i]) {
View merge.js
#!/usr/local/bin/node
var fs = require('fs');
var data = fs.readFileSync(process.argv[2]);
var target = fs.readFileSync(process.argv[3]);
var lines = (data+'').split('\n');
var rows = (target+'').split('\n');
var row = 0;
View Join.js
/**
* Join
* Joins async callbacks with arguments concatenated.
* Usage:
* var join = new Join;
* getScore (angel, buffy, join());
* getNextMatch (angel, join());
* recordVisitAndGetInfo (angel, buffy, join());
* join.after = function(score, next, vinfo) {
if (this.score > 0.9 && ! this.vinfo.last_visit) {
View heroku-ready_django_startproject.sh
#!/bin/sh
PROJECT_NAME=$1
if [ -z "$PROJECT_NAME" ]; then
echo "Usage: heroku-ready_django_startproject.sh projectname"
exit
fi
mkdir $PROJECT_NAME
@laughinghan
laughinghan / PyClass.js
Created Mar 10, 2012
Python-style classes in JavaScript
View PyClass.js
//because why not?
//please don't actually use this. Please use idiomatic JavaScript classes or a very thin class layer like github.com/jayferd/pjs
/*
Usage:
var Cat = PyClass({
__init__: function(self, name) {
self.name = name;
},
chase: function(self, prey) {
@laughinghan
laughinghan / 22_name_scores.py
Created Jun 11, 2012
Sexy, sexy Project Euler Problem 22 "Name Scores" Solution
View 22_name_scores.py
import string
def name_scores():
inputfile = open('./Downloads/names.txt')
inputstring = inputfile.read()
stringlist = inputstring.split(',')
strlst = []
for smallstring in stringlist:
strlst.append(smallstring[1:-1])