Skip to content

Instantly share code, notes, and snippets.

View james-m's full-sized avatar

James McKernan james-m

  • San Francisco, CA
View GitHub Profile
# Get latest Sun Java SDK in v6 from Oracle
wget http://download.oracle.com/otn-pub/java/jdk/6u31-b04/jdk-6u31-linux-x64-rpm.bin
# make it exec
chmod +x jdk-6u31-linux-x64-rpm.bin
# Install Java
sudo ./jdk-6u31-linux-x64-rpm.bin
# Check if the default java version is set to sun jdk
@james-m
james-m / base_2.8.1_Dockerfile
Last active August 21, 2016 18:49
RedisMasterSlaveOnDocker
vagrant@ubuntu-12:/docker-pub/redis$ cat base/2.8.1/Dockerfile
FROM ubuntu:12.10
MAINTAINER James McKernan james@hvflabs.com
RUN apt-get update
RUN apt-get install -y build-essential
ADD redis-2.8.1.tar.gz redis-2.8.1.tar.gz
RUN tar xvfz redis-2.8.1.tar.gz
RUN cd redis-2.8.1 && make
RUN cd redis-2.8.1 && make install
import os
import sys
import context
def get_env_name():
env = None #'dev' # the default
env = os.environ.get('ENV_NAME', env)
if env is None:
raise Exception("ENV_NAME=None")
env = env.lower()
import random
import itertools
x = [[random.randint(0, 100) for i in range(random.randint(1, 5))] for z in range(10)]
print x
def walk(seq):
for sub in itertools.izip_longest(*seq):
for i in sub:
if i is None:
DATA = [
[1, 2, 3],
[4, [5, 6], 7],
[[8, 9], 10, [11, 12, 13, 14]],
15,
[16, 17, [18, 19], 20]
]
def walk(data):
for el in data:
@james-m
james-m / pygmenter.py
Created December 15, 2011 18:19
pygments ftw
#!/usr/bin/python
#
import os
import sys
import argparse
import pygments
import pygments.lexers
import pygments.formatters
@james-m
james-m / gist:1254631
Created September 30, 2011 18:46
using serverlock.lock_server (process 2)
>>> import conf
>>> srvs = map(dict, conf.get('chatservers'))
>>> from common import serverlock
>>> serverlock.lock_server(srvs)
{'lockport': 8070, 'lock': <socket._socketobject object at 0xb776cd4c>, 'host': 'alkime', 'logdir': 'log1'}
>>>
@james-m
james-m / gist:1254624
Created September 30, 2011 18:44
using serverlock.lock_server (process 1)
>>> import conf
>>> conf.get('chatservers')
[{'lockport': 8080, 'host': $host, 'logdir': 'log0'}, {'lockport': 8070, 'host': $host, 'logdir': 'log1'}]
>>> conf.get('chatservers')[0]['host']
'alkime'
>>> conf.get('host')
'alkime'
>>> from common import serverlock
>>> srvs = map(dict, conf.get('chatservers'))
>>> serverlock.lock_server(srvs)
@james-m
james-m / gist:1254154
Created September 30, 2011 15:43
sample config file
host: 'alkime'
chatservers: [
{
lockport : 8080
logdir : 'log0'
host : $host
}
{
lockport : 8070
logdir : 'log1'