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
| # Force alt + tab to switch only on current workspace in GNOME shell | |
| gsettings set org.gnome.shell.app-switcher current-workspace-only true | |
| # Use 5 fixed workspaces instead of dynamic mode | |
| gsettings set org.gnome.mutter dynamic-workspaces false | |
| gsettings set org.gnome.desktop.wm.preferences num-workspaces 5 | |
| # Use alt for pinned apps | |
| gsettings set org.gnome.shell.keybindings switch-to-application-1 "['<Alt>1']" | |
| gsettings set org.gnome.shell.keybindings switch-to-application-2 "['<Alt>2']" |
| # use pacman with sudo only when needed | |
| pacman () | |
| { | |
| case $1 in | |
| -S | -D | -S[^sih]* | -R* | -U*) | |
| /usr/bin/sudo /usr/bin/pacman "$@";; | |
| *) /usr/bin/pacman "$@";; | |
| esac} | |
| # standard things |
| #!/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 |
| git filter-branch --env-filter ' | |
| WRONG_EMAIL="[email protected]" | |
| NEW_NAME="Randson" | |
| NEW_EMAIL="[email protected]" | |
| if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ] | |
| then | |
| export GIT_COMMITTER_NAME="$NEW_NAME" | |
| export GIT_COMMITTER_EMAIL="$NEW_EMAIL" | |
| fi |
| 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 |
| " ============================================================================= | |
| " Randson Oliveira .vimrc file | |
| " ----------------------------------------------------------------------------- | |
| " Heavily inspired by: @millermedeiros, @scrooloose, @nvie, @gf3, @bit-theory. | |
| " ----------------------------------------------------------------------------- | |
| " ----------------------------------------------------------------------------- | |
| " BEHAVIOR | |
| " ----------------------------------------------------------------------------- |
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
| 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"] |
#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
| # 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/; |