Skip to content

Instantly share code, notes, and snippets.

View mauriciomdea's full-sized avatar
👋
Looking for work

Mauricio Almeida mauriciomdea

👋
Looking for work
View GitHub Profile
@emad-elsaid
emad-elsaid / gravatar.rb
Created March 7, 2014 13:07
Gravatar image url generator simple method Gravatar image url generator simple method
#!/usr/bin/env ruby
require 'digest/md5'
require "addressable/uri"
# this is based on gravatar image API
# https://en.gravatar.com/site/implement/images/
# options :
# size : <integer> size of image
# default: <string> url of image if email not found or:
# * 404
@romanbsd
romanbsd / colored_logger.rb
Created December 22, 2011 11:10
Color logging for Mongoid
require 'logger'
class ColoredLogger < Logger
WHITE = "\e[37m"
CYAN = "\e[36m"
MAGENTA = "\e[35m"
BLUE = "\e[34m"
YELLOW = "\e[33m"
GREEN = "\e[32m"
RED = "\e[31m"
BLACK = "\e[30m"
@mauriciomdea
mauriciomdea / colored_logger.rb
Created December 24, 2011 08:16 — forked from romanbsd/colored_logger.rb
Color logging for Mongoid
require 'logger'
class ColoredLogger < Logger
WHITE = "\e[37m"
CYAN = "\e[36m"
MAGENTA = "\e[35m"
BLUE = "\e[34m"
YELLOW = "\e[33m"
GREEN = "\e[32m"
RED = "\e[31m"
BLACK = "\e[30m"
@mauriciomdea
mauriciomdea / python-on-ubuntu.sh
Created April 4, 2016 15:51 — forked from neuroticnerd/python-on-ubuntu.sh
Python 2.7.9 on Ubuntu 14.04.2 (without overwriting original version)
#! /usr/bin/env bash
# http://smirnov-am.blogspot.com/2015/04/installation-of-python-279-in-ubuntu.html
# http://davebehnke.com/python-pyenv-ubuntu.html
# https://renoirboulanger.com/blog/2015/04/upgrade-python-2-7-9-ubuntu-14-04-lts-making-deb-package/
# install dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
@bitzesty
bitzesty / config.enviroment.rb
Created January 4, 2010 22:58
Getting up and running with MongoDB/MongoMapper
# config/enviroment.rb
config.gem 'mongo'
config.gem 'mongo_mapper'
# remove AR
config.frameworks -= [ :active_record, :active_resource ]
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@neuroticnerd
neuroticnerd / python-on-ubuntu.sh
Last active July 27, 2018 07:09
Python 2.7.9 on Ubuntu 14.04.2 (without overwriting original version)
#! /usr/bin/env bash
# http://smirnov-am.blogspot.com/2015/04/installation-of-python-279-in-ubuntu.html
# http://davebehnke.com/python-pyenv-ubuntu.html
# https://renoirboulanger.com/blog/2015/04/upgrade-python-2-7-9-ubuntu-14-04-lts-making-deb-package/
# install dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
@oparrish
oparrish / bootstrap_pagination_helper.rb
Created September 28, 2011 18:35
Link renderer to be used with will_paginate to render links to work with Twitter Bootstrap
module BootstrapPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def page_number(page)
unless page == current_page
link(page, page, :rel => rel_value(page))
else
link(page, "#", :class => 'active')
end
@mauriciomdea
mauriciomdea / setup_iptables.sh
Created August 17, 2012 15:16
Basic Firewall configuration for new VPS
#!/bin/bash
# Accept already established connections (so it doesnt drop your current SSH session)
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Accept SSH connections from anywhere
iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
# (Optional) Accept HTTP connections from anywhere
iptables -A INPUT -p tcp -i eth0 --dport 80 -j ACCEPT
@matthutchinson
matthutchinson / fakeout.rake
Created February 10, 2010 16:49
fakeout.rake - a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# NOTE: requires the faker or ffaker gem
# sudo gem install faker - http://faker.rubyforge.org
# OR
# sudo gem install ffaker - http://github.com/EmmanuelOga/ffaker
require 'faker'
class Fakeout