Skip to content

Instantly share code, notes, and snippets.

@rsmoz
rsmoz / NewPG.py
Last active February 28, 2016 22:24
Copies a Sample playground from Documents to Desktop and opens it in Xcode. I trigger this from an Alfred workflow.
import shutil, errno, subprocess
def recurse(n):
fileAt = '/Users/rmozayeni/Desktop/Sample%s.playground' % ("" if n == 0 else str(n))
try:
shutil.copytree('/Users/rmozayeni/Documents/Sample.playground', fileAt)
except OSError as e:
if e.errno == errno.EEXIST:
return recurse(n+1)
else: exit(1)
public enum Producer<A> {
case Value(A)
case Error(ErrorType)
func produce() throws -> A {
switch self {
case let .Value(x):
return x
case let .Error(y):
throw y
@rsmoz
rsmoz / poster.py
Created August 15, 2015 19:46
Uploading a bitcoin transaction with OP_RETURN
# coding: utf-8
from bitcoin import *
import binascii
from test import *
priv = sha256('brain wallet words go here')
pub = privtopub(priv)
@rsmoz
rsmoz / idek.swift
Created May 25, 2015 05:30
Yea, partial application error, yo
struct Something {
func xyz() {
let F = doSomething(3)(3)
let G = doSomething(4)
let result = G(3)
}
func doSomething(y: Int)(_ x: Int) -> Int {
return 1
}
typealias DimensionVector = [Double]
protocol Dimensional {
var dimensions: DimensionVector { get } //Could make an Interpolable protocol to use instead of Double, but that would be a confusing design pattern in the case of Ints
static func itemFromDimensions(fromDimensions: DimensionVector) -> Self?
}
func inBetween(a: Double, b: Double, byRatio ratio: Double) -> Double {
let diff = abs(a - b)
let calcd = ratio * diff

Keybase proof

I hereby claim:

  • I am rsmoz on github.
  • I am rsmoz (https://keybase.io/rsmoz) on keybase.
  • I have a public key whose fingerprint is 5F5F A7F5 1983 173D 1443 0D9A 163B F889 4BE5 7328

To claim this, I am signing this object:

@rsmoz
rsmoz / dannyBoy
Created May 3, 2013 02:38
64 random chars and on SOH
print 64*"e" + chr(1)
@rsmoz
rsmoz / README.md
Created August 22, 2012 05:35
Using Python smtp with Gmail to send email