Skip to content

Instantly share code, notes, and snippets.

View michaelminter's full-sized avatar

Michael Minter michaelminter

View GitHub Profile
@zulhfreelancer
zulhfreelancer / readline_bundle_image_not_found.md
Last active November 3, 2021 20:50
How to fix 'readline.bundle image not found' problem?

If you get error like this:

Running via Spring preloader in process 7662
/Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
@bsnape
bsnape / gist:edff869d5b7dc0b0d7c2
Last active August 29, 2023 05:15
Rubymine find & replace string hash rockets with new syntax
find:
\'(\w+)\'\s*=>
replace:
$1:
replace symbol hash rockets with new syntax
find:
@jwicks
jwicks / sidekiq-worker-cloudwatch-queue-size.rb
Last active November 21, 2019 07:14
Sidekiq worker for publishing queue size metric to AWS CloudWatch
class QueueSizeMetricWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { minutely }
sidekiq_options retry: false
# Publish a custom metric on CloudWatch with the Sidekiq queue size
def perform
cloudwatch = Aws::CloudWatch::Client.new(
@mikaelbr
mikaelbr / destructuring.js
Last active February 21, 2024 20:41
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@miwahall
miwahall / jquery-bootstrap-datepicker.css
Created October 17, 2013 17:10
jQuery UI Datepicker Bootstrap 3 Style
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
}
@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
irb -Ilib -rGEMNAME
@michaelminter
michaelminter / keywords.rb
Last active December 22, 2015 06:18
Create Keywords from content
# gem install Sanitize
require 'Sanitize'
def generate_keywords(content)
# strip HTML tags
content = Sanitize.clean content
# dump content into array and remove short words
words = content.scan /[A-Za-z0-9]{3,}/
<a class="button" href="#openModal">Open it up!</a>
<div id="openModal" class="modalbg">
<div class="dialog">
<a href="#close" title="Close" class="close">X</a>
<h2>Holy Crap!!!</h2>
<p>You freakin' did it!</p>
<p>You opened up the freakin' modal window! Now close it, ya dingus.</p>
<p class="fineprint">Based on the article "Creating a modal window with HTML5 & CSS3" at <a href="webdesignerdepot.com">Webdesigner Depot</a></p>
<p class="fineprint">p.s. Sorry for calling you a dingus earlier.</p>