Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@dpratt
dpratt / spray-stream-enumerator
Created July 24, 2014 16:52
A Spray chunking marshaller for Play Enumerators
package com.vast.utils
import akka.actor._
import akka.io.Tcp
import play.api.libs.iteratee._
import scala.concurrent.ExecutionContext
import spray.http._
import spray.httpx.marshalling.{MarshallingContext, Marshaller}
import akka.util.{ByteString, Timeout}
import scala.util.control.NonFatal
@sdepold
sdepold / virtual-attributes.js
Created October 29, 2013 18:24
virtual attributes with sequelize
var Sequelize = require('sequelize')
, sequelize = new Sequelize('sequelize_test', 'root')
var User = sequelize.define('User', {
username: Sequelize.STRING,
password_hash: Sequelize.STRING
}, {
validate: {
password: function(next) {
if (((this._password || "").trim() !== '') && (this._password === this._password_confirmation)) {
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@carsonmcdonald
carsonmcdonald / revspdynpn.sh
Created April 27, 2011 14:52
How to set up ruby, eventmachine and spdy to use NPN
#
# Get development tools installed
#
sudo yum install -y git cvs zlib-devel
sudo yum groupinstall -y "Development Tools"
#
# Install RVM
#
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
@mbleigh
mbleigh / generate_markets.rb
Created April 5, 2011 03:55
The model and generation code to pull the 100 biggest US cities out as geographical models for a Rails app.
# Data culled from Wikipedia. Could be cleaner, but this is nice and simple.
major_cities = [["New York", "New York"], ["Los Angeles", "California"], ["Chicago", "Illinois"], ["Houston", "Texas"], ["Philadelphia", "Pennsylvania"], ["Phoenix", "Arizona"], ["San Antonio", "Texas"], ["San Diego", "California"], ["Dallas", "Texas"], ["San Jose", "California"], ["Jacksonville", "Florida"], ["Indianapolis", "Indiana"], ["San Francisco", "California"], ["Austin", "Texas"], ["Columbus", "Ohio"], ["Fort Worth", "Texas"], ["Charlotte", "North Carolina"], ["Detroit", "Michigan"], ["El Paso", "Texas"], ["Memphis", "Tennessee"], ["Baltimore", "Maryland"], ["Boston", "Massachusetts"], ["Seattle", "Washington"], ["Washington", "District of Columbia"], ["Nashville", "Tennessee"], ["Denver", "Colorado"], ["Louisville", "Kentucky"], ["Milwaukee", "Wisconsin"], ["Portland", "Oregon"], ["Las Vegas", "Nevada"], ["Oklahoma City", "Oklahoma"], ["Albuquerque", "New Mexico"], ["Tucson", "Arizona"], ["Fresno", "California"], ["Sacrame
@tenderlove
tenderlove / person_test.rb
Created February 10, 2011 23:04
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
module Tenderlove
class Spec < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
@croaky
croaky / Gemfile
Created January 18, 2011 03:46
Getting a CouchDB app running on Rails 3 as of September, 2010
gem 'couchrest_extended_document'