This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1996998310348137 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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++ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original | |
void indexOf(int[] haystack, int needle) { | |
for (int i = 0; i < haystack.length; i++) { | |
if (haystack[i] == needle) { | |
return i; | |
} | |
} | |
return -1; | |
} |
NewerOlder