Skip to content

Instantly share code, notes, and snippets.

View dennisfaust's full-sized avatar

Dennis Faust dennisfaust

View GitHub Profile
@dennisfaust
dennisfaust / gist:f181a8444ded0daef0b8
Created December 4, 2014 00:15
Convert types on Scala Collections
// TODO: Save this snippet for converting collections:
XXX.to[({type l[_] = collection.immutable.HashMap[UserInformationKind, String]})#l]
@dennisfaust
dennisfaust / nullstring_example.go
Created November 5, 2015 19:51
github.com/go-playground/validator Custom null.string validator example
// NewNotBlankValidator - given field must be declared as a null.* type. This checks to make sure the
// field value is its zero or null, or filled in but NOT set to empty String
// e.g. {value="", err=false} is not valid.
func NewNotBlankValidator(db *gorm.DB) validator.Func {
return func(v *validator.Validate, topStruct reflect.Value, currentStruct reflect.Value, field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string) bool {
switch fieldKind {
case reflect.String:
if field.String() == "" && field.IsValid() {
return false
}
tl;dr:
$ set -o vi
$ bind '"\ee": emacs-editing-mode'
Then hit Esc-e
$ bind -P| grep edit
edit-and-execute-command can be found on "\C-x\C-e".
emacs-editing-mode is not bound to any keys
vi-editing-mode is not bound to any keys
@dennisfaust
dennisfaust / session_cookie_manipulation.rb
Last active March 2, 2017 18:58
Manipulating Rails 3 Session Cookies in Minitest
@dennisfaust
dennisfaust / sidekiq_unique_jobs_hash_compactor.rb
Created July 12, 2017 20:46
sidekiq-unique-jobs gem not deleting expired keys in its uniquejobs hash
# https://github.com/mhenrixon/sidekiq-unique-jobs/issues/161
# Even worse: https://github.com/mhenrixon/sidekiq-unique-jobs/issues/234
class SidekiqUniqueJobsHashCompactor
include Sidekiq::Worker
sidekiq_options queue: "slow"
def perform
# Skip if there are jobs queued...
return unless Sidekiq::Queue.all.select { |q| q.size > 100 }.blank?