Skip to content

Instantly share code, notes, and snippets.

View kakra's full-sized avatar
🏠
Let's inject fun into Linux Gaming

Kai Krakow kakra

🏠
Let's inject fun into Linux Gaming
View GitHub Profile
@kakra
kakra / filter_payment_methods.rb
Created October 14, 2010 22:10
Filter payment methods in Spree depending on the shipping name
# Filter payment methods in Spree depending on the shipping name,
# use the following snippet within your activation method to
# make it work:
#
# CheckoutsController.class_eval { include FilterPaymentMethods }
#
# The magic happens within the InstanceMethods module, change the
# regexp to fit your needs.
#
# Kai Krakow, http://github.com/kakra
@kakra
kakra / associate_by.rb
Created October 15, 2010 17:29
Associates models to a parent by other methods, similar to delegates
# AssociateBy
#
# Associates models to a parent by other methods, similar to delegates but
# changing the association itself instead of the associated object when
# writing to the delegated attribute.
#
# Usage:
# ActiveRecord::Base.class_eval { include AssociateBy }
#
# Example:
@kakra
kakra / gist:1085054
Created July 15, 2011 16:49
PHP Stand-Alone Server based on LigHTTPd
#!/bin/bash
TMPNAME=$(mktemp /tmp/lighttpd-fastcgi-php-XXXXXX)
cat >$TMPNAME.conf <<-EOF
server.bind = "localhost"
server.port = "3000"
server.document-root = "$(pwd)"
server.indexfiles = ("index.php", "index.html", "index.htm", "default.htm")
server.modules += ("mod_cgi", "mod_accesslog")
@kakra
kakra / php-server.sh
Created August 15, 2011 09:07 — forked from kakra/gist:1085054
PHP Stand-Alone Server based on LigHTTPd
#!/bin/bash
TMPNAME=$(mktemp /tmp/lighttpd-cgi-php-XXXXXX)
if [ -d "www" ]; then
DOCROOT=$(pwd)/www
else
DOCROOT=$(pwd)
fi
@kakra
kakra / defrag-preloaded.rb
Last active December 17, 2015 00:19
A very basic ruby script for defragmenting files on btrfs loaded by preload daemon
#!/bin/env ruby
#
# basic concept script for defragmenting files on btrfs loaded by preload daemon
#
# Actually, this idea is working in the spirit of systemd's readahead function which
# can defrag (and relocate?) files on btrfs during boot. Preload takes on where
# readahead stops working, so it should be a great place to continue integrating that
# idea there. This script is actually here, to test the impact of such an idea and
# find first caveats and show-stoppers.
#
@kakra
kakra / usb-backup.service
Last active April 2, 2016 20:15
Simple script for creating space-efficient backups to btrfs using rsync and snapshots
# Call the backup script with systemd, and since it is a background service, treat it like that by lowering IO and CPU priority
# so it will work in the background without disturbing your normal workflow.
#
# Author: Kai Krakow <[email protected]>
# License: GPL3
[Unit]
Description=USB Backup Service
[Service]
@kakra
kakra / helper_proxy.rb
Created May 21, 2014 12:23
Snippet of a Rails helper proxy to make helpers available from anywhere without polluting namespace
# use helpers from models or any part of your app (you shouldn't do that, however...)
# ... put in config/initializers
#
# class MyModel < ActiveRecord::Base
# def some_attribute
# HelperProxy.instance.number_format some_value, precision: 4
# end
# end
class HelperProxy
@kakra
kakra / disable-overlay-scrollbars.css
Created November 14, 2016 21:13
Chrome Stylish extension: useful user styles
@-moz-document domain("autotask.net") {
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
visibility: hidden;
}
@kakra
kakra / 20-natural-scrolling.conf
Created April 21, 2017 17:00
xorg.conf.d/20-natural-scrolling.conf
Section "InputClass"
Identifier "Enable natural scrolling by default"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
MatchDriver "libinput"
Option "NaturalScrolling" "on"
EndSection
#!/bin/bash -e
COMMIT=${1:-HEAD}
VERSIONS=$(git tag --list --sort -v:refname --no-contains ${COMMIT})
SINCE=$(head -1 <<<${VERSIONS})
SINCE=${SINCE:-$(git rev-list --max-parents=0 HEAD)}
cat <<-SUBJECT
Changes since ${SINCE} up to ${COMMIT}