Skip to content

Instantly share code, notes, and snippets.

View jbutz's full-sized avatar

Jason Butz jbutz

View GitHub Profile
@jbutz
jbutz / clearVoicemail.ps1
Created August 27, 2012 21:11
Remove Cisco Voicemails >= 30 days old from the Downloads folder
# Remove Cisco Voicemails >= 30 days old from the Downloads folder
# 08/27/2012
## Use the debug value to change whether or not you delete things or say what you would delete
$debug = $TRUE
## Do you want to say which files you deleted?
$output = $TRUE
## Set the folder to the base directory you want to start your searches in
@jbutz
jbutz / status.rb
Last active December 16, 2015 05:59
Ruby on Rails Exceptions
class Status < ActiveRecord::Base
...
before_destroy :check_existing_events
private
...
def check_existing_events
raise Exception.new("Events exist that use that status.") unless Event.where(:status_id => self.id).count == 0
end
end
@jbutz
jbutz / sc_request.js
Last active August 29, 2015 13:55
ServiceNow - Navigation Handlers
var view = g_request.getParameter('sysparm_view');
if (!view && ! gs.getUser().hasRoles())
view = 'ess';
if (view == 'ess' || view == 'checkout') {
var checkOutForm = gs.getProperty('glide.sc.checkout.form', 'com.glideapp.servicecatalog_checkout_view');
if (checkOutForm == 'com.glideapp.servicecatalog_checkout_view') {
var realID = g_uri.get('sys_id');
g_uri.set('sysparm_sys_id', realID);
answer = g_uri.toString('com.glideapp.servicecatalog_checkout_view.do');
@jbutz
jbutz / example0.js
Created January 31, 2014 21:08
ServiceNow - Workflow E-Mails
current.variables['variable_name'].getGlideObject().getDisplayValue(); // For the displayed value
current.variables['variable_name'].getGlideObject().getValue(); // For the real value (sys_id when it is a reference)
@jbutz
jbutz / .bash_profile
Last active January 3, 2017 20:05
Mac Setup
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="~/bin:/usr/local/bin:/usr/local/sbin:$PATH"
export PATH="$PATH:`yarn global bin`"
@jbutz
jbutz / custom-jest-matcher.js
Created October 30, 2017 12:04
jasonbutz.info - Custom Jest Except Matcher
class NullLikeMatcher {
constructor() {
this.$$typeof = Symbol.for('jest.asymmetricMatcher');
}
asymmetricMatch(value) {
return value === null || value === undefined;
}
toString() {
return 'NullLike';
@jbutz
jbutz / main.js
Created November 15, 2017 15:25
Bootstrap Basic Navbar Collapse, no jQuery or Bootstrap JS
let collapseElements = document.querySelectorAll('[data-toggle="collapse"]');
const CLASS_SHOW = 'show';
const CLASS_COLLAPSE = 'collapse';
const CLASS_COLLAPSING = 'collapsing';
const CLASS_COLLAPSED = 'collapsed';
const ANIMATION_TIME = 350; // 0.35s
function handleCollapseElementClick(e) {
let el = e.currentTarget;
let collapseTargetId = el.dataset.target || el.href || null;
@jbutz
jbutz / cleanup-git-branches.sh
Last active February 7, 2018 15:13
Cleanup old git branches
#!/bin/bash
git checkout master
git pull
git fetch --prune
BRANCHES=`git branch --merged | grep -v master`
IFS=$'\n'
for i in $BRANCHES; do
@jbutz
jbutz / albums.js
Last active March 21, 2018 11:46
Greasemonkey Scripts - #DeleteFacebook Albums
// ==UserScript==
// @name Delete Facebook Albums
// @version 1
// @grant none
// @match https://www.facebook.com/*/photos_albums
// @run-at document-idle
// ==/UserScript==
function promiseDelay(timeout) {
return new Promise((r) => {
@jbutz
jbutz / script.js
Created March 21, 2018 11:46
Greasemonkey Script - #DeleteFacebook Videos
// ==UserScript==
// @name Delete Facebook Videos
// @description This script deletes videos from your Videos album.
// @version 1
// @grant none
// @match https://www.facebook.com/*/media_set?*type=2
// @run-at document-idle
// ==/UserScript==
function promiseDelay(timeout) {