Skip to content

Instantly share code, notes, and snippets.

View bonkydog's full-sized avatar

Brian Jenkins bonkydog

  • Nubank
  • SF Bay Area
View GitHub Profile
@bonkydog
bonkydog / slack_logs.rb
Last active June 11, 2018 21:50 — forked from 0x263b/slack_logs.rb
Obtain channel logs from Slack's API
#!/usr/bin/env ruby
# encoding: utf-8
# Uses the following Slack API methods:
# user.list → https://api.slack.com/methods/users.list
# channels.history → https://api.slack.com/methods/channels.history
require "open-uri"
require "json"
# Obtain a token
In shell:
export RUBYLIB=/Applications/RubyMine.app/rb/testing/patch/common:/Applications/RubyMine.app/rb/testing/patch/bdd
spring rspec spec/ # to launch spring server
In Rubymine:
Uncheck bundler
Select custom runner script as spring_rspec.rb
add same variable to environment variables:
RUBYLIB=/Applications/RubyMine.app/rb/testing/patch/common:/Applications/RubyMine.app/rb/testing/patch/bdd
@bonkydog
bonkydog / gist:1596942
Created January 11, 2012 21:46 — forked from rsanheim/gist:1054078
Devise + Spork + Rails 3.1 RC4 hacks to keep User model from loading prefork
Spork.prefork do
require "rails/application"
# Prevent Devise from loading the User model super early with it's route hacks for Rails 3.1 rc4
# see also: https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujutsu
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
# rest of your prefork here...
end
db.tweets.update({}, {'$unset' : {'reply_count' :1}}, false, true)
namespace :bundler do
task :install do
run("gem install bundler --source=http://gemcutter.org")
end
task :symlink_vendor do
shared_gems = File.join(shared_path, 'vendor/gems')
release_gems = "#{release_path}/vendor/gems"
# Example activerecord interator based on using an indexed 'id' column.
# See http://schuerig.de/michael/blog/index.php/2007/02/03/ar-enumerable/
# and http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord
class << ActiveRecord::Base
def each(chunk_size=1000)
(0..self.last.id / chunk_size).each do |offset|
self.find(:all,
:limit => chunk_size,
:conditions => ["id > ?", offset * chunk_size]).each do |i|
require "net/http"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
#