Skip to content

Instantly share code, notes, and snippets.

View stevelounsbury's full-sized avatar

Steve Lounsbury stevelounsbury

  • ReturnBear
  • Ottawa, ON
View GitHub Profile
@stevelounsbury
stevelounsbury / rx480-suspend.md
Created December 9, 2017 02:16
Ubuntu 17.10 suspend resume with RX480 GPU
require 'dry-types'
module Types
include Dry::Types.module
end
hash = Types::Hash.schema(name: Types::Strict::String, age: Types::Coercible::Int)
#
# When providing an invalid value for Strict types, a SchemaError is raised letting us know which key had the issue.
#
@stevelounsbury
stevelounsbury / remove_aj_subscribers.rb
Created June 15, 2016 15:57
Unsubscribing ActiveJob::Logging::LogSubscriber
def remove_aj_subscribers
patterns = ActiveSupport::Subscriber.subscribers.detect { |s| s.is_a? ActiveJob::Logging::LogSubscriber }.patterns
subscribers = patterns.map { |p| ActiveSupport::Notifications.notifier.listeners_for(p) }.flatten
subscribers.each do |subscriber|
ActiveSupport::Notifications.notifier.unsubscribe(subscriber)
end
end
/**
* ZF Controller Action helper for logging. Assumes you have the log resource
* setup in your bootstrap, but silently fails if it is not found.
*/
class My_Action_Helper_Log extends Zend_Controller_Action_Helper_Abstract
{
/**
* @var Zend_Log
*/
protected $_log = null;
/**
* Allow for some super easy templating
* @param {Object} ctx The context when you pass in an object literal
* ------------------------------------------------------------------
* Works like this:
* var People = { name: 'bob', age: 123, decades: function() { return parseInt(this.age/10); } }
* var my_tpl = "Hi, my name is {{ name }} and I'm {{ age }} years old (that's {{ decades }} decades!)."
* my_tpl.template(People); // Outputs: "Hi, my name is bob and I'm 123 years old";
*/
String.prototype.template = function(data){