Skip to content

Instantly share code, notes, and snippets.

View naftulikay's full-sized avatar
🌞

Naftuli Kay naftulikay

🌞
View GitHub Profile
@naftulikay
naftulikay / piper.py
Created May 30, 2016 23:27
Pipe Two Programs together in Python
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import argparse
import subprocess
def __main__():
parser = argparse.ArgumentParser(prog="piper", description="Pipes output of two programs together.")
parser.parse_args()
@naftulikay
naftulikay / stringpiper.py
Created May 31, 2016 02:48
Pipe a String into a Program's Input in Python
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import argparse
import subprocess
from StringIO import StringIO
def __main__():
SUBSYSTEMS=="usb", ACTION=="add|change", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="1066", RUN+="/usr/local/bin/schiit-fulla-switch added"
SUBSYSTEMS=="usb", ACTION=="remove", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="1066", RUN+="/usr/local/bin/schiit-fulla-switch removed"
@naftulikay
naftulikay / ubuntu-lts-xenial-macbook-suspend.patch
Created July 21, 2016 04:26
Ubuntu LTS Xenial MacBook Suspend Patch
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 1595f4f..b577af2 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2749,6 +2749,13 @@ static void quirk_hotplug_bridge(struct pci_dev *dev)
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
+static void quirk_hotplug_bridge_skip(struct pci_dev *dev)
+{

OSX Reinstall for Linux Users

  1. Make sure that there is at least 128MiB of free space after your OSX root partition. OSX [needs this space for upgrading itself][osx-128]. OSX will fail to upgrade otherwise.
    1. If this gap doesn't exist and you need it to, boot into a Linux LiveCD with GParted.
    2. Delete the OSX boot and recovery partitions (don't worry, we still have internet recovery mode).
    3. Create a single HFS+ filesystem where the partitions used to be.
    4. Leave 128MiB or more free after the partition! Probably more, maybe the recovery partition needs to occupy this space.
  2. Boot into Internet Recovery mode using a Thunderbolt ethernet adapter or the built-in ethernet adapter if present. This can be accomplished by holding Alt+Super+R on boot.
@naftulikay
naftulikay / color-spaces.pl
Created July 24, 2016 17:12
Test Terminal Color Support
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
print "256 color mode\n\n";
# display back ground colors
for ($fgbg = 38; $fgbg <= 48; $fgbg +=10) {

rfkrocktk

I've been hacking on this for a bit, but I'm trying to write a policy using the reference policy to contain Syncthing. I've done most of the files level permissions, but I'm having trouble with the networking aspects. My code is here: https://github.com/rfkrocktk/syncthing/blob/feature/selinux/etc/selinux/syncthing.te#L80 I'm still getting the following denied:

type=AVC msg=audit(1469458131.894:6800): avc:  denied  { create } for  pid=18349 comm="syncthing" scontext=unconfined_u:unconfined_r:syncthing_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:syncthing_t:s0-s0:c0.c1023 tclass=tcp_socket permissive=0
@naftulikay
naftulikay / tls-info.sh
Created September 7, 2016 00:44
Get TLS connection information for a given server.
#!/bin/bash
function usage() {
echo "Usage: $0 hostname [port]" >&2
echo " hostname Hostname of the server to connect to." >&2
echo " port Port of the server running TLS, defaults" >&2
echo " to 443." >&2
echo ""
exit 1
}
@naftulikay
naftulikay / mackie.py
Created September 8, 2016 06:34
Get 32 most or least significant bits of a MAC address - format a MAC address as a 32 bit integer.
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from math import floor, log
def binary_macaddress(macaddress):
"""Convert a mac address into a 48-bit integer."""
binary = 0
@naftulikay
naftulikay / s3-cloudfront-invalidation.sh
Last active November 7, 2022 21:44
Sync a directory to S3 and invalidate the CloudFront cache for changed resources.
#!/bin/bash
# output format is like this:
# upload: index.html to s3://$BUCKET/index.html
#
# so we grab the second item which is the file path and pass that via xargs to the
# cloudfront invalidation command
aws s3 sync --sse AES256 s3://$BUCKET/ site/ | awk '{print $2;}' | \
xargs aws cloudfront create-invalidation --distribution-id $CF_DISTRO_ID --paths