Skip to content

Instantly share code, notes, and snippets.

View tie-rack's full-sized avatar

Christopher Shea tie-rack

View GitHub Profile
(ns collection-predicates)
(defmacro report
"A macro that takes Clojure code then prints the code and its results."
[title & forms]
(concat
`(do
(printf "=== %s ===\n" ~title))
(map (fn [form]
(if (= 'skip (first form))
@tie-rack
tie-rack / oulipo-pal.js
Last active April 15, 2017 23:04
oulipo.social pal
// ==UserScript==
// @name oulipo.social pal
// @namespace http://kilosecond.com/
// @version 0.1
// @description Warn when you try to input a wrong thing
// @author ghosss
// @match https://oulipo.social/*
// @grant none
// ==/UserScript==

Keybase proof

I hereby claim:

  • I am tie-rack on github.
  • I am tierack (https://keybase.io/tierack) on keybase.
  • I have a public key whose fingerprint is 27FD D8B6 2705 5CA3 8228 6C8B C1AB 0987 55CD 0198

To claim this, I am signing this object:

@tie-rack
tie-rack / chunk-rows.clj
Last active August 29, 2015 14:15
Potential function for splitting a sequence of maps into groups to feed to a function that has a limit on the total number of keys it can handle in any given sequence of maps (SQLite statement parameter limit). (Naming suggestions welcome!)
(defn chunk-rows
"Given a seq of maps, split them into groups, such that no group
have more than n total keys across its maps."
[rows n]
(lazy-seq
(loop [this-chunk []
this-chunk-size 0
to-go rows]
(if (empty? to-go)
(list this-chunk)
h2:before {
content: "Name: "
}
h3:before {
content: "Status: "
}
h4:before {
content: "Serial number: "
@tie-rack
tie-rack / gi
Created October 3, 2013 20:36
A little script to help out when you misplace a space.
#!/bin/zsh
COMMAND=$1
COMMAND=${COMMAND[2,-1]}
ARGUMENTS=$@[2,-1]
echo "\e[33mYou typed: \e[31mgi $@\e[0m"
echo "\e[33mYou meant: \e[32mgit $COMMAND $ARGUMENTS\e[0m"
echo
(defn example-middleware [handler]
(fn [request]
(let [now (System/currentTimeMillis)
modified-request (assoc-in request [:headers "received-at"] now)
response (handler modified-request)]
(assoc-in response
[:headers "processing-time"]
(- (System/currentTimeMillis) now)))))
@tie-rack
tie-rack / gi.sh
Last active December 14, 2015 13:38
I'm always typing `gi tbranch` when I mean to type `git branch`. So have this in my PATH with the name `gi`.
#!/bin/zsh
COMMAND=$1
COMMAND=${COMMAND[2,-1]}
ARGUMENTS=$@[2,-1]
echo "\e[33mYou typed: \e[31mgi $@\e[0m"
echo "\e[33mYou meant: \e[32mgit $COMMAND $ARGUMENTS\e[0m"
echo
@tie-rack
tie-rack / xkcd.com.js
Created March 28, 2011 19:13
dotjs for adding the title text of XKCD comics on the page (no more tooltip for me!)
var comic = $("div.s img[title]");
var titleP = $("<p></p>");
titleP.css({"font-variant": "normal",
"border": "1px solid yellow",
"padding": "1em",
"background-color": "#FFFFCC"});
titleP.text(comic.attr("title"));
comic.after(titleP);
#!/usr/bin/env ruby
require 'yaml'
begin
YAML.load(STDIN)
puts '<h1 style="color: green;">GOOD</h1>'
rescue Exception => e
puts '<h1 style="color: red;">BAD</h1>'
puts e.message