Skip to content

Instantly share code, notes, and snippets.

View sanjayginde's full-sized avatar

Sanjay Ginde sanjayginde

View GitHub Profile
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
function base64_decode(input){
var output = new Array();
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
var orig_input = input;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
if (orig_input != input)
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@sanjayginde
sanjayginde / Attachment_from_remote_url_with_Paperclip.md
Last active May 17, 2016 14:25 — forked from jgv/gist:1502777
Support setting a Paperclip attachment from a remote URL with a generic mixin for Rails

See also: http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/

Forked from: https://gist.github.com/1502777

The goal was a more generic solution to the one in gist this is forked from. It does not require the addition of any more db columns, as I choose not to store the remote URL.

Currently missing, is validation of the remote URL and error handling. Probably makes sense to just work with ActiveRecord::Errors

Currently, the file upload takes precedence over the the remote url, if a user supplies both. I'm thinking that should probably be an option flag on can_attach_remote_url.