Skip to content

Instantly share code, notes, and snippets.

@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@jimtla
jimtla / underscoreR.coffee
Created May 6, 2012 21:51
Add CoffeeScript friendly argument order to Underscore.js
# Five lines of code that will make your underscore + CoffeeScript use cleaner.
# Creates an underscore function for each function in to_reverse with R (short for Reversed) appended to the name.
# The R version moves the function argument (first argument in normal underscore) to the end,
# so you can write:
$(window).scroll _.throttleR 500, ->
console.log "This print's at most every 500ms"
# Instead of:
$(window).scroll _.throttle ->
console.log "This prints at most every 500ms too"
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@gudbergur
gudbergur / README.markdown
Created February 19, 2012 23:49
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@vijaydev
vijaydev / gist:1472145
Created December 13, 2011 13:35
Rails 3.2.0 Changelogs

The latest release notes is available at http://edgeguides.rubyonrails.org/3_2_release_notes.html

Railties 3.2.0 (unreleased)

  • Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting config.reload_classes_only_on_change to false. José Valim

  • New applications get a flag config.active_record.auto_explain_threshold_in_seconds in the environments configuration files. With a value of 0.5 in development.rb, and commented out in production.rb. No mention in test.rb. fxn

  • Add DebugExceptions middleware which contains features extracted from ShowExceptions middleware José Valim

@thermistor
thermistor / assets.rake
Created October 20, 2011 13:55 — forked from shedd/assets.rake
Check asset encoding for valid UTF-8
namespace :assets do
desc "Check that all assets have valid encoding"
task :check => :environment do
paths = ["app/assets", "lib/assets", "vendor/assets"]
extensions = ["js", "coffee", "css", "scss"]
paths.each do |path|
dir_path = Rails.root + path
@samnang
samnang / rails31init.md
Created September 3, 2011 16:27 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@erans
erans / gmail_email.py
Created July 17, 2011 07:45
Check if an Email address is Gmail or Google Apps for your domain
import sys
import re
import dns.resolver # Requires dnspython
email_host_regex = re.compile(".*@(.*)$")
gmail_servers_regex = re.compile("(.google.com.|.googlemail.com.)$", re.IGNORECASE)
def is_gmail(email):
""" Returns True if the supplied Email address is a @gmail.com Email or is a Google Apps for your domain - hosted Gmail address
Checks are performed by checking the DNS MX records """
@geraldalewis
geraldalewis / debug_mode_for_coffee_script.md
Created May 15, 2011 23:10
Debug mode for running .coffee scripts #558, #987

Debug mode for running .coffee scripts #558, #987

Adds a --debug option for .coffee scripts that outputs more helpful error messages (mapping compiled .js lines of code to the input .coffee file's lines).

This branch should be considered experimental at the moment -- it serves as a proof-of-concept and to expose additional issues with adding debugging support to CoffeeScript

Current output:

TypeError: string is not a function

@guenter
guenter / move_to_rds.rb
Created November 11, 2010 02:14
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'