Skip to content

Instantly share code, notes, and snippets.

View devdatta's full-sized avatar

Devdatta Kane devdatta

View GitHub Profile
class User < ActiveRecord::Base
devise :database_authenticatable, :openid_authenticatable, :recoverable, :rememberable, :trackable, :validatable
# Handle creation of user authenticated via OpenID
def self.create_from_identity_url(identity_url)
User.new(:identity_url => identity_url)
end
# Set email as a required field from the Open ID provider

Nick's bash prompt code

Example

[13:14:19][~/Projects/ruby/redmine (master) {jruby-head@redmine}]
$ false
[exited with 1]

Features

@scottlowe
scottlowe / .bashrc
Created September 1, 2010 22:33
Part of a recipe for fronting Glassfish with Nginx
# ~/.bashrc: executed by bash(1) for non-login shells.
# If not running interactively, don't do anything
#[ -z "$PS1" ] && return
if [[ -n "$PS1" ]] ; then
# don't put duplicate lines in the history. See bash(1) for more options
#export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
##Prepare the Server
apt-get update
apt-get upgrade
apt-get install build-essential
apt-get install zlib1g-dev
apt-get install uuid-dev
##Download, Build, make, make install - Ruby 1.9.2p0
@gravis
gravis / readme
Created September 26, 2010 17:26
tcp syslog logger for rails draft
tcp_syslog is now a gem :
https://github.com/tech-angels/tcp_syslog
// Handles JavaScript history management and callbacks. To use, register a
// regexp that matches the history hash with its corresponding callback.
window.HashHistory = {
// The interval at which the window location is polled.
URL_CHECK_INTERVAL : 500,
// We need to use an iFrame to save history if we're in an old version of IE.
USE_IFRAME : jQuery.browser.msie && jQuery.browser.version < 8,
@janlelis
janlelis / pws.rb
Created November 1, 2010 16:58
Build your own PasswordSafe with Ruby
# pws has been refactored! See https://github.com/janlelis/pws
@rtdp
rtdp / gist:742461
Created December 15, 2010 19:27
Importing Gmail Contacts list to Rails Application.
class ImportedContactsController << ApplicationController
require 'net/http'
require 'net/https'
require 'uri'
#THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE.
def authenticate
# initiate authentication w/ gmail
# create url with url-encoded params to initiate connection with contacts api
# next - The URL of the page that Google should redirect the user to after authentication.
# scope - Indicates that the application is requesting a token to access contacts feeds.
class Message < ActiveRecord::Base
validate :image_size_validation, :if => Proc.new { |m| m.image.present? }
mount_uploader :image, MessageImageUploader
private
def image_size_validation
errors[:image] << "should be less than 2MB" if image.size > 2.megabytes
end
@thokra
thokra / gist:818689
Created February 9, 2011 15:50
jQuery fix
$.ajaxSetup({
headers: {
"X-CSRF-Token": $("meta[name='csrf-token']").attr('content')
}
});