Skip to content

Instantly share code, notes, and snippets.

View tysonmote's full-sized avatar
🤠
code cowboy

Tyson Mote tysonmote

🤠
code cowboy
View GitHub Profile

Config through public attributes on struct

  • exec.Cmd
  • http.Client
  • http.Server
  • net.Client
  • net.Server

Config through NewFoo() only

### Keybase proof
I hereby claim:
* I am tysonmote on github.
* I am tyson (https://keybase.io/tyson) on keybase.
* I have a public key ASDS5Fpv6B7bMOUwPhJob1M2gptcK39m2-WAUAhWTfYKwgo
To claim this, I am signing this object:
@tysonmote
tysonmote / keys.rb
Last active January 2, 2019 23:18
Utility functions for performing operations on large Redis keyspaces
require 'redis'
REDIS = Redis.new( url: "..." )
def each_keys_chunk( pattern = nil, &block )
opts = { count: 100 }
opts[:match] = pattern if pattern
cursor = 0
loop do
cursor, keys = REDIS.scan( cursor, opts )
@tysonmote
tysonmote / gist:1fa32995b25d49baddac
Created June 16, 2015 23:37
Delete large Redis sorted sets with Ruby and Resque
$redis = Redis.new
class SafeSortedSetDelete
@queue = :garbage_collection
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:zsets:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:8c9f4bae25aa8b57dbf3
Created June 16, 2015 23:30
Delete large Redis sorted sets with Ruby and Sidekiq
$redis = Redis.new
class SafeSortedSetDelete
include Sidekiq::Worker
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:zsets:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:20df8fb55a74cd193e9a
Last active August 29, 2015 14:23
Delete large Redis sets with Ruby and Sidekiq
$redis = Redis.new
class SafeSetDelete
include Sidekiq::Worker
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:sets:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:c02b0523c42ae60c27d1
Last active August 29, 2015 14:23
Delete large Redis sets with Ruby and Resque
$redis = Redis.new
class SafeSetDelete
@queue = :garbage_collection
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:sets:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:e2d915ef4f8ca4247cea
Last active August 29, 2015 14:23
Delete large Redis lists with Ruby and Sidekiq
$redis = Redis.new
class SafeListDelete
include Sidekiq::Worker
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:lists:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:9cda15bde7ffcb1e6b99
Last active February 13, 2017 22:49
Delete large Redis lists with Ruby and Resque
$redis = Redis.new
class SafeListDelete
@queue = :garbage_collection
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:lists:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:95dd2efa8c93fc0370c6
Last active August 29, 2015 14:23
Delete large Redis hashes with Ruby and Sidekiq
$redis = Redis.new
class SafeHashDelete
include Sidekiq::Worker
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:hashes:#{$redis.incr("gc:index")}"