Skip to content

Instantly share code, notes, and snippets.

🤠
code cowboy

Tyson Mote tysonmote

🤠
code cowboy
Block or report user

Report or block tysonmote

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View go_constructors.md

Config through public attributes on struct

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

Config through NewFoo() only

View gist:2a599b73189543cccae63d8389f208c1
### 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 Jan 2, 2019
Utility functions for performing operations on large Redis keyspaces
View keys.rb
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 Jun 16, 2015
Delete large Redis sorted sets with Ruby and Resque
View gist:1fa32995b25d49baddac
$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 Jun 16, 2015
Delete large Redis sorted sets with Ruby and Sidekiq
View gist:8c9f4bae25aa8b57dbf3
$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 Aug 29, 2015
Delete large Redis sets with Ruby and Sidekiq
View gist:20df8fb55a74cd193e9a
$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 Aug 29, 2015
Delete large Redis sets with Ruby and Resque
View gist:c02b0523c42ae60c27d1
$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 Aug 29, 2015
Delete large Redis lists with Ruby and Sidekiq
View gist:e2d915ef4f8ca4247cea
$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 Feb 13, 2017
Delete large Redis lists with Ruby and Resque
View gist:9cda15bde7ffcb1e6b99
$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 Aug 29, 2015
Delete large Redis hashes with Ruby and Sidekiq
View gist:95dd2efa8c93fc0370c6
$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")}"
You can’t perform that action at this time.