Skip to content

Instantly share code, notes, and snippets.

View Flushot's full-sized avatar
👀

Chris Lyon Flushot

👀
View GitHub Profile
#!/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`
#!/bin/bash
lines="-\|/"
i=0
while : ; do
printf "\r\033[5mReticulating splines\033[25m %s" ${lines:$i:1}
i=$(((i + 1) % 4))
sleep 0.5
done
@Flushot
Flushot / ps1.sh
Last active September 21, 2018 02:41
PS1
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
export PS1="\[\033[0;32m\][\D{%H:%M}] \[\033[0;32m\]\h:\[\033[0;33m\]\w\[\033[35m\]\$(__git_ps1) \[\033[0;36m\]\u\\$ \[\033[0m\]"