Skip to content

Instantly share code, notes, and snippets.

View jessitron's full-sized avatar
🚀
"I'm in"

Jessica Kerr jessitron

🚀
"I'm in"
View GitHub Profile
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 January 14, 2013 00:06
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.
// 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 January 14, 2013 00:22
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.
// 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 March 10, 2013 17:45
Ruby: Hash.each treats blocks and lambdas differently when the arity is 2
#
# 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!
#
@jessitron
jessitron / gem_cleaner.rb
Last active December 17, 2015 05:09 — forked from kgrz/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 June 15, 2013 17:58
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!"
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
jessitron / Properties.elm
Created April 17, 2016 00:04
An Elm program using elm-check that is compatible with elm-test (the Node module)
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 January 31, 2017 06:24
Gershom's Letter to a Young Haskell Enthusiast, summarized. I removed a lot of words, kept the themes, moved a few around a bit.
# 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.
function readConfig(): Promise<DeletionCriteria> {
return promisify(fs.readFile)("config/deletionCriteria.json", { encoding: "utf8" })
.then(configFileContent =>
JSON.parse(configFileContent));
}