Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Peter Hinchley hinchley

🎯
Focusing
View GitHub Profile
@hinchley
hinchley / index.js
Created Feb 23, 2020
HTTP requests in Node.js
View index.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);
View SetWallpaper.ps1
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 / tweets.php
Created Mar 17, 2017
Archive your twitter timeline into a sqlite database using PHP.
View tweets.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.
@hinchley
hinchley / AppLocker.ps1
Created Sep 12, 2016
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/
View AppLocker.ps1
<# 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 / UserWritableLocations.ps1
Created Sep 12, 2016
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/
View UserWritableLocations.ps1
# Paths that we've already excluded via AppLocker.
$exclusions = @()
# Paths to process.
$paths = @(
"C:\Windows"
)
# Setup log.
$log = "$PSScriptRoot\UserWritableLocations.log"
@hinchley
hinchley / profiler.cpp
Created Mar 25, 2016
Create an Outlook 2016 MAPI Profile
View profiler.cpp
#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 / Enigma.php
Created Jan 26, 2015
Enigma M3 Machine in PHP
View Enigma.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 / DisableBorder.ps1
Created Jan 18, 2015
Disable Microsoft Office 2013 Border Shadow with PowerShell
View DisableBorder.ps1
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 / Ciphers.php
Created Jan 18, 2015
Caesar Cipher and Vigenère Cipher in PHP
View Ciphers.php
<?php
class Map {
/* $table = [
* 'encrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
* ['A' => 'B', 'B' => 'C', ...],
* ...
* 'decrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
@hinchley
hinchley / Knockout Live Search
Last active Jun 26, 2019
Knockout.js Live Search Example
View Knockout Live Search