Skip to content

Instantly share code, notes, and snippets.

Skye Shaw sshaw

Block or report user

Report or block sshaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sshaw
sshaw / refills_flash.rb
Last active Jul 27, 2016
Ruby helper to render Bourbon/Neat Refills style flash messages
View refills_flash.rb
# Helper to render Bourbon/Neat Refills style flash messages
# https://gist.github.com/sshaw/bc27941c20f0adbfa5b5c9c57da095d7
module RefillsFlash
FLASH_KEYS = [:success, :notice, :error, :alert]
def flash_messages
FLASH_KEYS.inject("") do |html, name|
if flash[name]
html << content_tag(:div, :class => "flash-#{name}") {
content_tag :span, flash[name]
@sshaw
sshaw / erb_test_fixture.rb
Last active Jun 14, 2019
Ruby module that allows you use ERB in your test/spec fixtures and easily load them
View erb_test_fixture.rb
require "erb"
require "shellwords"
#
# Use ERB in your test fixtures and easily load them.
#
# By: Skye Shaw (https://github.com/sshaw)
# Date: 2016-06-30
# Source: https://gist.github.com/sshaw/f9bad743bb53d2439501d03fb6056a4c
#
@sshaw
sshaw / query_source.rb
Last active Jun 27, 2016
Make debugging a bit easier by determining the source of ActiveRecord queries. The source of queries will be output via logger.debug().
View query_source.rb
#
# Make debugging a bit easier by determining the source of ActiveRecord queries.
# The source of queries will be output via logger.debug().
#
# By: Skye Shaw (https://github.com/sshaw)
# Date: 2014-10-24
# Source: https://gist.github.com/sshaw/05d8bdf99e4175816db858323fb2169c
#
# === Usage
#
@sshaw
sshaw / page_number.gemspec
Last active Sep 14, 2018
Ruby utility methods for pagination page and per page that make sure you'll always have a valid number. Use them your controllers or model or anywhere where you process page info. Moved to https://github.com/sshaw/page_number.git
View page_number.gemspec
Gem::Specification.new do |s|
s.name = "page_number"
s.version = "0.0.2"
s.date = "2016-09-19"
s.summary = "Utility methods for pagination page and per page that make sure you'll always have a valid number."
s.description =<<-DESC
Utility methods for pagination page and per page that make sure you'll always have a valid number.
Use them your controllers or model or anywhere where you process page info.
DESC
s.authors = ["Skye Shaw"]
@sshaw
sshaw / iterm2_image.rb
Last active Jul 28, 2016
Ruby class & program to take an image and output it using an iTerm2 escape sequence. Supports all of the iTerm2 image protocol.
View iterm2_image.rb
require "base64"
#
# Take an image and output it using an iTerm2 escape sequence.
# Supports all of the iTerm2 image protocol: https://iterm2.com/documentation-images.html
#
# https://gist.github.com/sshaw/3687e4acdc2e1e9080d3dff04474e4e5
module ITerm2
class Image
@sshaw
sshaw / greeting.liquid
Last active May 12, 2016
"Random" Greeting in a Shopify Liquid Template
View greeting.liquid
{% assign name = "sshaw" %}
{% assign greetings = "Hi %s!|Oi %s!|¡Hola %s!" | split: "|" %}
{% assign index = "now" | date: "%s" | modulo: greetings.size %}
{{ greetings[index] | replace_first: '%s', name }}
@sshaw
sshaw / request-bin.el
Last active Apr 30, 2016
Interactive Emacs function to create a RequestBin on http://requestb.in/
View request-bin.el
;;; request-bin.el --- Create a RequestBin on http://requestb.in/
;; Author: Skye Shaw <skye.shaw@gmail.com>
;; Version: 0.0.1
;; Keywords: tools
;; URL: https://gist.github.com/19d1e0d85eadd555c178ae1754cc6211
;; This file is NOT part of GNU Emacs.
;;; License:
View rusage.rb
require 'get_process_mem'
require 'rusage' # gem install rusage
require 'benchmark'
n = 2000
gpm = GetProcessMem.new
Benchmark.bm(10) do |x|
x.report("status:") { n.times do gpm.linux_status_memory end }
# In sshaw version
@sshaw
sshaw / gh_update_remotes_owner.sh
Last active Mar 21, 2016
Batch update the GitHub user or organization in all repository remotes under the given directory.
View gh_update_remotes_owner.sh
# Batch update the GitHub user or organization in all repo remotes under the given directory.
# Does not work with JRuby.
#
# usage: usage: gh_update_remotes_owner dir oldorg neworg
gh_update_remotes_owner()
{
if [ $# -lt 3 ]; then
echo "usage: gh_update_remotes_owner dir oldorg neworg" >&2
return 1
fi
@sshaw
sshaw / gender_api.gemspec
Last active Mar 6, 2016
Ruby API client for the Gender API (https://gender-api.com)
View gender_api.gemspec
Gem::Specification.new do |s|
s.name = "gender_api"
s.version = "0.0.1"
s.date = "2016-03-05"
s.summary = "API client for the Gender API"
s.description = "API client for the gender detection service Gender API: https://gender-api.com/en/api-docs"
s.authors = ["Skye Shaw"]
s.email = "skye.shaw@gmail.com"
s.files = Dir["*.rb"]
s.require_paths = ["."]
You can’t perform that action at this time.