Skip to content

Instantly share code, notes, and snippets.

Matthew Dreyer Dreyer

Block or report user

Report or block Dreyer

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 keybase.md

Keybase proof

I hereby claim:

  • I am dreyer on github.
  • I am dreyer (https://keybase.io/dreyer) on keybase.
  • I have a public key whose fingerprint is 1FC2 90F9 9E14 B6D8 35D4 BC81 4758 2E67 AAD0 DFCD

To claim this, I am signing this object:

@Dreyer
Dreyer / database_fragmentation.sql
Created Jul 3, 2017
Display database fragmentation for each table.
View database_fragmentation.sql
-- USE AdventureWorks;
SELECT
s.name AS 'sys_schema',
t.name AS 'sys_table',
i.name AS 'sys_index',
x.alloc_unit_type_desc,
x.avg_fragmentation_in_percent,
x.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) x
INNER JOIN sys.tables t ON t.object_id = x.object_id
@Dreyer
Dreyer / dfwp.js
Last active Jun 18, 2017
Re-enable copy-paste for stupid sites that block it.
View dfwp.js
// Paste the snippet in Chrome console and hit enter.
// Source: https://chrome.google.com/webstore/detail/dont-fuck-with-paste/nkgllhigpcljnhoakjkgaieabnkmgdkb
document.addEventListener('paste', (e) => { e.stopImmediatePropagation(); return true; }, true);
View outdated.js
/**
* Outdated Disclaimer for Posts
*
* Adds a disclaimer to each post which exceeds the threshold.
* Set the threshold values in `_config.yml`:
*
* outdated:
* threshold:
* value: 12
* unit: months
@Dreyer
Dreyer / etc-postfix-main.cf
Last active Apr 6, 2017
Troubleshooting postfix (sendmail) support for PHP's mail() function on Ubuntu 16.04 Xenial.
View etc-postfix-main.cf
#
# Postfix local send only
#
# Based on the null client setup:
# http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
#
# $ vi /etc/postfix/main.cf
# $ hostname -f
#
@Dreyer
Dreyer / perlbrew_libgcc_s.txt
Created Jan 20, 2017
[perlbrew] ld: library not found for -lgcc_s.10.4
View perlbrew_libgcc_s.txt
$ cd /usr/local/lib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.4.dylib
@Dreyer
Dreyer / AutoConnectVPN.applescript
Created Jan 5, 2017
Automatically reconnect when disconnected from the VPN.
View AutoConnectVPN.applescript
on idle
tell application "System Events"
tell current location of network preferences
set myConnection to the service "WorkVPN"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
@Dreyer
Dreyer / mkv_fixer.sh
Last active Jan 5, 2017
Batch edit the properties of Matroska files.
View mkv_fixer.sh
#!/bin/bash
#
# Iterate through every .MKV file in the current directory and use the
# filename base as the title while assigning the second subtitle track
# as the default and the second audio track as the default.
#
# Requires mkvpropedit from MKVToolNix:
# https://github.com/mbunkus/mkvtoolnix
#
for file in *.mkv; do base=${file%.*}; mkvpropedit "${file}" --edit info --set "title=${base}" --edit track:s1 --set flag-default=0 --edit track:s2 --set flag-default=1 --edit track:a1 --set flag-default=0 --edit track:a2 --set flag-default=1; done
@Dreyer
Dreyer / nordvpn.sh
Last active Nov 3, 2017
Check the status of a NordVPN connection from your shell.
View nordvpn.sh
#!/bin/bash
URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data'
JSON=$(curl -s $URL)
printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] is True else "\033[31mUnprotected");'
printf "\n"
@Dreyer
Dreyer / release.js
Last active Dec 2, 2018
Create an Elastic Beanstalk release using Node.js + AWS CLI.
View release.js
const program = require('commander')
const moment = require('moment')
const {exec} = require('child_process')
const cwd = process.cwd()
const version = process.env.npm_package_version || '0.0.0'
// Amazon Elastic Beanstalk.
const name = 'Example App'
You can’t perform that action at this time.