Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am ec on github.
  • I am ec (https://keybase.io/ec) on keybase.
  • I have a public key whose fingerprint is CFF1 4DEF 6ADF A722 5190 D9AD 7CFC 2DB6 12FD 1FF5

To claim this, I am signing this object:

View keybase.md

Keybase proof

I hereby claim:

  • I am ecarnevale on github.
  • I am ec (https://keybase.io/ec) on keybase.
  • I have a public key whose fingerprint is CFF1 4DEF 6ADF A722 5190 D9AD 7CFC 2DB6 12FD 1FF5

To claim this, I am signing this object:

View user.rb
class User < ActiveRecord::Base
devise :trackable, :validatable, :database_authenticatable, :rememberable,
:omniauthable, :omniauth_providers => [:google_oauth2]
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :provider, :uid
def self.find_by_authentication_token(access_token)
client = OAuth2::Client.new(ENV['GOOGLE_OAUTH2_ID'],ENV['GOOGLE_OAUTH2_SECRET'])
begin
response = client.request(:get, 'https://www.googleapis.com/oauth2/v2/tokeninfo', :params => {
View application_controller.rb
class ApplicationController < ActionController::Base
# protect_from_forgery
before_filter :authenticate_user_from_token!
before_filter :authenticate_user! #for classic Devise authentication
def authenticate_user_from_token!
access_token = params[:access_token].presence
if access_token
user = User.find_by_authentication_token(access_token.to_s)
View gist:c79273714fbe9ba5abfd
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => ENV['SMTP_HOST'],
:port => 587,
:authentication => :plain,
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:domain => ENV['SMTP_DOMAIN'],
:enable_starttls_auto => true
}
@ecarnevale
ecarnevale / domokun.rb
Created Oct 4, 2008
A tributeto http://domokun.tumblr.com and an attempt to play with downloads in Shoes
View domokun.rb
#
# Domokun.rb
#
# Created by Emanuel Carnevale on 2008-08-30.
# Copyright (c) 2008 emanuelcarnevale.com. All rights reserved.
#
require "hpricot"
require 'open-uri'
Shoes.app(:title => "Domo nom nom", :width => 550, :height => 600, :resizeable => false) do
@ecarnevale
ecarnevale / fontified_shoes.rb
Created Oct 6, 2008
A lil test app to show how the fonts appear in Shoes
View fontified_shoes.rb
# Just a lil app to test out the new fonts in Shoes.
Shoes.app do
stack do
Shoes::FONTS.each { |font|
inscription font, :stroke => red
para font, :font => font
}
end
end
View gist:16832
class Image(webapp.RequestHandler):
def get(self):
url = "http://api.thumbalizr.com/?url=http://www.ford.de&width=250"
response = urlfetch.fetch(url)
if response.status_code == 200:
self.response.headers['Content-Type'] = "image/jpg"
self.response.out.write(response.content)
else:
self.error(404)
View pong_copycat.rb
#
# Pong Challenge, copycat version
#
# Created by Emanuel Carnevale on 2008-11-18.
# Shamelessly adapted by http://billmill.org/pong.html
Shoes.app :width => 400, :height => 400, :resizable => false do
paddle_size = 75
View gist:47224
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain