Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile
@alexpchin
alexpchin / geocoder-service.js
Created February 11, 2016 22:46 — forked from benmj/geocoder-service.js
An AngularJS Service for intelligently geocoding addresses using Google's API. Makes use of localStorage (via the ngStorage package) to avoid unnecessary trips to the server. Queries Google's API synchronously to avoid `google.maps.GeocoderStatus.OVER_QUERY_LIMIT`
/*global angular: true, google: true, _ : true */
'use strict';
angular.module('geocoder', ['ngStorage']).factory('Geocoder', function ($localStorage, $q, $timeout) {
var locations = $localStorage.locations ? JSON.parse($localStorage.locations) : {};
var queue = [];
// Amount of time (in milliseconds) to pause between each trip to the
@alexpchin
alexpchin / rspec_rails_cheetsheet.rb
Created February 9, 2016 18:42 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@alexpchin
alexpchin / gulpfile.js
Created January 20, 2016 13:56 — forked from edouard-lopez/gulpfile.js
Gulp copy font-awesome files to dist/ directory
'use strict';
// Generated on 2014-04-14 using generator-leaflet 0.0.14
var gulp = require('gulp');
var open = require('open');
var wiredep = require('wiredep').stream;
// Load plugins
var $ = require('gulp-load-plugins')();
@alexpchin
alexpchin / gulpfile.js
Created January 16, 2016 17:45 — forked from vincent-zurczak/gulpfile.js
Copy minified Bower dependencies with Gulp (better solution)
// Include our plug-ins
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var exists = require('path-exists').sync;
// Create some task
gulp.task( 'copy-bower-dep', function() {
// Replace files by their minified version when possible
var bowerWithMin = mainBowerFiles().map( function(path, index, arr) {
@alexpchin
alexpchin / oauth_twit_consume_example.js
Created January 6, 2016 11:46 — forked from tomshaw/oauth_twit_consume_example.js
Some Node.js Express, Jade, examples using Node-OAuth querying protected Twitter consumer resources.
function consumer() {
return new oauth.OAuth(
"https://twitter.com/oauth/request_token",
"https://twitter.com/oauth/access_token",
keys.twitterConsumerKey,
keys.twitterConsumerSecret,
"1.0A",
"http://localhost:3000/sessions/callback",
"HMAC-SHA1"
);
@alexpchin
alexpchin / angularjs_resource_tokenhandler.js
Last active September 3, 2015 22:58 — forked from nblumoe/angularjs_resource_tokenhandler.js
AngularJS service to send auth token with $resource requests
.factory('TokenHandler', function() {
var tokenHandler = {};
var token = "none";
tokenHandler.set = function( newToken ) {
token = newToken;
};
tokenHandler.get = function() {
return token;
@alexpchin
alexpchin / Git.md
Last active August 29, 2015 14:27 — forked from yegeniy/Git.md
git: commands I commonly use, relevant ramblings, and configuration.

Commands I Commonly Use

  1. Clone an existing repository:

    git clone <repo>

    (e.g. https://gist.github.com/1125520.git).

  2. [Checkout and pull an existing branch][gcp]:

@alexpchin
alexpchin / gist:b42343922a96698abd18
Last active August 29, 2015 14:27 — forked from liamcurry/gist:2597326
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@alexpchin
alexpchin / authentication_with_bcrypt_in_rails_4.md
Last active August 29, 2015 14:26 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#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

## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################