Skip to content

Instantly share code, notes, and snippets.

Install python env

On macOS the system python crashes with weird bugs.

You get around that using virtualenv and python 2.7

Here's what I did

This is a temporary workaround to have etcd listening on all interfaces so you can access it from docker containers.

Add a local etcd unit file

Create a file called /media/state/units/etcd-local.service that has the following contents:

[Unit]
Description=etcd local
@melito
melito / gist:3153481
Created July 20, 2012 21:48 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@melito
melito / html5uploader.coffee
Created March 18, 2012 05:20
Coffee Script html5 uploader
class HTML5Uploader
constructor:(obj, options) ->
@method = options['method'] ||= "POST"
@url = options['url'] ||= "/"
@params = options['params']
@obj = $(obj)
@files = []
@alerted = false
$("#media_items").html5Uploader({
url: "<%= assets_path %>",
method: 'POST',
params: {
authenticity_token: "<%= form_authenticity_token %>"
}
});
run "rm Gemfile"
file 'Gemfile', <<-FILE
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'rake', '~> 0.8.7'
gem 'devise', '~> 1.2.0'
gem 'cancan'
gem 'will_paginate', '~> 3.0.pre2'
gem 'tzinfo'
We couldn’t find that file to show.
@melito
melito / Initial setup
Created March 6, 2011 22:14
Don't use this verbatim. Just showcases the idea behind HOW to get everything setup
# Add a git user
adduser git
# Add your ssh key
sudo -u git mkdir ~git/.ssh/
sudo cp id_rsa.pub ~git/.ssh/authorized_keys
sudo chown -R git.git ~git/.ssh
# Make a repo
sudo -u git mkdir ~git/MyRepo.git
require "socket"
server = TCPServer.new('0.0.0.0', 6969)
loop do
socket = server.accept
Thread.start do
s = socket
# I cannot credit the original author
class Haversine
#EARTH_RADIUS = 3963.19 # miles
EARTH_RADIUS = 6371 # kilometers
RADIAN_PER_DEGREE = Math::PI / 180.0
def self.distance(lat1, lng1, lat2, lng2)
lat1_radians = lat1 * RADIAN_PER_DEGREE
lat2_radians = lat2 * RADIAN_PER_DEGREE