Skip to content

Instantly share code, notes, and snippets.

View joelongstreet's full-sized avatar

Joe Longstreet joelongstreet

  • Kodable
  • Kansas City, Missouri - United States
View GitHub Profile
Some test gist right here
var OAuth = require('oauth').OAuth;
var baseURL = 'https://passport.vml.com';
consumer = new OAuth(
baseURL + '/oauth/request_token',
baseURL + '/oauth/access_token',
'w9hJkqLgqRR9mPdrmxyh76qxMrnG3CeD',
'4TAfNxp2JCwCYz4Tn8hP8bwuHe7PWdjK',
'1.0', null, 'HMAC-SHA1'
);
@joelongstreet
joelongstreet / user.rb
Last active January 2, 2016 12:59
user.rb
require 'oauth'
class User < ActiveRecord::Base
validates :email, :email => true
validates :name, :passport_id, :presence => true
before_validation :get_passport_data, :on => :create
def get_passport_data
@consumer = OAuth::Consumer.new ENV['PASSPORT_OAUTH_KEY'],
require 'spec_helper'
describe User do
it 'should reach out to passport via oauth and populate user attributes' do
user = FactoryGirl.create(
:user,
:passport_id => 2322
)
user.email.should eq 'jlongstreet@vml.com'
@joelongstreet
joelongstreet / passport-oauth.rb
Last active January 2, 2016 12:59
a sample of how to use oauth with VML's passport product
require 'oauth'
require 'json'
consumer = OAuth::Consumer.new ENV['PASSPORT_OAUTH_KEY'],
ENV['PASSPORT_OAUTH_SECRET'],
{ :site => 'https://passport.vml.com' }
request_token = consumer.get_request_token
access_token = request_token.get_access_token
response_body = JSON.parse(access_token.get("/api/user/jlongstreet/ui.json").body)
@joelongstreet
joelongstreet / passport-oauth.js
Last active January 2, 2016 09:49
a sample of how to use oauth with VML's passport product
var OAuth = require('oauth').OAuth;
var baseURL = 'https://passport.vml.com';
consumer = new OAuth(
baseURL + '/oauth/request_token',
baseURL + '/oauth/access_token',
process.env.PASSPORT_OAUTH_KEY,
process.env.PASSPORT_OAUTH_SECRET,
'1.0', null, 'HMAC-SHA1'
);
@joelongstreet
joelongstreet / nextMeetup.md
Last active December 31, 2015 17:59
A list of ideas for the next nodekc meetup. A todo list for people.

Next Meetup

  • 6 - What happens if NPM goes down
  • 8 - Running Node in production
  • 5 - Show and Tell all the things
  • 7 - Database Year (mongo, cassandra, redis, leveldb, couch, manta, datomic)
  • 7 - Koa.js

ToDo

  • Teal - talk with the indie game dev group
@joelongstreet
joelongstreet / buttWipe.js
Created November 13, 2013 14:02
remove endless gobs of garbage produced by the world's worst text editor... MICROSOFT WORD
// Pasting from Microsoft word is an ABSOLUTE DISASTER
// this method removes the endless gobs of garbage produced
// by the world's worst, yet most popular, text editor
// Requires jQuery
var cleanHTML = function(pastedString){
// If this looks like some kind of raunchy ass microsoft bull shit,
// rip off it's effing <HEAD></HEAD>
var headRegex = new RegExp("<head[\\d\\D]*?\/head>", "g");
pastedString = pastedString.replace(headRegex, '');
var obj = [{"id":"user_1","name":"Matt Carter","gender":"male","age":"30"}, {"id":"user_2","name":"Erik Akers","gender":"male","age":"29"}]
var str = JSON.stringify(obj)
var parsed = JSON.parse(str)
require.config({
baseUrl : '/js/',
paths : {
'jquery' : '/vendor/jquery',
'underscore' : '/vendor/underscore',
'handlebars' : '/vendor/handlebars',
'hbs' : '/vendor/hbs',
'ejs' : '/vendor/ejs',
'backbone' : '/vendor/backbone',
'chaplin' : '/vendor/chaplin',