Skip to content

Instantly share code, notes, and snippets.

View deric's full-sized avatar

Tomas Barton deric

  • Prague, Czech Republic
View GitHub Profile
@deric
deric / init.d_graphite-api.sh
Last active August 29, 2015 14:03
graphite-api init.d script debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: graphite-api
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: graphite api init script
# Description: An init script for Graphite's API daemon.
### END INIT INFO
@deric
deric / gist:700489
Created November 15, 2010 15:44
overriding ubiquo routes
map.namespace :ubiquo do |ubiquo|
ubiquo.with_options :path_prefix => 'admin' do |admin|
admin.resources :articles
end
end
@deric
deric / birthday_number_validator.rb
Last active December 12, 2015 09:49
Validace rodného čísla v Ruby on Rails 3
# encoding: utf-8
require 'date'
# Validation of Czech (Slovak) birth number
class BirthNumberValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value
RC_FORMAT = Regexp.compile /^\s*(\d\d)(\d\d)(\d\d)[ -\/]*(\d\d\d)(\d?)\s*$/
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
class apt::repo {
# Base Directory shortcut
$basedir = '/var/www/apt/repo'
# Main reprepro class
class { 'reprepro':
basedir => $basedir,
}
@deric
deric / slides.md
Created September 27, 2013 09:54
Simple presentation generated by pandoc `pandoc -t beamer slides.md -o demo.pdf`

% Eating Habits % John Doe % September, 27 2013

In the morning

  • Eat eggs
  • Drink coffee

In the evening

Debug: /Stage[main]/Accounts::Groups/require: requires Class[Accounts::Users]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/User[john]/require: requires Anchor[accounts::user::groups::john]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/File[/home/john/.ssh]/require: requires File[/home/john]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/File[/home/john/.ssh]/before: requires File[/home/john/.ssh/authorized_keys]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/Group[john]/before: requires Anchor[accounts::user::groups::john]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/Ssh_authorized_key[john_ssh-rsa]/require: requires File[/home/john/.ssh/authorized_keys]
Debug: /Stage[main]/Accounts::Users/Accounts::User[john]/File[/home/john/.ssh]: Autorequiring
#!/bin/sh
puppet module install deric-accounts
mkdir -p /etc/puppet/hieradata
cat <<EOF > /etc/puppet/hiera.yaml
---
:backends:
- yaml
:hierarchy:
- common
#!/bin/sh
puppet module install deric-accounts
mkdir -p /etc/puppet/hieradata
cat <<EOF > /etc/puppet/hiera.yaml
---
:backends:
- yaml
:hierarchy:
- common
:yaml:
#!/bin/sh
puppet module install deric-accounts
mkdir -p /etc/puppet/hieradata
cat <<EOF > /etc/puppet/hiera.yaml
---
:backends:
- yaml
:hierarchy:
- common
:yaml:
@deric
deric / ip-detect
Created July 22, 2017 16:34
DC/OS ip-detect script for "deterministic network interfaces naming"
#!/usr/bin/env bash
set -o nounset -o errexit
export PATH=/usr/sbin:/usr/bin:$PATH
function msg { out "$*" >&1 ;}
function out { printf '%s\n' "$*" ;}
function showint {
msg $(ip addr show $1 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
}