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
@dgilperez
dgilperez / copy_bucket.rb
Created April 27, 2012 19:23 — forked from jaimeiniesta/copy_bucket.rb
Copy all files from a S3 bucket to another. Works between different S3 accounts.
require 'right_aws'
s3_credentials = {
:source_key => "...",
:source_secret => "...",
:source_bucket => "...",
:destination_key => "...",
:destination_secret => "...",
:destination_bucket => "..."
}
@dgilperez
dgilperez / capybara_debug.rb
Created May 3, 2012 12:10 — forked from tddium/capybara_debug.rb
Trap Capybara Stack Trace
### 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)
@dgilperez
dgilperez / page_cache_spec.rb
Created May 6, 2012 18:39
My attempt at testing a cached Page model
# spec/requests/page_cache_spec.rb
require 'spec_helper'
describe "Page cache" do
# Testing with local cache instead of Memcached for speed
before(:each) do
ActionController::Base.perform_caching = true
ActionController::Base.cache_store = :file_store, "tmp/cache"
FileUtils.rm_rf(Dir['tmp/cache'])
@dgilperez
dgilperez / gist:2829435
Created May 29, 2012 16:35 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end
@dgilperez
dgilperez / delayed_job
Created July 3, 2012 18:27
Delayed_job init script for linux
#!/bin/sh
set_path="cd /home/rails/my_app/current"
case "$1" in
start)
echo -n "Starting delayed_job: "
su - rails -c "$set_path; RAILS_ENV=production script/delayed_job start" >> log/delayed_job.log 2>&1
echo "done."
;;
stop)
@dgilperez
dgilperez / Guardfile
Created July 4, 2012 20:38
Our Guardfile
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 60, :notify_on_start => true do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch(%r{^spec/support/(requests|controllers|mailers|models)_helpers\.rb}) { :rspec }
watch(%r{^spec/acceptance/support/(.*)\.rb}) { :rspec }
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.tables.each do |table|
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};")
end
# https://gist.github.com/1623632
# bundler bootstrap
require 'bundler/capistrano'
# main details
set :application, "123"
role :web, "#{application}.cloud.voupe.net" # #{application}.cloud.voupe.net
role :app, "#{application}.cloud.voupe.net"
role :db, "#{application}.cloud.voupe.net", :primary => true
# Add these two gems
gem 'ice_cube', '0.9.3'
gem 'squeel', '1.0.16'
@dgilperez
dgilperez / author-box.html
Last active December 16, 2015 19:19
Author box example. www.saludenlanube.com
<div class="author-box vcard" style="line-height: normal; text-align: left;">
<span class='fn' itemprop='author' itemscope='itemscope' itemtype='http://schema.org/Person'>
<meta content='https://qoolife.com/servicios/diesalud' itemprop='url'/>
<img src="http://4.bp.blogspot.com/-Ev9vjf_3g-I/UVggOyxxDYI/AAAAAAAAAJU/7bvwKHlnC34/s1600/josefa+Cobo.jpg" alt="Doctora Josefa Cobo - Diesalud - Qoolife"/>
<a href='https://qoolife.com/servicios/diesalud' rel='author' title='Consulta a Josefa Cobos en Qoolife'>
<span itemprop='name'>
<strong>Josefa Cobos</strong>
</span>
</a>
</span>