Skip to content

Instantly share code, notes, and snippets.

View Flushot's full-sized avatar
👀

Chris Lyon Flushot

👀
View GitHub Profile
@Flushot
Flushot / pf_block.conf
Created August 21, 2018 23:32
Block IP addresses with macOS/BSD PF firewall
#
# Blocks list of IP addresses using macOS/BSD PF firewall.
#
# Enable: sudo pfctl -ef ./pf_block.conf
#
# Disable: sudo pfctl -d (completely disable firewall)
# sudo pfctl -f /etc/pf.conf (reset rules)
#
blocked_ips = "{ \
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "usage: %s [pid]", argv[0]);
return 1;
#!/usr/bin/env python
from __future__ import absolute_import, print_function, unicode_literals, division
import re
import logging
import threading
import time
import watchdog.events
import watchdog.observers
#!/bin/sh
set -e
openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:4096
openssl rsa -pubout -in private.pem -out public.pem
from PIL import ImageChops, ImageDraw
def create_diff_image(img1, img2):
"""
Compares two Images and either creates an Image with differences
outlined with red bounding boxes, or returns None if no differences
were found.
"""
diff_img = img2.copy()
@Flushot
Flushot / fp.php
Last active August 19, 2016 23:23
PHP functional programming sandbox
<?php
header('Content-Type: text/plain');
// y combinator
function y($F) {
$x = function ($f) use ($F) {
return $F(function () use ($f) {
return call_user_func_array($f($f), func_get_args());
});
};
<?php
function classNames() {
return join(' ',
array_map(
function ($arg) {
if (is_array($arg)) {
$values = [];
foreach ($arg as $className => $show) {
if ($show) {
@Flushot
Flushot / ip_utils.c
Last active April 22, 2016 21:01
Some IP utility methods
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/**
* Convert an IPv4 address string into a long
*
* @param ip_addr IPv4 address string to convert
* @return long representation of IP
*/
@Flushot
Flushot / getexif.sh
Created April 8, 2016 19:44
Gets EXIF info from an image
#!/bin/sh
identify -format '%[EXIF:*]' $1
@Flushot
Flushot / setup.sh
Last active April 8, 2016 19:45
Configures Git to use p4merge so that you can run `git mergetool`
# Configure
git config --global merge.tool p4mergetool
git config --global mergetool.p4mergetool.cmd "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED"
git config --global mergetool.p4mergetool.trustExitCode false
git config --global mergetool.keepBackup false
# Use with `git mergetool`