Skip to content

Instantly share code, notes, and snippets.

Avatar

Durran Jordan durran

View GitHub Profile
@durran
durran / button.jsx
Created Mar 12, 2019
Unsubscribe App Registry
View button.jsx
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 Aug 6, 2015
Mongoid Migration
View reasoning.txt
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 Jun 3, 2014
BSON Custom Serialization/Deserialization
View bson.rb
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 Jul 11, 2013
iterate models and fields.
View fields.rb
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
View JsonService.java
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 Oct 21, 2012
Interval configuration
View mongoid.yml
test:
sessions:
default:
database: mongoid_test
hosts:
- localhost:27017
options:
consistency: :strong
max_retries: 30
retry_interval: 1
@durran
durran / database.yml
Created Oct 6, 2012
Master/Slave configuration
View database.yml
development:
adapter: master_slave
connection_adapter: mysql2
database: myapp_procuction
username: myappuser
password: myapppass
master:
host: masterhost
@durran
durran / session_middleware.rb
Created Sep 14, 2012
Test session middleware.
View session_middleware.rb
# encoding: utf-8
module Rack
module Mongoid
module Middleware
class Sessions
def initialize(app)
@app = app
end
@durran
durran / override.rb
Created Jul 23, 2012
Override Mongoid setter.
View override.rb
def cte_attr(*attrs)
attrs.each do |name|
class_eval <<-ATTR
def #{name}=(value)
@#{name} = value
super
end
ATTR
end
end
View tcp_connections.txt
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