Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
tjmcewan / slack.sh
Created Jul 18, 2021 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
View slack.sh
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@tjmcewan
tjmcewan / localtunnel
Last active Oct 12, 2016
localtunnel restarter. all props to @michaelkeenan. slightly modified to be run as a executable & to remove ordinal numbers. original here: https://github.com/localtunnel/localtunnel/issues/81#issuecomment-218320442
View localtunnel
#!/usr/bin/env ruby
require 'optparse'
options = {:subdomain => 'defaultdomain', :port => 3000}
parser = OptionParser.new do|opts|
opts.banner = "Usage: localtunnel [options]"
opts.on('-s', '--subdomain subdomain', 'Subdomain') do |subdomain|
options[:subdomain] = subdomain;
@tjmcewan
tjmcewan / awsm.json
Created Oct 27, 2015
Excerpt from awsm.json that shows CORS setup for an API Gateway endpoint.
View awsm.json
"default": {
"statusCode": "200",
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
},
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'http://CORSdomain.com'"
},
@tjmcewan
tjmcewan / aws_route53_cleaner_instructions.md
Last active Aug 29, 2015
Want to delete a lot of old hosted zones on Route53? This should take the pain away.
View aws_route53_cleaner_instructions.md

AWS Route53 Hosted Zone Cleaner

Why?

My org buys lots of domains and configure lots of records on AWS. Removing them is a pain though; you have to remove each record set before you can remove the hosted zone. This makes it much more straightforward.

Feel free to use this; but you're on your own. I am not responsible if you break something.

Setup

You'll need ruby/ruby-gems and your AWS API credentials.

View keybase.md

Keybase proof

I hereby claim:

  • I am tjmcewan on github.
  • I am tjmcewan (https://keybase.io/tjmcewan) on keybase.
  • I have a public key whose fingerprint is 77AB E45C 44A2 6B7E C691 2F1F C16A 1AC7 7FAF 79D6

To claim this, I am signing this object:

@tjmcewan
tjmcewan / destroyer.rb
Created Apr 10, 2015
nation builder tag cleaner
View destroyer.rb
require "spec_helper"
NATION = "my-nation"
EMAIL = "admin@example.com"
PASSWORD = "Password1"
TAG_PATTERNS_TO_DELETE = [
/^mass_tag_/,
/^valuable_member_/,
]
@tjmcewan
tjmcewan / thing.sh
Created Feb 19, 2015
find the 10 longest git commit **messages** (not changesets) in a repo
View thing.sh
git log --pretty=oneline --abbrev-commit | awk '{print length() "\t" $1 }' | sort -rn | head -n 10
@tjmcewan
tjmcewan / js_equality.html
Created Dec 17, 2014
javascript table of equality
View js_equality.html
<html><head></head><body></body>
<script type="text/javascript">
// italics for objects
(function (values) {
function toString(x) {
var v = x;
v = (v || v === "") ? JSON.stringify(v) : String(v);
if (typeof x === 'object') v = v.italics();
return v;
}
@tjmcewan
tjmcewan / wtf.rb
Created Jul 21, 2014
putting alias_method above module_function allows the alias to be called
View wtf.rb
~$ ruby -v *[master]
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
~$ irb *[master]
irb(main):001:0> module I18nHelper
irb(main):002:1> def custom_translate
irb(main):003:2> "boo"
irb(main):004:2> end
irb(main):005:1>
irb(main):006:1* module_function :custom_translate
irb(main):007:1> alias_method :ct, :custom_translate
View shoulda_or_shoulda_not?.rb
it { is_expected.to have_many(:appointments).through(:outlets) }
it { is_expected.to validate_presence_of(:outlet_id) }
it { is_expected.to belong_to(:outlet) }