Skip to content

Instantly share code, notes, and snippets.

@careo
careo / configuration.rb
Last active August 29, 2015 14:20
errbit config
class Configuration < Attributor::Model
attribute :host, String
attribute :protocol, String
attribute :port, String
attribute :enforce_ssl, String
attribute :confirm_err_actions, String
attribute :user_has_username, String
attribute :use_gravatar, String
@careo
careo / application.md
Last active August 29, 2015 14:09
Preliminary Praxis Plugin Documentation

Uncaught Exceptions

Handling of uncaught exceptions is done by the error handler registered with Appication#error_handler. All applications are pre-configured to use a simple handler that wraps any exception in an InternalServerError response.

This behavior may be customized by registering an error handler with the application like this:

Praxis::Application.configure do |application|
  application.error_handler = MyErrorHandler.new
end
@careo
careo / freezing.rb
Last active August 29, 2015 13:56
freezing strings
RUBY_DESCRIPTION # => "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]"
"one".freeze.object_id # => 70098950078640
one = "one"
two = "one"
one.object_id # => 70098950065800
two.object_id # => 70098950065780
@careo
careo / README.md
Last active August 29, 2015 13:55 — forked from mbostock/.block
@careo
careo / locals.rb
Last active January 3, 2016 06:59
thread-fiber-locals
RUBY_DESCRIPTION
# => "ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.0]"
Thread.current[:some_local] # => nil
Thread.current[:some_local] = 'main' # => "main"
Thread.current[:some_local] # => "main"
f1 = Fiber.new do
Thread.current[:some_local] # => nil
Thread.current[:some_local] = 'f1' # => "f1"
[KSPEvent(guiActive=false, active=true)]
public void MechJebVesselStateUpdated()
{
// Debug.Log("MechJebVesselStateUpdated");
BaseEventData ed = new BaseEventData(BaseEventData.Sender.USER);
// vessel.torqueRAvailable = vessel.torqueRAvailable + vessel.mass * 20
// vessel.torquePYAvailable = vessel.torquePYAvailable + vessel.mass * 20
int main() {
int dollars, cents;
float paid = 4.00f;
float price = 3.10f;
int paidInt = paid * 100;
int priceInt = price * 100;
int changeInt = paidInt - priceInt;
@careo
careo / error
Created September 21, 2010 16:42
[info] Running CassandraTests
starting...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at scromium.reflect.Reflect$.New(Reflect.scala:23)
at scromium.Cassandra$.createConnectionPool(Cassandra.scala:77)
at scromium.Cassandra$.start(Cassandra.scala:27)
require 'benchmark'
require 'erb'
require 'rubygems'
require 'erubis'
# generate templates
LINES = 1_000
perline = ""
require 'rubygems'
require 'cassandra/0.7'
cassandra = Cassandra.new "system"
keyspaces = cassandra.send(:client).describe_keyspaces
keyspace_name = "SomeTest"
cf_name = "Tests"