Skip to content

Instantly share code, notes, and snippets.

@taylorleese
taylorleese / keybase.io - ttl
Created February 9, 2017 18:46
keybase.io - ttl
### Keybase proof
I hereby claim:
* I am taylorleese on github.
* I am ttl (https://keybase.io/ttl) on keybase.
* I have a public key ASD9ZjKFWnDqwlCkmbTpScLYBAB2NutroUiIyNoRQcMnHgo
To claim this, I am signing this object:
@taylorleese
taylorleese / migrate.gemset.default.log
Created July 7, 2014 16:40
Error migrating gems.
This file has been truncated, but you can view the full file.
[2014-07-07 01:47:51] __migrate_gemset
__migrate_gemset ()
{
\mkdir -p "${rvm_gems_path:-"$rvm_path/gems"}/$2"/ && \rm -rfv "${rvm_gems_path:-"$rvm_path/gems"}/$2"/* && \cp -rv "${rvm_gems_path:-"$rvm_path/gems"}/$1"/* "${rvm_gems_path:-"$rvm_path/gems"}/$2"/ && gemset_reset_env "$2"
}
current path: /Users/taylor/code/askdavinci/puppet
GEM_HOME=/Users/taylor/.rvm/gems/ruby-1.9.3-p194
PATH=/Users/taylor/.rvm/gems/ruby-1.9.3-p194/bin:/Users/taylor/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/taylor/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/taylor/.rvm/bin:/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/taylor/bin
GEM_PATH=/Users/taylor/.rvm/gems/ruby-1.9.3-p194:/Users/taylor/.rvm/gems/ruby-1.9.3-p194@global
command(3): __migrate_gemset ruby-1.9.3-p194 ruby-1.9.3-p547
@taylorleese
taylorleese / gist:2958236
Created June 20, 2012 05:09
squeryl_exception
object TestSchema extends Schema {
val applicationsTable = table[Application]("applications")
val clientsTable = table[Client]("clients")
val proxyConfigsTable = table[ProxyConfig]("proxy_configs")
val clientWithApplications = oneToManyRelation(clientsTable, applicationsTable).via((c, a) => c.id === a.clientId)
val applicationWithProxyConfigs = oneToManyRelation(applicationsTable, proxyConfigsTable).via((a, h) => a.id === h.appId)
on(applicationsTable)(t => declare(
@taylorleese
taylorleese / gist:2870739
Created June 4, 2012 20:39
Airbrake Example Actor Usage
def notifyAsync(notice: AirbrakeNotice) {
submitAsync(() => notify(prepareRequest(notice)).unsafePerformIO)
}
def submitAsync(f: () => Validation[Throwable, Int]) {
getRandomActor(f)
}
def getRandomActor: Actor[() => Validation[Throwable, Int]] = {
actorList(random.nextInt(actorList.length))
@taylorleese
taylorleese / gist:2870730
Created June 4, 2012 20:37
Airbrake Example Actor Setup
val actorList = Vector.fill(actorPoolSize)(airbrakeActor)
def airbrakeActor: Actor[() => Validation[Throwable, Int]] = {
actor(doNotify)
}
def doNotify(f: () => Validation[Throwable, Int]) {
f()
}
@taylorleese
taylorleese / gist:2870713
Created June 4, 2012 20:35
Airbrake Example IO
def notifySync(notice: AirbrakeNotice): Validation[Throwable, Int] = {
notify(prepareRequest(notice)).unsafePerformIO
}
def notify(xml: NodeSeq): IO[Validation[Throwable, Int]] = {
sendNotification(xml).map(_.success[Throwable]).except(_.fail[Int].pure[IO])
}
def sendNotification(xml: NodeSeq): IO[Int] = io {
. . .
@taylorleese
taylorleese / pom.xml
Created January 20, 2012 09:08
Example POM - StackMob Custom Code SDK
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourdomain</groupId>
<artifactId>yourdomain</artifactId>
<packaging>jar</packaging>
<name>YourName</name>
@taylorleese
taylorleese / LoggingSugar.scala
Created November 17, 2011 07:54
Cleaner Logging
package sugar
import org.slf4j.{Logger, LoggerFactory}
trait LoggingSugar {
/**
* This is just a convenience method so you can type:
*
* getLogger[Foo]
@taylorleese
taylorleese / FizzBuzz.scala
Created March 19, 2011 23:51
Scala FizzBuzz.
object FizzBuzz {
def main(args: Array[String]) {
for (i <- 1 to 100) {
(i % 3, i % 5) match {
case (0, 0) => println("FizzBuzz")
case (0, _) => println("Fizz")
case (_, 0) => println("Buzz")
case _ => println(i)
}
}
@taylorleese
taylorleese / Spiral.java
Created March 19, 2011 08:14
Print matrix in spiral order.
public class Spiral {
public static void main(String[] args) {
int row = Integer.parseInt(args[0]);
int col = Integer.parseInt(args[1]);
int[][] matrix = new int[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
matrix[i][j] = i * col + j + 1;