Skip to content

Instantly share code, notes, and snippets.

# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@rdkls
rdkls / gist:9104936
Created February 20, 2014 01:05
Ansible tasks to set (aka register) a variable, based on stdout of a shell command
- name: get gridfs host ip from name (required for nginx gridfs module)
shell: 'ping -q -c 1 -t 1 {{ gridfs_host }} | grep PING | sed -e "s/).*//" | sed -e "s/.*(//"'
register: gridfs_ip_command
when: gridfs_ip is not defined
- name: set gridfs ip
set_fact: gridfs_ip={{ gridfs_ip_command.stdout }}
when: gridfs_ip is not defined
@rdkls
rdkls / backup
Created February 24, 2014 02:17
duplicity backup script
#!/bin/bash
export FTP_HOST=YOUR_HOST_HERE
export FTP_USER=YOUR_USERNAME_HERE
export FTP_PASSWORD=YOUR_PASSWORD_HERE
export PASSPHRASE=YOUR_PASSPHRASE_HERE
export SIGN_PASSPHRASE=YOUR_SIGN_PASSPHRASE_HERE
usage='Usage: backups [list|ftp|retrieve|ship|restore]'
duplicity=/usr/bin/duplicity
@rdkls
rdkls / fog creek job prob
Last active August 29, 2015 14:01
My python solution to the problem on the Fog Creek job app page http://www.fogcreek.com/Jobs/Dev/
#!/usr/bin/python
the_letters = 'acdegilmnoprstuw'
target_hash = 910897038977002
target_word_length = 9
def possible_strings(given_hash, string_so_far=''):
try:
given_hash = float(given_hash)
except ValueError:
raise Exception('Hash must be a number')
[program:mongod]
autostart=true
command=/usr/bin/mongod -f /etc/mongod.conf
user=mongod
log_stderr=true
log_stdout=true
logfile=/var/log/mongo/mongod.log
stdout_logfile=/var/log/mongo/mongod.log
stderr_logfile=/var/log/mongo/mongod.log
stopsignal=2
@rdkls
rdkls / tampermonkey_trello_list_num_cards_show
Last active December 16, 2015 12:18
Tampermonkey script to show the number of cards in each Trello list Turns out it's already there, just need to set display = block
// ==UserScript==
// @name Trello Lists Show Num Cards
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://trello.com/board/*
// @copyright 2012+, You
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
// ==/UserScript==
setTimeout(function() {
@rdkls
rdkls / django_app_root_include_snippet
Last active December 16, 2015 15:49
django settings.py code to include apps dir
import os
import sys
PROJECT_ROOT = os.path.dirname(__file__)
sys.path.append(os.path.join(PROJECT_ROOT, "apps")
@rdkls
rdkls / bw_usage.sh
Last active December 24, 2015 15:39
Shell script to display an interface's bandwidth usage (Tx/Rx) every second
#!/bin/bash
secs=1
interface=eth0
echo "Displaying bandwidth on $interface every $secs seconds, ctrl-c to stop"
rx_bytes_prev=`ifconfig eth1|grep 'RX bytes'| sed -n 's/^\s*RX bytes:\([0-9]*\).*/\1/p'`
tx_bytes_prev=`ifconfig eth1|grep 'TX bytes'| sed -n 's/.*TX bytes:\([0-9]*\).*/\1/p'`
while [ true ] ; do
sleep $secs
rx_bytes=`ifconfig eth1|grep 'RX bytes'| sed -n 's/^\s*RX bytes:\([0-9]*\).*/\1/p'`
tx_bytes=`ifconfig eth1|grep 'TX bytes'| sed -n 's/.*TX bytes:\([0-9]*\).*/\1/p'`
@rdkls
rdkls / gtw.php
Created November 12, 2013 00:53
WordPress Plugin Malware after our site was compromised. Appears it used to be on the wordpress plugins site(!) http://wordpress.org/support/view/plugin-reviews/gtw With comments warning of spyware.
<?php
/*
Plugin Name: gtw
Description: Makes your website multilingual and available to the world using Google Translate. Please use <a href="http://gtranslate.net/forum/">GTranslate Forum</a> for your support requests.
Version: 1.0.3
Author: vendetta5
*/
/* Copyright 2008 - 2013 GTranslate (email : info [] gtranslate.net)
{{EPOLLIN, {u32=36974464, u64=36974464}}}, 512, 4294967295) = 1
accept4(11, {sa_family=AF_INET, sin_port=htons(37878), sin_addr=inet_addr("5.6.7.8")}, [16], SOCK_NONBLOCK) = 13
recvfrom(13, 0x2333d60, 1537, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(4, EPOLL_CTL_ADD, 13, {EPOLLIN|EPOLLET|0x2000, {u32=36974656, u64=36974656}}) = 0
epoll_wait(4, {{EPOLLIN, {u32=36974656, u64=36974656}}}, 512, 60000) = 1