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
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
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)
@dblock
dblock / dropbox.sh
Last active September 11, 2020 14:46
Auto-start Dropbox.
#!/bin/bash
DROPBOX_USERS="root"
DAEMON=.dropbox-dist/dropboxd
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
@dblock
dblock / dokku-mongo-export.sh
Last active June 11, 2020 12:20
Backup MongoDB databases with Dropbox and Dokku
#!/bin/bash
set -e
echo "Backing up MongoDB databases to Dropbox ..."
dt=$(date +"%Y-%m-%d")
echo " today is $dt"
@dblock
dblock / Gemfile
Created May 15, 2015 19:51
Grape on Goliath
source 'https://rubygems.org'
gem 'grape'
gem 'goliath'
gem 'json'
require 'mongoid'
require 'mongoid_collection_snapshot'
Mongoid.load!("mongoid.yml", :development)
class Widget
include Mongoid::Document
end

Keybase proof

I hereby claim:

  • I am dblock on github.
  • I am dblock (https://keybase.io/dblock) on keybase.
  • I have a public key whose fingerprint is 4A72 0FE7 90B0 7A68 744E 3716 75BF 031B 7C94 E183

To claim this, I am signing this object:

@dblock
dblock / live-coding.md
Last active August 29, 2015 14:08
Implement a Hypermedia API with Grape + Roar

Create Gemfile

source 'http://rubygems.org'

gem 'grape'
gem 'grape-roar'

Run bundle install.

@dblock
dblock / cursor_helper.rb
Created October 20, 2014 13:26
Pagination in a Grape API with Roar.
module Api
module V2
module Util
module CursorHelpers
extend ActiveSupport::Concern
# apply cursor-based pagination to a collection
# returns a hash:
# results: (paginated collection subset)
# next: (cursor to the next page)