Skip to content

Instantly share code, notes, and snippets.

@sudodoki
sudodoki / flatten-maps.clj
Last active November 29, 2023 00:26
Flatten nested maps using clojure / clojurescript using compound keys
(defn get-key
[prefix key]
(if (nil? prefix)
key
(str prefix "-" key)))
(defn flatten-map-kvs
([map] (flatten-map-kvs map nil))
([map prefix]
(reduce
(fn [memo [k v]]
@itod
itod / split_keyboards.md
Last active April 28, 2024 19:44
Every "split" mechanical keyboard currently being sold that I know of
#!/usr/bin/perl
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
#
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
#
# 10 May 2008
# Original version by John Gruber:
@jeremyheiler
jeremyheiler / with-system-out-str.clj
Last active March 13, 2019 16:50
Hijacking System.out with Clojure
(defmacro with-system-out-str
[& body]
`(let [out# System/out
buf# (java.io.ByteArrayOutputStream.)
prs# (java.io.PrintStream. buf#)
wtr# (java.io.OutputStreamWriter. prs#)]
(try
(System/setOut prs#)
(binding [*out* wtr#]
(do ~@body))
@aktau
aktau / imessage
Last active June 11, 2023 20:30
Send iMessage from the commandline
#!/bin/sh
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit
-- another way of waiting until an app is running
on waitUntilRunning(appname, delaytime)
repeat until my appIsRunning(appname)
tell application "Messages" to close window 1
delay delaytime
end repeat
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@miketheman
miketheman / zook_grow.md
Created July 22, 2013 21:36
Adding nodes to a ZooKeeper ensemble

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

@vasilisvg
vasilisvg / HTML-presentation-tools.md
Created January 14, 2012 13:53
HTML presentation tools

#HTML presentation tools

There are many HTML presentation tools and they are all created for slightly different reasons. Here's an overview. Please let me know if I forgot any.

##CSSS

CSS-based SlideShow System

@Folcon
Folcon / clipboard-utils.clj
Created August 24, 2011 11:50
Just a quick clipboard slip/slurp I put together because I didn't find anything similar, don't know if it's useful for anyone but found it invaluable when getting large strings being returned from the repl and sticking the result in an editor for more car
(defn get-clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp-clipboard []
(try
(.getTransferData (.getContents (get-clipboard) nil) (java.awt.datatransfer.DataFlavor/stringFlavor))
(catch java.lang.NullPointerException e nil)))
(defn spit-clipboard [text]
(.setContents (get-clipboard) (java.awt.datatransfer.StringSelection. text) nil))