Skip to content

Instantly share code, notes, and snippets.

View bensheldon's full-sized avatar
🏊‍♂️
Swimming through code.

Ben Sheldon [he/him] bensheldon

🏊‍♂️
Swimming through code.
View GitHub Profile
@bensheldon
bensheldon / domain disposal
Created January 12, 2013 21:22
Disposing Node's domains can have some odd effects on other async functions being called. (Node v0.8.15)
var domain = require('domain');
var d = domain.create();
d.on('error', function(err) {
// d.dispose(); // the nextTick() function DOES get called
process.nextTick(function() {
console.error('Caught:', err);
})
// d.dispose(); // the nextTick() function does NOT get called

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

Excerpt from the Port Huron Statement:

How shall the "public sector" be made public, and not the arena of a ruling bureaucracy of "public servants"? By steadfast opposition to bureaucratic coagulation, and to definitions of human needs according to problems easiest for computers to solve. Second, the bureaucratic pileups must be at least minimized by local, regional, and national economic planning -- responding to the interconnection of public problems by comprehensive programs of solution. Third, and most important, by experiments in decentralization, based on the vision of man as master of his machines and his society. The personal capacity to cope with life has been reduced everywhere by the introduction of technology that only minorities of men (barely) understand.

@bensheldon
bensheldon / *rail_static_assets_on_heroku_cedar.md
Last active March 2, 2020 20:20
Serving Rails Static Assets on Heroku using a CDN with gzip and cache control

Optimizing Rails Static Assets on Heroku Cedar

Serving Rails static assets is hard, especially on Heroku Cedar where Heroku forces Rails to serve static assets itself (which isn't particularly performant nor worth your dyno-dollar)---this is different than Heroku Bamboo which used Varnish and is no more. To make the best of the situation, I highly recomend:

  1. Using the Heroku-Deflater gem which will selectively gzips assets (it gzips text-based files; and excludes images or binary files, which can actually be bigger when gzipped)

  2. Configure your production environment to set cache-control headers and get out of denial about how static assets are being served on Heroku Cedar

  3. Use AWS Cloudfront (or a CDN of your choosing) to serve the assets. Cloudfront is great because you can use the same Distribution

Running rails in threadsafe mode

@bensheldon
bensheldon / random_n_emoji.rb
Last active December 14, 2015 21:59
Random N Emoji
#!/usr/bin/ruby
emojis = [["bowtie","smile","laughing","blush","smiley","relaxed","smirk","heart_eyes","kissing_heart","kissing_closed_eyes","flushed","relieved","satisfied","grin","wink","stuck_out_tongue_winking_eye","stuck_out_tongue_closed_eyes","grinning","kissing","kissing_smiling_eyes","stuck_out_tongue","sleeping","worried","frowning","anguished","open_mouth","grimacing","confused","hushed","expressionless","unamused","sweat_smile","sweat","disappointed_relieved","weary","pensive","disappointed","confounded","fearful","cold_sweat","persevere","cry","sob","joy","astonished","scream","neckbeard","tired_face","angry","rage","triumph","sleepy","yum","mask","sunglasses","dizzy_face","imp","smiling_imp","neutral_face","no_mouth","innocent","alien","yellow_heart","blue_heart","purple_heart","heart","green_heart","broken_heart","heartbeat","heartpulse","two_hearts","revolving_hearts","cupid","sparkling_heart","sparkles","star","star2","dizzy","boom","collision","anger","exclamation","question","grey_exclamati
@bensheldon
bensheldon / Preferences.sublime-settings
Created April 9, 2013 20:52
Sublime -> Preferences -> "Settings - User"
{
"ensure_newline_at_eof_on_save": true,
"font_size": 14.0,
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
class MyClass
self.instance
Dispatch.once { @instance ||= self.new }
end
end
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'motion-cocoapods'
require 'bundler'
Bundler.require
Dir.glob('lib/tasks/*.rake').each { |r| import r }
VERSION = "1.0.2"