Skip to content

Instantly share code, notes, and snippets.

View jakcharlton's full-sized avatar

Jak Charlton jakcharlton

View GitHub Profile
@jakcharlton
jakcharlton / README
Created June 20, 2011 01:03
Pros and Cos of TFS and Git
TFS
Pros
• Familiar to current team
• Has a UI tool within Visual Studio
• Close tie in to Work Items
Cons
• Slow to pull, check in and branch
• Merge conflicts are frequent
• Encourages infrequent check in due to merge conflicts and slow performance
• Branching frequently leads to time consuming conflicts
@jakcharlton
jakcharlton / contato_mailer.rb
Created June 5, 2018 04:20 — forked from andrerpbts/contato_mailer.rb
IMAP Mail Receive Ruby
#encoding: utf-8
class ContatoMailer < ActionMailer::Base
def receive(message)
p message
end
end
@jakcharlton
jakcharlton / 01-activerecord.rb
Created March 18, 2016 02:16 — forked from janko/01-activerecord.rb
PostgreSQL JSON querying in Sequel (my presentation from our local Ruby meetup)
require "active_record"
ActiveRecord::Base.establish_connection('postgres:///testing')
ActiveRecord::Migration.verbose = false
ActiveRecord::Migration.class_eval do
create_table :played_quizzes, force: true do |t|
t.integer :player_ids, array: true
t.json :quiz_snapshot
end
@jakcharlton
jakcharlton / 1.9.3.md
Created February 18, 2012 22:24
Ruby 1.9.3 and Rails 3.2 on Heroku

http://railsapps.github.com/rails-heroku-tutorial.html

Ruby 1.9.3 and Rails 3.2 on Heroku Heroku’s newest stack, “Celadon Cedar,” supports Rails 3.2 but installs Ruby 1.9.2 by default. Ruby 1.9.3 is recommended for Rails 3.2.

You can configure the Heroku environment to use Ruby 1.9.3.

Note: Heroku makes it clear that Ruby 1.9.3 on Heroku is experimental, which means “no support, the ruby_version will change in the future, and this feature may change or be removed without warning.” In response to an inquiry on January 31, 2012, Heroku said, “there is no timeline yet” to fully support Ruby 1.9.3.

Install the heroku-labs plugin:

@jakcharlton
jakcharlton / SlowMongoQueries.md
Created September 11, 2016 23:50 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

// Retrieve all the documents where val == 1
// If no document is returned, insert {newVal: 2}
// Else update all the documents with {newVal: 2}
//
// Note: This query is not atomic
r.table("test").filter({val: 1}).count().do(function(numResults) {
return r.branch(
numResults.eq(0),
r.table("test").insert({newVal: 2}),
@jakcharlton
jakcharlton / queryupdate.js
Created December 23, 2013 01:45
RethinkDB query/update
r.table("foo").get("idValue").update( function(doc) { return r.branch( doc.eq(A), B, {} ) })
@jakcharlton
jakcharlton / join.js
Created December 23, 2013 00:46
RethinkDB join against nested ID
r.db('master').table("machines").eqJoin(function(machine) { return machine("machine_memberships")("user_id") }, r.db('master').table("users")).zip()
@jakcharlton
jakcharlton / gist:8000864
Last active December 31, 2015 14:29
Rethink concepts

A Datacentre is a group of Servers

Servers can be grouped in a Datacentre

A Server (Instance) is a single Rethink process

A Database is a logical grouping for Tables - Tables may sit on different Servers

A Shard is a partition of a Table

@jakcharlton
jakcharlton / gist:7937470
Created December 12, 2013 23:29
eqJoin with missing key in RethinkDB
r.db("user1").table("others").filter(function(user) {
return user.hasFields('contact_id')
}).eqJoin("contact_id", r.db("user1").table("contacts"))