Skip to content

Instantly share code, notes, and snippets.

View samalba's full-sized avatar

Sam Alba samalba

View GitHub Profile
#!/bin/sh
### BEGIN INIT INFO
# Provides: dockercompose
# Required-Start: $docker
# Required-Stop: $docker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Docker Services
### END INIT INFO
@samalba
samalba / pipeline.py
Created November 4, 2022 03:28
Build a Golang api app and containerize it
import anyio
import dagger
async def pipeline(client: dagger.Client):
# Fetch source code from github
source_code = await (
client.git("https://github.com/kpenfound/greetings-api.git")
.branch("main")
.tree().id()
@samalba
samalba / main_test.go
Created July 23, 2013 02:50
How to assert values in golang unit tests
package main
import (
"fmt"
"testing"
)
func assertEqual(t *testing.T, a interface{}, b interface{}, message string) {
if a == b {
return
Anonymous "Accept"
Anonymous "Accept-Charset"
Anonymous "Accept-Encoding"
Anonymous "Accept-Language"
Anonymous "Authorization"
Anonymous "Cache-Control"
Anonymous "Connection"
Anonymous "Content-Length"
Anonymous "Content-Type"
Anonymous "Cookie"
@samalba
samalba / cop-stack.sh
Last active February 2, 2021 19:30
Copy a BL stack
#!/bin/bash
if [ "$#" -lt 3 ]; then
echo "Usage: $0 workspace from-stack to-stack"
exit 1
fi
set -eu
stackSrc="$2"
stackTo="$3"
@samalba
samalba / bl-gitlab-pipeline.yaml
Created December 15, 2020 20:14
Blocklayer Gitlab-CI
staging blocklayer:
stage: staging
environment:
name: staging
image: blocklayer/bl-cli
script:
- bl --stack "staging" --env "staging" push "api"=. --api-key ${BLOCKLAYER_API_KEY} --no-color
except:
- master
@samalba
samalba / README.md
Last active November 28, 2018 01:18
Demo a testnet of 2 nodes using the github.com/cosmos/sdk-application-tutorial
@samalba
samalba / config.yml
Created November 18, 2013 22:55
Enabling LRU cache on docker-registry
dev:
# This assumes the Redis info are in environment variables
cache:
host: _env:REDIS_HOST
port: _env:REDIS_PORT
password: _env:REDIS_PASSWORD
@samalba
samalba / gist:6465780
Last active December 22, 2015 11:29
Run docker-registry tests in docker-ci
#!/bin/sh
# NOTE: Run from the docker-registry root directory
# Setup the environment
export SETTINGS_FLAVOR=test
export DOCKER_REGISTRY_CONFIG=config_test.yml
export DOCKER_CREDS=REPLACE:ME
export S3_ACCESS_KEY=REPLACEME
export S3_SECRET_KEY=REPLACEME
@samalba
samalba / tohex.py
Last active December 20, 2015 03:29
Convert a binary file into an array of bytes which can be inserted in a code
#!/usr/bin/env python
import sys
if __name__ == '__main__':
fname = sys.argv[1]
with open(fname) as f:
print '['
while True:
b = f.read(14)