Skip to content

Instantly share code, notes, and snippets.

View Dreyer's full-sized avatar

Matthew Dreyer Dreyer

View GitHub Profile
@Dreyer
Dreyer / nordvpn.sh
Last active February 3, 2024 21:55
Check the status of a NordVPN connection from your shell.
#!/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 / ssl.sh
Created January 23, 2015 16:40
Shell script to make using OpenSSL a little easier.
#!/bin/bash
##
# General OpenSSL Commands
#
# These commands allow you to generate CSRs, Certificates,
# Private Keys and do other miscellaneous tasks.
##
DOMAIN_NAME=$1
@Dreyer
Dreyer / sys2007-crc16.php
Created August 22, 2012 12:41
A PHP equivalent of Visual FoxPro SYS(2007) checksum CRC 16-bit.
<?php
function crc16( $str, $params = array() )
{
$defaults = array(
'initial_value' => 0xFFFF,
'polynomial' => 0x1021, // CRC-CCITT
'xor_out' => 0,
);
foreach ( $defaults as $k => $v )
@Dreyer
Dreyer / perlbrew_libgcc_s.txt
Created January 20, 2017 11:27
[perlbrew] ld: library not found for -lgcc_s.10.4
$ 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 / mail-test.php
Created June 20, 2012 09:06
Quick & Dirty PHP Mail Test Script
<?php
/*
DONT FORGET TO DELETE THIS SCRIPT WHEN FINISHED!
*/
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = 'webmaster@example.com';
@Dreyer
Dreyer / database_fragmentation.sql
Created July 3, 2017 17:59
Display database fragmentation for each table.
-- 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 / keybase.md
Last active September 14, 2019 13:21

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 / random-string.js
Created April 12, 2012 15:24
Generate random alphanumeric string in JavaScript
// @source: http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
function randomStr(m) {
var m = m || 9; s = '', r = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i=0; i < m; i++) { s += r.charAt(Math.floor(Math.random()*r.length)); }
return s;
};
@Dreyer
Dreyer / dfwp.js
Last active June 18, 2017 21:41
Re-enable copy-paste for stupid sites that block it.
// 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);
@Dreyer
Dreyer / AutoConnectVPN.applescript
Created January 5, 2017 19:38
Automatically reconnect when disconnected from the VPN.
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