Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
"I'm in"

Jessica Kerr jessitron

🚀
"I'm in"
View GitHub Profile
@jessitron
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 http://rest.codemash.org/api/speakers > speakers.xml
val speakers = xml.XML.loadFile("codemashSpeakers.xml") \ "Speaker"
// curl http://rest.codemash.org/api/sessions > 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) =
View CarrotPotato.elm
module CarrotPotato where
import StartApp
import Task exposing (Task)
import Signal exposing (Signal, Address)
import Effects exposing (Effects, Never)
import Html exposing (Html)
--
-- StartApp boilerplate
@jessitron
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 blog.jessitron.com.
View transformers
// from https://github.com/jessitron/BlogCode/blob/master/optionAsFlow.scala
object transformers {
def openFile(n: String) : Option[java.io.File] = {
val f = new java.io.File(n) // catch IOException
if (f.exists)
Some(f)
else
None
@jessitron
jessitron / gist:4526987
Created Jan 14, 2013
The transformers now return a Result, with more detail on failure than an Option holds. See blog.jessitron.com for the purpose of this post.
View gist:4526987
// from https://github.com/jessitron/BlogCode/blob/master/optionToCustom.scala
object transformers {
def openFile(n: String) : Result[java.io.File] = {
val f = new java.io.File(n) // catch IOException
if (f.exists)
Success(f)
else
Failure("File does not exist: " + n)
@jessitron
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
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 blog.jessitron.com, 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")
View jquery-plugins.md

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
jessitron / Properties.elm
Created Apr 17, 2016
An Elm program using elm-check that is compatible with elm-test (the Node module)
View Properties.elm
module Main (..) where
import ElmTest
import Check exposing (Evidence, Claim, that, is, for)
import Check.Test
import Check.Producer as Producer
import List
import Signal exposing (Signal)
import Console exposing (IO)
import Task
@jessitron
jessitron / Condensed Letter to a Haskellyte
Last active Jan 31, 2017
Gershom's Letter to a Young Haskell Enthusiast, summarized. I removed a lot of words, kept the themes, moved a few around a bit.
View Condensed Letter to a Haskellyte
# Letter to a Young Haskell Enthusiast, by Gershom Bazerman.
Condensed from: http://comonad.com/reader/2014/letter-to-a-young-haskell-enthusiast/
The following letter is about tendencies that come with the flush of excitement of learning any new thing.
It is written specifically, because if we don't talk specifics, the generalities make no sense.
It is a letter full of things I want to remember.
You’ve entered the world of strongly typed functional programming, and it is great.
You want to share the great things you’ve learned, and you want to slay all the false statements in the world.
You can’t perform that action at this time.