Skip to content

Instantly share code, notes, and snippets.

@zuloo
zuloo / moonphase.sh
Created December 30, 2015 15:28
moonphase bash script
#!/bin/bash
moonphase(){
local lp=2551443
local now=$(date -u +"%s")
local newmoon=592500
local phase=$((($now - $newmoon) % $lp))
local phase_number=$((((phase / 86400) + 1)*100000))
# Multiply by 100000 so we can do integer comparison. Go Bash!
@zuloo
zuloo / process-bunlde.zsh
Created September 25, 2017 22:14
Download all files from a humble bundle order
# Download the bundle.json by watching for a XHR request in your browsers console that contains the bundle data
# The request to watch for has a 16 byte random file name and a complex json sturcture:
#{
# "amount_spent":1000.0,
# "product":{
# "category":"bundle",
# "machine_name":"foo",
# "post_purchase_text":"",
# "supports_canonical":false,
# "human_name":"foo bar",
@zuloo
zuloo / fun-fact-ory.ts
Last active January 8, 2022 18:40
Function to generate the funfact at round end from a CS:GO demofiles cs_win_panel_round event
export function FunFactOry(token:string, s1:string, s2:number, s3:number):string {
switch (token) {
case "#funfact_ace":
return `Ace! ${s1} killed the entire enemy team.`;
case "#funfact_best_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s3}%.`;
}
@zuloo
zuloo / mb
Last active December 20, 2017 02:23
Mandelbrot ASCII art
#!/bin/bash
mx=$(($(tput cols)/2));my=$(($(tput lines)-1));s=${1:-1000};cx=${2:--500};cy=${3:-0};
i=${4:-20};co=${5:-8};__="echo -ne ";___="return";:(){ [ $1 -lt $i ] || {
$__ "\x1b[m "; $___;};[ $((($4*$4)+($5*$5))) -gt 4000000000 ] && { :p $(($1-3));$___;};
: $(($1+1)) $2 $3 $((((($4*$4)-($5*$5))/10000)+$2)) $(((2*$4*$5)/10000+$3));};
:p(){ c=$1; [ $1 -lt 0 ] && c=0; [ $1 -gt $co ] && c=$(($1%$co+1)); $__ "\x1b[3$(($c))m$c";};
:_(){ [ $1 -lt $my ] || $___;:__ $1 -$mx;:_ $(($1+2));};:__(){ [ $2 -lt $mx ] || {
echo;$___;};: 0 $(($cx+$2*$s)) $(($cy+$1*$s)) 0 0;:__ $1 $(($2+1));};:_ -$my;
n="\x1b[m";r="\x1b[31m";g="\x1b[33m";echo -ne "${n}usage: mb step shiftx${r}[${g}-2500${r}:${g}1600${r}]$n ";
echo -e "shifty${r}[${g}-1500${r}:${g}1500${r}]$n iterations colors${r}[${g}1${r}:${g}8${r}]$n";exit 0
@zuloo
zuloo / flash2vlc
Created March 6, 2016 21:45
play flash viedeo in vlc
#!/bin/bash
FLASH_TMP=`ls /tmp | grep Flash*`
if [[ $FLASH_TMP ]]; then
vlc /tmp/Flash*
else
if [[ `ps x | awk '/libgcflashplayer.so\ /{print $1}'` ]]; then
flashvids() { lsof -p `ps x | awk '/libgcflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
else
@zuloo
zuloo / scdreader
Last active January 25, 2016 14:28
change the smart card reader used by gnupg2 (the dirty way)
#!/bin/bash
gpg2 --card-status > /dev/null 2>&1
READERS=($(echo scd getinfo reader_list | gpg-connect-agent –decode | awk '/^D/ {print $2}' | sed 's/%0A/ /g; /^$/d'))
BADCHOICE=true
while $BADCHOICE
do
INDEX=0
@zuloo
zuloo / .zshrc
Last active August 29, 2015 14:24
Open the last downloaded PDF in ~/Downloads
alias lastpdf='zathura "`ls -tc ~/Downloads/*.pdf | head -1`"'
@zuloo
zuloo / .vimrc
Created June 28, 2015 23:05
Vim: copy to X clipboard
" pipe range as a shellescaped string to the vimclip shell script
function Xclip() range
echo system('echo '.shellescape(join(getline(a:firstline, a:lastline), '\n')).'| ~/bin/vimclip')
endfunction
" bind Ctrl-c and Ctrl-Shift-c to copy
vmap <C-c> :call Xclip()<CR>
vmap <C-C> :call Xclip()<CR>
@zuloo
zuloo / .zshrc
Last active August 29, 2015 14:23
play Youtube audio with mpd [ use as external browser in w3m or links ]
# add a helpfull function to search youtube in w3m
tube (){ w3m "https://youtube.com/results?search_query=`echo $* | sed 's/[ ]/+/g'`" }
@zuloo
zuloo / bashmagic_luks
Last active August 29, 2015 14:08
Bash Command 4 Luks Header Backup
cat /etc/crypttab |\
grep uuid |\
sed -r 's/[\t ]+/ /g' |\
cut -d ' ' -f 2 |\
while read line; do
dev=$(ls -la $line);
ser=$(smartctl -a $line | grep 'Serial Number');
cryptsetup \
luksHeaderBackup /dev/${dev##*/} \
--header-backup-file \