This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMPNAME=$(mktemp /tmp/lighttpd-cgi-php-XXXXXX) | |
if [ -d "www" ]; then | |
DOCROOT=$(pwd)/www | |
else | |
DOCROOT=$(pwd) | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
# | |
# This does something similar as | |
# | |
# $ find <path> -type f -print0 | xargs -0 md5sum | sort | uniq --all-repeated=separate -w32 | |
# | |
# but dumps a collection of ln command lines to execute. | |
require 'md5' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tableless ActiveRecord models | |
# http://stackoverflow.com/questions/315850/rails-model-without-database/318919#318919 | |
class Tableless < ActiveRecord::Base | |
def self.columns | |
@columns ||= []; | |
end | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#slide-images { | |
position: relative; | |
display: block; | |
margin: 0px; | |
padding: 0px; | |
width: 738px; | |
height: 234px | |
overflow: hidden; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Delayed | |
class Job < ActiveRecord::Base | |
def self.db_time_now | |
(ActiveRecord::Base.default_timezone == :utc) ? Time.now.utc : Time.zone.now | |
rescue NoMethodError | |
Time.now | |
end | |
end |