In your shell:
cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/
rm -rf mustache.vim
loop do | |
print '>> ' | |
output = eval($stdin.gets) | |
print '=> ' | |
puts output.inspect | |
end |
# A polymorphic has_many :through relationship in Rails 2.3 | |
# based on Josh Susser's "The other side of polymorphic :through associations" | |
# http://blog.hasmanythrough.com/2006/4/3/polymorphic-through | |
class Authorship < ActiveRecord::Base | |
belongs_to :author | |
belongs_to :publication, :polymorphic => true | |
end | |
class Author < ActiveRecord::Base | |
has_many :authorships |
require 'rubygems' | |
require 'sinatra' | |
require 'datamapper' | |
require 'dm-paperclip' | |
require 'haml' | |
require 'fileutils' | |
APP_ROOT = File.expand_path(File.dirname(__FILE__)) | |
DataMapper::setup(:default, "sqlite3://#{APP_ROOT}/db.sqlite3") |
In your shell:
cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/
rm -rf mustache.vim
require 'oauth_util.rb' | |
require 'net/http' | |
o = OauthUtil.new | |
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--'; | |
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977'; | |
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true'; |
helpers do | |
def format | |
(params[:format] || :json).to_sym | |
end | |
def render_to(format, results) | |
case format | |
when :json | |
results.to_json | |
when :xml |
#!/usr/bin/env ruby | |
require 'bundler' | |
Bundler.setup(:default, :test) if defined?(Bundler) | |
require "selenium-webdriver" | |
require 'capybara/dsl' | |
Capybara.default_driver = :selenium | |
Capybara.default_selector = :css | |
Capybara.default_wait_time = 5 |
MySQL: SELECT * FROM user WHERE name = "foobar" | |
Mongo: db.user.find({"name" : "foobar"}) | |
MySQL: INSERT INOT user (`name`, `age`) values ("foobar", 25) | |
Mongo: db.user.insert({"name" : "foobar", "age" : 25}) | |
MySQL: DELETE * FROM user | |
Mongo: db.user.remove({}) | |
MySQL: DELETE FROM user WHERE age < 30 | |
Mongo: db.user.remove({"age" : {$lt : 30}}) $gt : > ; $gte : >= ; $lt : < ; $lte : <= ; $ne : != | |
MySQL: UPDATE user SET `age` = 36 WHERE `name` = "foobar" | |
Mongo: db.user.update({"name" : "foobar"}, {$set : {"age" : 36}}) |
# -*- encoding: utf-8 -*- | |
require 'digest/md5' | |
require 'nestful' | |
class Smsbao | |
def initialize(login, passwd) | |
@login = login | |
@passwd = Digest::MD5.hexdigest(passwd.to_s) | |
end |
There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.
So, these are the different settings we are going to compare: