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 / .eslintrc.js
Created December 15, 2015 13:58 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@nateberkopec
nateberkopec / delayed_job.rb
Created April 12, 2013 01:42
Comparison of top 3 Ruby background job systems on Ruby Toolbox
# DelayedJob
@user.delay.activate!(@device) # Delay any object
Notifier.delay.signup(@user) # Delay ActionMailer
#DelayedJob supports a number of ways to make methods async
def send_mailer
# Some other code
end
handle_asynchronously :send_mailer, :priority => 20
@dgilperez
dgilperez / README_Genealogy.textile
Last active December 17, 2015 12:49
Resources towards an online genealogical tree visualizing app
@seyhunak
seyhunak / app
Last active December 31, 2015 05:49
Varnish - Nginx - Unicorn Setup
upstream unicorn {
server unix:/tmp/unicorn.app.sock fail_timeout=0;
}
# HTTP server
#
server {
listen localhost:8080;
server_name app.me;
@jhjguxin
jhjguxin / 404.html.erb
Created August 13, 2012 05:13
exception catch on rails 3(eg, 400, 403, 500), base on BBTangCMS
<div id="error_page" class="box">
<h1>Ops, 404</h1>
<p>
似乎没有这个页面哦!大哥,去看看别的吧。
</p>
</div>
<!--因为不排除连rails 都无法运行的情况 所以添加 'public/STATUS.htm' 还是很有必要的-->
<!--more>
Finally, the default exceptions application used by Rails that simply renders a page in `public/STATUS.html` is available here: [action_dispatch/middleware/public_exceptions.rb](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/public_exceptions.rb)
Remember that whatever you do in the errors controller, it should not be anything “fancy”. Keep it simple because something already went wrong with your application!
@sj26
sj26 / wysihtml5_helper.rb
Created May 28, 2012 06:32
Helper for capybara to fill in wysihtml5 fields respecting `within` scopes
module Wysihtml5Helper
def fill_in_html name, options
options.to_options!.assert_valid_keys :with
if Capybara.current_driver == Capybara.javascript_driver
# Dip inside capybara session to respect current `within` scope
scope = page.send(:current_node).path
# Find the textarea based on label name within the given scope
query = "$('label:contains(#{name.inspect}) ~ textarea:eq(0)', document.evaluate(#{scope.inspect}, document).iterateNext())"
# Make sure the editor is instantiated -- this is us, not wysihtml5
wait_until { page.evaluate_script("!!#{query}.data('editor')") }
@brianr
brianr / hi.rb
Last active March 30, 2016 21:36
basic Rollbar usage with sinatra
require 'sinatra'
require 'rollbar'
configure do
Rollbar.configure do |config|
config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
config.environment = 'sinatra-test'
end
end
@nthj
nthj / example.rb
Last active October 14, 2016 19:32
Methods I like to monkey-patch onto the Object class in Ruby
# 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 $!
@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 {
@oz
oz / upgradepg.md
Created December 19, 2014 15:21
Upgading from PG 9.3 to PG 9.4 on Mac OS X, with Homebrew

Brew upgrade...

Run the usual brew update, and brew upgrade to get the latest 9.4 version of PostgreSQL.

After upgrading PG from 9.3 to 9.4 with brew, the server will not start as is. If you value your database contents, and configuration, pg_upgrade is here to migrate those.

Do not delete the old binaries at once: do not run brew cleanup, because you need 9.3 binaries to migrate.

Migration