Skip to content

Instantly share code, notes, and snippets.

View kevinkreiser's full-sized avatar

Kevin Kreiser kevinkreiser

  • osm.org/node/158543009
  • 11:42 (UTC -04:00)
View GitHub Profile
@kevinkreiser
kevinkreiser / TODO.txt
Last active October 14, 2019 19:17
Configuring Raid with mdadm
need to edit /etd/mdadm/mdadm.conf remove --name from newly created array or do so when using mdadm --create? remove other raids listed there
sudo update-initramfs -u
that way when problem occurs it wont reassign to /dev/md127
http://ubuntuforums.org/showthread.php?t=1764861
@kevinkreiser
kevinkreiser / zmq_server.py
Last active August 29, 2015 14:18
Blocking zmq zeromq Ømq http Request Echo Server
from BaseHTTPServer import BaseHTTPRequestHandler
from StringIO import StringIO
from cgi import urlparse
import json
import zmq
class HTTPRequest(BaseHTTPRequestHandler):
def __init__(self, request_text):
self.rfile = StringIO(request_text)
self.raw_requestline = self.rfile.readline()
@kevinkreiser
kevinkreiser / template_function_specialization.cpp
Created September 10, 2015 21:02
When only the return type differs an overload just isn't enough!
#include <iostream>
#include <list>
#include <vector>
//the guts that both specializations can use
template <class container_t>
void fill(container_t& c, int start, int end) {
for(;start <= end; ++start)
c.push_back(start);
}
@kevinkreiser
kevinkreiser / iterable.cpp
Last active October 13, 2015 20:17
Make primative array iterable
#include <string>
#include <iostream>
template <class T>
struct iterable_t {
public:
using iterator = T*;
iterable_t(T* first, size_t size): head(first), tail(first + size), count(size){}
iterable_t(T* first, T* end): head(first), tail(end), count(end - first){}
T* begin() { return head; }
#include <iostream>
#include <cinttypes>
#include <limits>
//combining a union with an anonymous bit field we can:
// get a summary value for the entire bit field
// reference bit field members directly from the union
// use an initializer list to set them
//TODO: how to initialize via the bit field members without un-anonymizing it
union bit_funion_t {
@kevinkreiser
kevinkreiser / code_timeline.sh
Last active November 11, 2015 21:16
CSV Generator for Graphing Bytes of Code Since a Date in the Past
#!/bin/bash
#run this like: DAYS=365 ./code_timeline.sh https://github.com/org/repo1.git https://github.com/org/repo2.git
#note that the types of files it checks for code are hardcoded below
code='\.cc$|\.h$|\.cpp$|\.hpp$|\.lua$|\.py$|\.js'
: ${DAYS:?Please set DAYS environment variable to a number of days in the past youd like to capture}
#setup each repo
echo -n "day,"
for url in ${@}; do
@kevinkreiser
kevinkreiser / cat.cpp
Created May 11, 2016 12:45
naive implementation of cat (without pipes)
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
int main(int argc, char** argv) {
if(argc < 2) {
std::cerr << "cat: Pass me a file\n";
return 2;
}
@kevinkreiser
kevinkreiser / valhalla_route_connectivity.geojson
Last active June 6, 2016 13:04
valhalla route tiles: where same-coloured tiles are approximately routable between each other
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kevinkreiser
kevinkreiser / mem_map_tar.cpp
Last active September 21, 2016 18:40
Memory Mapped Tar File Contents
/**
* build with: g++ -std=c++11 -O2 mem_map_tar.cpp -o list_tar
* run as: ./list_tar some_file.tar
*/
#include <unordered_map>
#include <string>
#include <utility>
#include <cmath>
#include <cstring>
@kevinkreiser
kevinkreiser / github_copy_issues.py
Last active February 13, 2017 16:14
Copy Github Issues Between Repositories
#!/usr/bin/env python
import sys
import json
import requests
from functools import partial
import pprint
import calendar
import time
issue_parameters = set(['title', 'body', 'milestone', 'labels', 'assignees', 'state'])