Skip to content

Instantly share code, notes, and snippets.

View jpablobr's full-sized avatar

Pablo Barrantes jpablobr

View GitHub Profile
@jpablobr
jpablobr / gitflow-breakdown.md
Created September 29, 2017 04:58 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

# for more info: https://gist.github.com/1120938
@jpablobr
jpablobr / 1_oo.rb
Created November 20, 2011 00:36 — forked from rbxbx/1_oo.rb
Bootstrapping a lightweight Object System in Ruby
class Person
def initialize(name, age)
@name = name
@age = age
end
def set_name(new_name)
@name = new_name
end
@jpablobr
jpablobr / Gemfile
Created November 1, 2011 05:35 — forked from libryder/Gemfile
Config files for integrating adhearsion and rails
source 'http://rubygems.org'
gem 'adhearsion', '>= 1.2.1'
gem 'ahn-restful-rpc'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
@jpablobr
jpablobr / command.sh
Created October 29, 2011 15:55 — forked from felixge/command.sh
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me:
@jpablobr
jpablobr / gist:1286249
Created October 14, 2011 04:32 — forked from dtsato/gist:1285321
Speeding up Rails specs
# Add these lines to your spec_helper.rb to speed up specs:
Sass::Plugin.options[:always_check] = false
Sass::Plugin.options[:always_update] = false
@jpablobr
jpablobr / gist:1269650
Created October 7, 2011 06:59 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
###
# This is a demonstration of using SQLite3's Virtual File System API in Ruby.
#
# == Synopsis
#
# This program will store its SQLite database after the __END__ line.
#
# === In Detail
#
# SQLite3 uses the DATABase class as a proxy for our IO object. Upon
@jpablobr
jpablobr / development.rb
Created August 1, 2011 23:32 — forked from banister/development.rb
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@jpablobr
jpablobr / gist:1096279
Created July 21, 2011 00:55 — forked from wayneeseguin/gist:1095634
My thought on improving Ruby construct end syntax.
# I have now programmed in a lot of languages, and one thing I can say for sure
# is that shell scripting does construct end styles very well.
#
# Example from http://redmine.ruby-lang.org/issues/5054
#
# This is indeed also one of my few personal issues with Ruby syntax, the end trail.
#
module MyModule
class MyClass