Skip to content

Instantly share code, notes, and snippets.

View dennisfaust's full-sized avatar

Dennis Faust dennisfaust

View GitHub Profile
@dennisfaust
dennisfaust / delayed_job_formatted_logger
Created December 20, 2013 01:57
Formatted log entries from Delayed Job without banging your head...
#
# config/delayed_job_config.rb
#
Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'delayed_job.log'))
# The base logger is terrible. It only puts what you send. Nothing else. So I had to dig this up and add it.
class DJFormatter
def call(severity, time, progname, msg)
formatted_severity = sprintf("%-5s","#{severity}")
"#{Time.now.utc} [#{progname} #{formatted_severity} pid:#{$$}] #{msg.strip}\n"
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?
@dennisfaust
dennisfaust / DesEncrypter.scala
Created February 23, 2012 22:08
Triple DES (3DES) Encryption for Scala - adapted from exampledepot java
import com.sun.org.apache.xml.internal.security.utils.Base64
import javax.crypto._
import javax.crypto.spec._
import java.security.spec._
import java.io._
import java.security.{NoSuchAlgorithmException, InvalidAlgorithmParameterException}
import javax.management.openmbean.InvalidKeyException
import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException
import play.api.Logger