Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🧠
Adding Digital Intelligence

Ken Collins metaskills

🧠
Adding Digital Intelligence
View GitHub Profile
@metaskills
metaskills / turbolinks_enquire.coffee
Created January 10, 2018 12:55
Turbolinks With Enquire JS
@metaskills
metaskills / turbolinks_trustpilot.coffee
Created January 10, 2018 12:52
Turbolinks Trustpilot Integration
@metaskills
metaskills / ready.js
Created January 10, 2018 12:34
When Are Things Ready?
document.addEventListener('DOMContentLoaded', function(){
console.log('DOMContentLoaded');
});
document.addEventListener('turbolinks:load', function(){
console.log('turbolinks:load');
});
jQuery(function(){
console.log('jQuery Document Ready');
@metaskills
metaskills / foo.rb
Created January 10, 2018 02:41
Basic HTML Page
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<script src="..."></script>
</head>
<body>
<h1>Hello World!</h1>
<script src="..."></script>
</body>
@metaskills
metaskills / sam-validate.rb
Created December 28, 2017 00:26
Parse AWS SAM YAML Templates & Validate JSON Schema
#!/usr/bin/env ruby
require 'pp'
require 'json'
require 'yaml'
require 'open-uri'
require 'json-schema'
SCHEMA = begin
file = open('https://raw.githubusercontent.com/awslabs/goformation/master/schema/sam.schema.json')
@metaskills
metaskills / gitio.sh
Last active August 29, 2017 12:09
Shell Function for Git.io
gitio () {
local url=$(curl -s -i https://git.io -F "url=$1" | grep "Location: " | cut -d" " -f2)
echo -n $url | tr -d '\n' | pbcopy
echo $url
}
@metaskills
metaskills / bm.rb
Created August 1, 2017 01:05
Simple SQL Server & PG Rails Benchmarks.
#!/usr/bin/env ruby
require 'benchmark'
require 'bundler/inline'
gemfile true do
source 'https://rubygems.org'
gem 'activerecord-sqlserver-adapter', ENV['VER_AR'] || '~> 5.1.0'
gem 'tiny_tds', ENV['VER_TTDS'] || '~> 2.0.0'
gem 'pg'
@metaskills
metaskills / lp.js
Last active January 17, 2018 19:27
LivePerson/Engage Turbolinks Hacking
// Assuming you put the LP init code into a function called window.lpTagCustomInit
document.addEventListener('turbolinks:before-cache', function(){
jQuery("[id^='LP_DIV']").empty();
})
document.addEventListener('turbolinks:load', function(){
delete window.liveperson;
delete window.lpMTagConfig;
delete window.lpTag;
@metaskills
metaskills / vcr_helper.rb
Created June 19, 2017 16:41
Per-Service VCR Cassettes - Reuse Common API Requests Across Your App's Tests
# This assumes you have a client with a URL config. Hard coded URLs work too.
# Will automiatically insert cassets whenever needed and organize them per servcie.
#
VCR.configure do |c|
c.around_http_request do |request|
if request.uri =~ Regexp.new(MyServiceClient.config.url)
VCR.use_cassette 'my_service', default_cassette_options, &request
else
request.proceed
end
@metaskills
metaskills / prepend.rb
Created May 11, 2017 01:03
Using Module Prepend To Extend Ruby Classes
class Foo
attr_reader :bar
def initialize
@bar = 'bar'
end
end
module Bar
def bar
super.upcase