Skip to content

Instantly share code, notes, and snippets.

View cameck's full-sized avatar
🍩
(ॢ◕ัڡ ◕ั ॢ)

Cameron Eckelberry cameck

🍩
(ॢ◕ัڡ ◕ั ॢ)
View GitHub Profile

#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

@cameck
cameck / database.yml
Created July 1, 2016 13:23
AWS Database Configs for Rails
production:
<<: *default
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
@cameck
cameck / scroll.js
Last active July 11, 2016 15:33
Scroll to Page Location upon Completion of Ajax Request - Jquery
$( document ).ajaxComplete(function() {
// First we get the position of the ID we want
var topLocation = $('#copy-link').position().top;
// Then we scroll to it!
$('html,body').animate( { scrollTop: topLocation } , 1000 );
});
@cameck
cameck / example_dynamo_db_failure.js
Created October 20, 2016 02:39
An example of what DynamoDB returns on a bulk request failure
{
"UnprocessedItems": {
"Table_Name": [ // This will be your actual table name
{
"PutRequest": {
"Item": {
"artist": {
"S": "The Beatles"
},
"Instruments": {
let count = 1;
dynamoDB.batchWriteItem(params, processItemsCallback);
function processItemsCallback(err, data) {
if (err) {
console.log(JSON.stringify(err, null, 2));
} else {
console.log("Response Data: ", JSON.stringify(data));
let itemsLost = data.UnprocessedItems;
// Check if Object size is greater than 0 so we can process missed items if needed
@cameck
cameck / unzip.rb
Last active January 15, 2017 20:58
# Thanks to http://www.markhneedham.com/blog/2008/10/02/ruby-unzipping-a-file-using-rubyzip/
require 'zip/zip'
def unzip_file(file, destination)
files = Zip::ZipFile.open(file) do |zip_file|
zip_file.each do |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
end
".apib.text":
whitespace:
removeTrailingWhitespace: false
@cameck
cameck / themer-dark.terminal
Last active September 1, 2017 14:45
Dark Terminal Theme for Mac Terminal (Made with Themer)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECkwLjA3NDUwOTgw
MzkyIDAuMTMzMzMzMzMzMyAwLjE4MDM5MjE1NjkgMU8QKDAuMDYyMTE3MjM3NiAwLjA5
def sum(arr)
arr.empty? ? 0 : arr.shift + sum(arr)
end
function injectGitFileStatus()
{
const timeout = 5000;
const addedColor = "#98C379";
const modifiedColor = "#D19A66";
const stagedColor = "#E06059";
const ignoredOpacity = "0.4";
const explorer = document.getElementById("workbench.view.explorer");
if (explorer)