Skip to content

Instantly share code, notes, and snippets.

View kballenegger's full-sized avatar

Kenneth Ballenegger kballenegger

View GitHub Profile
@kballenegger
kballenegger / screenshot-uploader.rb
Created August 4, 2014 05:59
Screenshot uploader script.
require 'cgi'
require 'terminal-notifier'
f = ARGV.first
fn = f.split('/').last
system("scp '#{f}' 'azure:/home/kenneth/www/akhun.com/public/seo/skitch/#{fn.gsub(' ', '\ ')}'")
system("mv '#{f}' '#{File.expand_path('~/.Trash/')}/'")
system("echo 'http://akhun.com/seo/skitch/#{CGI.escape(fn).gsub('+', '%20')}' | pbcopy")
@kballenegger
kballenegger / alexis.rb
Created August 4, 2014 05:21
Scout plugin.
#!/usr/bin/env ruby
require 'scout_api'
group_name = ARGV[0]
Scout::Account.new('chartboost', 'kenneth@chartboost.com', '...')
all_servers = Scout::Server.all(group_name: 'API')
@kballenegger
kballenegger / broker.clj
Created July 30, 2014 16:48
ZMQ message broker
(ns cb.broker
(:require clojure.pprint
clojure.stacktrace)
(:use [org.zeromq.clojure :as zmq]
[clojure.tools.cli :as cli]
[clj-yaml.core :as yaml])
(:import com.surftools.BeanstalkClient.Client
com.surftools.BeanstalkClientImpl.ClientImpl)
(:gen-class))
@kballenegger
kballenegger / web-app.1.service
Last active September 23, 2015 01:19
web-app.1.service
[Unit]
Description=web-app
After=init.kballenegger.service
Requires=init.kballenegger.service
[Service]
Environment=HOME=/root
TimeoutStartSec=0
ExecStartPre=/bin/bash /repos/services/web-app/init.sh 1 pre-start
ExecStart=/bin/bash /repos/services/web-app/init.sh 1 start
@kballenegger
kballenegger / Makefile
Created June 20, 2014 01:49
make build rules
# NOTE: There are two root files which are the entrypoints to compilation for
# both JavaScript and CSS. Those files are:
#
# src/js/app.{js,wisp,jsx}
# src/style/style.scss
# Tools
SHELL := /bin/bash
JSX ?= jsx
(React.renderComponent
(dom div {:id "one" :class "two"}
(dom span {:style {:color :red, :font-weight :bold}} "HELLO ")
(dom span {:style {:color :blue}} "WORLD ")
"ola"
)
(document.getElementById "app"))
@kballenegger
kballenegger / cloud-config.yml
Last active October 22, 2015 01:34
Cloud-config sample.
#cloud-config
# convert this file into json like this:
# cat file | ruby -ne 'puts " \"#{$_.gsub("\n","").gsub("\\","\\\\").gsub("\"","\\\"")}\\n\","'
coreos:
etcd:
discovery: https://discovery.etcd.io/...
# multi-region and multi-cloud deployments need to use $public_ipv4
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
@kballenegger
kballenegger / crypto.rb
Last active December 3, 2015 04:49
AES encryption wrapper
require 'openssl'
module SomeNamespace
# This module abstracts away the crypto implementation. Internally, it uses
# the AES cipher, with a length of 256, in CTR mode.
#
# The ciphertext and key are Base64 encoded strings. The plaintexts are not
# encoded.
#
@kballenegger
kballenegger / api-internal.1.service
Last active September 23, 2015 01:19
Systemd config mess.
[Unit]
Description=API Internal
After=docker.service
Requires=docker.service
[Service]
ExecStartPre=/bin/bash /repos/services/api-internal/init.sh pre-start
ExecStart=/bin/bash /repos/services/api-internal/init.sh start
@kballenegger
kballenegger / Vagrantfile
Created May 9, 2014 19:19
Vagrant+Docker networking problems.
# The two above specifies which version of the vagrant API is used.
Vagrant.configure('2') do |config|
# This is a hack around the networking slowness in the VM.
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
vb.customize ['modifyvm', :id, '--natpf1', 'app,tcp,,9977,,9977']
end