Skip to content

Instantly share code, notes, and snippets.

View charmoniumQ's full-sized avatar
:shipit:
dabbing on the haters

Sam Grayson charmoniumQ

:shipit:
dabbing on the haters
View GitHub Profile
@charmoniumQ
charmoniumQ / wabbits.py
Created November 6, 2018 06:11
See link embedded in source
#!/usr/bin/env python3
# https://www.reddit.com/r/riddles/comments/9sdy1y/a_hunter_and_a_rabbit_please_help_me_find_the/?utm_source=reddit-android
from bitstring import BitArray
import collections
class State(object):
def __init__(self, n, data):
self.data = data
@charmoniumQ
charmoniumQ / Makefile
Created April 28, 2019 02:12
Epic makefile that automatically detects dependencies and only recompiles when one of them changes
# Project-specific
# location to create for binaries
BUILD_DIR := build
# location of source code
SOURCE_DIR := source
# name of main executable in $(SOURCE_DIR) without .c
EXECUTABLE := main
# Space-separated pkg-config libraries used by this project
LIBS := gmp gmpxx
# source ext. Some people use .cxx, .cc, .cpp
@charmoniumQ
charmoniumQ / py_autogen.py
Created August 14, 2019 23:38
This implements a preprocessor macro system.
import click
import re
import io
import contextlib
#import colorama
#from termcolor import cprint
'''
# Overview #
@charmoniumQ
charmoniumQ / r
Created September 9, 2019 05:23
For configured directories, this script syncs them with the remote, runs a command, and then downloads the result.
#!/usr/bin/env ruby
# For configured directories, this script syncs them with the remote,
# runs a command, and then downloads the result.
#
## Motivation ##
#
# I am working on a project whose files are stored remotely. I would
# like to use my extensively curated and configured tools (zsh, emacs,
# tmux, ripgrep), but I need to run some commands on the remote. I
@charmoniumQ
charmoniumQ / docker.sh
Last active December 13, 2020 02:50
Shortcuts for common docker operations
#!/bin/sh
set -e -x
###############################################################################
# About
###############################################################################
# This script automates many common tasks I need to do using docker,
# such as emulating the current user in the container. Some of these
# tasks require changes at build-time, run-time, or both, so this
@charmoniumQ
charmoniumQ / test.c
Last active May 31, 2021 18:34
Executable C source
#define C_AND_POSIX_SHELL_POLYGLOT /*
# This section gets interpreted by the POSIX shell.
# It is inside a C comment, so it gets ignored by the C compiler.
CFLAGS=
NIXPKGS=
TARGET=/tmp/a.out
exec nix-shell \
--pure \
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Sam's Take on the Missing Semester of Your CS Education

Inspired by The MIT CSAIL course by the same name.

  • CLI intutition
    • --version (-V)
    • --verbose (-v)
    • Command-line flag conventions
      • Dashes
  • short vs long flags
import textwrap
import subprocess
import json
from pathlib import Path
## Configuration ##
# All langs except real_langs will be ignored
only_include_langs = {"C++", "C", "C Header", "C++ Header", "YAML", "Makefile", "Markdown", "Shell", "CMake", "Python", "Dockerfile"}
SPDX Identifier Trove Classifier
AFL-1.1 License :: OSI Approved :: Academic Free License (AFL)
AFL-1.2 License :: OSI Approved :: Academic Free License (AFL)
AFL-2.0 License :: OSI Approved :: Academic Free License (AFL)
AFL-2.1 License :: OSI Approved :: Academic Free License (AFL)
AFL-3.0 License :: OSI Approved :: Academic Free License (AFL)
Apache-1.1 License :: OSI Approved :: Apache Software License
Apache-1.2 License :: OSI Approved :: Apache Software License
Apache-2.0 License :: OSI Approved :: Apache Software License
APSL-1.0 License :: OSI Approved :: Apple Public Source License