Skip to content

Instantly share code, notes, and snippets.

🤔

Dan Douglas ormaaj

🤔
Block or report user

Report or block ormaaj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:eaffc3cf8d24fea8d0748ddf67133b46
Verifying my Blockstack ID is secured with the address 1JGNdApmYocuG1HTmDdhvhSQ78UizP4R3Z https://explorer.blockstack.org/address/1JGNdApmYocuG1HTmDdhvhSQ78UizP4R3Z
View gist:245417388175ad07fff5c7bdff0dea7a
unset -v aliasRestore
if ${BASH_VERSION+\:} false; then
shopt -s extglob lastpipe
if shopt -q expand_aliases; then
shopt -u expand_aliases
aliasRestore='shopt -s expand_aliases; unset -v aliasRestore'
fi
else
aliasRestore="$(alias) ; unset -v aliasRestore"
unalias -a
View aliascounter.sh
{ time dash /dev/fd/9; } 9<<\EOF
#set -x
n=0 max=2000
case $(command -v let) in let) ;; *) let() { while ${2+\:} return "$((! ( ${1:-0} )))"; do shift; done; }; esac
case $(command -v printf) in printf) ;; *) alias printf="echo -n "; esac
alias \
@eval=eval @eval2='eval ' \
@alias=alias @alias2='alias ' \
@echo='echo ' @printf='printf ';
View gist:27d8d7c548cd8839b6b549318e014e57
~ $ bash -x /dev/fd/9 9<<\EOF
FUNCNEST=5
# alias eval='eval ' function='function ' .fn='f { a+=( a.{0..9} ); }'
function f {
if [[ $1 ]]; then
typeset key
for key; do alias "a.${key}=$((n++))foo"; done
f
else
function f { a+=( a.{0..9} ); }
View gist:6dc167dce4f931f4866f4b87118200f0
function introspect {
if [[ ${FUNCNAME[0]} != "${FUNCNAME[1]}" ]]; then
typeset ret
if ! shopt -qo pipefail; then shopt -so pipefail; ret+='shopt -uo pipefail; '; fi
if shopt -qo monitor; then shopt -uo monitor; ret+='shopt -so monitor; '; fi
if ! shopt -q lastpipe; then shopt -s lastpipe; ret+='shopt -u lastpipe; '; fi
eval "\\${FUNCNAME[0]} \"\$@\"; ${ret}"
fi
unset -v ret
View gist:fbde9e2c0a22d0bfadb52055631e39a0
class Program {
static void Main(string[] args) {
var dict = new ConcurrentDictionary<string, ConcurrentBag<string>>();
Directory.GetFiles("/home/ormaaj/doc/text/ebooks/programming/unsorted")
.AsParallel()
.ForAll(x => dict.AddOrUpdate(
BitConverter.ToString(SHA256.Create().ComputeHash(File.OpenRead(x))),
new ConcurrentBag<string>() { x },
(y, z) => { z.Add(y); return z; }));
}
View functions
...
function getEnv {
${1:+\:} return 1
typeset -n name ret=$1
typeset -a names
compgen -e | mapfile -t names
set -- "${names[@]}"
for name; do
ret[${!name}]=$name
done
View gist:728defd43fe577bc94fc
~ $ mksh /dev/fd/3 3<<EOF
\${BASH_VERSION+shopt -s expand_aliases}
alias slow-ass-loop='for x in $(printf '%s ' {1..1000000}); do :; done'
foo1() { for x in {1..1000000}; do :; done; }
foo2() { slow-ass-loop; }
unalias -a
time foo1; time foo2
EOF
0m0.01s real 0m0.01s user 0m0.00s system
View gist:75784c8ac3ac48d3310a
function yt {
typeset vid file x
if ! vid=$(xsel -o); then
{
echo 'xsel failed'
typeset -p DISPLAY
} >&2
return 1
elif ! file=$(youtube-dl --get-filename -- "$vid"); then
echo 'Could not resolve file name from URL.' >&2
View magictest.sh
#!/bin/bash
shopt -s expand_aliases extglob
alias \[='x=${BASH_COMMAND#"${BASH_ALIASES[\[]} "} command eval eval \"[[ \$x]\" \#'
set -x
[ ormaaj == or+([ma])j ]
echo "$?"
You can’t perform that action at this time.