Skip to content

Instantly share code, notes, and snippets.

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

Cameron Eckelberry cameck

🍩
(ॢ◕ัڡ ◕ั ॢ)
View GitHub Profile
@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
@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 );
});

#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 / script.js
Created May 6, 2016 23:37
Scripts for the Loneliest Chat room
$(document).ready(function(){
var newChat = function() {
var author = ["Me", "Myself", "I"];
var randomNumber = Math.floor(Math.random() * 3);
var time = new Date();
time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
console.log(time);
var newMessage = $('#new-message-body').val();
@cameck
cameck / index.html
Last active April 15, 2016 03:10
The Holy Grail of Layouts with Flex Box
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>This is the Holy Grail</title>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<header>This is my header</header>
@cameck
cameck / person.rb
Created April 11, 2016 01:16
#This is a REPL directory creator for a mock Voting database. #It allows you to use all aspects of CRUD.
class Person
attr_accessor :name
def initialize(name)
@name = name
end
end
# Hostage! A Terminal based interactive Choose Your Own Adventure Game (All sounds from http://soundbible.com & http://www.freesound.org/)
# Download the audio files here: https://www.dropbox.com/sh/d4h5f36nwy4pw3j/AADjkh_ZLf9PK8cltX8ZUahTa?dl=0
# Once downloaded them place them in a folder named "audio" in the same directory as this game and start playing!
# variables
invalid_entry = "INVALID ENTRY TRY AGAIN"
thanks = "\nThanks for Playing! 👏 👏 👏 👏"
meet_cortana1 = "Upon entering the Cortana’s study, he smiles. As he open’s his mouth to speak..."
meet_cortana2 = "the room erupts in flames.🔥 🔥 🔥\nNorth Korea finally launched a successful ballistic missile. 🚀️"
hr = "______________________________________________________________________________"
@cameck
cameck / functions.php
Last active March 29, 2016 23:32
Cancel Constant Contact Subscription if User does not Check the sign up box on more than one form.
<?php
function disable_newsletter_signup( $form_id ) {
global $ninja_forms_processing;
$form_id = $ninja_forms_processing->get_form_ID();
if ( $form_id == 1 || $form_id == 2 || $form_id == 3 ) {
switch ($form_id) {
case 1: //Form 1
$opt_in = $ninja_forms_processing->get_field_value( 32 );
break;
<?php
/**
* This file adds the Home Page to the Cafe Pro Theme.
*
* @author StudioPress
* @package Cafe
* @subpackage Customizations
*/
add_action( 'genesis_meta', 'cafe_home_genesis_meta' );