Skip to content

Instantly share code, notes, and snippets.

View dgilperez's full-sized avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
@lsbardel
lsbardel / redis-server-for-init.d-startup
Created December 15, 2009 21:01 — forked from mtodd/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
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("."))
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@txus
txus / delegate_matcher.rb
Created February 2, 2011 09:19
RSpec matcher for delegations
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end
@tacsio
tacsio / Git Configs
Last active September 15, 2022 01:10
My git config
git config --global user.name "Tarcisio Coutinho"
git config --global user.email "tcs5cin@gmail.com"
git config --global color.ui true
git config --global alias.s status
git config --global alias.c checkout
git config --global alias.b branch
git config --global alias.lol log --oneline --graph --decorate
@ebeigarts
ebeigarts / gist:970898
Created May 13, 2011 17:04
html2haml recursive
for f in `find . -regex '.*\.html\.erb'`; do echo "Converting $f" && html2haml $f > "${f%.erb}.haml" && rm $f; done
@juggy
juggy / call_template.rb
Created May 17, 2011 19:25
Render a complete page in rails 3 without controller
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
@rgo
rgo / gist:1173243
Created August 26, 2011 11:36 — forked from diecrf/gist:1170410
Delete unused images in a rails project
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
@robertsosinski
robertsosinski / varnish.vcl
Created August 29, 2011 22:53
A Varnish config for Rails
backend default {
.host = "127.0.0.1";
.port = "3000";
}
acl admin {
"127.0.0.1";
}
sub vcl_recv {
@jcasimir
jcasimir / api.markdown
Created September 12, 2011 20:08
Exposing an API in Rails 3

Exposing an API

APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.

In the Controller

Let's work with the following example controller:

class ArticlesController < ApplicationController