Skip to content

Instantly share code, notes, and snippets.

View joshuaclayton's full-sized avatar

Josh Clayton joshuaclayton

View GitHub Profile
-- ghc -O --make BenchStringToInt.hs && ./BenchStringToInt --output bench_string_to_int.html&& open bench_string_to_int.html
import Criterion.Main
import Data.Maybe (fromMaybe)
import Text.Parsec (parse)
import Text.Parsec.Token (makeTokenParser, integer)
import Text.Parsec.Language (haskellStyle)
import Data.Char (digitToInt, isDigit)
main = defaultMain [
module Time.DateConversions
(
T.Day
-- current day from system
, today
-- average
, averageDaysBetween
-- beginning of period

This is a rough draft (which works!) handling file composition for vim-projectionist.

Each of the *.json files live in ~/.projections, and projections lives somewhere in your $PATH. This uses jq to combine multiple JSON files into one. With navigation.zsh, we hook into cding into a directory, run projections, and if there's a 0 exit code, overwrite the output to .projections.json, which vim-projectionist then uses.

I've updated my ~/.gitignore to ignore .projections.json, so I'm not concerned about things messing up git.

@joshuaclayton
joshuaclayton / 0_reuse_code.js
Created September 22, 2015 14:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
-- ghc -O --make BenchGroupBy.hs && ./BenchGroupBy --output bench_group.html&& open bench_group.html
import Criterion.Main
import Control.Arrow ((&&&))
import qualified Data.List as L
import Data.Function
main = defaultMain [
bgroup "group" [ bench "old" $ nf oldGroupBy numbers
, bench "new" $ nf newGroupBy numbers
]
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z_.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z_.]+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z_.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z_.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z_.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z_.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z_.]+):[^->\n]*$/\1/f,field/
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
@joshuaclayton
joshuaclayton / git-track
Created December 10, 2008 20:30 — forked from sstephenson/git-track
Auto-tracking of git branches
#!/bin/sh
branch=$(git branch 2>/dev/null | grep ^\*)
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}
git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking
echo "tracking origin/$tracking"
#!/bin/sh
branch=$(git branch 2>/dev/null | grep ^\*)
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}
git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking
echo "tracking origin/$tracking"
Webrat.configure do |config|
config.mode = :selenium
end
class Cucumber::Rails::World
def wait_for_ajax(timeout = 15000)
selenium.wait_for_condition "window.Ajax.activeRequestCount == 0", timeout
end
def wait_for_effects(timeout = 15000)