This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PostsController < ApplicationController | |
def show | |
@post = Post.find_by_slug(params[:id]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/meats.rb | |
class Meat < ActiveRecord::Base | |
end | |
# app/models/bacon.rb | |
class Bacon < Meat | |
end | |
# app/models/chunky_bacon.rb | |
class ChunkyBacon < Bacon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe 'iptables' | |
iptables_rule 'ssh_in' | |
iptables_rule 'http_in' | |
iptables_rule 'https_in' | |
iptables_rule 'mongo_in' do | |
only_if { node[:mongo][:replica_set][:enabled] } | |
variables :rs_members => search(:node, "role:mongo_#{node[:mongo][:replica_set][:name]}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'fssm' | |
monitor = FSSM::Monitor.new | |
monitor.path File.dirname(__FILE__) do | |
update do |base,relative| | |
# Why are they not strings?!? | |
base = base.to_s | |
relative = relative.to_s | |
extension = relative.split('.').last |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How often daemonizer's monitor process | |
# checks the status of workers. | |
poll_period 5 | |
pool :delayed_workers do | |
# Attempt to intuit the number of CPU cores on this machine and start | |
# a corresponding number of workers. Should work on any modern Linux | |
# (>= 2.6 kernel). | |
if File.exist? "/sys/devices/system/cpu/online" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch Mongo::GridIO to contain an each method. | |
require File.join File.dirname(__FILE__), 'lib/kimono/grid_io' | |
Mongo::GridIO.send(:include, Kimono::GridIO) | |
# You probably want to implement something a bit smarter than just talking | |
# to localhost. | |
database = Mongo::Connection.new.db('kimono_production') | |
app = proc do |env| | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
My second sketch: pulse the LED with a sine wave. | |
*/ | |
const float pi = 3.14159; | |
int ledPin = 9; | |
void sinArc(int analogPin, int duration, float arcStart, float arcStop) { | |
int steps = 255; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "OutputPin.h" | |
OutputPin::OutputPin (unsigned int pin) { | |
// FIXME: What about the Arduino MEGA?!? | |
switch (pin) { | |
case 3: | |
case 5: | |
case 6: | |
case 9: | |
case 10: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Connection.h" | |
void Connection::is_connected_to(State* state) { | |
_state = state; | |
has_new_connection(state); | |
} | |
State* Connection::is_connected_to() { | |
return _state; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Clock.h" | |
#include "WProgram.h" | |
void Clock::low_tick() { | |
if (finite) { | |
if (ticks_to_go >= 0) { | |
set_aiko_callback(0, interval); | |
ticks_to_go--; | |
tick(); | |
} |