Skip to content

Instantly share code, notes, and snippets.

View phdesign's full-sized avatar

Paul Heasley phdesign

View GitHub Profile
@phdesign
phdesign / .jshintrc
Created November 9, 2015 09:48
Using Grunt with pebble build
/*
* Example jshint configuration file for Pebble development.
* Adapted from http://developer.getpebble.com/blog/2014/01/12/Using-JSHint-For-Pebble-Development/
*
* Check out the full documentation at http://www.jshint.com/docs/options/
*/
{
// Declares the existence of a global 'Pebble' object
"globals": { "Pebble" : true },
@phdesign
phdesign / README.md
Last active December 9, 2015 03:38 — forked from warnergodfrey/Gemfile
Instructions for running remote JMeter

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
(*
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 / inject-jquery.js
Last active June 9, 2017 01:01
Inject jQuery onto page bookmarklet
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')
@phdesign
phdesign / App.xaml.cs
Last active July 20, 2017 22:20
Redux.NET Middleware to persist Actions to LiteDb
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 / analysis.js
Created May 23, 2018 07:13
Parse a webpack json output to compute size of our files vs. depedendencies
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 / emoji.ahk
Last active May 24, 2018 03:16
Some text emjoi autocompletes, e.g. :shurg: :table_flip:
; 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 / IPAddressIsInRange.sql
Created June 5, 2018 04:12
Check if a string IP address is in a CIDR range in SQL Server
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 / pwned-passwords.sh
Last active September 29, 2018 13:03
Bash One-Liner to Check Your Password(s) via pwnedpasswords.com’s API Using the k-Anonymity Method
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 / python2.bat
Created October 16, 2018 17:37
Python on Windows
rem Place this in C:\Python27\python2.bat
@echo off
set OLDPATH=%PATH%
path C:\Python27;%PATH%
python.exe %*
path %OLDPATH%