Skip to content

Instantly share code, notes, and snippets.

View axldyb's full-sized avatar
💭
Opening doors with digital keys @Unloc

Aksel Dybdal axldyb

💭
Opening doors with digital keys @Unloc
View GitHub Profile
@machu
machu / oauth-sample.rb
Created August 19, 2009 03:18
OAuth Consumer Example with Sinatra: http://www.machu.jp/diary/20090818.html#p01
require 'rubygems'
require 'sinatra'
require 'oauth'
require 'twitter'
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
//
// NSArray+BinarySearch.h
// BinarySearch
//
// Created by Ole Begemann on 19.04.10.
// Copyright 2010 Ole Begemann. All rights reserved.
//
#import <Foundation/Foundation.h>
@robcthegeek
robcthegeek / user.rb
Created November 9, 2011 21:32
"Standard" User Model Using Mongoid/BCrypt
require 'bcrypt'
class User
include Mongoid::Document
include Mongoid::Timestamps
include BCrypt
attr_accessor :password, :password_confirmation
attr_protected :password_hash
@shlomizadok
shlomizadok / omniauth_callbacks_controller.rb
Created May 19, 2012 10:37
How to integrate Omniauth and API
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
@docwhat
docwhat / keychain2certfile.rb
Last active November 17, 2015 01:54
Creates an SSL_CERT_FILE on OSX (when using Homebrew) that won't break JRuby. Make sure you run this with normal ruby, not JRuby! See https://github.com/jruby/jruby-openssl/issues/56
#!/usr/bin/env ruby
# General idea stolen with no regret from Homebrew's OpenSSL formula.
require 'optparse'
require 'forwardable'
require 'shellwords'
require 'openssl'
require 'digest/md5'
require 'digest/sha1'