Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
#!/usr/bin/env ruby
# this tool is similar to "git bisect" one, but for specs.
# it tries to find what spec from list of specs breaks execution of one specified spec.
#
# see more at http://zed.0xff.me/2010/01/28/rspec-bisect
#
# usage example:
# ./rspec-bisect.rb spec/**/*_spec.rb spec/controllers/spaces/tickets_controller_spec.rb
# [.] rspec runner: ./script/spec
@djones
djones / gist:720672
Created November 29, 2010 21:37
4 views in Refinery that use a new type of content_page
rendering a custom plugin
<% content_for :page_title do %>
<%= @destination.title %>
<% end %>
<% content_for :page_body do %>
<section>
<h1>Choose from our most popular recommended itineraries below</h1>
</section>
@wayneeseguin
wayneeseguin / Attribution
Created January 1, 2011 21:32
TextMate shell function to open project directory excluding some.
Original code from:
http://www.wezm.net/technical/2009/05/exclude-directories-from-textmate-side-bar-for-faster-find-in-project/
@parndt
parndt / gist:784143
Created January 18, 2011 08:40
Non translated keys in every language we have in the core
$ rake translate:lost_in_translation_all
Searching for missing translations for the locale: en
No missing translations for locale: en
--
Searching for missing translations for the locale: fr
No missing translations for locale: fr
--
Searching for missing translations for the locale: nl
No missing translations for locale: nl
@parndt
parndt / gist:882306
Created March 22, 2011 23:18
Useful unix functions
# Find files recursively in/under the current directory
function findin()
{
find . -exec grep $@ '{}' \; -print
}
# Rails 2 and Rails 3 console
function rc {
if [ -e "./script/console" ]; then
./script/console $@
else
#!/usr/bin/env ruby
#
# A quick script to dump an overview of all the open issues in all my github projects
#
require 'octokit'
require 'awesome_print'
require 'rainbow'
ruby-1.9.2-p0 > p=Page.last
Page Load (0.3ms) SELECT "pages".* FROM "pages" ORDER BY pages.id DESC LIMIT 1
=> #<Page id: 3, parent_id: nil, position: 1, path: nil, created_at: "2011-05-11 02:44:43", updated_at: "2011-05-11 02:44:43", show_in_menu: true, link_url: nil, menu_match: nil, deletable: true, custom_title_type: "none", draft: false, skip_to_first_child: false, lft: 5, rgt: 6, depth: nil>
ruby-1.9.2-p0 > p.read_attribute(:path)
=> nil
ruby-1.9.2-p0 > p.read_attribute(:position)
=> 1
ruby-1.9.2-p0 > p.attribute_names
=> ["title", "custom_title", "meta_keywords", "meta_description", "browser_title", "id", "parent_id", "position", "path", "created_at", "updated_at", "show_in_menu", "link_url", "menu_match", "deletable", "custom_title_type", "draft", "skip_to_first_child", "lft", "rgt", "depth"]
ruby-1.9.2-p0 > p.attributes
def capture_stdout(stdin_str = '')
begin
require 'stringio'
$o_stdin, $o_stdout, $o_stderr = $stdin, $stdout, $stderr
$stdin, $stdout, $stderr = StringIO.new(stdin_str), StringIO.new, StringIO.new
yield
{:stdout => $stdout.string, :stderr => $stderr.string}
ensure
$stdin, $stdout, $stderr = $o_stdin, $o_stdout, $o_stderr
end
@mhaylock
mhaylock / gist:995049
Created May 27, 2011 11:11
nginx config to add Cache-Control header to rails static cache files
location / {
try_files /system/maintenance.html $uri $uri/index.html $uri.html @passenger;
expires 60s;
add_header Cache-Control public;
add_header Vary Accept-Encoding;
}
@ugisozols
ugisozols / gist:1027992
Created June 15, 2011 20:13
Search Psych::SyntaxError
# This will help you trace .yml file which containts Psych::SyntaxError
require "rubygems"
require "psych"
$LOAD_PATH.unshift(File.dirname(__FILE__))
# specify your locales folder in Dir.glob("*") with relative path from this file
Dir.glob("*").sort.each do |file|
begin