Skip to content

Instantly share code, notes, and snippets.

@OaklandRocks
OaklandRocks / SETUP_DAY.md
Created March 4, 2021 08:25
Starting my coding journey...
@OaklandRocks
OaklandRocks / examples.js
Created March 22, 2015 18:55
Some simple JS examples
var english = {};
var americanEnglish = Object.create(english);
var britishEnglish = Object.create(english);
var define = function(dictionary,word,definition){
dictionary[word] = definition;
};
define(english,"house","place to live");
define(english,"tree","big green thing");
(function(angular) {
'use strict';
var app = angular.module('MyApp', []);
app.factory('GeolocationSvc', [
'$q', '$window',
function($q, $window) {
return function() {
var deferred = $q.defer();
vid = document.getElementsByClassName("video-stream html5-main-video")[0];
vid.playbackRate = 3.0;
require 'oauth2'
require 'net/http'
require 'uri'
API_KEY = 'XXXXXXXXX' #Your app's API key
API_SECRET = 'XXXXXXXXXXXXX' #Your app's API secret
REDIRECT_URI = 'http://localhost:3000/accept' #Redirect users after authentication to this path
#Instantiate your OAuth2 client object
def client
function GetCommentsWithOAuth(){
viewModel.comments([]);
$.ajax({ url: "/services/comments/oauth",
accepts: "application/json",
cache: false,
statusCode: {
200: function(data){
viewModel.comments(data);
},
@OaklandRocks
OaklandRocks / build-api-challenge.rb
Created March 9, 2015 22:13
Build-api-challenge
require 'spec_helper'
describe "index controller" do
describe "GET /users" do
context "when there are 0 users" do
before do
User.delete_all
end

#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

@OaklandRocks
OaklandRocks / fizz_buzz.rb
Created October 2, 2014 09:09
fizzbuzz game
def fizzbuzz(array)
result = []
array.each do |i|
if i % 15 == 0
result << "FizzBuzz"
elsif i % 5 == 0
result << "Buzz"
elsif i % 3 == 0
result << "Fizz"
else