Skip to content

Instantly share code, notes, and snippets.

"I'm in"

Jessica Kerr jessitron

"I'm in"
View GitHub Profile
jessitron / speakerStats.scala
Created Oct 18, 2012
Play with the CodeMash API to analyze gender distribution of speakers
View speakerStats.scala
import scala.xml._
// curl > speakers.xml
val speakers = xml.XML.loadFile("codemashSpeakers.xml") \ "Speaker"
// curl > sessions.xml
val sessions = xml.XML.loadFile("sessions.xml") \ "Session"
val masculineWords = List("he","his")
val feminineWords = List("she","her","hers","lady")
def bioContainsAnyWord( strings : Seq[String], speakerNode : Node) =
jessitron / transformers
Created Jan 14, 2013
These methods perform transformations on their input. They'll be tied together in different ways separately. Look for the blog post at
View transformers
// from
object transformers {
def openFile(n: String) : Option[] = {
val f = new // catch IOException
if (f.exists)
jessitron / gist:4526987
Created Jan 14, 2013
The transformers now return a Result, with more detail on failure than an Option holds. See for the purpose of this post.
View gist:4526987
// from
object transformers {
def openFile(n: String) : Result[] = {
val f = new // catch IOException
if (f.exists)
Failure("File does not exist: " + n)
jessitron / gist:5129618
Created Mar 10, 2013
Ruby: Hash.each treats blocks and lambdas differently when the arity is 2
View gist:5129618
# Ruby 2.0 hashes: they treat lambdas inconsistently from blocks.
# Pass in a block straight-up, and each (or each_pair) looks at the arity of the block.
# A block that accepts one argument gets an array of two elements, key and value.
# A block that accepts two arguments gets the key and value separately. How nice.
# But, if you pass in a lambda as a block, you always get just one argument.
# No key-value separation for you!
View gem_cleaner.rb
require 'bundler'
# Required for Bundler::LockfileParser. This can be empty though.
`touch Gemfile` unless File.exists?("Gemfile")
# Add the paths to the Gemfile.lock files, the gems in which
# need to be protected
jessitron / ExplicitErrorReturning
Created Jun 15, 2013
This is in response to a giant twitter thread. Thanks to @CraigBuchek, @brianbuttonxp, @adkron, @heathborders, and @marioaquino for the discussion. Post is at, titled "What's dirtier than comments? Exceptions!"
View ExplicitErrorReturning
case class Error(message:String)
case class AuthLevel(value: Int)
object AuthLevel {
val GUEST = AuthLevel(0)
class SettingGetter {
def get_setting(settingName: String): Either[Error, String] = Right("Fred")

Writing jQuery Plugins for Fun and (non)Profit

We all love jQuery - it's easy, efficient, and there's tons of information online. But with that mass of information comes confusion: When you want to abstract some of your code into a plugin, how do you structure it? How do you take in options, and how can you be sure you haven't broken the way jQuery works? And when you're done, where do you put it and how do distribute it to the masses?

This talk will run through some of the basics and guide you in the right direction. In particular, we'll cover:

  • structuring your plugin code
  • making your code testable - and testing it!
  • tracking your code on github
  • getting your plugin on the jQuery site
jessitron / gist:8376139
Created Jan 11, 2014
scala: print all URLs on classpath
View gist:8376139
def urlses(cl: ClassLoader): Array[] = cl match {
case null => Array()
case u: => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
val urls = urlses(getClass.getClassLoader)
jessitron / gist:8777503
Created Feb 3, 2014
The magic of blocking { ... } in Scala's global ExecutionContext: it leads to the creation of more threads, so the CPUs don't get bored
View gist:8777503
val des =
import scala.concurrent._
import duration._
def ct = Thread.currentThread.getName
val n = Runtime.getRuntime.availableProcessors
def hogThread(sec:Int) = future {
jessitron / gist:9191499
Created Feb 24, 2014
StackOverflow in scalaz-stream. My trampoline is not bouncy enough
View gist:9191499
import Process._
import scalaz.concurrent.Task
import scala.concurrent.duration._
// git bisect identifies the offending commit as
object Test {