Skip to content

Instantly share code, notes, and snippets.

@cmccandless
cmccandless / compiled.py
Last active August 6, 2020 17:46
Python regex compiled vs inline
import re
from pathlib import Path
p = Path("big.txt")
t = p.read_text()
rgx = re.compile(r"\w+")
for _ in range(10):
rgx.findall(t)
@cmccandless
cmccandless / readinglist.md
Created November 26, 2019 15:12
Justin's Thanksgiving Reading List
@cmccandless
cmccandless / GitHub-Forking.md
Last active May 31, 2019 12:52 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@cmccandless
cmccandless / inspect-tarball.sh
Created May 3, 2019 19:37
Tarball Tree script
#!/bin/bash
set -e
DEFAULT_MAX_DEPTH=4
DEFAULT_OUTPUT_PATH=./update
print_usage()
{
echo "$0 [options] TARFILE"
echo "options:"
@cmccandless
cmccandless / pipeline.py
Last active February 27, 2019 01:25
Pipeline Demo
class Job():
def __init__(self, *args, **kwargs):
pass
def __call__(self, data):
raise NotImplementedError()
class Square(Job):
def __call__(self, data):
return [d * d for d in data]
@cmccandless
cmccandless / what-i-did.sh
Created February 14, 2019 15:18
Script for listing commit subjects over time period specified
#!/bin/bash
if [[ "$@" == *'--help'* ]]; then
echo "usage: what-i-did [since] [until] [format]"
echo ' See `man git-log` for more information'
echo " Examples:"
echo " what-i-did commits from self since 6am today"
echo " what-i-did yesterday commits from self over last 24hrs"
echo " what-i-did '6am yesterday' '6pm yesterday'"
echo " commits from self between 6am-6pm"
@cmccandless
cmccandless / generate_report.py
Last active November 12, 2018 15:30
wazuh-docs requirements file test
#!/usr/bin/env python3.6
import os
msg = {
# 'passed': '✔',
'failed': '🗙',
'passed': ':heavy_check_mark:',
'failed': ':x:',
'timed_out': '**T***'
@cmccandless
cmccandless / create_canonical_data.json
Created September 19, 2018 16:45
Exercism pythagorean-triplets: generating canonical-data.json
#!/usr/bin/env python3.6
import json
def tripletsWithSum(n):
triplets = set()
b_limit = int(n / 2) + 1
for a in range(1, n - 2):
a2 = a * a
n_a = n - a
@cmccandless
cmccandless / usbaudioctl.sh
Last active August 28, 2018 18:19
Switch USB Audio mode (Headset <-> Speaker) on Ubuntu 16.04
#!/bin/bash
set -e
# CARD=1
PROFILE_BASE=output:analog-stereo
DEVICE=usb-Generic_USB_Audio_200901010001-00
CARD_NAME="alsa_card.${DEVICE}"
SINK_BASE="alsa_output.${DEVICE}.analog-stereo"
# Find card index
@cmccandless
cmccandless / make_github_issue.py
Last active August 6, 2018 13:02 — forked from JeffPaine/make_github_issue.py
Make an issue on github using API V3 and Python
# -*- coding: utf-8 -*-
# Uses Python 2.7
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requests
import json