Skip to content

Instantly share code, notes, and snippets.

View entp's full-sized avatar

ENTP entp

View GitHub Profile
class ApiSerializer < ActiveRecord::Serialization::JsonSerializer #:nodoc:
def serializable_record
@host_name = @options.delete :host
@is_supporter = @options.delete :supporter
@site_permalink = @options.delete :site_permalink
@site_prefix = nil
super
end
def site_prefix
@entp
entp / gist:662049
Created November 4, 2010 02:23
Get around FireSheep issues for non-SSL connections
One of the problems with requiring SSL for all pages in a site is that you can't rely on a lot of the benefits of browser caching. However, many sites DO require login over SSL.
During login process, set a LocalStorage private key. This won't be visible to any attacker.
Periodically, ask user to encrypt or hash something asymmetrically and send the (public) result back.
If a user sends back the same result twice, or it wasn't encrypted correctly, log them out.
This may require some way to track individual tabs - if a user opens a new tab/window, there's likely some way to track this. Maybe they can encrypt the last URL they opened, and set that as a cookie.
@entp
entp / Rakefile
Created February 15, 2011 02:02
Downloads all the messages in your imap mailbox and saves them as files.
IMAP = { :user => "[email protected]", :pass => "yourpassword" }
namespace :imap do
wrapper = nil
task :connect do
dir = "#{File.dirname(__FILE__)}/../../../../"
require 'imap_wrapper'
include ImapWrapper::Constants
wrapper = ImapWrapper.new(IMAP[:user], IMAP[:pass], ENV['PURGE'], ENV['VERBOSE'])