Skip to content

Instantly share code, notes, and snippets.

View younata's full-sized avatar

Rachel Brindle younata

View GitHub Profile
@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):
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
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.
syntax on
set tabstop=2
set expandtab
set shiftwidth=2
let mapleader = ","
nnoremap / /\v
vnoremap / /\v
class Foo: NSObject {
var obj: NSObject? = nil
}
func createObjectOfType(type: NSObject.self) -> Foo {
let obj = type()
if obj.respondsToSelector("obj") {
obj.setValue(NSObject(), forKey: "obj") // never gets called
}
//obj.setValue(NSObject(), forKey: "obj") // Exceptions if you don't call it with 'Foo.self'
@younata
younata / Polynomial.swift
Created October 24, 2015 04:26
Bad Self. Don't do comparisons like this.
func ==(a: Polynomial, b: Polynomial) -> Bool {
return a.description == b.description
}
@younata
younata / configuration.yml
Last active December 24, 2015 07:05
Home Assistant Configuration
homeassistant:
name: Apartment
latitude: [Redacted]
longitude: [Redacted]
temperature_unit: F
time_zone: America/Los_Angeles
customize:
scene.romantic:
friendly_name: "Romantic"
scene.lights_on:
@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
@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 / 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