Skip to content

Instantly share code, notes, and snippets.

View rands0n's full-sized avatar

Randѕon rands0n

View GitHub Profile
@rands0n
rands0n / setup_osx.sh
Last active February 13, 2018 03:09
setup_osx
# install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew install git
brew install node
brew install wget
brew install z
brew install ag
brew install ack
brew install ffind
@rands0n
rands0n / gist:4d314a4f419af795f5a0
Created January 23, 2016 16:30 — forked from mikestone14/gist:11198630
Getting a GoDaddy domain to point to a Heroku app.
@rands0n
rands0n / weather.sh
Created February 28, 2016 00:40 — forked from devthiago/weather.sh
Cool shell functions
# WEATHER INFO ------------------------------------------------------------
# Usage:
# $ weather [CITY_NAME]
# Examples:
# $ weather #returns current local weather
# $ weather "Porto Alegre" #returns Porto Alegre weather
function weather {
if [ -z "$1" ]; then
curl http://wttr.in/;

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

namespace :db do
desc "Copy production database to local"
task :copy_production => :environment do
# Download latest dump
system("wget -O tmp/latest.dump `heroku pg:backups public-url -q`")
# get user and database name
config = Rails.configuration.database_configuration["development"]
database = config["database"]
user = config["username"]
@rands0n
rands0n / vim.md
Last active October 5, 2016 17:59

i → Insert mode. Type ESC to return to Normal mode.

x → Delete the char under the cursor

:wq → Save and Quit (:w save, :q quit)

dd → Delete (and copy) the current line

p → Paste

@rands0n
rands0n / .vimrc
Last active September 9, 2018 21:24
.vimrc config
" =============================================================================
" Randson Oliveira .vimrc file
" -----------------------------------------------------------------------------
" Heavily inspired by: @millermedeiros, @scrooloose, @nvie, @gf3, @bit-theory.
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" BEHAVIOR
" -----------------------------------------------------------------------------
@rands0n
rands0n / Dockerfile
Created March 25, 2017 16:06
Docker to run ruby
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /app # app name
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
git filter-branch --env-filter '
WRONG_EMAIL="orandson@gmail.com"
NEW_NAME="Randson"
NEW_EMAIL="orandson@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@rands0n
rands0n / mongodb-s3-backup.sh
Created May 22, 2019 13:26 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh