Skip to content

Instantly share code, notes, and snippets.

View dom111's full-sized avatar
⌨️

Dom Hastings dom111

⌨️
View GitHub Profile
Q="q=Q.link()[8];alert(`Q=${q+Q+q};eval(Q)`)";eval(Q)
// longer alternative:
console.log(a="console.log(a=%s%s%s,q=a.link()[8],a,q)",q=a.link()[8],a,q)
@dom111
dom111 / polyquine.pl.rb.php.js.sh.py
Last active June 9, 2020 08:21
Perl/Ruby/PHP/JavaScript/Bash/Python 2 polyquine
s=1//2;_=r'''<?#/.__id__;s=+0;#';read -d '' q<<'';s=\';Q='echo s=1//2\;_=r$s$s$s\<\?\#/.__id__\;s=+0\;#$s\;read -d $s$s q\<\<$s$s\;s=\\$s\;Q=$s$Q$s\;eval\ \$Q;echo $q';eval $Q
$_='eval("0"?0?"def strtr(s,f,t);s.tr(f,t) end;class String;def chr(n);self+n.chr end;end":"$u=strtr=(s,f,t)=>[...f].reduce((s,a,i)=>s.replace(RegExp(a,`g`),t[i]),s);printf=console.log;(S=String).prototype.chr=function(n){return this+S.fromCharCode(n)}":[]&&"sub strtr{eval q(q(X)=~y/X/X/r)=~s/X/shift/ger}");printf(strtr("%s<?#/.__id__;s=+0;#j;read -d jj q<<jj;s=zj;Q=jecho s=1//2z;_=rksksksz<z?z#/.__id__z;s=+0z;#ksz;read -d ksks qz<z<ksksz;s=zzksz;Q=kskQksz;evalz zkQ;echo kqj;eval kQwk_=j%sj;eval(k_);//;#jjj;f=jjjs=1//2;_=r%%s%%s%%s;f=%%s%%s%%s;q=_[18]*3;print f%%%%(q,_,q,q,f,q)jjj;q=_[18]*3;print f%%(q,_,q,q,f,q)%s","jkwz","".chr(39).chr(36).chr(10).chr(92).chr(92)),[]&&"s=1//2;_=r".chr(39).chr(39).chr(39),$_,$u?"":"".chr(10));';eval($_);//;#''';f='''s=1//2;_=r%s%s%s;f=%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)''';q=_[18]*3;print f%(q,_,q,
@dom111
dom111 / quine.js
Last active August 29, 2017 13:49
s='s=S;console.log(s.replace(/S/,(q=String.fromCharCode(39))+s+q))';console.log(s.replace(/S/,(q=String.fromCharCode(39))+s+q))
// or
s='s=S;q=String.fromCharCode(39);console.log(s.replace(/S/,q+s+q))';q=String.fromCharCode(39);console.log(s.replace(/S/,q+s+q))
osascript -e 'tell application "System Events"
repeat while true
key down {shift}
delay 1
key up {shift}
delay (random number from 12 to 48)
end repeat
end tell' &
@dom111
dom111 / ssh_mount.sh
Last active February 17, 2018 01:50
#!/bin/bash
unmount=0;
force=0;
server="";
mount_name=""; # defaults to $server
mount_location="~"; # we'll expand this later
mount_path=""; # remote point point, defaults to ~ usually
mount_opts=",auto_cache,follow_symlinks,transform_symlinks,defer_permissions,noappledouble"; # exclude reconnect unless using keys
binary="sshfs"; # change this if you're using a differently named binary
curl https://gist.githubusercontent.com/dom111/f18f95dfcdff16eae901f69bb49d2f32/raw/932f9549351141965d16dc390b89eb4845f83982/TODO.sh > ~/TODO.sh;
chmod +x ~/TODO.sh;
if [ ! -e ~/TODO ]; then
echo "First TODO item" > ~/TODO;
echo "Second TODO item" >> ~/TODO;
echo "Third TODO item" >> ~/TODO;
fi
if [ -n $PROMPT_COMMAND ]; then
#!/bin/bash
tput sc;
# ASCII table style:
# perl -nle "\$c=$(tput cols);"'push@F,$_}{$M=$c-($c/4);$L=(sort{$b-$a}map{y///c}@F)[0];$L=($L,$M)[$L>$M];print map{$i=$c-($L+3);$-++;"\x1b[$-;${i}f$_\n"}($s="+"."-"x($L+2)."+"),(map{"|".sprintf(" %-$L.${L}s ",$_)."|"}@F),$s' < ~/TODO;
# coloured
background=44;
foreground=97;
perl -nle "\$c=$(tput cols);\$b=$background;\$f=$foreground;"'push@F,$_}{$M=$c-($c/4);$L=(sort{$b-$a}map{y///c}@F)[0];$L=($L,$M)[$L>$M];print map{$i=$c-($L+5);$-++;"\x1b[$-;${i}f\x1b[$b;${f}m".sprintf(" %-$L.${L}s ",$_)}"",@F,""' < ~/TODO;
tput rc;
$_="....".$"x6;{print"\ec[$_]
";select$a,$a,!s/(.*)(.)/$2$1/,.1;redo}
(function() {
var data = site.panels.getData(),
_randomEmailAddress = function() {
return _randomString(10, _randomCharacter) + '@' + _randomString(10, _randomCharacter) + '.net';
},
_randomString = function(length, generator) {
var s = '';
while (length--) {
s += generator();
# a version of __git_ps1 that should show the current branch quickly without many git commands
function __git_ps1() {
local path="$(git rev-parse --show-toplevel)/.git";
local branch="$(cat ${P}HEAD | sed -re 's/.+\///g')";
if [[ -d "$path/rebase-merge/" ]]; then
if [[ -f "$path/rebase-merge/interactive" ]]; then
B="$branch|MERGING-i";
else