I hereby claim:
- I am joeyaghion on github.
- I am joeya (https://keybase.io/joeya) on keybase.
- I have a public key whose fingerprint is 7388 6671 6CF0 51A2 97BE 5D80 E61F 207F EE3F 0C11
To claim this, I am signing this object:
# Adapted from https://raw.github.com/github/hubot-scripts/master/src/scripts/plusplus.coffee | |
# | |
# Description: | |
# Give or take away points. Keeps track and even prints out graphs. | |
# | |
# Dependencies: | |
# "underscore": ">= 1.0.0" | |
# "clark": "0.0.6" | |
# | |
# Configuration: |
var collectionNames = db.getCollectionNames(), stats = []; | |
collectionNames.forEach(function (n) { stats.push(db[n].stats()); }); | |
stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); | |
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); } |
sudo yum install socat # if not already installed | |
sudo nano -w /etc/haproxy/haproxy.cfg # add ..."level admin" to stats socket line | |
sudo /etc/init.d/haproxy reload # reload config | |
sudo socat readline /tmp/haproxy.sock | |
prompt | |
> set timeout cli 1d | |
> help | |
> disable server rails_app_servers/rails-app1 | |
> disable server rails_app_servers_ssl/rails-app1 | |
> enable server rails_app_servers/rails-app1 |
# Number of queued jobs per queue and priority | |
pp Delayed::Job.distinct(:queue).sort.map{|q| Delayed::Job.where(queue: q).distinct(:priority).sort.map{|p| [q, p, Delayed::Job.where(queue: q, priority: p).count] } }.sort; nil | |
# [[["any", 2, 3], ["any", 3, 3323], ["any", 4, 5542], ["any", 5, 2]], | |
# [["bidding", 3, 15]], | |
# [["default", 3, 10]], | |
# [["fair", 3, 246]]] | |
# First 20 jobs, in order that workers dequeue them | |
pp Delayed::Job.where(:run_at.lte => Time.now.utc, failed_at: nil).any_of({locked_by: /worker/}, {locked_at: nil}, {locked_at: {'$lt' => (Time.now.utc - 14400)}}).any_in(queue: %w{any imgs}).desc(:locked_by).asc(:priority).asc(:run_at).limit(20).map{|j| [j.id, j.handler.inspect[0..250], j.locked_by, j.run_at, (Time.now.utc - j.locked_at if j.locked_at)] }; nil | |
# [[<BSON::ObjectId:0x135554220 data=5629067d7261696db2000040>, |
class ImportBase | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :import_version, type: String, default: 'v1' # legacy imports use 'v1' connection | |
before_create do | |
self.import_version = 'v2' # new imports use 'v2' connection | |
end |
#!/usr/bin/env ruby | |
# Adapted from https://gist.github.com/hanloong/9849098 | |
require 'english' | |
require 'rubocop' | |
ADDED_OR_MODIFIED = /A|AM|^M/.freeze | |
changed_files = `git status --porcelain`.split(/\n/) |
# apps in the *first* section of heroku apps output (i.e., apps that I own) | |
apps=( `heroku apps | sed -e '/^$/,$d' | grep -v '^=='` ) | |
# for each app that I own, show associated domains | |
for (( i = 0 ; i < ${#apps[@]} ; i++ )) | |
do | |
echo `heroku domains --app ${apps[$i]}` | |
done |
I hereby claim:
To claim this, I am signing this object:
# In gravity Rails console, for example. | |
url = app.reset_password_url(a: 'b', c: 'd') | |
# => "http://www.example.com/reset_password?a=b&c=d" | |
url.html_safe? | |
# => false | |
ERB::Util.h(url) # explicitly call the h() helper that's implicitly called by <%= ... %> | |
# => "http://www.example.com/reset_password?a=b&c=d" | |
view = ActionView::Base.new('app/views', {}, ActionController::Base.new) | |
# => #<ActionView::Base:0x000000110c5a60 ...> | |
view.render(inline: "<html><body><%= url %></body></html>", locals: {url: url}) # encode implicitly |
> "Báe".length | |
=> 4 | |
> "Báe".encoding | |
=> #<Encoding:UTF-8> | |
> "Báe".encode('utf-8', 'utf-8-mac').encoding | |
=> #<Encoding:UTF-8> | |
> "Báe".encode('utf-8', 'utf-8-mac').length | |
=> 3 |