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
module Hooks | |
def before(*method_names, &block) | |
to_prepend = Module.new do | |
method_names.each do |name| | |
define_method(name) do |*args, &blk| | |
yield(name, *args) | |
super(*args, &blk) | |
end | |
end | |
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
def piratize(text) | |
dictionary = {"address"=>"port o' call", "admin"=>"helm", "am"=>"be", "an"=>"a", "and"=>"n'", "are"=>"be", "award"=>"prize", "bathroom"=>"head", "beer"=>"grog", "before"=>"afore", "belief"=>"creed", "between"=>"betwixt", "big"=>"vast", "bill"=>"coin", "bills"=>"coins", "boss"=>"admiral", "bourbon"=>"rum", "box"=>"barrel", "boy"=>"lad", "buddy"=>"mate", "business"=>"company", "businesses"=>"companies", "calling"=>"callin'", "canada"=>"Great North", "cash"=>"coin", "cat"=>"parrot", "cheat"=>"hornswaggle", "comes"=>"hails", "comments"=>"yer words", "cool"=>"shipshape", "country"=>"land", "dashboard"=>"shanty", "dead"=>"in Davy Jones's Locker", "disconnect"=>"keelhaul", "do"=>"d'", "dog"=>"parrot", "dollar"=>"doubloon", "dollars"=>"doubloons", "dude"=>"pirate", "employee"=>"crew", "everyone"=>"all hands", "eye"=>"eye-patch", "family"=>"kin", "fee"=>"debt", "female"=>"wench", "females"=>"wenches", "food"=>"grub", "for"=>"fer", "friend"=>"shipmate", "friends"=>"crew", "fuck"=>"shiver me timbers |
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
module Cipher | |
ENCRYPTOR = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base) | |
def self.encrypt(data) | |
ENCRYPTOR.encrypt_and_sign(data) | |
end | |
def self.decrypt(data) | |
ENCRYPTOR.decrypt_and_verify(data) | |
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
#!/usr/bin/env ruby | |
require 'json' | |
require 'open-uri' | |
#require 'byebug' | |
def load_json(url) | |
#JSON.parse(`wget -q -O- #{url}`, symbolize_names: true) | |
JSON.parse(open(url).read, symbolize_names: true) | |
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
#!/usr/bin/env ruby | |
require 'acme-client' | |
require 'openssl' | |
require 'uri' | |
require 'net/http' | |
class Acme::Client::Crypto | |
def generate_signed_jws(header:, payload:) | |
jwt = JSON::JWT.new(payload || {}) |
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
class String | |
def black; "\e[30m#{self}\e[0m" end | |
def red; "\e[31m#{self}\e[0m" end | |
def green; "\e[32m#{self}\e[0m" end | |
def brown; "\e[33m#{self}\e[0m" end | |
def blue; "\e[34m#{self}\e[0m" end | |
def magenta; "\e[35m#{self}\e[0m" end | |
def cyan; "\e[36m#{self}\e[0m" end | |
def gray; "\e[37m#{self}\e[0m" end | |
def bg_black; "\e[40m#{self}\e[0m" 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
/* | |
* If the loop bumps into an function, it returns true, and moves on, | |
* but if it bumps into a number, it waits x milliseconds, | |
* it stops the _.every loop by returning false, and recursively | |
* calls the sequence function with the rest of the array. | |
* Nifty, huh? 😝😝 | |
*/ | |
const sequence = b => b.every((a, i) => !(a.call ? a() : setTimeout(() => sequence(b.slice(++i)), a))); |
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><head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>SVG Helper Tool</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
</head> | |
<body> | |
<p>click and drag on the canvas ... you're making a polygon ... <button id="reset">reset</button><button id="undo">undo</button></p> | |
<canvas id="x" width="500" height="500" style="border: 1px solid black;"></canvas> |
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
<style>*{margin:0;padding:0;box-sizing:border-box;}canvas{width:100%;height:100%}</style> | |
<canvas id='C' style='background:#000;'> | |
<script> | |
var c=C.getContext("2d"),R=Math.random,tick=Date.now(),selectedPlanets=new Set(),i,j,ships=[],planets=[],sfx=[]; | |
C.width = window.innerWidth; C.height = window.innerHeight; | |
c.font = '18px Helvetica'; c.textAlign = 'center'; c.textBaseline = 'middle'; | |
function synth(f,d){ | |
for(var t=0,s='RIFF_oO_WAVEfmt '+atob('EAAAAAEAAQBAHwAAQB8AAAEACAA')+'data';++t<d;)s+=String.fromCharCode(f(t)); |
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> | |
<head> | |
<meta charset="utf-8" /> | |
<title>MiniCodepenClone</title> | |
<style> | |
body,textarea,iframe{ margin:0; box-sizing:border-box; } | |
textarea,iframe { width:100%; height:50vh; float:left; } | |
textarea { color:#eee; background:#111; font-family:monospace; font-size:11pt; line-height:1.4; width:33.33%; } | |
#shareBtn { position:absolute; bottom:0; left:0; } |