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);
# Problem: Given the following document in the database, I want to update
# Dave Gahan's second prescription for Dilaudid from a quantity of 45 to
# a quantity of 30.
{ "_id" : 1
"name" : "Dave Gahan"
"medications" : [
{ "id" : 23,
"name" : "Dilaudid",
"type" : "Rx",
@durran
durran / mongodb.monitrc
Created December 1, 2011 14:14
MongoDB Monit Config
check process mongodb
with pidfile "/var/lib/mongodb/mongod.lock"
start program = "/sbin/start mongodb"
stop program = "/sbin/stop mongodb"
if failed port 28017 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
@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