Skip to content

Instantly share code, notes, and snippets.

package mustachelet;
import com.google.common.base.Function;
import com.sampullara.mustache.Mustache;
import com.sampullara.mustache.Scope;
import scala.collection.JavaConversions;
import scala.runtime.AbstractFunction1;
/**
* Scala iterables and functions in mustache.
@pch
pch / watermark.rb
Created January 18, 2011 13:43
Paperclip Watermark processor
class User
has_attached_file :photo,
:processors => [:watermark],
:styles => {
:medium => {
:geometry => "300x300>",
:watermark_path => "#{Rails.root}/public/images/watermark.png"
},
:thumb => "100x100>",
}
@tenderlove
tenderlove / person_test.rb
Created February 10, 2011 23:10
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
class 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')
end
@pfleidi
pfleidi / fiberchat.rb
Created February 19, 2011 18:51
A naive socket chat using select() and ruby fibers
require 'rubygems'
require 'socket'
include Socket::Constants
class ChatServer
def initialize
@reading = Array.new
@writing = Array.new
@clients = Hash.new
@sstephenson
sstephenson / config.ru
Created April 8, 2011 04:46
Rackup file for Rails 2.3 apps
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new
@vincentchu
vincentchu / histogram.rb
Created May 18, 2011 02:39
histogram.rb
#!/usr/bin/ruby
binwidth = ARGV[0].to_f
filename = ARGV[1]
rand_file_name = "rand_file-#{(rand*1000000).to_i}.data"
nums = File.open(filename, "r") {|f| f.readlines}.collect {|n| n.to_f }
binned_data = {}
nums.each do |n|
0 km, Vcirc = 2425.56 m/s, Tcirc = 25.90 min, Vesc = 3430.27 m/s
5 km, Vcirc = 2415.52 m/s, Tcirc = 26.23 min, Vesc = 3416.06 m/s
10 km, Vcirc = 2405.60 m/s, Tcirc = 26.55 min, Vesc = 3402.03 m/s
15 km, Vcirc = 2395.80 m/s, Tcirc = 26.88 min, Vesc = 3388.18 m/s
20 km, Vcirc = 2386.12 m/s, Tcirc = 27.21 min, Vesc = 3374.49 m/s
25 km, Vcirc = 2376.56 m/s, Tcirc = 27.54 min, Vesc = 3360.96 m/s
30 km, Vcirc = 2367.11 m/s, Tcirc = 27.87 min, Vesc = 3347.60 m/s
35 km, Vcirc = 2357.77 m/s, Tcirc = 28.20 min, Vesc = 3334.39 m/s
40 km, Vcirc = 2348.54 m/s, Tcirc = 28.54 min, Vesc = 3321.34 m/s
45 km, Vcirc = 2339.42 m/s, Tcirc = 28.87 min, Vesc = 3308.44 m/s
@nimbupani
nimbupani / index.html
Created December 2, 2011 05:00
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
@schinckel
schinckel / jekyllmarkdown.rb
Created January 9, 2012 14:26
Jekyll renderer for Marked.app
#!/usr/bin/ruby
# Github-flavored markdown to HTML, in a command-line util.
#
# $ cat README.md | ./ghmarkdown.rb
#
# Notes:
#
# You will need to install Pygments for syntax coloring
#
# $ pip install pygments
#!/bin/sh
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar xzvf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure --prefix=/usr/local
make
make install
cd
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
tar xzvf ruby-1.9.3-p392.tar.gz