Skip to content

Instantly share code, notes, and snippets.

View niallsmart's full-sized avatar

Niall Smart niallsmart

View GitHub Profile
#!/bin/bash
#
# generates a script that will delete merged branches
# that were last updated prior to 2016-10-01
#
function list_ancient_branches() {
git branch -r --merged | \
grep -v HEAD | \
@niallsmart
niallsmart / ie-display-json.reg
Created March 4, 2015 17:23
Get Internet Explorer to display JSON inline (via http://stackoverflow.com/questions/2483771)
Windows Registry Editor Version 5.00
;
; Tell IE to open JSON documents in the browser.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
@niallsmart
niallsmart / copy-checklist.js
Last active December 28, 2023 00:10
Copy Trello checklist to clipboard
copy($(".checklist-item:not(.checklist-item-checked)").map(function() {
var e = $(this),
item = e.find(".checklist-item-details-text").text()
if (e.hasClass("checklist-item-state-complete")) {
item = item + " (DONE)"
}
return item
}).get().join("\n"))
@niallsmart
niallsmart / totp.rb
Last active August 29, 2015 14:13
TOTP tester using rotp gem
require 'rotp'
require 'qrencoder'
random = "m5qckrq57y2s6232"
totp = ROTP::TOTP.new(random)
qr_string = totp.provisioning_uri("niall.smart@gethightower.com")
qr_code = QREncoder.encode(qr_string)
qr_code.png(pixels_per_module: 4, margin: 1).save("qr_code.png")
@niallsmart
niallsmart / alfred_search_gmail.scpt
Last active August 29, 2015 14:12
Alfred workflow to search Gmail
alfred_script("foo")
on alfred_script(q)
search_gmail("niall.smart@gmail.com", q)
end alfred_script
on search_gmail(account, searchString)
@niallsmart
niallsmart / check-url-status.sh
Created September 23, 2014 19:55
Check URL status
#!/bin/bash
while read url; do
output=`curl -sI "$url" 2>&1 | head -1`
if ! echo $output | grep '200 OK' >/dev/null; then
echo $url
echo $output
fi
done
@niallsmart
niallsmart / restore_deal_comments_proposals
Last active August 29, 2015 14:06
Set last comment/last proposal on restored deals
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.logger.level = Logger::DEBUG
deal_ids = [11929, 11930, 11928, 11927, 12166, 11933, 11934, 12369, 11984, 11931, 11924, 11922, 11921, 11920, 11919, 11926, 11923];
Deal.where(id: deal_ids).find_each do |deal|
deal.update_column :last_comment_id, deal.comments.last.try(:id)
deal.update_column :last_proposal_id, deal.proposals.last.try(:id)
deal.update_column :last_dying_update_id, deal.updates.where(type: 'DealDyingUpdate').last.try(:id)
deal.update_column :last_executed_update_id, deal.updates.where(type: 'DealExecutedUpdate').last.try(:id)
@niallsmart
niallsmart / twc-traceroute
Last active August 29, 2015 14:04
TWC Traceroute (columbia.edu)
# columbia.edu
Tracing route to [128.59.105.24]
over a maximum of 30 hops:
1 440ms 370ms 430ms 68.173.144.1
2 440ms 510ms 590ms 68.173.214.57
3 920ms 310ms 270ms 184.152.112.91
4 470ms 300ms 330ms 107.14.19.22
5 510ms 360ms 340ms 66.109.6.163
6 360ms 320ms 430ms 154.54.13.81
@niallsmart
niallsmart / circleci-fix-5866
Last active August 29, 2015 14:04
Fix for CircleCI build failure 5866
commit d83cdc36a40fc090c02bc0e1df1eaf8687bd3ea4
Author: Brent Wheeldon <brent.wheeldon@gmail.com>
Date: Fri Jul 18 09:33:57 2014 -0400
Don’t hide popovers in feature tests, this makes them really flaky.
diff --git a/app/assets/javascripts/common/directives/ht_deal_changed_popover_factory.coffee b/app/assets/javascripts/common/directives/ht_deal_changed_popover_factory.coffee
index a324389..19b88eb 100644
--- a/app/assets/javascripts/common/directives/ht_deal_changed_popover_factory.coffee
+++ b/app/assets/javascripts/common/directives/ht_deal_changed_popover_factory.coffee
@niallsmart
niallsmart / compare_assets.sh
Last active August 29, 2015 13:57
Compare web/app vs app/assets
DIFF_FLAGS=-qwc
(cd web/app; find . -name *.coffee) | while read file; do
diff $DIFF_FLAGS web/app/$file app/assets/javascripts/$file
done
(cd web/app; find . -name *.scss) | grep -v vendor | while read file; do
diff $DIFF_FLAGS web/app/$file app/assets/stylesheets/$file
done