Skip to content

Instantly share code, notes, and snippets.

@thibaudgg
thibaudgg / truncate_middle.rb
Created May 19, 2010 10:09
truncate in the middle like Finder
# If text is longer than +options[:length]+ (defaults to 30), text will be middle-truncated
# and the last characters will be replaced with the +options[:omission]+ (defaults to "...").
def truncate_middle(text, *args)
options = args.extract_options!
options.reverse_merge!(:length => 30, :omission => "...")
if text
if text.mb_chars.length <= options[:length]
text
else
@dkubb
dkubb / gist:556033
Created August 29, 2010 06:26
DO API ideas
connection = DataObjects::Connection.new(uri)
connection.close
# immediately executed statements
reader = connection.query('SELECT * FROM table WHERE id = ?', 1)
reader.set_types(Integer) # returns self for chaining
reader.each { |row| ... }
class Numeric
def commify
to_s.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/,'\1,').reverse
end
end
require 'rubygems'
require 'yajl'
tests = []
module Test
module Unit
TestCase = RSpec::Core::ExampleGroup
end
end
class Test::Unit::TestCase
def self.inherited(host)
host.set_it_up host.name.gsub(/(Spec|Test)/,'')
def host.method_added(name)
@tobitailor
tobitailor / def.js
Created July 13, 2010 23:32
Simple Ruby-style inheritance for JavaScript
/*
* def.js: Simple Ruby-style inheritance for JavaScript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*
*
* Example:
*
* def ("Person") ({

Pressure cooker Pho Ga (vietnamese chicken soup)

OK. First of all, this does not aim to be authentic in any sense of the word or be simple or be perfect. It is a reasonable approximation of a favorite chicken soup/flavor profile produced with what I see as the right level of tradeoffs between time saving and being finicky. The most memorable Pho Ga I've had was at Turtle Tower in SF. This is chasing that flavor memory but also maybe some of my own chicken soup preferences.

Tools required:

  • Pressure Cooker (stovetop or electric)
  • Fine mesh sieve or chinois
  • Cast iron pan
@brianmario
brianmario / bars.md
Last active June 14, 2019 21:29
Some places to check out in Portland

Bars

PROTIP: Bars in Oregon have to serve food as long as they're serving alcohol. As a result, some of them have amazing food.

PROTIP: You can't buy alcohol (other than beer or wine) anywhere else but a state-controlled liquor store. Most of them are closed on Sundays and close around 7pm every other night of the week.

Southeast

  • The Night Light - This was our favorite bar just before we moved to Italy. Right in the heart of the quiet Clinton district (where we were living at the time).
  • The Doug Fir Lounge - I hate to use the word swanky again but that's the only way I can describe it. The entire place is built to look like a log cabin. Used to go here all the time. Pretty good bar. The restaurant is open until 3am (or at least was when I lived there) and has some DAMN good gastro pub style food. The halibut fish and chips and burger are insane. Funny enough, I saw the GitHub guys here (including maddox and Tek I think?) after
@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]

@frsyuki
frsyuki / article.md
Last active June 23, 2020 12:02
MessagePack for Ruby version 5

MessagePack for Ruby version 5

Today, I released the new version of MessagePack for Ruby!

Even faster

I rewrote all the code and achieved significant performance improvement, especially for serialization. I compared the new version to the old version (v4) using ruby-serializers benchmark, and the new version is faster for all data sets including Twitter, Image, Integers, Geo and 3D model.

@brianmario
brianmario / config.ru.rb
Created April 21, 2011 06:11
minimal rails3 app
# minimal rails3 app
require 'action_controller'
Router = ActionDispatch::Routing::RouteSet.new
Router.draw do
root :to => 'site#index'
end
class SiteController < ActionController::Metal