Skip to content

Instantly share code, notes, and snippets.

@tkhn
tkhn / gc-cow.rb
Created December 4, 2013 11:47 — forked from wr0ngway/gc-cow.rb
#!/usr/bin/env ruby
rss = '.+?Rss:\s+(\d+)'
share = '.+?Shared_Clean:\s+(\d+)'
share << '.+?Shared_Dirty:\s+(\d+)'
priv = '.+?Private_Clean:\s+(\d+)'
priv << '.+?Private_Dirty:\s+(\d+)'
MEM_REGEXP = /\[heap\]#{rss}#{share}#{priv}/m
def mem_usage_linux
@tkhn
tkhn / gist:7794106
Last active December 30, 2015 07:09 — forked from jessedearing/gist:2351836
#!/bin/bash
d=$1
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out $d.key 4096
echo "Generating a Certificate Signing Request..."
openssl req -new -key $d.key -out $d.csr
@tkhn
tkhn / upstart-python-daemon.conf
Created December 9, 2013 17:58
upstart-python-daemon.conf
description "pyservice"
start on runlevel [345]
stop on runlevel [!345]
exec su - user -s /bin/bash -c "/home/user/bin/service.py"
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Benchmarking Nginx with Go

Today I just wanted to know which of these options is faster:

  • Go HTTP standalone
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI

Hardware

#!/usr/bin/env python
#
# To run, first set this environment variable to point to the Evernote API python bindings you downloaded from Evernote:
# export PYTHONPATH=/path/to/evernote/python/api
#
import sys
import hashlib
import time
import thrift.protocol.TBinaryProtocol as TBinaryProtocol
# Python OAuth example
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient
##
# Helper function to turn query string parameters into a
# Python dictionary
##
import sys
import re
from enauath import client
from string import Template
#Accepts the GUID(string) of the note you want to append
def appendNote(guid):
#Get the note to be updated using the note's guid http://dev.evernote.com/documentation/reference/NoteStore.html#Fn_NoteStore_getNote
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@tkhn
tkhn / check-redis-lag.sh
Created December 23, 2013 14:10
check redis replication lag
#!/bin/bash
# defaults
warning=3
critical=5
while getopts "w:c:" OPTION
do
case $OPTION in