Skip to content

Instantly share code, notes, and snippets.

@bakins
bakins / nginx.init
Last active December 15, 2015 04:09
Simple nginx init script for ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
local _M = {}
local cjson = require "cjson"
local mysql = require "resty.mysql"
local math = require "math"
local encode = cjson.encode
local random = math.random
local insert = table.insert
@bakins
bakins / Rockfile
Last active December 16, 2015 00:39
rock https://raw.github.com/Neopallium/lua-pb/master/lua-pb-scm-0.rockspec
rock git https://github.com/bakins/lua-resty-riak refactor
@bakins
bakins / gist:5503176
Last active December 16, 2015 21:58
Horrible node.js "omnibus"
#!/bin/bash
#some defaults
PROJECT_VERSION=0.1.0
NODE_VERSION=0.10.5
PROJECT=$(basename $(pwd))
if [ -r .node_version ]; then
. .node_version
fi
desc "Generate jekyll site"
task :generate do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
puts "## Generating Site with Jekyll"
system "bundle exec compass compile --css-dir #{source_dir}/stylesheets"
system "bundle exec jekyll"
Find.find "public" do |path|
if FileTest.file?(path) and path.match(/\.(css|js|html|xml|txt)$/)
system "gzip -c #{path} > #{path}.gz"
user www www;
worker_processes 1;
worker_rlimit_nofile 8256;
events {
worker_connections 8192;
}
http {
#!/usr/bin/bash
if [[ ! -f /root/.ssh/authorized_keys ]]; then
authorized_keys=$(/usr/sbin/mdata-get root_authorized_keys)
if [[ -n ${authorized_keys} ]]; then
mkdir -p /root/.ssh
echo -e "${authorized_keys}" > /root/.ssh/authorized_keys
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
fi
require "ridley"
require "multi_json"
require 'pp'
require 'chef_zero/server'
plan = MultiJson.load(IO.read(ARGV[0]))
#pp plan
environment = {
@bakins
bakins / gist:6130279
Created August 1, 2013 10:40
doodling on "container" log forwarding.
#!/bin/bash
# should be /etc/sv/my-awesome-containerized-app/log/run
# create a lumberjack ( https://github.com/jordansissel/lumberjack ) config like
#
# {
# ..put serevr stuff here...
# "files": [
# {
# "paths": [ "-" ],
# "fields": { "type": "stdin" }
@bakins
bakins / gist:6130281
Last active December 20, 2015 12:19
doodling on "container" log forwarding.
#!/bin/bash
# should be /etc/sv/my-awesome-containerized-app/log/run
# create a lumberjack ( https://github.com/jordansissel/lumberjack ) config like
#
# {
# ..put server stuff here...
# "files": [
# {
# "paths": [ "-" ],
# "fields": { "type": "stdin" }