Skip to content

Instantly share code, notes, and snippets.

@harigopal
harigopal / 2017-04-15-service-loggable-concern.rb
Created April 15, 2017 15:55
2017-04-15-service-loggable-concern
module Loggable
extend ActiveSupport::Concern
def log(message)
return if Rails.env.test?
Rails.logger.info "[#{current_timestamp}] [#{current_service_name}] #{message}\n"
end
private
@evanleck
evanleck / http-decorator.rb
Created September 22, 2016 17:12
Decorating Ruby's Net::HTTP for Fun and Profit
# encoding: UTF-8
# frozen_string_literal: true
require 'net/http'
require 'json'
require 'uri'
class HTTPDecorator
# Timeouts
OPEN_TIMEOUT = 10 # in seconds
READ_TIMEOUT = 120 # in seconds
@joyrexus
joyrexus / README.md
Last active February 3, 2026 21:18 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@willurd
willurd / web-servers.md
Last active February 3, 2026 15:05
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jgv
jgv / gist:1502777
Created December 20, 2011 19:03 — forked from trevorturk/gist:34895
Allow "uploads via url" with Rails and Paperclip
#
# See also: http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/
#
# Allow "uploads via url" with Rails and Paperclip
#
# http://www.thoughtbot.com/projects/paperclip
# http://github.com/thoughtbot/paperclip/tree/master
# http://groups.google.com/group/paperclip-plugin/browse_thread/thread/456401eb93135095
#
# This example is designed to work with a "Photo" model that has an "Image" attachment