Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Share2chOnTumblr
// @namespace http://saitamanodoruji.tumblr.com/
// @description Share 2ch conversation on Tumblr as Quote
// @include http://*.2ch.net/test/read.cgi/*
// @include http://*.2ch.net/*/kako/*
// @include http://*.bbspink.com/test/read.cgi/*
// @include http://jbbs.livedoor.jp/bbs/read.cgi/*
// @include http://jbbs.livedoor.jp/*/*/*/*.html
// @include http://p2.chbox.jp/read.php?url=http://*.2ch.net/test/read.cgi/*
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
# -*- mode: ruby; coding: utf-8 -*-
class SeedImporter
def initialize
@model = nil
@with_id = false
end
def run
Dir.glob( File.dirname(__FILE__) + '/seeds/**/*.{yml,csv}' ).sort.each { |seed|
send( "import_#{File.extname( seed )[1..seed.bytesize]}_seed", seed )
@Epictetus
Epictetus / date_time.coffee
Created May 14, 2011 18:12 — forked from markbates/date_time.coffee
Example: Rails-style date/time helpers in CoffeeScript
Number::seconds = ->
@ * 1000
Number::minutes = ->
@seconds() * 60
Number::minute = Number::minutes
Number::hours = ->
@minutes() * 60
@Epictetus
Epictetus / config.ru
Created May 20, 2011 05:05 — forked from silviorelli/config.ru
config.ru for using POW Rack server with Rails 2
# Rails.root/config.ru
require "./config/environment"
run ActionController::Dispatcher.new

Rails 2.3.11 on App Engine (DataMapper)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also: gist.github.com/gists/269075

Install the Development Environment

@Epictetus
Epictetus / Bluepill Uncorn Config File
Created May 29, 2011 03:39
Bluepill used at Halftoneapp.com
#
# Halftoneapp.com Sample Bluepill Configuration File
# Read more at: http://blog.halftoneapp.com
#
# Set paths
home_dir = "/home/railsapp"
rails_shared = "#{home_dir}/app/shared"
unicorn_path = "/path/to/unicorn_rails"
class Favorite < ActiveRecord::Base
module HasManyExtension
def videos
proxy_owner.favorites.where(:favorite_type => "Video")
end
end
end
class User < ActiveRecord::Base
has_many :favorites, :extend => Favorite::HasManyExtension
@Epictetus
Epictetus / chinatra.rb
Created June 7, 2011 20:50 — forked from melborne/app_for_chinatra.rb
Another syntax Sinatra
require "sinatra"
module Chinatra
class Application
SINATRA_METHODS = Sinatra::Delegator.private_instance_methods(false)
def self.parse(fname)
file = open(fname) rescue open("#{fname}.rb")
code = file.lines.each_with_object([]) do |line, mem|
case line
when /^(#{SINATRA_METHODS.join('|')})\s*(.*)\s*$/
mem << "};" << %[ #{$1}("#{$2}") { ]
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.