Skip to content

Instantly share code, notes, and snippets.

@noteed
noteed / psql-ssh-tunnel.md
Last active May 25, 2018 21:51
SSH tunnel for PostgreSQL connection

SSH tunnel for PostgreSQL connection

Create a .pgpass file that will be used to provide the password for any libpq-based program for the matching hostname/port/database/user. That file should be chmod'd 0600.

> cat .pgpass
127.0.0.1:5433:database:user:password

Create a SSH tunnel: we open the local port 5433 and, out of the tunnel, go to localhost:5432. You probably really want localhost and not remote: your PostgreSQL database is probably accepting connections only from locahost.

> ssh -N -L 5433:localhost:5432 user@remote

@noteed
noteed / body.txt
Created October 7, 2013 14:07
Send something to Sentry.
{
"project": "site",
"event_id": "ac7d8c1c34fc4630ad850ee518f1b9d1",
"culprit": "my.module.my.function",
"timestamp": "2013-09-19T17:41:36",
"message": "SyntaxError: abcd!",
"exception": [{
"type": "SyntaxError",
"value": "efgh",
"module": "__builtins__"
@noteed
noteed / docker.md
Last active December 24, 2015 23:48
List of Docker things.

Docker things

  • quay.io (now acquired by CoreOS)
    • 5/10/20/50/125 private repositories for $12/$25/$50/$100/$200 (it was $7/$12/$22 for 5/10/20 repositories before) per month
    • unlimited public repositories
  • Reesd
    • 10GB/25GB/50GB for €20/€45/€80 per month
    • Illimited number of repositories/images/layers, only compressed layer space counts.
    • Disclaimer: it is a project of mine.
  • Now in beta :-)
@noteed
noteed / sha-streams.hs
Created November 20, 2013 18:27
Use the `SHA` package (modified to expose an incremental interface; a fork exists in my repositories) to compute SHA hashes using the `io-streams` package.
module Main (main) where
import Data.Binary.Get
import System.IO.Streams.Internal (InputStream (..))
import qualified System.IO.Streams as Streams
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as S
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
@noteed
noteed / Dockerfile
Created November 30, 2013 17:55
Dockerfile demonstrating (probably) a bug in Docker (in 0.7 and I think in 0.6.5).
from ubuntu:12.04
maintainer Vo Minh Thu <noteed@gmail.com>
run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
run apt-get update
# Install PostgreSQL (for the postgres user)
run apt-get install -q -y postgresql-9.1
# Install OpenSSH (for scp)
@noteed
noteed / introducing-rees.md
Last active January 4, 2016 00:18
Introducing Rees (blog post)

Introducing the rees command-line tool

I have been interested in creating a simple service to backup files. At first, the service was mainly intended to save PostgreSQL WAL segment files and I thought to simply use the scp command to upload the files to a remote machine. Then putting some more thoughts in it, it felt like a nice well-defined project and possibly like a minimum viable product.

More precisely I decided to expose a service, scp@reesd.com (think about the similarity with git@github.com or git@bitbucket.org when using the SSH transport) that would allow users to use the regular scp command to save and restore files. When scp would complete an upload to Reesd, it would mean that Reesd has actually streamed the content to multiple backend machines.

Although useable, Reesd is not yet ready for commercial use. I have still some tools to write to automate its deployment and more importantly, make sure I can restore data quickly in the event a replica fails. That being said, I have be

@noteed
noteed / docker-ovs.md
Last active December 29, 2023 07:07
Docker - Open vSwitch setup
@noteed
noteed / docker-reesd.md
Last active August 29, 2015 13:56
How I use Docker for Reesd

How I use Docker for Reesd

Docker is all the rage these days. I started to look at Docker seriously maybe around April last year. It has gained a lot of momentum and I think it's just the beginning. For instance new tools and services are created regularly, or Docker, inc. has not yet unveiled their exact commercial offering (and I think they have a very rich view about what it is possible to achieve with Docker).

When I started to build Reesd, I have directly used Docker. Even if it is not production-ready, or even if there is some risk that it might evolve

@noteed
noteed / goto.py
Last active July 27, 2020 22:11
Dumb workflow engine (in Python)
"""
Simple workflow engine.
A workflow is a directed graph where nodes are activities. The returned
value of an activity is used to dispatch on its outgoing transitions.
Activities are functions, accepting a `state` argument.
def ACTIVITY(state):
pass
@noteed
noteed / docker-tinc.md
Last active April 17, 2019 06:22
Docker - Tinc setup