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 / gist:5777415
Created June 13, 2013 21:12
Git push to Heroku with a segfault during asset compilation.
[2013-06-13 20:40:48 +0000] git push -f git@heroku.com:gravity-production.git FETCH_HEAD:master
Warning: Permanently added the RSA host key for IP address '50.19.85.154' to the list of known hosts.
-----> Deleting 13 files matching .slugignore patterns.
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
find: `spec': No such file or directory
find: `bin': No such file or directory
@dblock
dblock / snapshot_names.cs
Created April 1, 2013 12:55
Get the list of snapshots using VMWareTasks.
private List<string> GetSnapshotNames(IEnumerable<VMWareSnapshot> snapshots)
{
List<string> result = new List<string>();
foreach (VMWareSnapshot snapshot in snapshots)
{
result.Add(snapshot.DisplayName);
result.AddRange(GetSnapshotNames(snapshot.ChildSnapshots));
}
return result;
}
@dblock
dblock / svn2svn-sample.txt
Created March 30, 2013 19:58
Run sv2svn, revision 2 to 136.
C:\>Svn2Svn.exe /source:c:\source\dni\trunk /destination:c:\Users\dblock\Source\CodePlex\Dni\trunk -r:2:136 -prompt
Svn2Svn: 1.0.12089.0
From: c:\source\dni\trunk
To: c:\Users\dblock\Source\CodePlex\Dni\trunk
Collecting svn log: 2:136 Source SVN root: https://dotnetinstaller.svn.sourceforge.net/svnroot/dotnetinstaller/
Source SVN uri: https://dotnetinstaller.svn.sourceforge.net/svnroot/dotnetinstaller/trunk/
Relative path: /trunk/
.........................................................................................................
Collected 105 revisions.
Revision 2 (11/27/2006 6:42:51 PM)
@dblock
dblock / thin_connection.rb
Created February 16, 2013 16:28
Instrument thin to measure wait time inside its internal queue.
module Thin
class Connection < EventMachine::Connection
attr_accessor :init_ts, :data_ts
def initialize
super
@init_ts = Time.now
Gravity.metrics.increment 'thin.connection'
end
@dblock
dblock / mongoid_paginate_by_cursor_helper.rb
Created February 14, 2013 14:53
A way to paginate "by cursor" with mongoid.
def cursor_and_tiebreak_id_from_params(options = {})
cursor, tiebreak_id = nil
if params[:cursor]
raw_cursor = params[:cursor].split(":")[0...-1].join(":")
cursor = (options[:field_type] == String ? raw_cursor : raw_cursor.to_i)
tiebreak_id = params[:cursor].split(":")[-1]
elsif options[:default_cursor]
cursor = (options[:field_type] == String ? options[:default_cursor] : options[:default_cursor].to_i)
end
[ cursor, tiebreak_id ]
@dblock
dblock / find_corrupted_mongoid_embedded_items.rb
Created February 2, 2013 20:17
Find corrupted MongoDB embedded items inside multiple collections. Code from @macreery.
summary_totals = {}
summary_totals.default = 0
count = 0
{
Collection => :items,
Artwork => :images
}.each do |coll, orderable_subcoll|
coll.all.each do |item|
$stdout.write "." if count % 1000 == 0
count += 1
@dblock
dblock / deep_zoom.rb
Last active December 11, 2015 17:48
Tile images for SeaDragon.
# MIT License (c) Artsy Inc. 2013
# Deep Zoom module for generating Deep Zoom (DZI) tiles from a source image
# Borrows heavily from https://github.com/meso-unimpressed/deep_zoom_slicer
module DeepZoom
extend ActiveSupport::Concern
# Defaults
DEFAULT_TILE_SIZE = 512

Mongoid::CachedJson 1.2.3

Benchmarking 1.2.3 with ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0], Dalli 2.6.0

  • dalli_store:flat => 4.070754
  • dalli_store:manager => 2.670791
  • dalli_store:artwork => 4.310461
  • dalli_store:child_secret => 1.058889
  • dalli_store:child_not_secret => 0.800552
require 'devise/strategies/rememberable'
module Devise
module Strategies
class Rememberable < Authenticatable
private
def remember_key
key = "_app_remember_#{scope}_token"
key += "_#{Rails.env.to_s}" unless Rails.env.production?
key
@dblock
dblock / Gemfile
Last active December 11, 2015 02:59
Infinite loop in bundler?
source "http://rubygems.org"
ruby '1.9.3'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
gem "rails", "~> 3.2"
gem "thin", "1.5.0"
gem "grape", "0.2.6"