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 / branch_handling.md
Last active Oct 31, 2017
some options & shortcuts to make git branch management simple and sane
View branch_handling.md

Run these once to setup git options:

git config --global push.default current
git config --global merge.defaultToUpstream true
git config --global branch.autosetupmerge true
git config --global branch.autosetuprebase remote
git config --global alias.cb 'checkout -b'
git config --global alias.ps 'push -u'
git config --global alias.pl '!git fetch -p && git rebase'

Use them like this:

@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 / 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 / inside.sh
Created Nov 26, 2013
inside the heroku beast
View inside.sh
~/projects$ h run bash
Running `bash` attached to terminal... up, run.2192
~ $ uname -a
Linux 7fa29fb1-2e9c-4510-a0a7-df92cfaff4c8 3.8.11-ec2 #1 SMP Fri May 3 09:11:15 UTC 2013 x86_64 GNU/Linux
~ $ free -m
total used free shared buffers cached
Mem: 34302 29994 4307 0 1927 8232
-/+ buffers/cache: 19835 14466
Swap: 34815 732 34083
@tjmcewan
tjmcewan / instructions.md
Last active Dec 26, 2015
Ninefold db updates
View instructions.md

This is a quick way to Push or Pull your app database between your local machine and your Ninefold app server. "Pushing" is useful in the early stages of app development when you need to update seed data. "Pulling" is eternally useful for debugging.

  1. setup public key authentication (the SSH username is "user"). NB ensure you don't remove the existing SSH key - it's needed by the Ninefold Portal.

  2. obtain your database password from the "database" tab in the Ninefold portal.

  3. put the password where Postgres can find it (on the database server): echo "localhost:*:*:app:<PASSWORD>" > ~/.pgpass then chmod 0600 .pgpass more info on password files

@tjmcewan
tjmcewan / database.yml
Last active Dec 24, 2015
app-agnostic, feature branch supporting, drop-in database.yml(based on http://www.reinteractive.net/posts/22-branch-specific-database-yml)
View database.yml
<%
app_name = Dir.getwd.split('/')[-1]
branch = `git symbolic-ref --short HEAD 2>/dev/null`.chomp.gsub(/\W/, '_')
db_name = branch.match(/feature/) ? "#{app_name}_#{branch}" : "#{app_name}_master"
puts "DATABASE: #{db_name}"
%>
mysql2: &mysql2
adapter: mysql2
socket: /tmp/mysql.sock
@tjmcewan
tjmcewan / git-rebase-todo
Last active Dec 19, 2015
multi-stage deploy using git rebase -i
View git-rebase-todo
# x (or exec) will run anything on the same line as a shell command.
# we need to checkout a temporary branch because git won't push detached HEADs.
# after deploy, the "checkout -" means checkout the previously checked out thing,
# which will go back to our detached head and we clean up the temporary branch so
# that we don't need to worry about merging.
# if your branch is already based on the same point as your rebase command, then
# the 'pick' stage is essentially the same as a fast-forward merge; no new commits
# are created.
@tjmcewan
tjmcewan / unsyncer.js
Last active Dec 15, 2015
Sync or Unsync all Box folders on the current page
View unsyncer.js
$('#mod-item-list>li').each(function(index, el){
// defaults to unsync; to sync, set unsync to 0
var unsync = 1;
var folder_id = el.attributes['data-view_id'].textContent;
var data = ["q[items][0]=", folder_id, "&q[unsync]=", unsync, "&request_token=", request_token, "&realtime_subscriber_id=", realtime_subscriber_id].join('');
var url = ["https://", location.host, "/index.php?rm=box_sync_mark_item_sync"].join('');
$.post(url, data, function(x,status,z){ console.log(folder_id, ': ', status) });
});
@tjmcewan
tjmcewan / successful install.sh
Created Feb 17, 2013
The words "fatal error" and "1 error generated" should generally _not_ be followed by "Successfully installed..."
View successful install.sh
$ pip install pyyaml
Downloading/unpacking pyyaml
Downloading PyYAML-3.10.tar.gz (241kB): 241kB downloaded
Running setup.py egg_info for package pyyaml
Installing collected packages: pyyaml
Running setup.py install for pyyaml
checking if libyaml is compilable
cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c build/temp.macosx-10.8-x86_64-2.7/check_libyaml.c -o build/temp.macosx-10.8-x86_64-2.7/check_libyaml.o
build/temp.macosx-10.8-x86_64-2.7/check_libyaml.c:2:10: fatal error: 'yaml.h' file not found