Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
module ::Guard | |
class Redis < Guard | |
def start | |
puts "Starting Redis on port #{port}" | |
IO.popen("#{executable} -", 'w+') do |server| | |
server.write(config) | |
server.close_write | |
end | |
puts "Redis is running with PID #{pid}" | |
$?.success? |
#!/usr/bin/env sh | |
# Copy public key to authorized_keys of a remote machine | |
if [ -z $1 ] || [ -z $2 ];then | |
echo "Usage" | |
echo "ssh-copy-id hostname /path/to/public/key" | |
exit | |
fi | |
KEYCODE=`cat $2` | |
ssh -q $1 "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo "$KEYCODE" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys" |
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
require 'logger' | |
class String | |
LOGGER = Logger.new($stderr) | |
def -@; LOGGER.info self; end | |
end | |
# Extracted earlier, hardcoded for speed | |
ENTITIES = %w(I-ORG O I-MISC I-PER I-LOC B-LOC B-MISC MO B-ORG) |
Some exercises from the Falsy Values workshops.
The good parts:
require 'celluloid' | |
require 'open-uri' | |
require 'cgi' | |
require 'benchmark' | |
module Enumerable | |
def pmap(&block) | |
futures = map { |elem| Celluloid::Future(elem, &block) } | |
futures.map { |future| future.value } | |
end |
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]
From http://everything2.com/title/nontheist
The Buddha is the first historically known nontheist. Most Buddhists are nontheist.
The Buddha was often asked whether God existed. Usually, he replied with a complete silence. Once, however, he told the story of the man shot by a poisoned arrow.
When the doctor came and wanted to pull the arrow out of the wound, the man grabbed the doctor's hand and asked:
"Before you start treating me, Doctor, tell me, who was it that shot me? Was he of warrior class or some other class? Was he tall or was he short? Was he young or was he old? Was he dark skinned or light skinned?"
require 'action_controller' | |
Router = ActionDispatch::Routing::RouteSet.new | |
Router.draw do | |
root :to => 'site#index' | |
end | |
class SiteController < ActionController::Metal | |
def index | |
self.response_body = "waddup son" |
# minimal rails3 app | |
require 'action_controller' | |
Router = ActionDispatch::Routing::RouteSet.new | |
Router.draw do | |
root :to => 'site#index' | |
end | |
class SiteController < ActionController::Metal |