Skip to content

Instantly share code, notes, and snippets.

@jjrh
jjrh / mpd_stop_start
Created June 25, 2013 16:15
Toggles mpd to play if it's stopped or paused, toggles mpd to pause if it's playing. Useful if you have a keybinding to toggle music.
#/bin/sh
status=$(mpc status | grep play)
if [ -n "$status" ]
then
mpc pause >> /dev/null
else
mpc play >> /dev/null
fi
@jjrh
jjrh / rotate.sh
Created July 23, 2013 15:20
Rotates your screen remembering the last position.
#!/bin/sh
check_file="/home/jjrh/scripts/rotation_status"
screen="HDMI1"
#if the rotation file doesn't exist create it and assume normal.
if [ ! -e $check_file ]
then
touch $check_file
@jjrh
jjrh / remember_good_song
Created August 22, 2013 15:12
tool for mpd that formats the output of mpc in a way I can remember it. If I like a song in my playlist dump its name and file location into $file_path
#!/bin/sh
# tool for mpd that formats the output of mpc in a way I can remember it.
# If I like a song in my playlist dump its name and file location into $file_path
#
file_path="~/temp/good_songs"
echo "--------------------------------------------------------------------------------" >> $file_path # note this line is 80characters wide.
SONG_INFO=`mpc status -f "%artist% - %title% \n%file%" | head -1`
SONG_LOCATION=`mpc status -f "%artist% - %title% \n%file%" | head -2 | tail -n -1`
@jjrh
jjrh / hour_log_pest
Created August 28, 2013 18:50
I tend to forget to log my time, then I tend to forget what I did and for how long. The idea of this is to have a popup on my screen every hour that displays a text box and asks me what I did. I enter a short line saying what I was doing.
#!/bin/sh
DISPLAY=:0
export DISPLAY
prompt_dialog ()
{
text=$(zenity --text-info --title="what have you been working on?" --editable)
length=${#text}
@jjrh
jjrh / mpd_startup
Created September 3, 2013 17:07
Checks if mpd and mpdscribble are running, if not start them up. check_prog function will also work to check/start any program
#!/bin/sh
# checks if a program is running, if not, it tries to start it.
# after 3 tries, if the program hasn't started we print out the error
# and return.
errors=""
check_prog ()
{
if [ $count -eq 3 ]
@jjrh
jjrh / colored import
Created September 3, 2013 17:36
'termcolor' is a handy module for outputting stuff to the term with colors and other term things. Module is somewhat obscure and totally unnecessary though so this is a little wrapper to allow the program to still run. pip install termcolor
try:
from termcolor import colored, cprint
except Exception as e:
# if they don't have this library we define it here.
def colored(input_string,*args,**kwargs):
return input_string
@jjrh
jjrh / gplus_ttopten.py
Last active December 23, 2015 11:19 — forked from jarobins/gplus_ttopten.py
- Implemented copy to clipboard for the trending stuff. - clicking buttons now also opens the link in your browser.
import urllib2, re, time
from Tkinter import *
import datetime
import webbrowser
class App:
def __init__(self, master):
self.master = master
frame = Frame(master, bg="")
frame.pack()
import sys
import argparse
def create_line(str_in,length,decorate="-"):
line_length = len(str_in)
if(line_length > length):
print "error:"
print "line is %s characters too long. ( length=%s )" % (line_length - length, line_length)
@jjrh
jjrh / api_bitcoincharts.py
Created November 29, 2013 02:10
wrapper around the the telnet output from api.bitcoincharts.com
import telnetlib
import json
import datetime
from termcolor import colored
print ""
print "opening telnet connection to api.bitcoincharts.com:27007"
print ""
@jjrh
jjrh / sort_buffs.tcl
Last active December 29, 2015 18:39
Weechat plugin to sort your buffers alphabetically (which results in grouping them by server) and correct the buffer numbering. ibuffer has a sort mode, but it does not correct the numbering. has the hook for channel joins
weechat::register "sort_buffs" "FlashCode" "0.1" "GPL3" "sorts buffers" "" ""
proc sortbuffs {data signal signal_data} {
set bufflist []
set infolist [weechat::infolist_get "buffer" "" ""]