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 / rserve.init.d
Created March 7, 2016 10:57
rserve init.d file
#!/bin/bash
### BEGIN INIT INFO
# Provides: rserve
# 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: Startup script for RServe
# Description: Rserve is a server for execution of R code
### END INIT INFO
@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 / 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

class apt::repo {
# Base Directory shortcut
$basedir = '/var/www/apt/repo'
# Main reprepro class
class { 'reprepro':
basedir => $basedir,
}
require 'benchmark'
require 'set'
n = 100000
bench = {}
set = Set.new
array = Array.new
rand= Random.new
@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
@deric
deric / producer-consumer.rb
Created October 27, 2012 12:28
Producer-consumer in Ruby
require 'monitor'
queue = []
queue.extend(MonitorMixin)
cond = queue.new_cond
consumers, producers = [], []
for i in 0..5
consumers << Thread.start(i) do |i|
print "consumer start #{i}\n"
@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