Skip to content

Instantly share code, notes, and snippets.

Paul Heasley phdesign

Block or report user

Report or block phdesign

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
@phdesign
phdesign / sort_json.sh
Created May 28, 2019
Sort JSON properties on the command line using python
View sort_json.sh
cat /dev/clipboard | python -c 'import json, sys; json.dump(json.load(sys.stdin), sys.stdout, indent=4, sort_keys=True);'
@phdesign
phdesign / python2.bat
Created Oct 16, 2018
Python on Windows
View python2.bat
rem Place this in C:\Python27\python2.bat
@echo off
set OLDPATH=%PATH%
path C:\Python27;%PATH%
python.exe %*
path %OLDPATH%
@phdesign
phdesign / pwned-passwords.sh
Last active Sep 29, 2018
Bash One-Liner to Check Your Password(s) via pwnedpasswords.com’s API Using the k-Anonymity Method
View pwned-passwords.sh
echo "Enter your password:"; read -s pass_str; sha1=$(echo -n $pass_str | tr -d '\n' | openssl sha1); echo "Hash prefix: ${sha1:0:5}"; echo "Hash suffix: ${sha1:5:35}"; result=$(curl https://api.pwnedpasswords.com/range/${sha1:0:5} 2>/dev/null | grep $(echo ${sha1:5:35} | tr '[:lower:]' '[:upper:]')); printf "Your password appeared %d times in the database.\\n" "${result#*:}" 2>/dev/null
@phdesign
phdesign / IPAddressIsInRange.sql
Created Jun 5, 2018
Check if a string IP address is in a CIDR range in SQL Server
View IPAddressIsInRange.sql
create function dbo.IPAddressIsInRange(@ip as varchar(15), @range as varchar(18))
returns bit
as
begin
declare @prefix varchar(15),
@cidr varchar(2),
@mask bigint
set @prefix = left(@range, charindex('/', @range) - 1)
set @cidr = right(@range, len(@range) - charindex('/', @range))
@phdesign
phdesign / emoji.ahk
Last active May 24, 2018
Some text emjoi autocompletes, e.g. :shurg: :table_flip:
View emoji.ahk
; NOTE: This must be saved as UTF-8 BOM
emoji(text){
If (A_EndChar = ":") {
SendInput %text%
} Else {
StringMid, s, A_ThisHotKey, 3 ; A_ThisHotKey contains 2 starting colons
SendRaw %s%%A_EndChar%
}
}
@phdesign
phdesign / analysis.js
Created May 23, 2018
Parse a webpack json output to compute size of our files vs. depedendencies
View analysis.js
const buildStats = require('./build.json');
function getSize(modules) {
return modules.reduce((acc, val) => acc + val.size, 0);
}
const tpl = (type, modules) => `${type} files
--------
no. of modules: ${modules.length}
total size: ${Math.round(getSize(modules) / 1000)} KB`
@phdesign
phdesign / App.xaml.cs
Last active Jul 20, 2017
Redux.NET Middleware to persist Actions to LiteDb
View App.xaml.cs
public App()
{
InitializeComponent();
var dbPath = DependencyService.Get<IFileHelper>().GetLocalFilePath("todo.db");
var persistActionsMiddleware = new PersistActionsMiddleware<ApplicationState>(dbPath);
Store = new Store<ApplicationState>(
Reducers.Reducers.ReduceApplication,
new ApplicationState(),
persistActionsMiddleware.CreateMiddleware());
@phdesign
phdesign / inject-jquery.js
Last active Jun 9, 2017
Inject jQuery onto page bookmarklet
View inject-jquery.js
javascript: (function(url) {
var script = document.createElement("script");
script.setAttribute("src", url);
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
console.log('jQuery injected');
}, false);
document.body.appendChild(script);
})('//code.jquery.com/jquery-latest.min.js')
View SetWindowSize.scpt
(*
This Apple script will resize any program window to an exact size and the window is then moved to the center of your screen.
Specify the program name, height and width below and run the script.
Written by Amit Agarwal on December 10, 2013
*)
set theApp to "Google Chrome"
@phdesign
phdesign / README.md
Last active Dec 9, 2015 — forked from warnergodfrey/Gemfile
Instructions for running remote JMeter
View README.md

Instructions for running remote JMeter

Server

Create a AWS instance

aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type m1.medium --key-name MyKeyPair --security-groups MySecurityGroup
You can’t perform that action at this time.