Skip to content

Instantly share code, notes, and snippets.

@ionrock
ionrock / lockfile.py
Created June 29, 2012 04:14
A file locking example
"""
A file lock implementation that tries to avoid platform specific
issues. It is inspired by a whole bunch of different implementations
listed below.
- https://bitbucket.org/jaraco/yg.lockfile/src/6c448dcbf6e5/yg/lockfile/__init__.py
- http://svn.zope.org/zc.lockfile/trunk/src/zc/lockfile/__init__.py?rev=121133&view=markup
- http://stackoverflow.com/questions/489861/locking-a-file-in-python
- http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
- http://packages.python.org/lockfile/lockfile.html
/usr/local/bin/nginx:
apt install nginx
VENV=.venv
$(VENV):
virtualenv $(VENV)
$(VENV)/bin/py.test: $(VENV)
$(VENV)/bin/pip install dev_requirements.txt
test: $(VENV)/bin/py.test
$(VENV)/bin/py.test .
SOURCES=$(shell find . -name '*.go')
myapp: $SOURCES
go build -o myapp ./cmd/myapp
func CreateExecutor(cmdType string, cmdCfg CommandConfig) *CommandExecutor {
ce := &CommandExecutor{}
switch cmdType {
case "docker":
ce.Command = CreateDockerCommand(cmdCfg)
case "ssh":
ce.Command = CreateSSHCommand(cmdCfg)
}
type CreateCommand func() []string
type CommandExecutor struct {
CmdString string
Command CreateCommand
}
func (ce *CommandExecutor) defaultCommand() []string {
return []string{"/bin/bash", "-c", ce.CmdString}
}
---
- exec:
cmd: ls -la
- docker:
image: ubuntu
cmd: ls -la
- ssh:
connect: foo.example.com
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"github.com/ionrock/procs"
@ionrock
ionrock / rspec_failure
Created May 7, 2017 03:29
this makes no sense....
Failure/Error: expect(model).to eq('environment')
expected: "environment"
got: "environemnt"
(compared using ==)
craps.core=> (def my-list '(1 2 3 4))
#'craps.core/my-list
craps.core=> (map println my-list)
(1
2
nil 3
nil 4
nil nil)
craps.core=> (map print my-list)
(12nil 3nil 4nil nil)