Skip to content

Instantly share code, notes, and snippets.

View celluloid_supervision_group_spec.rb
require 'spec_helper'
describe Celluloid::SupervisionGroup, actor_system: :global do
before :all do
class MyActor
include Celluloid
def running?; :yep; end
end
View RailsTemplate.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE template SYSTEM "../../../project-config.dtd">
<template>
<name>Rails</name>
<settings>
<options>
<option name="executionTimeoutMin" value="20" />
</options>
<parameters>
View gist:7475186
# Output line:
2013-11-14 22:07:08.266 UTC [6687] - [postgres@[local] pgbench] SELECT - ERROR: column "sync_statex" does not exist at character 20
# Logstash grok matcher...
# In config file:
%{DATESTAMP:timestamp} UTC \\[%{POSINT:pid}\\] - \\[%{WORD:user}@\\[local\\] %{WORD:db}\\] %{WORD:command} - %{WORD:level}:%{SPACE}%{GREEDYDATA:message}
View gist:7364989
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
View RubyHttpParser.java
package org.ruby_http_parser;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.RubyHash;
import org.jruby.RubyModule;
import org.jruby.RubyNumeric;
import org.jruby.RubyObject;
import org.jruby.RubyString;
View Windowslivelogin.rb
def initialize(appid=nil, secret=nil, securityalgorithm=nil,
force_delauth_nonprovisioned=nil,
policyurl=nil, returnurl=nil)
self.force_delauth_nonprovisioned = force_delauth_nonprovisioned
self.appid = appid if appid
self.secret = secret if secret
self.securityalgorithm = securityalgorithm if securityalgorithm
self.policyurl = policyurl if policyurl
self.returnurl = returnurl if returnurl
end
View 01. Gemfile
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@doxavore
doxavore / TimeTextBox.js
Created Feb 12, 2013
setTimeout for the win. Thanks, Dojo!
View TimeTextBox.js
// setTimeout() because the keystroke hasn't yet appeared in the <input>,
// so the get('displayedValue') call below won't give the result we want.
setTimeout(dojo.hitch(this, function(){
// set this.filterString to the filter to apply to the drop down list;
// it will be used in openDropDown()
var val = this.get('displayedValue');
this.filterString = (val && !this.parse(val, this.constraints)) ? val.toLowerCase() : "";
// close the drop down and reopen it, in order to filter the items shown in the list
// and also since the drop down may need to be repositioned if the number of list items has changed
View migration.rb
create_table :users, id: false do |t|
t.uuid :id, primary: true, null: false
# ...
end
@doxavore
doxavore / tmpdir.rb
Created Nov 2, 2012
JRuby Dir.tmpdir
View tmpdir.rb
def Dir::tmpdir
tmp = '.'
if $SAFE > 0
tmp = @@systmpdir
else
# Search a directory which isn't world-writable first. In JRuby,
# FileUtils.remove_entry_secure(dir) crashes when a dir is under
# a world-writable directory because it tries to open directory.
# Opening directory is not allowed in Java.
dirs = [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', tmp]