Skip to content

Instantly share code, notes, and snippets.

View iboard's full-sized avatar
🏠
Crafting beautiful code at home

Andreas Altendorfer iboard

🏠
Crafting beautiful code at home
View GitHub Profile
@iboard
iboard / .vimrc.after
Last active December 14, 2015 21:39
My vimrc
let mapleader=","
set shell=/bin/sh
set nocompatible
set background=dark
set guifont=Monaco:h18
set guitablabel=%M%t
set helplang=en
set langmenu=none
set backspace=indent,eol,start
set fileencoding=utf-8
@iboard
iboard / run_tags
Last active January 20, 2019 08:03
# A script to run ctags on all .rb files in a project
#!/usr/bin/env ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
@iboard
iboard / .tmux.conf
Last active January 20, 2019 08:02
My .tmux-config for Mac OS X, iTerm2
set-window-option -g utf8 on
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
set-option -g prefix C-q
set -g history-limit 50000
unbind-key C-b
bind-key q send-prefix
set -g base-index 1
@iboard
iboard / ruby-destructor-example.rb
Last active February 12, 2022 13:54
Ruby 'Destructor' example.
class Foo
attr_reader :bar
def initialize
@bar = 123
ObjectSpace.define_finalizer( self, self.class.finalize(bar) )
end
def self.finalize(bar)
proc { puts "DESTROY OBJECT #{bar}" }
end
@iboard
iboard / tr_on_click.coffee
Created June 16, 2013 12:45
Handle click on a table-row with Rails4 and coffeescript
# WORKS THE FIRST TIME BUT FAILES WHEN RETURNING TO THE PAGE UNLESS RELOADING
jQuery ->
$('.clickable-row td').click ->
target_id = $(this).parent().attr('id').replace /row-id-/,''
document.location = "/controller_xy/#{target_id}/edit"
# WORKS FINE EVERY TIME
jQuery ->
$(document).on( 'click', '.clickable-row td', ->
@iboard
iboard / wombatAndi.vim
Last active January 20, 2019 08:00
My vim colors
" Vim color file
" Original Maintainer: Lars H. Nielsen (dengmao@gmail.com)
" Last Change: 2010-07-23
"
" Converting for 256-color terminals by
" Danila Bespalov (danila.bespalov@gmail.com)
" with great help of tool by Wolfgang Frisch (xororand@frexx.de)
" inspired by David Liang's version (bmdavll@gmail.com)
set background=dark
@iboard
iboard / ruby_sort_exceptions.rb
Last active January 20, 2019 07:59
Stackoverflow-example
require 'ostruct'
# ad 1)
def sort_descending1 _objects, field
_objects.sort { |b,a| a.send(field) <=> b.send(field) }
end
# ad 2)
def safe_compare2 a,b,field
a.send(field) <=> b.send(field)
@iboard
iboard / rspec-vim.vim
Created April 21, 2014 06:47
Run rspec from vim
" Call rspec from vim
" Apr 21st, 2014 Andi Altendorfer <andreas@altendorfer.at>
"
" RspecLine() ... run rspec for the current cursor line
" RspecFile() ... run rspec for the current file
" RspecAll() .... run entire suite
"
" Copy this file to your ./vim/pluglin directory
function RspecLine()
@iboard
iboard / rspec-vim.vim
Last active January 20, 2019 07:58
Vim-functions to run rspec from current file, line
" Call rspec from vim
" Apr 21st, 2014 Andi Altendorfer <andreas@altendorfer.at>
"
" RspecLine() ... run rspec for the current cursor line
" RspecFile() ... run rspec for the current file
" RspecAll() .... run entire suite
"
" Copy this file to your ./vim/pluglin directory
function RspecLine()
@iboard
iboard / run_ruby.vim
Last active January 20, 2019 07:53
Run the current line in vim with rspec
" Call rspec from vim
" Apr 21st, 2014 Andi Altendorfer <andreas@altendorfer.at>, License MIT
"
" RunCurrentLine() ... evaluate current line with ruby-interpreter and append " output to the end of the line
" RunCurrentFile() ... evaluate current file with ruby-interpreter and append " output to the end of the file
"
" Copy this file to your ./vim/pluglin directory
function! RunCurrentLine ()
exec "normal! $F#D"
let _current_line = getline(".")