Skip to content

Instantly share code, notes, and snippets.

View dblock's full-sized avatar
🐝
Alexa, ask the future of America to be great again! (try it)

Daniel (dB.) Doubrovkine dblock

🐝
Alexa, ask the future of America to be great again! (try it)
View GitHub Profile
@dblock
dblock / test.rb
Created August 13, 2018 23:33
Kramdown parser repro
require 'kramdown'
text = <<-MARKDOWN
# Example
The quick brown fox jumps over the lazy dog.
```ruby
# one
@dblock
dblock / restart-bots.sh
Created June 20, 2018 19:30
Restart all the bots.
#!/bin/bash
for D in `find . -type d -name "*bot"`
do
NAME=`basename $D`
echo Restarting $NAME ...
dokku ps:restart $NAME
done
require 'mongoid'
require 'mongoid-collection-snapshot'
Mongo::Logger.logger.level = Logger::INFO
Mongoid.connect_to 'widgets-and-gadgets', max_pool_size: 16
class Widget
include Mongoid::Document
end
@dblock
dblock / debug_require.rb
Created February 18, 2013 22:10
Measure how long require(s) take.
if ENV['DEBUG_REQUIRE']
require 'benchmark'
def require(file)
@@first ||= Time.now
rc = false
ts = Benchmark.measure do
rc = super
end
if ENV['DEBUG_REQUIRE'].to_f < ts.total
@dblock
dblock / delayed_job_observer.rb
Created August 16, 2012 13:21
A mongoid delayed job observer, used in test environment to kick off any delayed jobs as they are queued.
class DelayedJobObserver < Mongoid::Observer
observe Delayed::Job
class << self
attr_accessor :total_processed
attr_accessor :total_errors
attr_accessor :enabled
def enabled?
!! DelayedJobObserver.enabled
@dblock
dblock / ARKonamiKeyboardView.h
Created March 24, 2014 01:28
ASCII Art + Konami Code Easter Egg for iOS
//
// ARKonamiKeyboardView.h
// Artsy
//
// Created by Daniel Doubrovkine on 3/21/14.
// Copyright (c) 2014 Art.sy. All rights reserved.
//
#import <DRKonamiCode/DRKonamiGestureRecognizer.h>
@dblock
dblock / capybara_wait_until.rb
Created July 24, 2013 07:38
Re-implementation of Capybara wait_until.
class Capybara::Session
def wait_until(timeout = Capybara.default_wait_time)
Timeout.timeout(timeout) do
sleep(0.1) until value = yield
value
end
end
end
Team.active.asc(:_id).each do |team|
begin
next if team.premium
STDOUT.write "#{team.name}: "
client = Slack::Web::Client.new(token: team.token)
channels = client.channels_list['channels'].select { |channel| channel['is_member'] }
channels.each do |channel|
STDOUT.write "#{channel['name']} "
client.chat_postMessage(
channel: channel.id,
@dblock
dblock / try.rb
Created June 14, 2016 14:54
Slack celluloid connection test.
require 'celluloid/current'
require 'celluloid/io'
require 'http'
require 'websocket/driver'
class Connection
include Celluloid::IO
extend Forwardable
def initialize(url)
require 'spec_helper'
require 'grape'
module DATA
class User
attr_accessor :loginname, :email, :person
def initialize(attrs)
@loginname = attrs[:loginname]
@email = attrs[:email]