Skip to content

Instantly share code, notes, and snippets.

@kiela
kiela / ZFS_geli_freebsd
Last active January 26, 2022 16:00
Simple HOWTO of creation an encrypted ZFS pool under FreeBSD using geli + 256-bit AES-XTS encryption + a 4 kb random data partial key and a secondary passphrase (required to type on each boot).
root@rizzo ~$ uname -a
FreeBSD rizzo.heimdall.pl 9.1-RELEASE FreeBSD 9.1-RELEASE #0: Wed Mar 13 21:02:32 CET 2013 [email protected]:/sys/amd64/compile/rizzo amd64
root@rizzo ~$ kldload opensolaris
root@rizzo ~$ kldload zfs
root@rizzo ~$ kldload geom_eli
root@rizzo ~$ gpart destroy -F da0
da0 destroyed
root@rizzo ~$ gpart create -s gpt da0
da0 created
root@rizzo ~$ gpart add -t freebsd-zfs -a 4096 da0
@kiela
kiela / ubuntu_12.04_notifyosdconfiguration
Last active December 15, 2015 10:09
HOWTO install notify osd configuration tool on Ubuntu 12.04 LTS
kiela@rico ~$ uname -a
Linux rico 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
kiela@rico ~$ sudo add-apt-repository ppa:leolik/leolik
kiela@rico ~$ sudo apt-get update
kiela@rico ~$ sudo apt-get upgrade
kiela@rico ~$ sudo apt-get install libnotify-bin
kiela@rico ~$ pkill notify-osd
kiela@rico ~$ sudo add-apt-repository ppa:nilarimogard/webupd8
kiela@rico ~$ sudo apt-get update
kiela@rico ~$ sudo apt-get install notifyosdconfig
@kiela
kiela / active_record_extension.rb
Created April 8, 2013 13:47
Some ActiveRecord extensions which are helpful for me in a couple of projects
module ActiveRecordExtension
extend ActiveSupport::Concern
module ClassMethods
def from_current(period, options = { column: 'created_at' })
raise "Invalid options in #{self.to_s}\##{__method__.to_s}" unless [:year, :quarter, :month, :week, :day].include? period
start_method = "beginning_of_#{period.to_s}"
end_method = "end_of_#{period.to_s}"
@kiela
kiela / zfs
Last active October 21, 2022 16:10
HOWTO: Hetzner + FreeBSD 13.1 + mirrored root on ZFS + optimized for 4K drives
# Wipe out disks from whatever they contain.
root@mfsbsd:~ # dd if=/dev/zero of=/dev/nvd0 bs=1M status=progress
dd: /dev/nvd0: short write on character devicesferred 1186.001s, 3237 MB/s
dd: /dev/nvd0: end of device
3662831+0 records in
3662830+1 records out
3840755982336 bytes transferred in 1186.555877 secs (3236894322 bytes/sec)
root@mfsbsd:~ # dd if=/dev/zero of=/dev/nvd1 bs=1M status=progress
dd: /dev/nvd1: short write on character devicesferred 1187.004s, 3233 MB/s
# validator
class UnchangeableValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
if !object.new_record? && value.present?
original = object.class.send(:where, "id = #{object.id}").select("id, #{attribute.to_s}").first
if original.send(attribute) != value
object.errors[attribute] << (options[:message] || "cannot be changed once assigned")
end
end
end
@kiela
kiela / commit-msg
Last active December 31, 2015 13:29
Add branch name at the beginning of commit message if branch name starts with WEB or OP or SEC or FM
#!/bin/sh
branch=$(git symbolic-ref HEAD | awk -F/ '{ if($3 ~ /^(WEB|OP|DEVOPS|SEC|FM|PS|DAT|AD)-[[:digit:]]/) print $3 }' | awk -F"_" '{ if($1) print $1 }')
if [ -n "$branch" ]; then
sed -i "1 s/^/$branch: /" $1
sed -i '/'$branch\:'/a \\nIssue: https://acorns.atlassian.net/browse/'$branch $1
fi

Keybase proof

I hereby claim:

  • I am kiela on github.
  • I am kamilkieliszczyk (https://keybase.io/kamilkieliszczyk) on keybase.
  • I have a public key whose fingerprint is E0AB 45B1 CB04 F2D4 E98F 2F41 4194 4F7D 0010 B692

To claim this, I am signing this object: