Skip to content

Instantly share code, notes, and snippets.

View c4urself's full-sized avatar

Christian Verkerk c4urself

  • Tubular Labs
  • Mountain View
View GitHub Profile
@c4urself
c4urself / simple_logging.js
Last active December 13, 2015 19:38
Simple logging utility for JS, takes IE's lack of console into account as well as difference in browser abilities with regard to console.info, console.warn and console.error.
app = {
DEBUG: true,
VERSION: '1.0.0'
};
app.logs = app.logs || { info: [], error: [], warn: [] };
app.logger = app.logger || {
log: function () {
var type = arguments[0],
msg = arguments[1],
@c4urself
c4urself / ui_install_guide.sh
Last active December 14, 2015 09:50
UI Install steps
# Current version: 0.8.4
scp beehive:~jeremy/nimbula-ui/nimbula-ui-X.X.X.zip
unzip nimbula-ui-X.X.X.zip
cd nimbula-ui
./nimbula-ui-installer.py -ahttps://api.usdev290.nimbula -u/root/root
# Visit https://10.33.19.10 ... replace with your IP
package main
import (
"os"
)
func main() {
w := os.Args[1]
print(string(w[0]))
print(len(w))
println(string(w[len(w) - 1]))
@c4urself
c4urself / subprocess_capture_stderr.py
Last active February 23, 2016 05:20
Test out subprocess
import subprocess
# http://stackoverflow.com/questions/18774476/subprocess-call-logger-info-and-error-for-stdout-and-stderr-respectively
# http://stackoverflow.com/questions/21953835/run-subprocess-and-print-output-to-logging
def my_buddy_popen():
"""
Since only stderr is bound, we only get a value for stderr. if this was a good call (exit 0)
then out _would_ exist and sent to parent's and _not_ be in `out`.

strace up to 1kb with -f to follow children

strace -s 1024 -f <cmd>

@c4urself
c4urself / toptip3.md
Created May 24, 2016 15:33
time drift issue between vagrant/virtual box

Discovered a time drift issue between the vagrant/virtualbox vm and the host:

root@82879b06345b:/opt/tubular/s3debbie# telnet s3.amazonaws.com 80 Trying 54.231.16.136... Connected to s3-1.amazonaws.com. Escape character is '^]'. GET / HTTP/1.1

HTTP/1.1 400 Bad Request Transfer-Encoding: chunked

@c4urself
c4urself / tagging_instances.tf
Created June 8, 2016 17:50
How to dynamically tag instance via a module in Terraform?
variable "ami_id" { }
variable "subnet_id" { }
variable "security_group_id" { }
variable "key_name" { }
variable "instance_profile" { }
variable "instance_type" { }
variable "instance_name" { }
variable "hostname" { }
variable "tag_role" { }
variable "tag_cost_environment" { }
PULL=$( echo $BRANCH | awk -F/ '{ print $3 }' )
html_url=https://api.github.com/repos/Tubular/$PROJECT/pulls/$PULL/commits
LINK=https://github.com/Tubular/$PROJECT/pull/$PULL
USER=$(curl $html_url?access_token=$GITHUB_TOKEN | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[0]["commit"]["author"]["name"]')
curl -H "Content-Type: application/json" -d "{\"fallback\": \"Jenkins Pull-Request Publisher\", \"channel\": \"#deploys\", \"icon_emoji\": \":vertical_traffic_light:\", \"color\": \"#f2144b\", \"fields\": [{\"title\": \"$USER updated a pull-request in $PROJECT\", \"value\": \"<$LINK|$LINK>\", \"short\": false}]}" https://tubular.slack.com/services/hooks/incoming-webhook?token=$SLACK_TOKEN

Keybase proof

I hereby claim:

  • I am c4urself on github.
  • I am c4urself (https://keybase.io/c4urself) on keybase.
  • I have a public key ASBaqM5prpaQZAoTI4cL1wNlBEMYaRPAHyenuaahYJRxpAo

To claim this, I am signing this object:

@c4urself
c4urself / terraform.sh
Created September 28, 2016 20:50
Wrapper around Terraform
#!/bin/sh
set -e
TERRAFORM_BUCKET_REGION='us-east-1'
TERRAFORM_BUCKET_NAME=''
TERRAFORM_VERSION="0.7.4"
actions="plan apply fmt plan-destroy destroy refresh graph validate"