Skip to content

Instantly share code, notes, and snippets.

View durran's full-sized avatar

Durran Jordan durran

View GitHub Profile
@durran
durran / button.jsx
Created March 12, 2019 14:24
Unsubscribe App Registry
class TextWriteButton extends React.Component {
/**
* Instantiate the component.
*
* @param {Object} props - The properties.
*/
constructor(props) {
super(props);
this.boundNamespaceChanged = this.namespaceChanged.bind(this);
@durran
durran / reasoning.txt
Created August 6, 2015 06:37
Mongoid Migration
The problem with the Github issues is a tradeoff. In order for MongoDB to officially
support Mongoid we need to have the issues in Jira in order to properly adhere to our
commercial support contracts with respect to response times, as well as free support.
There's no simple way to setup 301 redirects from the old Github issues to the new Jira issues,
but every single Github issue was migrated - over 4000 since the project's inception in
2009 and all are public (https://jira.mongodb.org/browse/MONGOID). Google will eventually
resolve them. It's better in the short and long term to give up some of this to have Mongoid
officially supported and actively developed.
As for the documentation, the separation of the Mongoid 5 docs and the 3/4 docs was to
@durran
durran / bson.rb
Created June 3, 2014 21:12
BSON Custom Serialization/Deserialization
class MyObject
def to_bson(encoded = ''.force_encoding(BINARY))
to_hash.to_bson(encoded)
end
def self.from_bson(bson)
new(Hash.from_bson(bson))
end
end
@durran
durran / fields.rb
Created July 11, 2013 15:30
iterate models and fields.
Mongoid.models.each do |model|
model.fields.each do |name, field|
# name is the string name of the field, field is the Field object.
end
end
package org.bson;
import java.io.IOException;
import org.jruby.Ruby;
import org.jruby.RubyModule;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.BasicLibraryService;
@durran
durran / mongoid.yml
Created October 21, 2012 15:52
Interval configuration
test:
sessions:
default:
database: mongoid_test
hosts:
- localhost:27017
options:
consistency: :strong
max_retries: 30
retry_interval: 1
@durran
durran / database.yml
Created October 6, 2012 08:16
Master/Slave configuration
development:
adapter: master_slave
connection_adapter: mysql2
database: myapp_procuction
username: myappuser
password: myapppass
master:
host: masterhost
@durran
durran / session_middleware.rb
Created September 14, 2012 12:52
Test session middleware.
# encoding: utf-8
module Rack
module Mongoid
module Middleware
class Sessions
def initialize(app)
@app = app
end
@durran
durran / override.rb
Created July 23, 2012 12:40
Override Mongoid setter.
def cte_attr(*attrs)
attrs.each do |name|
class_eval <<-ATTR
def #{name}=(value)
@#{name} = value
super
end
ATTR
end
end
tcp4 0 0 localhost.27017 localhost.50942 ESTABLISHED
tcp4 0 0 localhost.50942 localhost.27017 ESTABLISHED
tcp4 0 0 localhost.27017 localhost.50941 ESTABLISHED
tcp4 0 0 localhost.50941 localhost.27017 ESTABLISHED
tcp4 0 0 localhost.27017 localhost.50940 ESTABLISHED
tcp4 0 0 localhost.50940 localhost.27017 ESTABLISHED
tcp4 0 0 localhost.27017 localhost.50939 ESTABLISHED
tcp4 0 0 localhost.50939 localhost.27017 ESTABLISHED
tcp4 0 0 localhost.27017 localhost.50938 ESTABLISHED
tcp4 0 0 localhost.27017 localhost.50937 ESTABLISHED