Skip to content

Instantly share code, notes, and snippets.

@lottspot
lottspot / pianobar-mediakeys.py
Created September 22, 2012 19:25 — forked from flaviocdc/pianobar-mediakeys.py
Quick python script to handle media keys for pianobar
#!/usr/bin/env python
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
import os.path
APP_ID="pianobar-mediakeys"
pianobar_key_bindings = {}
@lottspot
lottspot / gollum-init
Created January 14, 2013 01:58
Init script for the gollum wiki engine
#!/bin/bash
GOLLUM_DIR='/home/git/docs.git'
GOLLUM_USER='gollum-data'
CURRENT_USER=$(whoami)
INVOCATION='gollum --mathjax --user-icons gravatar'
PID=${$}
as_user(){
21[[ ${GOLLUM_USER} != ${CURRENT_USER} ]] && su ${GOLLUM_USER} -c "$1"
[[ ${GOLLUM_USER} == ${CURRENT_USER} ]] && bash -c "$1"
@lottspot
lottspot / htauth-gen
Created January 14, 2013 02:01
Script to create and add users to a .htauth file using SSHA encruption
#!/bin/bash
# DEPENDENCIES: openssl
AUTHFILE_NAME='.htpasswd'
AUTHFILE_DIR='/etc/nginx'
[[ $(id -u) -gt 0 ]] && this script must be run as root && exit 1
echo -n "Enter users to add to .htpasswd file (separated by space, return to exit): "
read USERS
[[ ${#USERS} -lt 1 ]] && exit 0
# Following two lines declare currently unused associative arrays
@lottspot
lottspot / htsite
Created January 17, 2013 07:13
A script used to link sites from a sites-available directory to a sites-enabled directory; for use with web server stacks utilizing both nginx and apache.
#!/bin/bash
APACHE_AVAIL_DIR=/etc/httpd/conf/extra/sites-available
APACHE_EN_DIR=/etc/httpd/conf/extra/sites-enabled
NGINX_AVAIL_DIR=/etc/nginx/servers-available
NGINX_EN_DIR=/etc/nginx/servers-enabled
ARGS=$*
enable_site(){
if [[ ! -h ${APACHE_EN_DIR}/${1} && -f ${APACHE_AVAIL_DIR}/${1} && ! -h ${NGINX_EN_DIR}/${1} && -f ${NGINX_AVAIL_DIR}/${1} ]]
@lottspot
lottspot / hashing_passwords.py
Created January 19, 2013 23:40
Scripts for creating and checking hashed/salted passwords in Python
# coding: utf8
"""
Securely hash and check passwords using PBKDF2.
Use random salts to protect againt rainbow tables, many iterations against
brute-force, and constant-time comparaison againt timing attacks.
Keep parameters to the algorithm together with the hash so that we can
change the parameters and keep older hashes working.
@lottspot
lottspot / collect-libs
Created May 23, 2013 07:49
This single loop script is designed to make it simple to gather any needed libraries to execute a particular executable in one location, such are during the creation of an initramfs.
#!/bin/bash
###########################################################################################################
#
# Single loop for copying all dynamically linked libraries needed by an executable to a specified location
#
###########################################################################################################
EXECUTABLE=$1
DEST=/path/to/destination/dir/
@lottspot
lottspot / nettest.pl
Created July 31, 2013 15:33
Test connectivity to a websocket Original script: http://johnallen.us/?p=332
#!/usr/bin/perl
#
# nettest.pl
#
use IO::Socket;
use Errno;
$| = 1;
$host = shift;
@lottspot
lottspot / octopress-post-recieve-hook.md
Last active December 23, 2015 17:19
A post-receive deployment hook for octopress repositories.

Depends on:

  • Octopress git repo
  • tar
  • rsync
  • rake

Fill in the variables appropriately and copy to hooks/post-receive in your bare git repo

  • git_branch: git branch which holds the source files for the live site
@lottspot
lottspot / btsync-init
Last active December 28, 2015 01:59
A simple init script for BitTorrent Sync. Written and tested on CentOS 6.
#!/bin/bash
BIN='/usr/local/bin/btsync'
CONF='/usr/local/etc/btsync/sync.conf'
PID='/var/run/btsync/btsync.pid'
PIDMATCH=true
SERVICE=$(basename $0)
test $(id -u) -ne 0 && echo "This is for root." >&2 && exit 1
main(){
@lottspot
lottspot / btsync.service
Created November 12, 2013 04:00
Systemd unit file for managing BitTorrent Sync processes. Based on service file provided with btsync package in Arch Linux AUR.
[Unit]
Description=Bittorent Sync service
After=network.target
[Service]
ExecStart=/usr/local/bin/btsync --config /usr/local/etc/btsync/sync.conf --nodaemon
Restart=on-abort
[Install]
WantedBy=multi-user.target