Skip to content

Instantly share code, notes, and snippets.

@daleobrien
daleobrien / gist:5464219
Created April 26, 2013 00:06
Nginx & pagespeed build settings for Amazon Linux.
sudo yum install gcc-c++ pcre-dev pcre-devel zlib-devel make gd-devel perl-ExtUtils-Embed
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.5.27.1-beta.zip
unzip release-1.5.27.1-beta.zip
get http://nginx.org/download/nginx-1.4.0.tar.gz
tar -xvzf nginx-1.4.0.tar.gz
cd nginx-1.4.0
./configure --add-module=$HOME/ngx_pagespeed-release-1.5.27.1-beta --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-ht
# coding: utf-8
import csv
import cStringIO
import codecs
class DictUnicodeWriter(object):
def __init__(self, f, fieldnames, dialect=csv.excel, encoding="utf-8", **kwds):
# Redirect output to a queue
######################################################################
# CURRENT AWARE LOCAL DATETIME
######################################################################
from datetime import datetime
from tzlocal import get_localzone
local_tz = get_localzone()
local_dt = datetime.now(local_tz)
@daleobrien
daleobrien / Vim install script.sh
Last active September 12, 2016 22:39
Install a later version of VIM
sudo yum -y install hg ncurses-devel python-devel gcc-c++
# hg clone https://vim.googlecode.com/hg/ vim
git clone https://github.com/vim/vim.git vim
cd vim
hg update default
./configure --with-features=huge \
--disable-selinux \
--enable-multibyte \
@daleobrien
daleobrien / install_pypy.sh
Last active February 15, 2017 12:20
pypy install script on AWS
# Needs a larger machine, with at least 2GB Ram, say a m2.xlarge!
sudo yum install \
gcc make python-devel libffi-devel lib-sqlite3-devel pkgconfig \
zlib-devel bzip2-devel ncurses-devel expat-devel \
openssl-devel gc-devel python-sphinx python-greenlet tcl-devel
wget https://bitbucket.org/pypy/pypy/downloads/pypy-2.1-beta-src.tar.bz2
tar -xvf pypy-2.1-beta-src.tar.bz2
cd pypy-2.1-beta-src
@daleobrien
daleobrien / gist:5993593
Created July 14, 2013 08:12
Install pillow (for pypy) onto AWS
# support for pillow
yum install libX11-devel
wget http://prdownloads.sourceforge.net/tcl/tcl8.4.20-src.tar.gz
tar -xvf tcl8.4.20-src.tar.gz
cd tcl8.4.20/unix/
./configure && make -j4 && sudo make install
cd ~
@daleobrien
daleobrien / get_sydney_ec2_prices.py
Last active December 20, 2015 21:24
Quick script to get the costs for EC2 instances for Sydney only. Needs 2 installs to work, pip install requests pip install workbook
#!/usr/bin/env python
'''
'''
try:
import requests
except ImportError:
print 'You need to install "requests". Run "pip install requests" '
@daleobrien
daleobrien / dyndns_route53.py
Created August 25, 2013 09:06
This script updates Route53
"""
Requeriments:
$ sudo pip install boto dnspython
Edit ~/.boto to use your AWS credentials
"""
import time
import sys
@daleobrien
daleobrien / ncurses_stl.cpp
Created November 18, 2013 21:19
A general purpose example of using ncurses in C++ e.g. with STL strings. Note: copied from http://pastebin.com/jRK9C129
/* ncurses C++
*
* A general purpose example of using ncurses in C++ e.g. with STL strings.
* I guess whatever license ncurses uses applies, otherwise public domain.
*/
# include <algorithm>
# include <iostream>
# include <fstream>
# include <iterator>
@daleobrien
daleobrien / yield.cpp
Last active January 2, 2016 18:18
Way to do a yield statement in C++.
#include <iostream>
// clang++ -Wno-c++11-extensions yield.cpp;./a.out
class range {
private:
int last;
int iter;
bool finished;