Skip to content

Instantly share code, notes, and snippets.

View kevinkreiser's full-sized avatar

Kevin Kreiser kevinkreiser

  • osm.org/node/158543009
  • 03:01 (UTC -04:00)
View GitHub Profile
#include <sstream>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
// To test performance you can compile with different preprocessor defines:
// g++ -std=c++11 -O2 -D USE_PRINTF string_format.cpp -o using_printf
// g++ -std=c++11 -O2 -D USE_IOSTREAM string_format.cpp -o using_iostream
// g++ -std=c++11 -O2 -D USE_STRING string_format.cpp -o using_string
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kevinkreiser
kevinkreiser / scoped_timer.cpp
Last active March 20, 2019 17:20
timer that fires a callback with the elapsed duration when going out of scope
//Try this out like so:
//g++ -std=c++14 scoped_timer.cpp -o scoped_timer && ./scoped_timer
#include <chrono>
#include <functional>
#include <thread>
#include <iostream>
template <typename clock_t = std::chrono::steady_clock>
struct scoped_timer {
@kevinkreiser
kevinkreiser / urldecode.hpp
Created September 25, 2018 16:08
simple header only url decoder
#ifndef TEST_DECODE
#pragma once
#else
#include <iostream>
#endif
#include <string>
std::string urldecode(const std::string& url) {
// make a place for the output
std::string decoded;
@kevinkreiser
kevinkreiser / filesystem.hpp
Last active March 5, 2024 15:39
a replacement for std::filesystem when its not available to your compiler
#include <functional>
#include <iostream>
#ifdef use_std_filesystem
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#else
#include <cstring>
#include <memory>
@kevinkreiser
kevinkreiser / lz4_test.cpp
Last active January 17, 2018 20:08
lz4 Compress Test Utility
#include <vector>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstdint>
#include <fstream>
#include <lz4.h>
@kevinkreiser
kevinkreiser / get_cloud_watch_logs.py
Last active October 5, 2023 06:02
A simple python script that uses aws cli to download logs from cloud watch
#!/usr/bin/env python
import sys
import os
import time
import math
import calendar
import threading
import argparse
import boto3
from functools import partial