Skip to content

Instantly share code, notes, and snippets.

@nistude
nistude / category_list.rb
Created August 14, 2011 09:05
A category list tag for jekyll
# place this file in your plugins directory and add the tag to your sidebar
#$ cat source/_includes/custom/asides/categories.html
#<section>
# <h1>Categories</h1>
# <ul id="categories">
# {% category_list %}
# </ul>
#</section>
module Jekyll
@nistude
nistude / pomodoro.lua
Created August 19, 2011 14:30
Pomodoro Timer Widget for the Awesome Window Manager
-- pomodoro timer widget
pomodoro = {}
-- tweak these values in seconds to your liking
pomodoro.pause_duration = 300
pomodoro.work_duration = 1200
pomodoro.pause_title = "Pause finished."
pomodoro.pause_text = "Get back to work!"
pomodoro.work_title = "Pomodoro finished."
pomodoro.work_text = "Time for a pause!"
@nistude
nistude / exported_resources.feature
Created September 4, 2011 12:04
Storeconfigs setup for cucumber-puppet
Feature: storeconfigs
Scenario: export resource
Given a node of class "exporting"
When I compile its catalog
Then it should export a resource "File[foo]"
Scenario: collect resource
Given a node of class "collecting"
And an exported resource "File[bar]"
@nistude
nistude / gist:1397967
Created November 27, 2011 18:44
double('Foo') vs. Demeter's Law
# in Rails
class BarCollection
def initialize
@bars = [Bar.new, Bar.new]
end
def get_bars
@bars
end
end
@nistude
nistude / database.tddium.yml
Created February 8, 2012 06:45
minimal tddium setup for multiple database connections
foo: &foo
adapter: <%= ENV['TDDIUM_DB_ADAPTER'] %>
database: <%= ENV['TDDIUM_DB_NAME'] %>
username: <%= ENV['TDDIUM_DB_USER'] %>
password: <%= ENV['TDDIUM_DB_PASSWORD'] %>
<%= "socket: #{ENV['TDDIUM_DB_SOCKET']}" if ENV['TDDIUM_DB_SOCKET'] %>
development: &development
adapter: <%= ENV['TDDIUM_DB_ADAPTER'] %>
database: <%= ENV['TDDIUM_DB_NAME'] %>
@nistude
nistude / custom_server.rb
Created March 4, 2012 13:47
An example of recipe composition
include_recipe "sample_app::_group"
include_recipe "sample_app::_user"
include_recipe "apt::add_company_repository"
include_recipe "sample_app::_server_install_from_package"
include_recipe "sample_app::_server_runit"
include_recipe "sample_app::_server_config"
@nistude
nistude / prime_factors_2_spec.rb
Created July 4, 2012 05:14 — forked from shostakovich/prime_factors_2_spec.rb
PrimeFactors Kata Second iteration
module PrimeFactors
def decompose(number)
if number <= 3
[number]
else
prime_factors = []
(2..number / 2).each do |prime|
while(number % prime).zero? do
number = number / prime
prime_factors << prime
@nistude
nistude / 1-without_callbacks.rb
Created November 28, 2012 17:15
Callback example
# uses exception-throwing !-methods in lower level code to communicate errors
class ApiController < ApplicationController
def update
publisher = PublishingService.new
publisher.update(params[:article], params[:author])
render_success
rescue => e
render_failure("Failed to publish article: #{e.message}")
end
@nistude
nistude / .kitchen.yml
Last active April 19, 2016 15:03
Sample configuration files for a test-kitchen setup based on vagrant-lxc and chef-zero.
---
driver_plugin: vagrant
provisioner: chef_zero
driver_config:
require_chef_omnibus: 11.6.0
http_proxy: http://10.0.3.1:8123
https_proxy: https://10.0.3.1:8123
provider: lxc
platforms: