Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
View quickerclip.rb
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class Thumbnail
def make
src = Test::FileHelper.fixture_file('white_pixel.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
@rgo
rgo / gist:1173243
Created Aug 26, 2011 — forked from diecrf/gist:1170410
Delete unused images in a rails project
View gist:1173243
images = Dir.glob('public/images/*')
images.each do |image|
unless File.directory?(image)
puts "Checking #{image}..."
if IO.popen("ack-grep -1 -G '(app|public)' --ruby --html --css #{File.basename(image)}").eof?
IO.popen("svn delete #{image}")
puts " Deleted"
end
end
@tddium
tddium / capybara_debug.rb
Created Nov 16, 2011
Trap Capybara Stack Trace
View capybara_debug.rb
### Show stack trace for 500 errors
### (adapted from https://gist.github.com/1079020)
# Given an application, yield to a block to handle exceptions
class ExceptionRaiserApp
def initialize(app)
@app = app
end
def call(env)
@bsodmike
bsodmike / gist:1698390
Created Jan 29, 2012
git diff between Rails 3.2.0 and Rails 3.1.0 generated apps
View gist:1698390
diff --git a/.gitignore b/.gitignore
index 923b697..eb3489a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,15 @@
-.bundle
-db/*.sqlite3
-log/*.log
-tmp/
-.sass-cache/
@chsh
chsh / appapp_delegate.rb
Created May 10, 2012
RubyMotion Localization sample.
View appapp_delegate.rb
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
alert = UIAlertView.new
alert.message = t('start')
alert.show
true
end
def t(key)
NSBundle.mainBundle.localizedStringForKey(key, value:nil, table:nil)
@ParkinT
ParkinT / uilabel_adjustable.rb
Created Jul 8, 2012
RubyMotion class to auto-size font for text in a multi-line UILabel
View uilabel_adjustable.rb
class UILabel_Adjustable
# Borrowed and modified the excellent example at http://www.11pixel.com/blog/28/resize-multi-line-text-to-fit-uilabel-on-iphone/
# adapting it for RubyMotion
# This applies only to a multi-line label. You can use '.adjustsFontSizeToFitWidth = true' for a single-line label
# usage is:
# text = "It's bad luck to be superstitious"
# text_label = UILabel.alloc.initWithFrame([[20, 20], [70, 120]])
# text_label.numberOfLines = 0 # set 0 for word wrap
# text_label.lineBreakMode = UILineBreakModeWordWrap
@jrochkind
jrochkind / gist:4342817
Created Dec 20, 2012
Still SimpleDelegator based Decorator, but with an ActionView::Context view_context passed in too
View gist:4342817
require 'delegate'
class Base
def foo
"foo"
end
def bar
"bar"
end
end
@felipeelias
felipeelias / spec_helper.rb
Last active Dec 10, 2015
Simple 'database cleaner' approach using `config.around`. Was able to cut down some seconds out of the suite. Thanks to @brandonhilkert
View spec_helper.rb
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
@dhenze
dhenze / bootstrap-typeahead.js
Created Jan 10, 2013
This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions. For example, process typeahead list asynchronously and return objects This is an adoption of gudburgurs gist to Version 2.2.2 of Bootstrap. See https://gist.github.com/1866577
View bootstrap-typeahead.js
/* =============================================================
* bootstrap-typeahead.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
View README.md

Benchmark Bundler

Because loading gems can take longer than you think

Now available as a gem - get it here

You can’t perform that action at this time.