This file contains 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
,---------------------. | |
_.--._ ( I only bone *artists* ) | |
,' `. `-,-------------------' | |
/ __) __` \ _.-' | |
( (`-`(-') ) | |
/) \ _ / ( | |
/' )-._.' . \ ___ | |
( ,--., `.)___(___) | |
)( /-.,--'\ _ \X/` | |
'/ .'/ \ ( Uu")\ |
This file contains 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
#!/usr/bin/env ruby | |
# Open a new tab in Terminal | |
# usage: tab [cmd] | |
# If cmd is specified, it will be run in new tab while old tab is reactivated. | |
# If no cmd, new tab is activated | |
require "rubygems" | |
# gem install rb-appscript | |
require "appscript" | |
include Appscript |
This file contains 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
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def scoped_variable(*objects) | |
yield(objects) | |
end | |
alias scoped_variable scoped_variables | |
end | |
This file contains 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
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def with(object) | |
yield(object) | |
end | |
end | |
@reports = [] |
This file contains 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
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def with(object) | |
yield(object) | |
end | |
end | |
@reports = [] |
This file contains 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
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def with(object) | |
yield(object) | |
end | |
end | |
@reports = [] |
This file contains 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
value = "Don T Alias" | |
first_name, last_name = value.reverse.split(' ', 2).reverse.collect(&:reverse) | |
first_name = first_name.to_s | |
last_name = last_name.to_s | |
# Refactored to take into account Xavier's pathological aversion to case statements: | |
last_space_index = value.rindex(' ') || value.size | |
first_name, last_name = value[0..last_space_index].strip, value[last_space_index..value.size].strip | |
--- |
This file contains 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
# what is the idiomatic ruby for this: | |
# if the var is an array, do_something with each element, otherwise just do something with the var | |
# if var.is_a?(Array) | |
# var.each do |element| | |
# do_something(element) | |
# end | |
# else | |
# do_something(var) | |
# end | |
This file contains 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
# I don't tend to like writing this kind of code: | |
if Rails.env == 'development' or Rails.env == 'staging' | |
# ... | |
end | |
# So, an alternative Ruby way to do this is: | |
if %w(development staging).include?(Rails.env) | |
# ... |
This file contains 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
- @items && @items.each do |item| | |
- name = item.gsub(/views\/.+\/(.+).haml/, '\1') | |
- unless name == "index" || name[/^hide-/] | |
%p do some stuff |
OlderNewer