Skip to content

Instantly share code, notes, and snippets.

View kcrwfrd's full-sized avatar

Kevin Crawford kcrwfrd

View GitHub Profile
@kcrwfrd
kcrwfrd / rainforest.coffee
Created June 21, 2015 21:35
Fun little puzzle to apply to Rainforest QA
http = require 'http'
url = require 'url'
entry_url = 'http://letsrevolutionizetesting.com/challenge.json'
recurse = (url_string) ->
console.log '\nfollowing...', url_string
url_obj = url.parse url_string
@kcrwfrd
kcrwfrd / rot13.coffee
Last active August 29, 2015 14:23
Encode or decode rot13
# To run tests:
# npm install -g jasmine-node
# jasmine-node --color --coffee --matchall --autotest rot13.coffee
###
@name translateChar
@description
Encodes or decodes a single character either to or from rot13
@param char {String} - Must be exactly 1 character
@kcrwfrd
kcrwfrd / wishlist.md
Last active August 29, 2015 14:10
Christmas Wishlist 2014
@kcrwfrd
kcrwfrd / getTree.coffee
Created June 18, 2014 15:48
Creates a node tree from a flat array of objects with `path` attributes
animals = [
name: 'Labrador'
path: ['Animals', 'Dogs', 'Labrador']
,
name: 'Poodle'
path: ['Animals', 'Dogs', 'Poodle']
,
name: 'Cheetah'
path: ['Animals', 'Cats', 'Cheetah']
,
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/assets/img/favicon/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/assets/img/favicon/apple-touch-icon-144x144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="/assets/img/favicon/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/assets/img/favicon/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="/assets/img/favicon/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/assets/img/favicon/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/assets/img/favicon/apple-touch-icon-precomposed.png">
<link rel="icon" href="/assets/img/favicon/favicon-16x16.png" sizes="16x16">
<link rel="icon" href="/assets/img/favicon/favicon-32x32.png" sizes="32x32">
@kcrwfrd
kcrwfrd / clone_existing_octopress_blog.sh
Last active December 27, 2015 00:49
Cloning an existing install of Octopress
# Assuming that you have your Ruby environment configured
git clone -b source git@github.com:username/username.github.io.git username.github.io
git clone -b master git@github.com:username/username.github.io.git username.github.io/_deploy
cd username.github.io
bundle install
@kcrwfrd
kcrwfrd / overview.md
Last active December 27, 2015 00:29
Architecture of an Angular thick client, with a Node middle tier, communicating with a separate RESTful web service.

Angular is a thick client, served by Node.js, primarily interfacing with a separate RESTful web service.

Node.js comes in for user authentication, communicating with an oAuth provider, getting the returned data, and looking up or creating the user on the web service. It then stores that user data as a session in Mongo. The user data is then made available to angular as JSON from Node.js.

Once authenticated, the Angular app should communicate directly with the RESTful web service.

@kcrwfrd
kcrwfrd / Overview.md
Last active June 5, 2016 22:48
OAuth user authentication with Node.js, Express, Passport, and Angular.

Proposed improvement to user authentication for the MEAN boilerplate. See linnovate/mean#121

Node/Express/Passport

  1. An express route for /auth/<service_provider> uses passport to redirect to the oauth service provider
  2. The OAuth provider redirects back to /auth/<service_provider>/callback
  3. Finally, Express redirects to /. Once authenticated, user data is available as JSON from /users/me.

Angular

  1. There is a main controller set on the body element, MainCtrl.
  2. It calls the login method on a service, AuthService. AuthService.login() attempts to make an Angular $http request to /users/me.
@kcrwfrd
kcrwfrd / .bash_profile
Created June 7, 2013 08:02
home dotfiles
# Custom bash prompt
export PS1="\u@\h:\w$ "
# Add /usr/local/bin to path for Homebrew
export PATH="/usr/local/bin:/usr/local/share/npm/bin:/usr/local/sbin:~/bin:$PATH"
# Enable shims and auto-complete for rbenv
eval "$(rbenv init -)"
# Postgres
@kcrwfrd
kcrwfrd / RegEx
Created May 1, 2013 18:16
A collection of RegEx search/replaces that I've used
Search:
(-?[0-9.]+)rem
Replace:
rem($1)
Example:
2rem -> rem(2)
-2rem -> rem(-2)
1.5rem -> rem(1.5)