This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Slack Message to Emoji</title> | |
<script src="slack.js"></script> | |
<style> | |
h1 { | |
text-align: center; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/sshaw/29d6f7379771e3b4596e228b626bcf9a | |
def convert(chr) | |
chr = chr.upcase | |
# subtract "A" | |
n = (chr.ord - 65) / 3 | |
# account for #7 & #9 which have 4 chars | |
n -= 1 if chr == "S".freeze || chr == "V".freeze || chr >= "Y".freeze | |
(n + 2).to_s | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "erb" | |
class Template | |
def initialize(template) | |
@__template = ::ERB.new(template, nil, "-") | |
end | |
def render(__vars = {}) | |
__b = binding | |
__names = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_support/core_ext/string/inflections" | |
class String | |
def to_pluralizer | |
->(*a) { pluralize(*a) } | |
end | |
end | |
__END__ | |
CUSTOMER = "customer".to_pluralizer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 }} |