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
# The Rails Guide on Caching suggests to use ActionController#expire_fragment | |
# in a controller to expire a cached fragment | |
# (http://guides.rubyonrails.org/caching_with_rails.html#fragment-caching) | |
# | |
# Unfortunately, hooking into controllers is not easily possible in Rails Admin, | |
# why another strategy for expiring cached fragments must be used. | |
# | |
# The Rails Guide also describes how to use custom keys for caching. | |
# To implement caching in Rails Admin, maintain a custom key for each fragment | |
# in the cache. Whenever the model changes, use a callback to update the key. |
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
# Convert m4a (iTunes store) to flac using avconv. | |
ls *m4a | while read f; do avconv -i "$f" "${f/m4a/flac}"; done |
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
class Hash | |
def deep_traverse(&block) | |
stack = self.map{ |k,v| [ [k], v ] } | |
while not stack.empty? | |
key, value = stack.pop | |
yield(key, value) | |
if value.is_a? Hash | |
value.each{ |k,v| stack.push [ key.dup << k, v ] } | |
end | |
end |
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
# Reset the password of any user in Mac OS X 10.4. | |
# Boot into single user mode pressing and holding Ctrl + S after pressing the power button. | |
# When the root prompt appeats, do: | |
sh /etc/rc | |
passwd admin | |
reboot |
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
# Install Locomotive CMS's wagon and engine | |
# Ruby version used: ruby-2.1.1 [ i686 ] RVM | |
# Depends: mongo, imagemagick | |
# Wagon | |
# See http://doc.locomotivecms.com/get-started/install-wagon#linux | |
gem install locomotivecms_wagon | |
# Engine |
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
# https://no0p.github.io/postgresql/2014/03/29/upgrading-pg-ubuntu.html |
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
# Use lsleases (https://github.com/j-keck/lsleases) to detect the Raspberries IP address. | |
# Other suggested using ping and arp, both of which rely on the hostname of the Raspberry to display as 'raspberry'; | |
# depending on the network, the hostname may change; | |
# lsleases will still work. | |
$ sudo lsleases -s | |
2015/01/15 15:36:40 startup - version: 1.4.0 | |
2015/01/15 15:36:40 enable active check - ping every: 15m | |
# | |
# Reboot the Raspberry and wait |
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
# Use with `rails new -m https://gist.githubusercontent.com/sepastian/8d9bf523d3950d4c8a4d/raw/88fd29455af48f5d99569063a6239b5dcdac3d96/rails_4.2_default.rb -d postgresql` | |
require 'fileutils' | |
if Rails.version !~ /\A4\.2/ | |
puts "Required: Rails 4.2.x; found: Rails #{Rails.version}." | |
puts "$ bundle update rails" | |
exit 2 | |
end |
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
# Run a Ruby script every minute. | |
# Use the Ruby provided by rbenv. | |
# | |
# Edit with crontab -e. | |
*/1 * * * * /bin/bash -c 'export PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:"$PATH"; eval "$(rbenv init -)"; cd $HOME/path/to/script/; ruby ./graph.rb > /output/path/index.html' |
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
### Keybase proof | |
I hereby claim: | |
* I am sepastian on github. | |
* I am sepastian (https://keybase.io/sepastian) on keybase. | |
* I have a public key whose fingerprint is 214D 35E9 65E8 6DDF AFE4 F388 03AB E849 A825 7946 | |
To claim this, I am signing this object: |