Skip to content

Instantly share code, notes, and snippets.

View fsmv's full-sized avatar

April Kallmeyer fsmv

View GitHub Profile
@fsmv
fsmv / regex.md
Last active April 29, 2017 22:14
A primer/tutorial on the theory and practice regular expressions

Regular Expressions

In theory:

  • Regular expressions define a set of strings called the Language
    • If a string matches the regular expression, it's in the language set
  • There are only three operations (because math strives to be minimal)
    • Concatenation - "a concatenated with b" is just ab
    • Or - written a|b. In most regex libraries
    • Klenee Star - zero or more of the expression it's applied to; writtena*
@fsmv
fsmv / MathClass.txt
Created January 19, 2017 16:04
WARNING: Bad code. I found this on my old computer and thought it was interesting to see my parsing before I knew any parsing. I was 16 and teaching myself C++ for the first time when I wrote this.
//////////////////////////////////////////////
// //
// MathClass: //
// version = 0.01 planning //
// modified = 08/09/2010 //
// license = GPL //
// //
//////////////////////////////////////////////
TODO:
@fsmv
fsmv / build.bat
Created June 10, 2016 02:38
Loading and executing code directly from an obj file on Windows!
@echo off
rem Set up the Visual Studio 2013 compiler environment variables
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
cl -c lib.cpp
cl runner.cpp /link user32.lib
@fsmv
fsmv / logger.cpp
Created June 29, 2015 23:13
C++ Logger
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Andrew Kallmeyer
*
* 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, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@fsmv
fsmv / envinfo
Created March 12, 2015 04:34
Performance Testing Scripts
#!/bin/sh
echo "CPU Model: `grep -m1 'model name' /proc/cpuinfo | cut -d' ' -f3- | tr -s ' '`"
echo "CPU/Core Speed (MHz): `grep -m1 'cpu MHz' /proc/cpuinfo | cut -d' ' -f3` MHz"
echo "RAM: `grep 'MemTotal' /proc/meminfo | awk '{ print $2,$3 }'`"
echo "Operating System: `uname -sr`"
echo "Interconnect: N/A"
echo "g++ version: `g++ --version | head -1`"
echo "javac version: `javac -version 2>&1`"
echo "icpc version: `icpc --version | head -1`"
@fsmv
fsmv / miniupnpcTest.c
Created September 12, 2014 19:47
Miniupnpc Port Forwarding Example
#include <stdio.h>
#include <arpa/inet.h> //INET6_ADDRSTRLEN
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
int main(int argc, char *argv[]) {
int error = 0;
//get a list of upnp devices (asks on the broadcast address and returns the responses)
struct UPNPDev *upnp_dev = upnpDiscover(1000, //timeout in milliseconds
NULL, //multicast address, default = "239.255.255.250"
@fsmv
fsmv / KDTree.h
Last active August 29, 2015 14:04
A K-D Tree implementation which preforms a nearest neighbor seach on any point type and returns the distance between them in any type using a user-defined distance function.
/**
* A K-D Tree implementation which preforms a nearest neighbor seach on any point type and returns the
* distance between them in any type using a user-defined distance function.
*
* Rather than returning the actual nearest object this class returns the index of the nearest object in
* the original vector that was passed in.
*
* Provided under the MIT License
* Copyright (c) 2014 Andrew Kallmeyer <fsmv@sapium.net>
*
@fsmv
fsmv / .vimrc
Last active October 17, 2022 14:05
my vim config
"
" Terminal Colors: http://terminal.sexy/#IyMjoKCgMDAw03CjbZ4_tYhYYJXFrHveO6J1z8_PaGho_6fao9Vy772LmMv-5bD_ddqp____
"
set nocompatible
filetype off
"Set up the Vundle plugin manager
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
@fsmv
fsmv / .xbindkeysrc
Last active December 27, 2015 21:39
Set of scripts for a nice screenshot environment on linux Requires gnome-screenshot, notify-send, curl, and xclip Optionally depends on scrot for the scrn -s option
#On release because otherwise xbindkeys has problems with this command also using X at the same time
"scrn -a"
Release + Print
"scrn"
Release + Shift + Print
"scrn -s"
Release + Control + Print
@fsmv
fsmv / wifi.sh
Last active December 11, 2015 14:58
A wifi utility for Mac that gets status and sets state. To use you have to place the airport binary in your path per these instructions http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/
#!/bin/bash
# Run this command to link airport into the path
# sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
if [ "$1" == "status" ]
then
out=$(airport -I)
if [ "$out" == "AirPort: Off" ]
then