Skip to content

Instantly share code, notes, and snippets.

Teddy Caddy tcaddy

Block or report user

Report or block tcaddy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .gitconfig
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = Firstname Lastname
email = user@domain.com
[color]
ui = auto
[rebase]
autosquash = true
[alias]
@tcaddy
tcaddy / freeze_benchmark.rb
Last active Oct 12, 2017
Benchmark String#freeze
View freeze_benchmark.rb
#!/usr/bin/env ruby
# Based on http://blog.honeybadger.io/when-to-use-freeze-and-frozen-in-ruby/#reducing-object-allocations
# but for Ruby 1.9.3
require 'benchmark'
class FreezeBenchmark
NORMAL = 'NORMAL'
FROZEN = 'FROZEN'.freeze
def self.init(n = 100000)
@tcaddy
tcaddy / script.bat
Last active May 23, 2017
BAT file to copy files and make a ZIP archive
View script.bat
@ECHO OFF
SET CURRENTDIR="%cd%"
SET DIRTOZIP="%TEMP%\_A%time::=.%"
MKDIR %DIRTOZIP%
CD %DIRTOZIP%
COPY /B /V /Z "source" "destination"
set FILETOZIP="%DIRTOZIP%\*"
@tcaddy
tcaddy / aes-128-ecb.rb
Created Mar 8, 2017
Ruby AES-128-ECB encryption / decryption example. This was written to interface with a 3rd party that required string parameters to be encrypted the following way: Rinndael cipher, Electronic Code Block mode (ECB), no padding, encrypted buffer should be padded with spaces such that its length is divisible by 32.
View aes-128-ecb.rb
# setup some input parameters
encrypted_decrypted = 'some string to encrypt or decrypt'
action = :encrypt # set to :encrypt or :decrypt
secret_key = 'abc123' # define shared secret key here
# encryption / decryption code...
cipher = OpenSSL::Cipher.new('AES-128-ECB')
if action == :decrypt
cipher.key = [secret_key].pack('H*')
cipher.padding = 0
@tcaddy
tcaddy / ping_gateway.ps1
Last active Nov 30, 2016
PowerShell Script to ping the gateway constantly at intervals below 1000 milliseconds so that flaky wireless connections stay alive.
View ping_gateway.ps1
# This script will let you ping in intervals less than 1 second
$ip4_gateway = (Get-WmiObject -Class Win32_IP4RouteTable | where { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0'} | Sort-Object metric1 | select nexthop).nexthop
$target = $ip4_gateway # target host
$interval = 200 # in milliseconds
$ping=New-Object System.Net.NetworkInformation.ping
function Ping-It() {
$success = 0 # initialize as zero
$failure = 0 # initialize as zero
$cumaltive_time = 0 # initialize as zero
View ncatfuture-fix.js
var v = [],
opts = ha31lib.ge('survey').getElementsByTagName('input'),
i;
for (i=0;i<opts.length;i++) {
var opt = opts[i];
if (opt.name == 'illbe') {
if (opt.checked) {
v.push(opt.id);
}
}
@tcaddy
tcaddy / crontab
Last active Jan 6, 2016
Linux CPU and Memory Logging
View crontab
#############################################################
# Log memory and CPU usage
#############################################################
*/5 * * * * /usr/local/bin/log_memory_usage.sh > /dev/null
*/5 * * * * /usr/local/bin/log_cpu_usage.sh > /dev/null
@tcaddy
tcaddy / bbts-meal-plans.sql
Last active Jan 6, 2016
Meal Plan Queries
View bbts-meal-plans.sql
SELECT LPAD(CAST(ENVISION.CUSTOMER.custnum AS INTEGER),7,'0'),
ENVISION.BOARDPLAN.boardplan
FROM ENVISION.BOARDPLAN
LEFT OUTER JOIN ENVISION.CUSTOMERBOARD ON ENVISION.CUSTOMERBOARD.boardplan_id=ENVISION.BOARDPLAN.boardplan_id
LEFT OUTER JOIN ENVISION.CUSTOMER ON ENVISION.CUSTOMER.CUST_ID=ENVISION.CUSTOMERBOARD.CUST_ID
WHERE CAST(ENVISION.CUSTOMER.custnum AS INTEGER) > 0
AND ENVISION.BOARDPLAN.boardplan IS NOT NULL
ORDER BY CAST(ENVISION.CUSTOMER.custnum AS INTEGER)
@tcaddy
tcaddy / check_student_planning.js
Last active Mar 16, 2018
A PhantomJS script to monitor Ellucian Student Planning / Self-Service for unresponsiveness. A PowerShell script to run the PhantomJS script and recycle the app pool, send an email.
View check_student_planning.js
/*
Student Planning goes down randomly and we have to recycle the app pool to fix it.
This script will try to login to Student Planning and make an AJAX request. It will
return text output (console.log() output) about whether it is working or not.
NOTE: this script relies on PhatomJS, which you can download here:
http://phantomjs.org/download.html
NOTE: change the values of the host, user, and pass variables. Optionally change the timeout variable.
*/
@tcaddy
tcaddy / ellucian-api-tester.html
Last active Oct 13, 2015
This will test the Ellucian API. It will retrieve the photo and phone numbers associated with a PERSON ID.
View ellucian-api-tester.html
<html>
<head>
<title>Ellucian API Tester</title>
<style>
body {
margin: 10px;
font-family: Calibri,Helvetica,Arial,sans-serif;
font-style:normal;
}
.flexbox-container {
You can’t perform that action at this time.