Skip to content

Instantly share code, notes, and snippets.

View terenced's full-sized avatar
Fueled by Coffee

Terry Dellino terenced

Fueled by Coffee
View GitHub Profile
@terenced
terenced / clean-branch.sh
Created March 8, 2021 15:42
Clean up git branches
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@terenced
terenced / dump_mongo_query.sh
Last active March 4, 2021 19:06
Dump Mongo query results to file
mongo DB_NAME --quiet --eval 'DBQuery.shellBatchSize = 2000; db.COLLECTION_NAME.find({}).limit(2000).toArray()' > collection.json
@terenced
terenced / Bash
Created September 14, 2020 15:27
How to check if a variable is set in bash
+----------------------+------------+-----------------------+-----------------------+
| if VARIABLE is: | set | empty | unset |
+----------------------+------------+-----------------------+-----------------------+
- | ${VARIABLE-default} | $VARIABLE | "" | "default" |
= | ${VARIABLE=default} | $VARIABLE | "" | $(VARIABLE="default") |
? | ${VARIABLE?default} | $VARIABLE | "" | exit 127 |
+ | ${VARIABLE+default} | "default" | "default" | "" |
+----------------------+------------+-----------------------+-----------------------+
:- | ${VARIABLE:-default} | $VARIABLE | "default" | "default" |
:= | ${VARIABLE:=default} | $VARIABLE | $(VARIABLE="default") | $(VARIABLE="default") |
@terenced
terenced / string-format-extension.cs
Created March 27, 2013 14:59
Extension to make string formatting for pretty ;;)
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Helpers
{
public static class StringFormatExtension
{
// http://james.newtonking.com/archive/2008/03/27/formatwith-string-format-extension-method.aspx
public static string FormatWith(this string format, params object[] args)
@terenced
terenced / mac-mini-price-watcher.rb
Last active December 15, 2015 07:39
Quick and dirty script to watch prices on refurbished Mac Mini on Apple.ca. Sends an email (via gmail) when it finds one under the threshold price. Will most likely set it up in a cron
require 'gmail'
require 'open-uri'
require 'nokogiri'
product_url = "http://store.apple.com/ca/browse/home/specialdeals/mac/mac_mini"
username = 'GMAIL USER NAME'
password = 'PASSWORD, DUH!'
email = "[email protected]"
threshold = 600 # How much you would like to spend
@terenced
terenced / binary_counter.ino
Created February 11, 2013 01:12
3-bit binary counter for Arduino
// 3-bit binary counter (since I only have 3 LEDs [^_-])
// Counts from 1 to 7
// Video: https://plus.google.com/116685752536817026018/posts/8BbTWriKykB
int led2 = 5;
int led1 = 4;
int led0 = 3;
void setup() {
pinMode(led0, OUTPUT);