Skip to content

Instantly share code, notes, and snippets.

@ze-
ze- / eratime.sh
Last active November 28, 2017 07:27
Simple (and robust) "<any>time" to track the uptime-of/time-since <any>thing
#!/bin/bash
era="$(basename "${0%time*}")" # name/symlink me as ubertime, worktime.sh, quitsmoking, married, <any>[time][.sh]
[[ "${*/-r}" != "$*" ]] && date +%s >~/".${era}time" 2>/dev/null # "-r" option (re)sets start to right now
until timestring="$(cat ~/".${era}time" 2>/dev/null)"; date -d "@$timestring" >/dev/null 2>&1;do
read -r -e -p "Enter ${era} start date (e.g. YYYY-MM-DD HH:MM): " timestring # or any format recognized by date(1)
[[ -n "$timestring" ]] && date -d "$timestring" +%s >~/".${era}time" 2>/dev/null
done;shopt -s extglob # just stashing this here for the +() later, since "-O extglob" in the shebang doesn't work
while esecs="$(($(date +%s) - timestring))";do
upstring=" $((esecs/3600/24/365))y $(printf "%3id %2ih %2im %2is" $((esecs/3600/24%365)) $((esecs/3600%24)) $((esecs/60%60)) $((esecs%60)))"
printf "\r%s for%s" "${era}" "${upstring/+(+( )0[ydhm])}"
@ze-
ze- / invert_brightness.css
Created May 7, 2012 05:00
Hue-preserving Brightness-Inversion Filter-Effects Userstyles for Firefox
@namespace url(http://www.w3.org/1999/xhtml);
/* this filter can cause bizarre breakage on some pages,
sometimes mild but sometimes a severe smearing into fuzzy lines!?
it also fails to affect background colors or images for some reason. */
@-moz-document url-prefix(http://), url-prefix(ftp://), url-prefix(file://), url-prefix(https://), url("about:blank") {
body {
/* this can crudely work-around the inability to affect backgrounds, but can cause breakage */
background-color:black !important;
(taken straight from http://gitorious.org/lcd-filtering/pages/Xft)
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.dpi: 96
Xft.rgba: rgb
@ze-
ze- / urxvt.sh
Created April 26, 2012 20:54
ze's urxvt launch script
#!/bin/sh
case "$((RANDOM/5461))" in
0)
color="SeaGreen2" ;;
1)
color="LimeGreen" ;;
2)
color="DarkTurquoise" ;;
3)
color="green3" ;;