Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am lottspot on github.
  • I am lottspot (https://keybase.io/lottspot) on keybase.
  • I have a public key whose fingerprint is C908 CC37 93F4 98FE 98AD 9DC4 443E A8D6 A536 53A9

To claim this, I am signing this object:

@lottspot
lottspot / http_check.py
Last active October 1, 2015 05:08
A nagios-like HTTP check which can import a python callable to handle a critical threshold
#!/usr/bin/python
import Queue
import threading
import time
import sys, os
from urllib import urlopen
import logger
# check_http.py
# $1: SCHEME
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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