Skip to content

Instantly share code, notes, and snippets.

View jeffjohnson9046's full-sized avatar

Jefe Johnson jeffjohnson9046

View GitHub Profile
SELECT DISTINCT TABLE_NAME, TABLE_SCHEMA
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN (/* list of column names go here */)
AND TABLE_SCHEMA IN (/* list of schemas go here */);
#!/usr/bin/perl -w
#-----------------------------------------------------------------------------------------------------------------------------------------
# File: aws-email-sender.pl
#
# Desc: Send an email via Amazon SES.
#
# Code for this gist came from this article: https://blog.vpetkov.net/2015/11/29/sending-html-emails-with-perl-to-a-remote-smtp-with-tls/
# To install the packages/libraries required to support this script, the following commands were used:
#
# cpan Email::Sender
@jeffjohnson9046
jeffjohnson9046 / setjdk.sh
Created May 24, 2016 15:00
A function for switching between Java JDKs on OS X
# I'm in a situation where I have multiple JDKs installed for various projects. While I'm sure there are a million was to handle this
# issue (a number of sites recommended jenv), I just wanted a quick & easy way to switch between JDKs that are installed on my machine.
# I took the following steps:
#
# 1. Add the functions below to your ~/.bash_profile
# 2. Source your ~/.bash_profile (command is . ~/.bash_profile) or exit and reload your terminal window
#
# These functions came from here: https://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/, so all credit goes to the author of that article
function setjdk() {
if [ $# -ne 0 ]; then
@jeffjohnson9046
jeffjohnson9046 / dm_io_virtual_file_stats.sql
Created December 26, 2015 19:56
MS SQL Server database file I/O stats
SELECT
a.io_stall, -- Total time, in milliseconds, that users waited for I/O to be completed on the file.
a.io_stall_read_ms, -- Total time, in milliseconds, that the users waited for reads issued on the file.
a.io_stall_write_ms, -- Total time, in milliseconds, that users waited for writes to be completed on the file.
a.num_of_reads, -- Number of reads issued on the file.
a.num_of_writes, -- Number of writes made on this file.
--a.sample_ms, a.num_of_bytes_read, a.num_of_bytes_written, a.io_stall_write_ms,
( ( a.size_on_disk_bytes / 1024 ) / 1024.0 ) AS size_on_disk_mb,
db_name(a.database_id) AS dbname,
b.name,
@jeffjohnson9046
jeffjohnson9046 / UuidHelper.java
Last active December 11, 2023 11:06
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
@jeffjohnson9046
jeffjohnson9046 / sql-server-product-info.sql
Created December 23, 2015 07:51
SQL Server Product Information
/* Run this query against any database on a SQL Server instance to get version details*/
SELECT
SERVERPROPERTY('productversion') AS ProductVersion,
SERVERPROPERTY('productlevel') AS ProductLevel,
SERVERPROPERTY('edition') AS Edition,
@@VERSION AS VerboseVersion;
@jeffjohnson9046
jeffjohnson9046 / .gitignore
Created August 11, 2015 21:12
Visual Studio .gitignore used @ Fairway
Thumbs.db
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
@jeffjohnson9046
jeffjohnson9046 / git-ignore.sh
Created August 11, 2015 21:02
Remove unwanted files from a git repo AFTER adding a .gitignore. The files will remain on disk.
## I just ran into this after initializing a Visual Studio project _before_ adding a .gitignore file (like an idiot).
## I felt real dumb commiting a bunch of files I didn't need to, so the commands below should do the trick. The first two commands
## came from the second answer on this post: http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files
# See the unwanted files:
git ls-files -ci --exclude-standard
# Remove the unwanted files:
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
@jeffjohnson9046
jeffjohnson9046 / sql-server-generate-random-date.sql
Created July 31, 2015 23:36
MSSQL - Generate a random datetime value for a given year.
DECLARE @RandomDate datetime
SELECT @RandomDate =
DATEADD(day, ROUND(DATEDIFF(day, '2015-01-01', '2015-12-31') * RAND(CHECKSUM(NEWID())), 0),
DATEADD(second, CHECKSUM(NEWID()) % 48000, '2015-01-01'))
/* Verify */
SELECT RandomDate = @RandomDate
/* Check existing indexes */
SELECT
@@SERVERNAME AS [ServerName]
, DB_NAME() AS [DatabaseName]
, [SchemaName]
, [ObjectName]
, [ObjectType]
, [IndexID]
, [IndexName]
, [IndexType]