Skip to content

Instantly share code, notes, and snippets.

@ik5
ik5 / daemon.rb
Created June 22, 2010 18:43
a quick and dirty jruby daemon based on basic_daemon
#!/usr/bin/env jruby
#
#
require 'rubygems'
require 'spoon'
EXEC = '/tmp/exec.rb'
PID_PATH = '/tmp/exec.pid'
WORK_PATH = '/tmp/'
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
require 'rubygems'
require 'spoon'
Spoon.spawnp 'jruby', *ARGV
@phred
phred / pedantically_commented_playbook.yml
Last active June 27, 2024 13:39
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
$ rvm install jruby
jruby-1.6.7.2 - #downloading jruby-bin-1.6.7.2, this may take a while depending on your connection...
jruby-1.6.7.2 - #extracting jruby-bin-1.6.7.2 to /Users/tony/.rvm/src/jruby-1.6.7.2
jruby-1.6.7.2 - #extracted to /Users/tony/.rvm/src/jruby-1.6.7.2
jruby-1.6.7.2 - #nailgun
Error running 'jruby_install_build_nailgun', please read /Users/tony/.rvm/log/jruby-1.6.7.2/nailgun.log
require 'queue'
module Rack
module Mongoid
module Middleware
class Sessions
def initialize(app)
@app = app
@sessions = Queue.new
require 'queue'
# Simplified version of the pooling from datamapper's data_objects.
# https://github.com/datamapper/do/blob/master/data_objects/lib/data_objects/pooling.rb
class Moped::Session
class << self
alias new __new
end
@__pool_lock = Mutex.new
@ayosec
ayosec / CORSDirectives.scala
Created December 18, 2012 03:28
CORS with Spray
package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {
@cpuguy83
cpuguy83 / mongoid_conn_pool.rb
Last active December 19, 2015 11:09
Working out connection pooling for Mongoid. Right now in Mongoid every thread gets a new connection, and is not closing those connections when the thread is complete.
require 'thread'
require 'thread_safe'
require 'monitor'
module Mongoid
def with_session(&block)
Sessions.with_session(&block)
end
module Config
option :session_pool_size, :default => 5
@evgenius
evgenius / onchange.sh
Last active December 15, 2018 22:17 — forked from senko/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of