Skip to content

Instantly share code, notes, and snippets.

@vsajip
vsajip / pyvenvex.py
Last active May 18, 2024 23:13
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages.The script needs Python 3.3 or later; invoke it using"python pyvenvex.py -h"fo…
#
# Copyright (C) 2013-2020 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
@charliek
charliek / parameter_test.js
Created March 20, 2013 01:42
Parameter test
var paramPrefix = 'charliek';
var iterations = 1000;
function foundAll(postValues, rtnStr) {
var notFound = ''
$.each(postValues, function( key, value ) {
var expected = key + ':' + value;
if(rtnStr.indexOf(expected) == -1) {
notFound += '\t' + expected + '\n'
}
@MrDrews
MrDrews / Default.sublime-theme
Created April 22, 2013 13:41
Solarized (light) -- Complement the stock Solarized (light) theme in sublime text 3 by placing this `Default.sublime-theme` inside the `Packages/User` folder. It will recolor the sidebar.
[
{
"class": "sidebar_container",
// $base02: #073642
"layer0.tint": [7,54,66],
"layer0.opacity": 1.0,
"layer0.draw_center": false,
"layer0.inner_margin": [0, 0, 1, 0],
"content_margin": [0, 0, 1, 0]
@jtimberman
jtimberman / default_spec.rb
Created May 10, 2013 03:14
this is cookbooks/java/spec/default_spec.rb. Then install the chefspec gem and run rspec. (yay!)
require 'chefspec'
describe 'java::default' do
let (:chef_run) { ChefSpec::ChefRunner.new.converge('java::default') }
it 'should include the openjdk recipe by default' do
chef_run.should include_recipe 'java::openjdk'
end
context 'windows' do
let(:chef_run) do
@cdimartino
cdimartino / rebalance.sh
Created May 16, 2013 20:30
Quick and dirty rebalancing of Cassandra cluster.
#!/bin/sh
# This will allow you to rebalance the Cassandra ring
#
# $ ./rebalance.sh file_of_hosts
RING_SIZE=$(echo "2^127" | bc)
HOSTS=$(cat $1 | sed 'N;s/\n/ /')
HOST_NUM=$(echo $HOSTS | wc -w)
INDEX=0
@miketheman
miketheman / zook_grow.md
Created July 22, 2013 21:36
Adding nodes to a ZooKeeper ensemble

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@timyates
timyates / .bash_profile.sh
Last active December 22, 2015 10:49
Two bash functions to switch JVM on OS X (with GVM installed as well)
export JAVA7_HOME=`/usr/libexec/java_home -v 1.7*`
export JAVA8_HOME=`/usr/libexec/java_home -v 1.8*`
function jdk7 {
export JAVA_HOME=$JAVA7_HOME
set_path
echo "Using Java 7 $JAVA_HOME"
}
function jdk8 {
def camel_to_snake(column_name):
"""
converts a string that is camelCase into snake_case
Example:
print camel_to_snake("javaLovesCamelCase")
> java_loves_camel_case
See Also:
http://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-camel-case
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', column_name)
@hummus
hummus / gist:8592113
Last active April 26, 2024 19:45
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \