Skip to content

Instantly share code, notes, and snippets.

View kaeff's full-sized avatar

Klaus Fl kaeff

View GitHub Profile
@kaeff
kaeff / gist:31a9b5b8e7f5945ace8c
Created January 15, 2015 19:47
Mean time to segfault
➜ ~ crystal eval '3.times { |n| puts n}'
0
1
2
➜ ~ crystal eval '2..3.times { |n| puts n}'
0
1
2
➜ ~ crystal eval '2...times { |n| puts n}'
/usr/local/bin/crystal: line 6: 80376 Segmentation fault: 11 "$INSTALL_DIR/embedded/bin/crystal" "$@"
@kaeff
kaeff / Gruntfile.js
Created October 12, 2014 19:47
Grunt task to deploy a static app to GitHub Pages
module.exports = function (grunt) {
grunt.initConfig({
packageJson: require('./package.json'),
shell: {
deploy: {
command: [
'git show head "--format=oneline" | head -n 1 > .git/commitmsg',
@kaeff
kaeff / readability_deleter.js
Created December 3, 2013 10:06
UserScript for deleting readability entries from Amazon's Kindle Personal Document settings UI
var ReadabilityDeleter = function () {
var readabilityColumnOnly = function(el) {
return el.innerHTML.indexOf("@readability.com") > 0;
};
var queryReadabilityRows = function () {
var candidates = document.querySelectorAll("#orderList td.greyed");
return Array.prototype.slice.call(candidates).filter(readabilityColumnOnly);
};
module RentARoleModel
class Application < Rails::Application
config.action_mailer.default_options = { from: "rent-a-role-model@kaeff.net" }
end
end
@kaeff
kaeff / .vimrc
Last active December 22, 2015 08:48
JSON prettyfying, requires NodeJS. I use from VIM in combination with the vim-json plugin for syntax highlighting and extra sweetness. See https://github.com/elzr/vim-json
" Settings for vim-json
au! BufRead,BufNewFile *.json set filetype=json
au FileType json setlocal foldmethod=syntax
" Use jsonpp for auto-indendting
au FileType json setlocal equalprg=jsonpp\ -
@kaeff
kaeff / Guardfile
Last active December 17, 2015 15:59
Spork, Guard Test Setup for Rails
guard 'rspec', cli: '--drb', all_on_start: false, all_after_pass: false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@kaeff
kaeff / .bowerrc
Last active December 15, 2015 22:50
How to use Bower with the Asset Pipeline in Rails
{
"directory" : "vendor/assets/components"
}
<!DOCTYPE html>
<head>
<script type="text/javascript">
var produkte = ["Sonnenbrillen", "Anzuege", "Kopfhoerer"];
var zielgruppen = ["Vaeter", "Schlagerfans", "Tiere"];
function randomArrayEl(arr) {
return arr[Math.floor(Math.random()*arr.length)];
}
function generate() {
document.getElementById("produkt").textContent = randomArrayEl(produkte);
@kaeff
kaeff / gitconfig-diff-settings
Created November 25, 2011 13:49
Git settings for perfect visual diff from both command line and gitg
# Use case: I use git mainly from the command line, but occasionally track commits with gitg. I prefer visual diffs.
# Inspired by http://jeetworks.org/node/90
[diff]
tool = meld
[difftool]
prompt = false
[alias]
d = difftool