Skip to content

Instantly share code, notes, and snippets.


Berg Paulo bergpb

View GitHub Profile
mislav /
Created Oct 12, 2010
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

mateusg / inflections.rb
Created Apr 17, 2011
pt-BR inflections file for Ruby on Rails applications
View inflections.rb
# encoding: utf-8
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
BaylorRae / flash_messages.php
Created May 21, 2011
Flash Messages for PHP
View flash_messages.php
class FlashMessages {
private $messages = array();
private $now = false;
private static $instance = null;
private function __construct() {
// Save all messages
$this->messages = $_SESSION['flash_messages'];
sarahhodne / gist:1341827
Created Nov 5, 2011
Use pry for rails console
View gist:1341827
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry
# instead. If you don't, you can load it through the lines below :)
rails = File.join(Dir.getwd, 'config', 'environment.rb')
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == '2'
require 'console_app'
rstacruz /
Last active Apr 24, 2021
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User


geoffalday /
Created Mar 12, 2012
How to generate a secret key with Python
# How to generate a secret key with Python
# via
import os
baali /
Created May 8, 2012
Python script to download all gmail attachments.
# Something in lines of
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
daltonjorge /
Created Aug 8, 2012 — forked from hakagura/
Explicações de conceitos do Rails e outras infos úteis.

Active Record

É um design pattern que o Rails implementa a partir da gem ActiveRecord.

Serve para conectar a camada Model da aplicação com tabelas do database, para assim criar um modelo de domínio persistível, onde a lógica (Model) e dados (BD) são apresentados em uma única solução.

Já persiste no BD:

View .pryrc
# === EDITOR ===
Pry.editor = 'vim'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil
Pry.config.color = true
runemadsen / app.rb
Created Oct 17, 2012
Sinatra File Upload
View app.rb
require 'sinatra'
get "/" do
erb :form
post '/save_image' do
@filename = params[:file][:filename]
file = params[:file][:tempfile]