Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
Build that!

David Gil dgilperez

🌊
Build that!
View GitHub Profile
View stackleveltoodeep_tracer.rb
$enable_tracing = false
$trace_out = open('trace.txt', 'w')
set_trace_func proc { |event, file, line, id, binding, classname|
if $enable_tracing && event == 'call'
$trace_out.puts "#{file}:#{line} #{classname}##{id}"
end
}
$enable_tracing = true
@dgilperez
dgilperez / gource.sh
Last active Nov 11, 2016 — forked from XueshiQiao/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
View gource.sh
# 1.install gource using HomeBrew
brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@dgilperez
dgilperez / example.rb
Created Oct 14, 2016 — forked from nthj/example.rb
Methods I like to monkey-patch onto the Object class in Ruby
View example.rb
# Say you want to look up the attrs of a Stripe Event for logging to your internal database.
attrs = begin
retriable(Stripe::APIConnectionError, Stripe::APIError, max: 25) do
# ... retrieve attrs from the Stripe event here...
end
rescue Stripe::APIConnectionError, Stripe::APIError
# We're inside an SQS queue block
throw :skip_delete # we'll just have to wait on this event, come back later
rescue Stripe::Error
notify $!
@dgilperez
dgilperez / trello-import.rb
Last active Apr 18, 2017
Taiga to Trello - ruby script to import Taiga cards into Trello
View trello-import.rb
require 'trello'
# Trello.open_public_key_url # copy your public key
# Trello.open_authorization_url key: 'yourpublickey' # copy your member token
Trello.configure do |config|
config.developer_public_key = 'your_public_key' # The "key" from step 1
config.member_token = 'your_member_token' # The token from step 3.
end
@dgilperez
dgilperez / deploy.rb
Created Apr 14, 2016 — forked from andrey-skat/deploy.rb
Local assets precompilation on Rails 4 using Capistrano 3
View deploy.rb
# also you need to uncomment next line in Capfile
# require 'capistrano/rails/assets'
namespace :deploy do
namespace :assets do
Rake::Task['deploy:assets:precompile'].clear_actions
desc 'Precompile assets locally and upload to servers'
task :precompile do
@dgilperez
dgilperez / delayed_job_init_script.sh
Created Apr 11, 2016 — forked from mdesantis/delayed_job_init_script.sh
Delayed Job init script; it uses start-stop-daemon and supports every Ruby version manager (RVM, rbenv, chruby...)
View delayed_job_init_script.sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: delayed_job
# Required-Start: $all
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the delayed_job instances
# Description: starts the delayed_job server instances using start-stop-daemon
#
View chat.rb
#!/usr/bin/env ruby -I ../lib -I lib
# coding: utf-8
require 'rtoken'
require 'json'
require 'sinatra/base'
require 'thin'
class Chat < Sinatra::Base
@dgilperez
dgilperez / chat.rb
Created Apr 2, 2016 — forked from HoneyryderChuck/chat.rb
Simple Chat Application, proof of concept for hybrid of thread-server http with evented-server SSE.
View chat.rb
# chat.rb
require 'sinatra/base'
# this also loads celluloid io, let's keep that in mind
require 'celluloid/current'
require 'reel'
# The chat server, an IO Event Loop held by the actor
# Collects connections (Reel Event Streams)
#
# Contrary to EventMachine, there is no event callback for
@dgilperez
dgilperez / puma.monitrc
Last active Mar 30, 2016 — forked from sudara/puma.monitrc
Example config needed to use monit with puma, monitoring workers for mem.
View puma.monitrc
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid
@dgilperez
dgilperez / rack_sse.ru
Created Mar 23, 2016 — forked from raggi/rack_sse.ru
Rack SSE Example
View rack_sse.ru
# rack_sse.ru
#
# An example of basic real-time, single-room broadcast chat using Server Sent
# Events in plain old Rack. This example does NOT use hijack, or the async
# hacks, it just relies on a well implemented threaded Rack server (at time of
# writing this will therefore only work with puma!). Other servers should be
# fixed to support this, as it is pretty critical to how Rack *should* work on
# most servers. The only spec-acceptable failure in this case is not flushing
# the content stream on each yield (for which the rack spec has no workaround
# today).
You can’t perform that action at this time.