Skip to content

Instantly share code, notes, and snippets.

@abriening
abriening / gist:4278282
Created December 13, 2012 17:53
Fix for Pow with rvm/bundler
rvm env . -- --env > .powenv
@abriening
abriening / rails_log_parameters.rb
Created January 2, 2013 12:49
Reads a rails log and extracts the given parameters, prints CSV.
#!/usr/bin/env ruby
file = ARGV.shift
parameters = ARGV
unless file && !parameters.empty?
puts <<-end_usage
Usage #{$0} logfile param [param, ...]
Reads a rails log and extracts the given parameters, prints CSV.
Useful to include [action, controller] in parameters.
jQuery(function($){
$('.toggle.hidden').hide();
$(document).on('click','.toggle_button', function(){
$(this).parent().find('.toggle').fadeToggle();
});
});
{
"color_scheme": "Packages/Color Scheme - Default/SpaceCadet.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"show_tab_close_buttons": false,
"tab_size": 2,
Node = Struct.new(:value, :left, :right)
node = Node.new(24, Node.new(12, Node.new(10), Node.new(14)), Node.new(28, nil, Node.new(30)))
def values(node)
return [] if node.nil?
[values(node.left),
node.value,
values(node.right)].flatten
end
class Proc
def bind(receiver)
unbound_method = receiver.class.unbound_method self
unbound_method.bind receiver
end
end
class Object
def self.unbound_method(proc)
define_method :__temp_unbound_method__, &proc
class PostPolicy < Struct.new(:user, :post)
def update?
post.user == user
end
def destroy?
false
end
def show?
true
end
@abriening
abriening / Preferences.sublime-settings.json
Last active December 17, 2015 17:19
Sublime Text user preferences
{
"color_scheme": "Packages/Color Scheme - Default/SpaceCadet.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 15.0,
"highlight_column": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"show_tab_close_buttons": false,
@abriening
abriening / aliases.sh
Created May 24, 2013 19:26
ls aliases
alias ls='ls -F'
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias lsa='ls -al'
@abriening
abriening / goals_controller.rb
Created August 24, 2013 21:28
How pretty the Rails 3 controllers can be.
class GoalsController < ApplicationController
respond_to :html, :json
before_action :set_goal, only: [:show, :edit, :update]
def show
respond_with @goal
end
def edit
respond_with @goal