Skip to content

Instantly share code, notes, and snippets.

View rcoh's full-sized avatar

Russell Cohen rcoh

View GitHub Profile
.....
File "./filepicker/client/url_client.py", line 102, in get_file_info_response
url = urls_lib.sanitize_url(url, strict=True)
File "./filepicker/urls_lib.py", line 50, in sanitize_url
error()
File "./filepicker/urls_lib.py", line 38, in error
raise exceptions_lib.FilepickerException("Invalid Url", 400)
TypeError: 'AuthException' object is not callable
@rcoh
rcoh / main.py
Last active December 15, 2015 05:19
How to Hang Yourself With Exceptions
import other
def thrower():
raise other.Exp1
def catcher():
try:
thrower()
except other.Exp1, other.Exp2:
pass
@rcoh
rcoh / scala-patterns.scala
Last active September 13, 2018 12:59
Scala patterns for compiler construction
// Useful Scala Patterns for Compiler Design
// 1. Case Classes
// [For full details, see Programming in Scala 2ed, page 310]
// Case classes are syntactic sugar around normal Scala classes. They come prebaked with the following properties:
// * Factory constructor (don't need new) :
case class Foo(bar: String)
@rcoh
rcoh / sshupdate.py
Created February 3, 2013 22:57
Automatically update your SSH config to allow ssh-ing into EC2 instances by their name. Works on Linux and Mac OS X.
import os
import subprocess
import boto.ec2
import itertools
AWS_KEY = os.getenv('AWS_ACCESS_KEY')
AWS_SECRET = os.getenv('AWS_SECRET_KEY')
# Tweak as necessary for your infrastructure
regions = ['us-east-1', 'us-west-1', 'eu-west-1']
logs.view.map(_.takeWhile(_ != ' ')).grouped(8).count(_.contains("ERROR"))
logs.view.map(_.takeWhile(_ != ' ')).grouped(8).count(_.contains("ERROR"))
@rcoh
rcoh / funcexample.scala
Created July 20, 2012 22:21
functional example
(1 to 10) map (_ + 5) map (_ * 2)
@rcoh
rcoh / count2.scala
Created July 20, 2012 21:44
count java style
var x = 1
var num = 0
while(x < 1000) {
if(x % 10 == 0) { num += 1 }
x += 1
}
@rcoh
rcoh / count.scala
Created July 20, 2012 21:43
Scala count
(1 until 1000).count(_ % 10 == 0)
@rcoh
rcoh / gist:3153431
Created July 20, 2012 21:41
Scala for loop
var x = 0L
for(i <- 0 to 10000; j <- 0 to 1000; k <- 0 to 1000) {
x += 1
}