Skip to content

Instantly share code, notes, and snippets.

@tkhn
tkhn / apache-self-signed-certificate.sh
Created January 24, 2014 13:38
Apache self-signed certificate generation
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@tkhn
tkhn / redirect-from-non-www-to-www.conf
Created February 12, 2014 13:19
nginx return redirect 301 from non-www to-www.conf
server {
listen 192.168.1.1:80;
server_name example.com;
return 301 http://www.example.com$request_uri;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
}
@tkhn
tkhn / go.spec
Created February 12, 2014 14:44 — forked from jehiah/go.spec
# Specfile for go used @ bitly for CentOS 5.*, RHEL5
%define name go-devel
%define path /usr/local
%define version go1.0.2
%define release 13
%define group Development/Languages
%define __os_install_post %{nil}
Name: %{name}
@tkhn
tkhn / xmpp-register.py
Created March 11, 2014 15:36
XMPP register.py
import sys
import os
import xmpp
if len(sys.argv) < 3:
print "Syntax: register.py [JID] [Password]"
sys.exita(64)
jid=xmpp.protocol.JID(sys.argv[1])
cli=xmpp.Client(jid.getDomain(), debug=[])
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
#!/bin/sh
# Standard Nagios plugin return codes.
STATUS_OK=0
STATUS_WARNING=1
STATUS_CRITICAL=2
STATUS_UNKNOWN=3
# Query pending updates.
updates=$(/usr/lib/update-notifier/apt-check 2>&1)
@tkhn
tkhn / apache-redirect-to-https.conf
Created April 18, 2014 14:11
apache config: http to https
<VirtualHost *:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""nginx_error_rate -- Munin plugin to report the error rate in an access log.
The access log defaults to `/var/log/nginx/access.log`. This may be
customized with the following stanza in your munin plugin conf:
[nginx_error_rate]
env.access_log /path/to/access.log