Skip to content

Instantly share code, notes, and snippets.

View harlantwood's full-sized avatar
💭
☀️

Harlan T Wood harlantwood

💭
☀️
View GitHub Profile
@bitdivine
bitdivine / decimal-number.js
Created February 26, 2016 13:03
HTML input type number with decimal precision.
(function(){
// Input field given to n decimal places. Degrades gracefully to standard numeric input.
// Usage: <input type="number" is="decimal-number" data-places="2" name="..." value="...">
try {
var proto = Object.create(HTMLInputElement.prototype);
proto.createdCallback = function() {
this.type = "number";
this.addEventListener("change", this.decimate);
this.value = parseFloat(this.value).toFixed(this.getAttribute('data-places'));
};
@maxivak
maxivak / 00.md
Last active April 20, 2024 22:17
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@joost
joost / update_cache_counters.rake
Last active September 25, 2018 15:05 — forked from svyatov/update_cache_counters.rake
Rails Rake Task: Update all cache counters / counter caches.
# More robust version to update new or existing counter cache columns in your Rails app.
# See: https://gist.github.com/svyatov/4225663
desc 'Update all cache counters'
task :update_cache_counters => :environment do
models_to_update = {}
# or: Rails.application.eager_load!
# Dir loads less, so it's faster
Dir.glob(Rails.root.join('app/models/**/*')).each { |model| require model if File.file?(model) }
ruby -e 'system("heroku create z#{29.times.map{ (("a".."z").to_a + ("0".."9").to_a).sample }.join}")'
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@technoweenie
technoweenie / github_oauth_busy_developer_guide.md
Created May 30, 2010 18:34
GitHub OAuth Busy Developer's Guide

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@harlantwood
harlantwood / .gitignore
Created October 28, 2009 00:43
bash_profile extensions
custom