Skip to content

Instantly share code, notes, and snippets.

View kdwinter's full-sized avatar

Kenneth De Winter kdwinter

  • Belgium
  • 08:26 (UTC +02:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kdwinter on github.
  • I am kdwinter (https://keybase.io/kdwinter) on keybase.
  • I have a public key whose fingerprint is 6B53 97C8 5A66 AA0F 4D4C F915 3C0E 8824 60A5 849A

To claim this, I am signing this object:

@kdwinter
kdwinter / Arch-ZFSRoot-on-dm-crypt-UEFI.md
Last active July 24, 2023 21:31 — forked from aaronlauterer/Arch-ZFSRoot-on-dm-crypt-UEFI
ZFSRoot installation over a dm-crypt volume for Arch Linux (UEFI)

Install Arch Linux on root ZFS filesystem

Pre-installation

Download Arch linux

https://archlinux.org

Create bootable USB (don't add partition number!)

Keybase proof

I hereby claim:

  • I am gigamo on github.
  • I am kdwinter (https://keybase.io/kdwinter) on keybase.
  • I have a public key whose fingerprint is 6B53 97C8 5A66 AA0F 4D4C F915 3C0E 8824 60A5 849A

To claim this, I am signing this object:

@kdwinter
kdwinter / define_method_vs_class_eval.rb
Created August 17, 2010 17:05
Some interesting Ruby benchmarks
require 'benchmark'
Benchmark.bm 20 do |x|
x.report "define_method" do
25_000.times do
class MyClass
define_method :foo do
puts 'hi'
end
end
@kdwinter
kdwinter / authenticable.rb
Last active September 5, 2015 05:45
Authlogic plugin for MongoMapper
module Authenticable
extend ActiveSupport::Concern
included do
key :username, String
key :email, String
key :crypted_password, String
key :password_salt, String
key :persistence_token, String
key :login_count, Integer, :default => 0
@kdwinter
kdwinter / authenticable.rb
Created June 14, 2010 21:52
Authlogic with Mongoid (in spirit of http://pastie.org/503478)
module Authenticable
def self.included(model)
model.class_eval do
extend ClassMethods
include InstanceMethods
field :username
field :email
field :crypted_password
field :password_salt
<% cache 'recent_pages' do %>
<% @pages.each do |page| %>
<%=h page.title %>
<%# ... %>
<% end %>
<% end %>
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
@kdwinter
kdwinter / partials.rb
Created December 20, 2009 10:50 — forked from lenary/partials.rb
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)