Skip to content

Instantly share code, notes, and snippets.

View ijonas's full-sized avatar

Ijonas Kisselbach ijonas

View GitHub Profile
@ijonas
ijonas / logrotateconf
Created December 1, 2014 09:57
Quick & dirty Ruby script to generate a whole bunch of logrotate conf files.
#! /usr/bin/env ruby
# license: MIT
# example usage: ./logrotateconf $PWD/newrelic_agent.log > newrelic_agent
conf = <<-eos
{
rotate 14
daily
missingok
create 640 ubuntu ubuntu
notifempty
@ijonas
ijonas / keybase.md
Created September 17, 2014 14:47
keybase.md

Keybase proof

I hereby claim:

  • I am ijonas on github.
  • I am ijonas (https://keybase.io/ijonas) on keybase.
  • I have a public key whose fingerprint is DE26 F284 D61B 9703 78D7 B94C E3AC 4853 1526 EB62

To claim this, I am signing this object:

@ijonas
ijonas / gist:896e35cb6d0be921decb
Created July 30, 2014 16:17
Not using default scope
class Product < ActiveRecord::Base
validates :title, :description, :image_url, :presence=> true
validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
validates :title, :uniqueness => true
validates :image_url, format: {
:with => %r{\.(gif|jpg|png)\Z}i,
:message => 'must be a url'
}
def ordered_by_title
@ijonas
ijonas / Vagrantfile
Created April 28, 2014 11:04
CBStack Configuration Files
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "opscode/ubuntu1404"
config.vm.network "forwarded_port", guest: 80, host: 8090
config.vm.network "forwarded_port", guest: 3306, host: 3306
config.vm.network "forwarded_port", guest: 9200, host: 9200
@ijonas
ijonas / speedtest.go
Created April 9, 2014 05:47
Go / Node / Ruby Speed comparison
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
r := rand.New(rand.NewSource(99))
@ijonas
ijonas / gist:9719722
Last active August 29, 2015 13:57
Reading in a config file.
if configBytes, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", os.Getenv("HOME"), ".ddknife")); err == nil {
for _, row := range strings.Split(string(configBytes), "\n") {
if tuple := strings.Split(row, "="); len(tuple) == 2 {
configFileSettings[tuple[0]] = tuple[1]
}
}
}
@ijonas
ijonas / gist:7766492
Created December 3, 2013 09:23
DiDate Docker Install Steps
# after launching an Ubuntu 12.04 instance and ssh-ing into the VM
apt-get update
apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
reboot
# ssh-ing back into the VM
sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sh -c "echo deb http://get.docker.io/ubuntu docker main /etc/apt/sources.list.d/docker.list"
apt-get update
apt-get install lxc-docker
@ijonas
ijonas / gist:7100217
Last active December 26, 2015 05:19
kisselbug - when you get your if-condition the wrong way round.... As epitomised almost daily by the Great Indigenous Ijonous as he traversed the frozen wastelands of Software Development.
class Kisselbugger
def something_that_evaluates_to_true
# ...
end
def decide_and_do_something
# several hours of looking at line 9 results in a: "AArgh, ya wee bugger. Not again!"
if not something_that_evaluates_to_true
do_the_true_response
@ijonas
ijonas / Dockerfile
Last active December 25, 2015 10:19
MySQL Docker Files
# MySQL service
#
# Version 0.0.1
FROM ubuntu
MAINTAINER support@caseblocks
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
@ijonas
ijonas / Dockerfile
Last active December 24, 2015 18:39
Basic MongoDB config file and Dockerfile used by caseblocks/mongodb MongoDB container.
# MongoDB
#
# VERSION 0.0.1
#
# requires mongodb.conf @ https://gist.github.com/ijonas/6844358
FROM ubuntu
MAINTAINER support@caseblocks.com
# make sure the package repository is up to date