Skip to content

Instantly share code, notes, and snippets.

Ken Collins metaskills

Block or report user

Report or block metaskills

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
@metaskills
metaskills / sam-validate.rb
Created Dec 28, 2017
Parse AWS SAM YAML Templates & Validate JSON Schema
View sam-validate.rb
#!/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 Aug 29, 2017
Shell Function for Git.io
View gitio.sh
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 Aug 1, 2017
Simple SQL Server & PG Rails Benchmarks.
View bm.rb
#!/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 Jan 17, 2018
LivePerson/Engage Turbolinks Hacking
View lp.js
// 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 Jun 19, 2017
Per-Service VCR Cassettes - Reuse Common API Requests Across Your App's Tests
View vcr_helper.rb
# 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
Using Module Prepend To Extend Ruby Classes
View prepend.rb
class Foo
attr_reader :bar
def initialize
@bar = 'bar'
end
end
module Bar
def bar
super.upcase
View profile.sh
# Always make it easy to edit all the script.
$ which profile
profile: aliased to subl ~/.zshkit ~/.zshkit/01_path
# Always make it easy to version control my ZSH kit.
# Ex: `profile-save "New Docker Functions"`
$ which profile-save
profile-save () {
pushd ~/.zshkit/
git add .
View 240.rb
>> RbConfig::CONFIG.each { |k,v| puts "#{k} => #{v}\n" } ; true
DESTDIR =>
MAJOR => 2
MINOR => 4
TEENY => 0
PATCHLEVEL => 0
INSTALL => /opt/local/bin/ginstall -c
EXEEXT =>
prefix => /Users/kencollins/.rbenv/versions/2.4.0
ruby_install_name => ruby
View mkmf.log
find_header: checking for sybfront.h... -------------------- no
"clang -o conftest -I/Users/kencollins/.rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/kencollins/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/kencollins/.rbenv/versions/2.3.1/include/ruby-2.3.0 -I../../../../ext/tiny_tds -I/Users/kencollins/.rbenv/versions/2.3.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/kencollins/.rbenv/versions/2.3.1/lib -L. -L/Users/kencollins/.rbenv/versions/2.3.1/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
@metaskills
metaskills / rails502.md
Created Mar 2, 2017
Step ?) Create Rails Application
View rails502.md
$ gem install rails
$ rails new my_application --database=sqlserver
$ cd my_application

Now setup your development and test databases.

$ export SA_PASSWORD=...
You can’t perform that action at this time.