Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile
@pboling
pboling / slim_vs_haml.md
Last active February 11, 2024 16:33
Slim vs Haml

Analysis of Slim vs. Haml Project Health

  • Static data as of April 13, 2015, some updates as of October 1, 2015
# Metric Haml Slim Winner
1 Issues Open Issues Open Issues Slim
2 Stars Stars Open Issues Slim
3 Quality Code Climate technical debt Code Climate maintainability -- Haml
4 Test Coverage ![Code Climate coverage](https://i
@pboling
pboling / prepare-commit-msg
Last active September 19, 2015 08:28
commit message git hook: Adds story type and story ID to the end of each commit
#!/usr/bin/env ruby
# vim: set syntax=ruby
# branches should be named like:
# <story_type>/<story_id>-explosion-in-the-fudge-factory-spec-suite-fix
# where story type is one of "hotfix", "bug", "feature", "candy"
#
branch = `git branch 2> /dev/null | grep -e ^* | awk '{print $2}'`
regex = /^(?<story_type>(hotfix)|(bug)|(feature)|(candy))\/(?<story_id>\d{8,})-.+\Z/
match_data = branch.match(regex)
@pboling
pboling / PhantomJS Install.md
Last active July 23, 2019 17:54
How to install old PhantomJS 1.8.2 on Mac OS X

I upgraded to El Capitan, with Homebrew & Ruby, and this is how I did it flawlessly.

... and Xcode and Java, etc.

Prepare

If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.

Hardware

@pboling
pboling / plpgsql.rake
Last active October 12, 2015 18:56 — forked from rietta/plpgsql.rake
Are you using PostgreSQL and don't want to make your app run as PostgreSQL super user, then add this custom rake task to your `lib/tasks` folder and be happy.
#
# PostgreSQL writes two optional commands to the database schema
# file, called db/structure.sql, that can only be run as a root
# database user. These are not needed actually, so comment them
# out automatically
#
# CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
# COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
#
namespace :db do
@pboling
pboling / std_out.rb
Created October 18, 2015 00:37
Rspec support: Silnce the `puts`
# Some specs causes a lot of stuff to output to the console during the spec run which interrupts the flow of lovely green dots.
# We don't want to ignore stuff that we want to see, like rspec deprecation warnings, but for an otherwise clean spec,
# that is puts ing things, we can turn those off by tagging the spec as :noisy.
RSpec.configure do |config|
original_stderr = $stderr
original_stdout = $stdout
config.before(:each, :noisy) do
# Redirect stderr and stdout
$stderr = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3
$stdout = File.open(File::NULL, "w") # to /dev/null, since Ruby 1.9.3
var isDev = false;
if (window.__env.NODE_ENV === 'development') {
isDev = true;
}
if (isDev) {
var MixpanelMock;
MixpanelMock = (function() {
function MixpanelMock() {
this.init = function() {
@pboling
pboling / extract_embedded_flickr_image_url_for_google_sheets.rb
Last active March 1, 2017 10:51
Extract image URL from Flickr Embedded Image Code for use in Google Sheets
# Example:
#
# embedded = '<a data-flickr-embed="true" href="https://www.flickr.com/photos/galtzo/32796076230/in/album-72157679012034441/" title="IMG_2054"><img src="https://c1.staticflickr.com/3/2939/32796076230_773e54a3b0_h.jpg" width="1200" height="1600" alt="IMG_2054"></a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>'
# extract_embedded_flickr_image_url_for_google_sheets(embedded)
#
def extract_embedded_flickr_image_url_for_google_sheets(embedded, mode: 4, aspect: "4:3", height: nil, width: nil)
options = []
url = embedded[(start = embedded.index("img src=\"https")+9)..(start+embedded[start..(-1)].index("g\" "))]
options << "\"#{url}\""
class Foo
def calls_bar
bar + " from foo"
end
private
def bar
raise "define #{__method__} in subclasses"
end
end
class SubFooPrivateOverride < Foo
@pboling
pboling / unobtrusively_logged.rb
Last active September 26, 2017 09:30
Unobtrusive Debug Logging that examines wonders of Ruby: Module < Class; include Module.new(*args); and more!
# Simpler version of what the debug_logging gem does; see https://github.com/pboling/debug_logging
#
############# THIS IS A BAUBLE
############# FOR EXAMINING SEVERAL OF THE WONDERS OF RUBY
############# TO ACCOMPLISH SOMETHING PRACTICAL
############# For a more robust implementation use the gem debug_logging itself,
############# which makes use of these same principles.
#
# Automatically log Class.method(arguments) as they are called at runtime (instance or singleton)!
#