Skip to content

Instantly share code, notes, and snippets.

@LeastFixedPoint
LeastFixedPoint / dirtyfox
Last active May 31, 2024 19:51
Facebook event IDs
1996998310348137
public static final Creator<${enclosing_type}> CREATOR = new Creator<${enclosing_type}>() {
@Override
public ${enclosing_type} createFromParcel(Parcel source) {
return new ${enclosing_type}();
}
@Override
public ${enclosing_type}[] newArray(int size) {
return new ${enclosing_type}[size];
}
import Control.Monad (foldM)
split s = let prefix = takeWhile (/= ' ') s in (prefix, drop (1 + length prefix) s)
main = do
nm <- getLine
let (sn, sm) = split nm
let (n, m) = (read sn, read sm)
let step songs index = do
line <- getLine
function spy() {
PID=`[ $# == 0 ] && jobs -p | tail -1 || echo $$`
touch /tmp/spy.$PID
[ $# -eq 0 ] && fg || "${@}"
rm /tmp/spy.$PID
}
Usage:
$ spy long-running-operation
or
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Layout.LayoutModifier
import qualified XMonad.StackSet as W
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks (avoidStruts, manageDocks)
import XMonad.Actions.PhysicalScreens
import XMonad.Util.Run (spawnPipe)
@LeastFixedPoint
LeastFixedPoint / treeify.awk
Created December 12, 2012 18:56
Composable beautifier of lists of paths. Usage (e.g.): git diff HEAD^ --stat | treeify.awk
#!/usr/bin/awk -f
BEGIN { FS = ""; prev = "" }
{
prefix = ""; n = 1
while ((n <= NF) && ($n == substr(prev, n, 1))) {
if ($n == "/") { prefix = substr($0, 1, n) }
n++
}
let rec hcf a b =
if a = 0u then b
elif a<b then hcf a (b - a)
else hcf (a - b) b
type Fraction =
{ n : uint32; d : uint32 }
override this.ToString() =
if (this.d = 1u)
for (String x = "Blah"; x != null; x = null) {
System.out.println("OMG");
}
0: ldc #19 // String Blah
2: astore_1
3: goto 16
6: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;
9: ldc #27 // String OMG
(defmacro chain-rebind [var-name init-value & cmds]
(let [init-binding `(~'temp ~init-value)
cmd-to-binding (fn [cmd] `(~'temp (binding [~var-name ~'temp] ~cmd)))
cmd-bindings (map cmd-to-binding cmds)
bindings-list (cons init-binding cmd-bindings)
bindings (apply concat bindings-list)]
`(let ~(vec bindings) ~'temp)))
Usage:
// Original
void indexOf(int[] haystack, int needle) {
for (int i = 0; i < haystack.length; i++) {
if (haystack[i] == needle) {
return i;
}
}
return -1;
}