Skip to content

Instantly share code, notes, and snippets.

View brenoperucchi's full-sized avatar

Breno Perucchi brenoperucchi

View GitHub Profile
@brenoperucchi
brenoperucchi / Rails, Puma & Nginx.md
Created February 14, 2023 03:36 — forked from davidteren/Rails, Puma & Nginx.md
Example setup for Puma with Nginx in a Rails app

In the apps config/puma.rb file:

Change to match your CPU core count
# Check using this on the server => grep -c processor /proc/cpuinfo
workers 4

# Min and Max threads per worker
threads 1, 6

app_dir = File.expand_path('../..', FILE)

# First the end result of what we want:
class Foo
before_hook :whoa
before_hook :amazing
def test
puts "This is kinda cool!"
end
@brenoperucchi
brenoperucchi / rails_bootstrap_delete_confirmation_modal.md
Created October 18, 2012 01:07 — forked from trey/rails_bootstrap_delete_confirmation_modal.md
A nice delete confirmation modal in Rails courtesy of Bootstrap

Here's what you get.

Some JavaScript

// Delete confirmation modals
$('#delete-confirm').on('show', function() {
  var $submit = $(this).find('.btn-danger'),
      href = $submit.attr('href');
  $submit.attr('href', href.replace('pony', $(this).data('id')));
# Paginate a collection
#
# Usage:
#
# {% paginate contents.projects by 5 %}
# {% for project in paginate.collection %}
# {{ project.name }}
# {% endfor %}
# {% endpaginate %}
#
@brenoperucchi
brenoperucchi / rbenv-howto.md
Created September 28, 2012 13:39 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@brenoperucchi
brenoperucchi / gist:2042397
Created March 15, 2012 06:13 — forked from rlander/gist:1941157
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Cmd+C copy current line (if no selection)
Cmd+X cut current line (if no selection)
Ctrl+⇧+K delete line
Cmd+↩ insert line after