Skip to content

Instantly share code, notes, and snippets.

View younata's full-sized avatar

Rachel Brindle younata

View GitHub Profile
import MathKit
let p = SimplePolynomial(string: "3x^2 + x + 1")
let p2 = SimplePolynomial(string: "(x)(y)")
let p3 = SimplePolynomial(string: "thisIsOneLongVariable^2")
p + p2 // returns 3x^2 + x + (x)(y) + 1
p - p2 // returns 3x^2 + x - (x)(y) + 1
p * p2 // don't feel like figuring that one out.
function CSSScanner(e) {
this.init(e)
}
function CSSParser(e) {
this.mToken = null, this.mLookAhead = null, this.mScanner = new CSSScanner(e), this.mPreserveWS = !0, this.mPreserveComments = !0, this.mPreservedTokens = [], this.mError = null
}
function jscsspToken(e, t, n) {
this.type = e, this.value = t, this.unit = n
@younata
younata / scrabble.py
Created February 2, 2014 05:56
Scrabble
#!/usr/bin/env python
dictionary="/usr/share/dict/words"
# usage: scrabble.py <letters>
# also, pass it through grep if you want more complex patterns. Personally, my regex-fu isn't that strong.
# for the most part, I'll do something like './scrabble.py oschwi*us | grep 'us$' for a word ending in us.
# that's about the extent of my regex-fu
def readDict(diction=dictionary):
@younata
younata / gist:8264679
Created January 5, 2014 05:12
weird output from stlparser.
you$ ./stlparser untitled.stl
(triangle 0:)
Normal: 0.000000, 0.000000, -1.000000
Vertex 0: 4.341105, 20.788564, 0.000000
Vertex 1: -19.261895, 0.018564, 0.000000
Vertex 2: -19.261895, 20.788564, 0.000000
(triangle 1:)
Normal: 0.000000, 0.000000, -1.000000
Vertex 0: -19.261895, 0.018564, 0.000000
Vertex 1: 4.341105, 20.788564, 0.000000
@younata
younata / gist:8264623
Created January 5, 2014 05:05
heisenbug in stlparser.
you$ ./stlparser untitled.stl
stlparser(71086,0x7fff77ac2310) malloc: *** error for object 0x7fbcd8d007a8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
you$ ./stlparser untitled.stl # no change to the code/binary.
<normal output>
@younata
younata / blog.py
Created December 12, 2013 21:45
Very hacky blog script. I stuck it in cron, it gets run daily as me.
#!/usr/local/bin/python
from webhelpers.feedgenerator import Atom1Feed
import os
import datetime
def genPost(webRoot, homeDir):
f = open(homeDir + "flightSim/post1.html")
idx = f.read()
f.close()
@younata
younata / AssembleMapFromMapquest.py
Created November 30, 2013 06:24
Script to generate large satellite image maps by querying mapquest. note that the inputs is the zoom, far north, far west, [far south, far west]. If far_south and far_west are not given, they are the next lowest integers. everything is in degrees. for non-US areas, max zoom level is 11, for US-areas, max zoom level 18. Todo is pretty much parall…
#!/usr/bin/env python
from PIL import Image
import math
import requests
import StringIO
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
@younata
younata / gist:7460963
Created November 14, 2013 03:41
bash script to create git repo on server using ssh...
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <reponame>"
else
echo "creating $1.git"
mkdir $1.git
cd $1.git
@younata
younata / gist:6970602
Created October 14, 2013 04:07
auto-update script for twIRCk
#!/bin/sh
pushd ~/foo/twIRCk/ # change this to wherever you keep your twIRCk sources.
git pull origin master
# removing the mac app store signing
cp TwIRCk.xcodeproj/project.pbxproj backup.pbxproj
sed '/CODE_SIGN_IDENTITY/d' < TwIRCk.xcodeproj/project.pbxproj >> new.pbxproj
mv new.pbxproj TwIRCk.xcodeproj/project.pbxproj
xcodebuild -target twIRCk