Skip to content

Instantly share code, notes, and snippets.

View rands0n's full-sized avatar

Randѕon rands0n

View GitHub Profile
@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

#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 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/;
@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 / node-and-npm-in-30-seconds.sh
Created October 14, 2015 19:41 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@rands0n
rands0n / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rands0n
rands0n / Gemfile
Last active August 29, 2015 14:07 — forked from xavez/Gemfile
# ~/Gemfile
source "http://rubygems.org"
group :development do
# CSS Preprocessing
gem 'sass'
gem 'compass'
gem 'jekyll'