Skip to content

Instantly share code, notes, and snippets.

View XayOn's full-sized avatar
🐍

David Francos XayOn

🐍
View GitHub Profile
@XayOn
XayOn / weather_segment.bash
Last active December 11, 2015 11:28
tmux-powerline weather segment written in bash
#!/bin/bash
declare -A tp_weather
tmp_tmp=$(mktemp -d);
tp_weather=(
[location]="779063"
[unit]="c"
[tmp]="${tp_tmp}/weather"
[update_secs]=600
);
(( $(( $(date "+%s") - $(stat -c "%Y" ${tp_weather[tmp]}) )) > 100)) && {
@XayOn
XayOn / gist:4027564
Created November 6, 2012 21:09
Print a file as a qr code animation in firefox
# QR code generation library by http://code.google.com/p/jsqrencode/ GPL3
# This code is GPL3 as well by David Francos Cuartero (XayOn)
{ cat <<EOF
<!DOCTYPE html><html><head><meta name="apple-touch-fullscreen" content="yes" /><style type="text/css">html { width:100%; height: 100% } body { width:100%; height: 100%; margin: 0px; padding: 0px } div#qrdiv {width:200px; height:200px} </style><script type="text/javascript">adelta=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28];vpat=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177];fmtword=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107];eccblocks=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,2
@XayOn
XayOn / gist:4020993
Created November 5, 2012 23:03
Launch deluged, then launch flexget and get the subtitles
deluged & { flexget && sleep 1m && subdownloader -cli -l en; } &
@XayOn
XayOn / gist:3983568
Created October 30, 2012 22:38
Automagically scroll down an image when you scroll to its half.
($ document).ready ->
(($ document) .find '.showoff') .live 'mouseover', () ->
h = (($ this).css 'height').replace 'px', ''
($ document) .data 'next_position', ($ this).position().top + h + 20
($ document) .data 'launch_position', ($ this).position().top + (h / 2)
($ document).live 'scroll', (event) ->
if ((Number) ($ document).scrollTop() > ((Number) (($ document) .data 'launch_position'))
window.scrollTo(0, ($ document).data 'next_position')
@XayOn
XayOn / gist:3979955
Created October 30, 2012 12:40
shell-fm configuration file
# This makes shell-fm download everything in ~/Music/<artist>-<title>.mp3
# Then plays it with mplayer and software volume mixer, thus making volumne 10 times louder than usual max.
extern=tee ~/Music/%a-%t.mp3 | mplayer -really-quiet -softvol -softvol-max 1000 -volume 1000 -noconsolecontrols -demuxer lavf -lavfdopts format=mp3 -
np-cmd = lyricsdownloader --artist "%a" --songname "%t" 2> /dev/null > /tmp/lyrics.txt
# Then I execute a tail -f /tmp/lyrics.txt on another tmux split
@XayOn
XayOn / gist:3970424
Created October 28, 2012 23:26
Play the lastest file in a serie
# My dir structure is like this:
# Series name/
# Season X/
# Chapter
# So, this script get a random series and plays the lastest chapter
# This way, flexget gets all the tv series from me, and this command plays randomly the lastest chapter.
# Soon I'll add something like a read flag, or I'll check out the last file access, if last file access < 7 days, a new chapter is probably there!
a=(*); mplayer "$(find ${a[ $[ ( $RANDOM % ${#a[@]} ) + 1 ] - 1 ]}/*|tail -n1)"
@XayOn
XayOn / gist:3935320
Created October 22, 2012 23:05
Make a screencast and upload it to youtube
read -p "Press enter to select window"
tmp=$(mktemp);
recordmydesktop --windowid $(xwininfo | awk '/Window id:/ {print $4}') -o $tmp && {
read -p "Enter video category: " category
read -p "Enter video title: " title
read -p "Enter video summary" summary
google youtube post --title "$title" --summary "$summary" --category "Tech" $tmp
}
@XayOn
XayOn / gist:3934819
Created October 22, 2012 21:59
Record a specific window with recordmydesktop
# Recommended by recordmydesktop manpage
recordmydesktop --windowid $(xwininfo | awk '/Window id:/ {print $4}')
@XayOn
XayOn / .bashrc
Created October 18, 2012 12:53
Export dbus_session_bus_address on bashrc
# This checks if we're connecting via ssh, gets dbus-daemon --session address and exports it.
[[ -n $SSH_CLIENT ]] && export $(cat /proc/$(command pgrep -u "$USER" -f -- "dbus-daemon --session" )/environ| tr '\0' '\n' | command grep "DBUS_SESSION_BUS_ADDRESS=")
@XayOn
XayOn / gist:3911423
Created October 18, 2012 12:14
Irssi remote notifications with irssi-dbus
# Call me with your ssh options (and probably DISPLAY=YOUR_REMOTE_DISPLAY)
# This is actually NOT the way, but the dbus-monitor approach + ssh might come handy.
ssh $@ dbus-monitor --session|while read line; do echo $line | command grep ": " &>/dev/null && notify-send "Irssi" "$(echo $line|sed s/\"//g|sed s/string//g)"; done