Skip to content

Instantly share code, notes, and snippets.

@adeelejaz
adeelejaz / downloader.rb
Last active Aug 29, 2015
How to download a bunch of files in Rails and save them?
View downloader.rb
require 'open-uri'
arr = ['http://example.com/file1.txt', 'http://example.com/file2.txt']
arr.each do |url|
open(url.split('/').last, 'wb') do |file|
file << open(url).read
end
end
@adeelejaz
adeelejaz / jquery.browser.js
Last active Jan 9, 2018
jQuery $.browser as a separate file in case you do not want to include the full migration file
View jquery.browser.js
(function( jQuery, window, undefined ) {
"use strict";
var matched, browser;
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||