Skip to content

Instantly share code, notes, and snippets.

View rhcarvalho's full-sized avatar
🎥
Building something new

Rodolfo Carvalho rhcarvalho

🎥
Building something new
View GitHub Profile

Cannot reuse volume if container is run by a different user

$ VOLUME_DIR=`mktemp -d --tmpdir pg-data.XXXXX | tee >(xargs chmod a+rwx)`
$ echo $VOLUME_DIR 
/tmp/pg-data.26hxm

$ docker run --rm -u 12345 -v ${VOLUME_DIR}:/var/lib/pgsql/data -e POSTGRESQL_USER=u -e POSTGRESQL_PASSWORD=p -e POSTGRESQL_DATABASE=db openshift/postgresql-92-centos7

(...snip...)

How do file and dir permissions look like depending on how we layout our Dockerfile?

RUN yum install first, COPY contrib next (#57):

$ ls -la /var/lib/pgsql/
total 48
drwxrwxrwx.  4 postgres postgres 4096 Aug 27 12:35 .
drwxr-xr-x. 12 root     root     4096 Aug 26 14:43 ..
drwxrwxrwx.  3 root     root     4096 Aug 26 14:43 .pki
@rhcarvalho
rhcarvalho / README.md
Created March 3, 2014 15:57
Finding typos in Django

Usage

  1. Run collectwords.py with file paths as arguments to build a database of words.
  2. Run spellcheck.py to mark misspells.
  3. Use sqlite3 shell or anything else to output misspelled words to a file.
  4. Go through the file eliminating false positives.
  5. Search through the codebase and fix typo by typo :-)
@rhcarvalho
rhcarvalho / glue.py
Created February 8, 2015 17:01
Glueing together independent WSGI apps
import random
from django_demo.wsgi import application as django_app
from falcon_demo.hello import app as falcon_app
falcon_prefix = r'/falcon'
random_prefix = r'/random'
def random_app(environ, start_response):
return random.choice([falcon_app, django_app])(environ, start_response)
{
"id": "foobar",
"kind": "List",
"apiVersion": "v1beta3",
"name": "foobar",
"items": [
{
"apiVersion" : "v1beta3",
"kind": "Service",
"metadata" : {
@rhcarvalho
rhcarvalho / main.go
Last active August 29, 2015 14:27
comparing strings.Join to concatenating strings
package test
import "strings"
func stringjoin(key, namespace string) {
_ = strings.Join([]string{namespace, "build.", key}, "")
}
func concat(key, namespace string) {
_ = namespace + "build." + key
@rhcarvalho
rhcarvalho / go test
Last active August 29, 2015 14:27
Compare sorting structs and pointer to structs
$ go test -bench . -benchmem
testing: warning: no tests to run
PASS
BenchmarkVal5 10000000 161 ns/op 32 B/op 1 allocs/op
BenchmarkPtr5 10000000 152 ns/op 32 B/op 1 allocs/op
BenchmarkValFromPtr5 1000000 2280 ns/op 1312 B/op 2 allocs/op
BenchmarkPtrFromVal5 3000000 334 ns/op 80 B/op 2 allocs/op
BenchmarkVal50 300000 4120 ns/op 32 B/op 1 allocs/op
BenchmarkPtr50 500000 3174 ns/op 32 B/op 1 allocs/op
BenchmarkValFromPtr50 100000 19084 ns/op 12320 B/op 2 allocs/op
@rhcarvalho
rhcarvalho / buildstr_test.go
Last active September 8, 2015 09:17
Comparing how to build a long string
package buildstr_test
import (
"fmt"
"testing"
)
type EnvVar struct {
Name string
Value string
@rhcarvalho
rhcarvalho / lang__reader.rkt
Created October 7, 2011 23:47
Creating a custom #lang language
#lang s-exp syntax/module-reader
(planet rodolfo/ratematica/language)
#:read ratematica-read
#:read-syntax ratematica-read-syntax
(require (prefix-in ratematica- "../parser.rkt"))
# 2012/03/11 Rodolfo Carvalho
# Small demo showing how two bots connected with the same JID
# (and different resources) can communicate using xmpppy
import xmpp
import random
from getpass import getpass
from time import sleep
from threading import Thread, Event