Skip to content

Instantly share code, notes, and snippets.

View zeisss's full-sized avatar
🍪
Eat More Chocolate Cookies!

Stephan zeisss

🍪
Eat More Chocolate Cookies!
View GitHub Profile
// parallel performs the given actions with `n` actions in parallel.
// Make `n == len(actions)` to perform all actions in parallel.
//
// Arguments
// actions - The functions you want to execute. Error results will be reported to the errors channel.
// n - the number of parallel actions to execute in maximum. Must be positive.
// errors - Optional channel to report errors back to. Will be closed.
// cancel - Optional channel to signal abortion of processing.
func parallel(actions []func() error, n int, errors chan<- error, cancel <-chan struct{}) {
if len(actions) == 0 {
@zeisss
zeisss / parse.js
Last active August 29, 2015 14:07
Transform the state in a etcd snapshot into a etcd-dump compatible json file
var fs = require('fs');
function visit(node, state) {
// console.log('visit', node.Path);
if (node.Value == "") {
return;
}
state.push({
key: node.Path,
@zeisss
zeisss / randhex.go
Created September 13, 2014 23:19
Random hex formatted string generator.
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
"flag"
)
@zeisss
zeisss / service1a.service
Last active August 29, 2015 14:04
Scheduling bug in fleet/systemd for a failover
[Unit]
Description=S1
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'sleep 30; echo OK'
[X-Fleet]
X-ConditionMachineOf=service2.service
@zeisss
zeisss / main.go
Last active August 29, 2015 13:57
Alternative design to specify name/group/... for goHystrix
package main
import (
"fmt"
goHystrix "github.com/ZeissS/goHystrix"
)
type DeleteTransactionCommand struct {
TransactionId string
}
$ ./etcd -v -f -data-dir /var/lib/etcd -bind-addr 0.0.0.0 -addr 192.168.53.2:4001 -peer-addr 192.168.53.2:7001 -peer-bind-addr 0.0.0.0 -discovery https://discovery.etcd.io/86bf5ce860eef35b94f9f616fb55964f -name dockzero-01
[etcd] Mar 10 10:19:40.979 DEBUG | open /var/lib/etcd/snapshot: permission denied
[etcd] Mar 10 10:19:40.982 INFO | Discovery via https://discovery.etcd.io using prefix /86bf5ce860eef35b94f9f616fb55964f.
[etcd] Mar 10 10:19:42.081 INFO | Discovery _state was empty, so this machine is the initial leader.
[etcd] Mar 10 10:19:42.081 INFO | Discovery fetched back peer list: []
[etcd] Mar 10 10:19:42.081 DEBUG | This peer is starting a brand new cluster based on discover URL.
@zeisss
zeisss / update_somafm_playlists.sh
Last active December 26, 2015 11:19
Updates somafm m3u playlists files in the current folder
#!/bin/sh
# Create the interested streams by touching:
# $ touch somafm_groovesalad.m3u
# $ touch somafm_covers.m3u
for x in somafm_*.m3u
do
PLAYLIST_FILE=$x
STREAM=$(echo $PLAYLIST_FILE | sed -e 's/^somafm_//' -e 's/\.m3u$//')
echo Checking $STREAM
type Args struct {
Values []string `json:values`
}
type Service int
// {"id": 1, "method": "echo2.Echo2", "params": {"values": ["hello", "world"]}}
func (this *Service) Echo2(params *Args, response *string) error {
*response = "Hello World"
return nil
// {"id": 1, "method": "echo2.Echo", "params": ["hello", "world"]}
package main
import (
"log"
"fmt"
"net"
"net/rpc"
"net/rpc/jsonrpc"
)
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box"
AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9"
FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']