Skip to content

Instantly share code, notes, and snippets.

View bsima's full-sized avatar
drinking coffee

Ben Sima bsima

drinking coffee
View GitHub Profile
@alandipert
alandipert / index.cljs.hl
Last active May 1, 2017 16:32
Hash fragment routing in Hoplon with core.match
(page "index.html"
(:require-macros [cljs.core.match.macros :refer [match]])
(:require [cljs.core.match]
[tailrecursion.hoplon.reload :refer [reload-all]])
(:refer-clojure :exclude [hash]))
(reload-all 1000)
(defn route [parts]
(match [parts]
@alandipert
alandipert / method.rb
Created September 1, 2014 14:55
unary ~ on Symbol for a Lisp-2 feel
class Symbol
def ~@
method(self)
end
end
def inc(n)
n + 1
end
@andyfriesen
andyfriesen / TestableIO.hs
Last active August 10, 2021 18:25
Tiny example showing how to force your Haskell code to be 100% deterministic under unit tests
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Control.Applicative ((<$>))
import Control.Monad.State.Lazy as S
class Monad m => World m where
writeLine :: String -> m ()
instance World IO where
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@tiberiucorbu
tiberiucorbu / Gemfile
Last active September 15, 2021 15:24
Middleman - Markdown from text or url
# If you have OpenSSL installed, we recommend updating
# the following line to use "https"
source 'http://rubygems.org'
gem "middleman", "~>3.2.2"
gem 'redcarpet'
# Live-reloading plugin
gem "middleman-livereload", "~> 3.1.0"
@wrburgess
wrburgess / mailchimp.haml
Created February 17, 2014 05:29
Mailchimp Embedded Email Form in Haml
%form.form-inline#mc-embedded-subscribe-form{ action: "[sign_up_url]", method: "post", name: "mc-embedded-subscribe-form", novalidate: "", target: "_blank"}
%input#mce-EMAIL.required.email{ name: "EMAIL", type: "email", value: "", placeholder: "email"}/
%div{ style: "position: absolute; left: -5000px;" }
%input{ type: "text", name: "[hex_code]", value:"" }
%input#mc-embedded-subscribe{name: "subscribe", type: "submit", value: "Subscribe" }/
anonymous
anonymous / emacs.memory.leak.aka.distnoted.patch.diff
Created January 22, 2014 03:45
This is a patch (with commentary) that fixes a memory leak in 24.3 for OSX Mavericks (10.9) users who experience excessive resource consumption by distnoted.
From 8ab91751069e391a95151c6716a546b1732ade92 Mon Sep 17 00:00:00 2001
From: JP <twitter:canoeberry>
Date: Sun, 19 Jan 2014 11:58:54 +0000
Subject: [PATCH] partial memleak fix
This patch was created by JP (twitter: @canoeberry) based on a memleak fix by Dirk (emacs committer) below:
https://github.com/mirrors/emacs/commit/57ae6509a3b6a274f89b9caea0284c6156470625
This memory leak is fixed in the trunk as of now and will be in the next official release: 24.4.
@bsima
bsima / clojure-resources.md
Last active October 25, 2016 15:35
As I'm learning Clojure, I'm finding all kinds of awesome resources for learning, tools for building and testing, etc. Here's what I'm finding.

For most of the tools on here, if you follow the GitHub repos back to the user that owns the repo, they usually have other cool Clojure tools they build. Just a general observation about the Clojure community.

Learnings

  • Clojure home - There's a ton of good stuff here, like the rationale behind the design and explanations of the best features of Clojure.
  • Clojure.github.io - The core Clojure documentation. Useful for looking up functions and such.
  • Clojuredoc - Community written Clojure documentation and articles
  • Clojure Koans - Learn Clojure with Koans
  • 4Clojure - Solve simple problems to stretch your Clojure skills
@dannypurcell
dannypurcell / trailing-slash-middleware
Created January 2, 2014 05:30
Ring middleware fn. Removes a trailing slash from the uri before calling the handler.
(defn ignore-trailing-slash
"Modifies the request uri before calling the handler.
Removes a single trailing slash from the end of the uri if present.
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex.
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash"
[handler]
(fn [request]
(let [uri (:uri request)]
(handler (assoc request :uri (if (and (not (= "/" uri))
@zbrdge
zbrdge / customize_s.sh
Last active May 6, 2016 21:00
Shell script I wrote to customize Automattic/_s after pulling from the repo (simple find and replace).
#!/bin/bash
# Five step search and replace with find, sed, and bash (tested on OS X, should work with Linux)
# check usage and parse command line arguments
OPTIND=1
while getopts "n:m:" opt; do
case "$opt" in
n)
human=$OPTARG