Skip to content

Instantly share code, notes, and snippets.

View hinchley's full-sized avatar
🎯
Focusing

Peter Hinchley hinchley

🎯
Focusing
View GitHub Profile
@hinchley
hinchley / Knockout Live Search
Last active June 26, 2019 22:08
Knockout.js Live Search Example
@hinchley
hinchley / Ciphers.php
Created January 18, 2015 04:55
Caesar Cipher and Vigenère Cipher in PHP
<?php
class Map {
/* $table = [
* 'encrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
* ['A' => 'B', 'B' => 'C', ...],
* ...
* 'decrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
@hinchley
hinchley / DisableBorder.ps1
Created January 18, 2015 09:03
Disable Microsoft Office 2013 Border Shadow with PowerShell
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
namespace Utilities {
public static class Display {
private const uint WM_USER = 0x0400;
private const uint WM_MSO = WM_USER + 0x0900;
private const uint WM_MSO_WPARAM_OMFRAMEENABLESHADOW = 0x0075;
@hinchley
hinchley / Enigma.php
Created January 26, 2015 07:25
Enigma M3 Machine in PHP
<?php namespace Enigma;
class Reflector {
protected $table;
public function __construct($table) {
$this->table = array_combine(range('A', 'Z'), str_split($table));
}
public function convert($character) {
@hinchley
hinchley / profiler.cpp
Created March 25, 2016 04:28
Create an Outlook 2016 MAPI Profile
#include "stdafx.h"
#include <windows.h>
#include <mapix.h>
#include <mapiutil.h>
#include <edkmdb.h>
#include <atlbase.h>
#include <iostream>
#include <vector>
#include <map>
#include <sstream>
@hinchley
hinchley / UserWritableLocations.ps1
Created September 12, 2016 09:35
A PowerShell script for identifying user-writable folders. Usage is discussed in the following article: http://hinchley.net/2016/06/13/an-approach-for-managing-microsoft-applocker-policies/
# Paths that we've already excluded via AppLocker.
$exclusions = @()
# Paths to process.
$paths = @(
"C:\Windows"
)
# Setup log.
$log = "$PSScriptRoot\UserWritableLocations.log"
@hinchley
hinchley / AppLocker.ps1
Created September 12, 2016 09:39
A PowerShell script for generating AppLocker policies. Usage is discussed in the following article: http://hinchley.net/2016/06/13/an-approach-for-managing-microsoft-applocker-policies/
<# examples:
# generate a baseline policy.
powershell.exe -file applocker.ps1 -baseline -output c:\policies\baseline.xml
# generate an application-specific policy.
powershell.exe -file applocker.ps1 -application -in c:\policies\baseline.xml -out c:\policies\application.xml
# generate an adhoc policy.
powershell.exe -file applocker.ps1 -adhoc -in c:\path -filter *.* -out c:\policies\adhoc.xml
@hinchley
hinchley / tweets.php
Created March 17, 2017 23:21
Archive your twitter timeline into a sqlite database using PHP.
<?php
# define api keys.
define('CONSUMER_KEY', 'XXX');
define('CONSUMER_SECRET', 'XXX');
define('OAUTH_TOKEN', 'XXX');
define('OAUTH_SECRET', 'XXX');
define('USER_TIMELINE', 'https://api.twitter.com/1.1/statuses/user_timeline.json');
# tweets to retrieve per request.
Add-Type -TypeDefinition @"
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Linq;
using Microsoft.Win32;
@hinchley
hinchley / index.js
Created February 23, 2020 04:19
HTTP requests in Node.js
const fetch = (url, cb, options = {}) => {
const { protocol } = new URL(url);
const http = protocol === 'https:'
? require('https')
: require('http');
options = { headers: { 'User-Agent': 'node.js' }, ...options };
const error = e => console.log(e.message);