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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Program { | |
public class NodeThing<T> { | |
public T Value; | |
public NodeThing() { } |
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/env bash | |
{ code=$(</dev/fd/0); } <<\EOF | |
${ZSH_VERSION+false} || emulate ksh | |
# eval showEnv (funcname) to display the state of "x" from a subprocess. | |
showEnv=$'bash -c \'${x+:} typeset x=unset; printf "subprocess %s: %s\\n" "$1" "$(typeset -p x)"\' --' | |
function printTest { | |
printf '%s test %d:\n' "$1" $((testnum++)) >&2 |
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/env bash | |
# bash / ksh93 / mksh / zsh | |
# Don't do this! | |
${ZSH_VERSION+false} || emulate ksh | |
unset -v isKsh93 | |
[[ ${!KSH_VERSION} == .sh.version ]] && isKsh93= | |
# Reads lines from file or stdin into arrayName, stupidly. | |
# evilReadLines arrayName [ file ] |
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/env ksh | |
# Example for merging directories of files with possibly | |
# overlapping names into a single directory. | |
mkdir a b c new | |
touch a/{0..5} b/{3..7} c/{4..10} | |
echo before: */* | |
typeset -A files | |
for x in ~(N)./*/*; do |
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
bash -xO expand_aliases <<\EOF | |
alias magic='x=${BASH_COMMAND#"${BASH_ALIASES[magic]} "} command eval cmd=\$x \#' | |
magic oh hi there | |
printf 'The command that would have evaluated is: "%s"\n' "$cmd" | |
EOF |
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 T Clamp<T>(this T value, T min, T max, IComparer<T> comparer = null) { | |
if (comparer.Equals(null)) | |
comparer = Comparer<T>.Default; | |
if (comparer.Compare(value, min) <= 0) { | |
return min; | |
} else if (comparer.Compare(value, max) >= 0) { | |
return max; | |
} else { | |
return value; |
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
foo=666 | |
{ eval "$(</dev/fd/4)"; } 3<<EOF1 4<<EOF2 | |
var=$(printf %q "$foo") | |
EOF1 | |
$(</dev/fd/3) | |
echo "$var" | |
EOF2 |
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
_jshon() { | |
shopt -s lastpipe | |
{ tee /dev/fd/3 | jshon "$@" >&4; } 3>&1 | | |
input=$(</dev/fd/0) | |
((PIPESTATUS)) || echo "$input" | |
} 4>&1 |
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
_jshon() { | |
shopt -s lastpipe | |
typeset input status | |
{ tee /dev/fd/3 | jshon "$@" >&4; } 3>&1 | |
input=$(</dev/fd/0) | |
((PIPESTATUS[0])) && printf %s "$input" >&2 | |
return "${PIPESTATUS[0]}" | |
} 4>&1 |
OlderNewer