(mostly collected over the last 3-4 streams)
# Pattern | |
# <docker-machine name>=<host name>,<host name>,... | |
registry=docker-registry |
#!/usr/bin/env bash | |
#Usage docker-machine-update-hosts.sh hosts.conf default | |
#arg1 is a configuration file with hosts | |
#arg2 is the docker-machine name e.g. default | |
DOCKER_IP=$(docker-machine ip $2) | |
echo "$2 ip: $DOCKER_IP" | |
#Remove existing lines from hosts | |
while IFS='' read -r line || [[ -n "$line" ]]; do |
FROM ubuntu | |
MAINTAINER Dustin Sallings "[email protected]" | |
ADD http://cbfs-ext.hq.couchbase.com/couchbase-dist/couchbase-server-enterprise_2.2.0_x86_64.deb /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN apt-get update | |
RUN apt-get install -y librtmp0 python-httplib2 | |
RUN dpkg -i /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN rm /tmp/couchbase-server-enterprise_2.2.0_x86_64.deb | |
RUN /etc/init.d/couchbase-server stop |
import threading | |
# Based on tornado.ioloop.IOLoop.instance() approach. | |
# See https://github.com/facebook/tornado | |
class SingletonMixin(object): | |
__singleton_lock = threading.Lock() | |
__singleton_instance = None | |
@classmethod |
#!/bin/bash | |
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/ | |
yum groupinstall "Development tools" | |
yum install zlib-devel | |
yum install bzip2-devel openssl-devel ncurses-devel | |
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 | |
tar xf Python-2.7.3.tar.bz2 | |
cd Python-2.7.3 |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |
First there was: http://snipplr.com/view/15246/color-coded-svn-status
Then there was: http://snipplr.com/view/16540/color-coded-svn-status-v2
A few days ago, I found a handy script online that colorized the output of SVN status. It worked pretty well, but needed a little polish and a couple of tweaks to make it use more common Python idioms. As I continued to use it and fix bugs and inefficiencies, I ended up replacing nearly every line in the original, but it was still a great starting point.
Additional changes include ANSI word-wrapping, a configurable tab expansion feature (for better code alignment), the 'colorizedSubcommands' sequence so that only applicable commands get colorized, use of proper subprocess
module calls so that piping through less
will work (for example, try svn-color diff | less -r
to see colorized diff output).
To use, stick it somewhere, make executable (`chmod 7
# Copyright (c) 2010 Curt Micol <[email protected]> | |
# Permission to use, copy, modify, and distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |