Skip to content

Instantly share code, notes, and snippets.

@dandorman
dandorman / if-modified-since-test.sh
Created December 31, 2019 22:34
A simple test script for a web server's If-Modified-Since behavior
#!/bin/bash
set -e
echo "Setting last_mod to before foo is created..."
last_mod=$(date -u +"%a, %d %b %Y %H:%M:%S GMT")
sleep 2
touch foo
function rm_foo {
@dandorman
dandorman / deps.edn
Last active March 5, 2019 15:56
clj -Sdeps '{:deps {hash-algo {:git/url "https://gist.github.com/dandorman/e1698fbe259c3fb706a6dda64cacfa6d" :sha "1fecec9e37629cefd6e826f724c821d550e3720e"}}}' -m hash-algo
{:paths ["."]
:deps {metasoarous/oz {:mvn/version "1.5.6"}}}
{:paths ["."]}

Keybase proof

I hereby claim:

  • I am dandorman on github.
  • I am dandorman (https://keybase.io/dandorman) on keybase.
  • I have a public key ASD7AYlqEB-6ty7h79xKGLDMRKAeee586Fqhi7EPOZr7YAo

To claim this, I am signing this object:

@dandorman
dandorman / reverse-vowels.cljs
Created August 18, 2017 19:01
A little Clojure(Script) solution for a weird little problem.
#!/usr/bin/env planck
(def vowel? #{\A \a \E \e \I \i \O \o \U \u})
(defn reverse-vowels
"Takes in a string and reverses all the vowels in the string."
[in]
(let [idx->letter (zipmap (range) in)
idx->vowel (filter (fn [[_ letter]] (vowel? letter)) idx->letter)
[idxes vowels] ((juxt keys vals) idx->vowel)
@dandorman
dandorman / clj.rb
Created August 8, 2017 15:33
A Ruby script for connecting to a Clojure socket REPL
#!/usr/bin/env ruby
# Start up a Clojure process with a socket REPL:
# java -Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}" -cp clojure.jar clojure.main
require "socket"
s = TCPSocket.new "localhost", 5555
Thread.new do
// Write a function that returns the "leaves" of a nested map like the one below.
// You may assume values are either numbers, or another map.
{
a: 1,
b: {
c: 2,
d: {
e: 3,
f: 4
@dandorman
dandorman / pairs.rb
Created May 20, 2015 04:38
A Ruby regular expression for matching pairs of braces
braces = /\A([^(){}\[\]<>]*)(\((\g<1>\g<2>*\g<1>)\)|\{\g<3>\}|\[\g<3>\]|<\g<3>>)*\g<1>\z/
@dandorman
dandorman / SassMeister-input.scss
Created April 16, 2015 15:42
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
.btn {
font-weight: bold;
&:focus {
font-style: italic;
}
@dandorman
dandorman / map_into.rb
Created March 13, 2015 23:27
A fun li'l Ruby experiment.
module Enumerable
def map_into(callable, *args)
map { |value|
value, args = yield(value, *args) if block_given?
callable.call value, *args
}
end
end
require "uri"