View pubsub.ex
defmodule Pubsub do
use Application
def start(_type, _options) do
import Supervisor.Spec
IO.puts("Initializing Pubsub app on #{inspect self}")
children = [
worker(Pubsub.Server, [], [name: :server_supervisor])
View daily_walk.go
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
var wg sync.WaitGroup
View party.java
LaundryMachine washer = getLaundryMachine();
washer.open();
List<Unerdwear> pileOfUnerdwear = gatherUnerdwear();
for (Unerdwear underwear : pileOfUnerdwear) {
if (underwear.isDirty() OR underwear.isSticky()) {
washer.load(underwear);
} else {
putOn(underwear);
while (undewear.isntDirty()) {
View application.rb
require 'middlewares/extended_logger_middleware'
config.middleware.insert_after Rails::Rack::Logger, ::ExtendedLoggerMiddleware
View spec_helper.rb
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
View selector.rb
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
# for Mongoid
# match { |record| record.class.ancestors.include? Mongoid::Document }
end
View gist:3259519
HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE "KTHX <33"
IZ VAR BIGGER THAN 100? KTHX
IM OUTTA YR LOOP
KTHXBYE
View html_with_coderay.rb
# Gemfile
gem 'coderay', '~> 0.9.8'
gem 'redcarpet', '2.0.0b5'
# lib/html_with_coderay.rb
class HTMLWithCoderay < Redcarpet::Render::HTML
def block_code(code, language)
language = language.blank? ? "text" : language
CodeRay.scan(code, language).div
end
View gemspec
Gem::Specification.new do |s|
# bla, bla..
if Gem::Version.new(RUBY_VERSION.dup) <= Gem::Version.new("1.8.7")
s.add_dependency "gem_required_to_ruby_version_less_than_1.8.7"
end
end
View post-receive.sh
#!/bin/bash
APP_PATH=/home/applicake/app
# Production environment
export RAILS_ENV="production"
export PATH="/opt/ruby/bin:$PATH"
exit_with_error() {