This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if defined? ::NewRelic | |
module Mongoid | |
class Collection | |
(%w(find find_one map_reduce) + Collections::Operations::PROXIED - ['<<']).uniq.each do |method| | |
add_method_tracer method, "MongoDB/\#{@klass}##{method}" | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Authenticated | |
module Controller | |
extend ActiveSupport::Concern | |
included do | |
helper_method :current_user, :current_user?, :no_current_user? | |
end | |
module ClassMethods | |
def require_login(options = {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/backup/database/heroku_pgbackups.rb' | |
Backup::Model.new(:heroku, 'Heroku hosted data') do | |
database Backup::Database::HerokuPgbackups do |db| | |
db.name = 'my-heroku-app-name' | |
end | |
# Followed by other databases, storage, compression, etc. | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Including this module in an OmniAuth strategy implementation allows it to have | |
# a runtime-defined callback path extension. The callback path always begins | |
# with the predefined callback path, but may extend it. Specify a callback path | |
# extension at runtime by passing the 'callback' parameter to the request-phase | |
# auth URL. For example, the below URL: | |
# | |
# http://your.host/auth/facebook?callback=users/create | |
# | |
# Will issue a callback to: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module ConnectionAdapters | |
module DatabaseStatements | |
# | |
# Run the normal transaction method; when it's done, check to see if there | |
# is exactly one open transaction. If so, that's the transactional | |
# fixtures transaction; from the model's standpoint, the completed | |
# transaction is the real deal. Send commit callbacks to models. | |
# | |
# If the transaction block raises a Rollback, we need to know, so we don't |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Unobservant | |
mattr_accessor :enabled_observers | |
mattr_accessor :all_observers_enabled | |
self.enabled_observers = Set[] | |
self.all_observers_enabled = true | |
class <<self | |
def enable_all | |
self.all_observers_enabled = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE localhost:9200/test?pretty=true | |
echo "" | |
curl -XPUT localhost:9200/test?pretty=true | |
echo "" | |
curl -XPUT localhost:9200/test/parent/_mapping?pretty=true -d '{"parent":{"properties":{"name":{"type":"string","index":"analyzed"},"notes":{"properties":{"body":{"type":"string"}}}}}}' | |
echo "" | |
curl -XPUT localhost:9200/test/child/_mapping?pretty=true -d '{"child":{"_parent":{"type":"parent"}, "properties":{"body":{"type":"string","index":"analyzed"}}}}' | |
echo "" | |
curl -XPUT localhost:9200/test/parent/1?pretty=true -d "{\"name\":\"parent document\"}" | |
echo "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE http://localhost:9200/test1?pretty=true | |
echo '' | |
curl -XDELETE http://localhost:9200/test2?pretty=true | |
echo '' | |
curl -XPUT http://localhost:9200/test1?pretty=true -d '{}' | |
echo '' | |
curl -XPOST http://localhost:9200/_aliases?pretty=true -d '{"actions":[{"add":{"index":"test1","alias":"test"}}]}' | |
echo '' | |
curl -XPUT http://localhost:9200/test2?pretty=true -d '{}' | |
echo '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkill -f $(pwd) | |
for i in {0..2} | |
do | |
bin/elasticsearch | |
done | |
echo -n "waiting for cluster to come up" | |
until curl -s localhost:9200/_cluster/health?wait_for_status=green > /dev/null | |
do | |
echo -n '.' | |
sleep 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
IO.popen('/usr/bin/xscreensaver-command -watch') do |io| | |
while line = io.gets | |
case line | |
when /^BLANK\b/, /^LOCK\b/ | |
system('xchat', '-e', '--command=away') | |
when /^UNBLANK\b/ | |
system('xchat', '-e', '--command=back') | |
end |