Skip to content

Instantly share code, notes, and snippets.

Randѕon rands0n

Block or report user

Report or block rands0n

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rands0n
rands0n / mongodb-s3-backup.sh
Created May 22, 2019 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
View mongodb-s3-backup.sh
#!/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
@rands0n
rands0n / authentication.rb
Created Apr 17, 2019 — forked from theCrab/authentication.rb
A Hanami Framework authentication based on JSON Web Tokens.
View authentication.rb
# lib/authentications/authentication.rb
# @api auth
# Authentication base class
#
module Authentication
def self.included(base)
base.class_eval do
before :authenticate!
expose :current_user
View gist:97f63c6b3703778087288c682990a6ac
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 / Dockerfile
Created Mar 25, 2017
Docker to run ruby
View Dockerfile
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
@rands0n
rands0n / .vimrc
Last active Sep 9, 2018
.vimrc config
View .vimrc
" =============================================================================
" Randson Oliveira .vimrc file
" -----------------------------------------------------------------------------
" Heavily inspired by: @millermedeiros, @scrooloose, @nvie, @gf3, @bit-theory.
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" BEHAVIOR
" -----------------------------------------------------------------------------
@rands0n
rands0n / ruby-rbenv.sh
Created Dec 27, 2016
Install ruby with rbenv
View ruby-rbenv.sh
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# plugins
git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
## postgres
View vim.md

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

View heroku-pg.rake
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"]
View authentication_with_bcrypt_in_rails_4.md

#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

@rands0n
rands0n / weather.sh
Created Feb 28, 2016 — forked from devthiago/weather.sh
Cool shell functions
View weather.sh
# 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/;
You can’t perform that action at this time.