Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Jordan andschwa

View GitHub Profile
@andschwa
andschwa / main.cpp
Last active March 20, 2022 15:32
Algorithm for Efficient Chunked File Reading in C++
View main.cpp
/* Algorithm for Efficient Chunked File Reading in C++
*
* The MIT License (MIT)
*
* Copyright 2014 Andrew Schwartzmeyer
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
@andschwa
andschwa / mailgun_tracking.js
Last active July 15, 2021 10:31
Google Scripts web app to receive MailGun webhooks
View mailgun_tracking.js
// Hook location: https://app.mailgun.com/app/webhooks
var API_KEY = "key-abcd1234...";
var EMAIL = "postmaster@yourwebsite.com";
// Naive function to email a posted event from a MailGun web hook.
// `doPost(e)` signature: https://developers.google.com/apps-script/guides/web#deploying
// `parameter` schema: https://mailgun-documentation.readthedocs.io/en/latest/user_manual.html#webhooks
// Events API: https://documentation.mailgun.com/en/latest/api-events.html#api-events
function doPost(e) {
// The output is not consumed, but required by the Google Scripts API.
@andschwa
andschwa / installkernel
Created August 17, 2015 00:12
Arch Linux development kernel installation script
View installkernel
# Arch Linux development installkernel script
# Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
# See `Documentation/kbuild/kbuild.txt`
# Copy to `/sbin/installkernel`
# Use with `sudo make install`
# Copy the kernel image
cp -v $2 $4/vmlinuz-linux-$1
# Make initial RAM disk
@andschwa
andschwa / provided-mode-derived-p.el
Last active September 21, 2018 06:46
Make `provided-mode-derived-p` support `defalias` parents
View provided-mode-derived-p.el
;; Fixed to support `(defalias 'my-parent-mode ...)`
(defun provided-mode-derived-p (mode &rest modes)
"Non-nil if MODE is derived from one of MODES.
Uses the `derived-mode-parent' property of the symbol to trace backwards.
If you just want to check `major-mode', use `derived-mode-p'."
(while (and (not (memq mode modes))
(let ((parent (get mode 'derived-mode-parent)))
(let ((parentfn (symbol-function parent)))
(setq mode (if (and parentfn (symbolp parentfn))
parentfn
@andschwa
andschwa / vs_cmake_bug.md
Created May 11, 2017 19:19
Visual Studio 2017 CMake Build Tools Bug
View vs_cmake_bug.md

Problem

The 3.7.2 version of CMake bundled with Visual Studio 2017 (latest update) cannot on its own find the Visual Studio 2017 build tools. This is reproducing for me using Visual Studio 2017 with individual components selected. Using CMake 3.8.1 (current CMake release), the tools can be found no problem. This becomes problematic when using the Visual Studio CMake tools because the ExternalProject_Add macro (used to include third-party CMake driven projects) re-invokes CMake, at which point it fails to find the compilers. It seems that Visual Studio originally invokes CMake "specially" shomehow as it finds the tools for the top-level project, but does not retain this environment when ${CMAKE_COMMAND} is invoked from within the build.

@andschwa
andschwa / keybase.md
Created May 6, 2017 19:27
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am andschwa on github.
  • I am andschwa (https://keybase.io/andschwa) on keybase.
  • I have a public key ASBNS9VF0YqQ9M0J_vZ1D_C3YsmCwqsoTsRZP7QclouNxwo

To claim this, I am signing this object:

@andschwa
andschwa / git-branch-simplify.md
Last active August 29, 2015 14:27 — forked from datagrok/git-branch-simplify.md
How to simplify the graph produced by git log --graph
View git-branch-simplify.md

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@andschwa
andschwa / g++ test.cpp
Last active August 29, 2015 14:15 — forked from 13abylon/g++ test
View g++ test.cpp
// g++ test.cpp --std=c++11 -lpthread -O2
//#ifdef WIN32 <- stdafx breaks this ifdef...
//#include "stdafx.h"
//#endif
#include <iostream>
#include <atomic>
#include <thread>
#include <vector>
@andschwa
andschwa / .vimrc
Created January 20, 2015 06:42
VIM configuration
View .vimrc
""" Andrew Schwartzmeyer's VIM configurations
""" I now use Emacs, but am saving these for posterity
""" Set Vim mode, not Vi
set nocompatible
""" Vundle
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()