Skip to content

Instantly share code, notes, and snippets.

View bbkane's full-sized avatar
🤜

Benjamin Kane bbkane

🤜
View GitHub Profile
@bbkane
bbkane / 2048.py
Created July 17, 2014 16:14
2048.py
import console
from random import randint, choice, randrange
class Board:
def __init__(self, xSize=4, ySize=4):
self.xSize=xSize
self.ySize=ySize
self.tiles=[]
for i in range(self.ySize):
self.tiles.append([])
@bbkane
bbkane / Logger.cpp
Last active August 29, 2015 14:26
Logger to be improved
#include <iostream>
#include <fstream>
#include <string>
#define STR(x) #x
#define STRINGIFY(x) STR((x))
#define ERROR_INFO __FILE__ " : " __FUNCTION__ " : " STRINGIFY(__LINE__) " : "
class Error_Logger {
private:
@bbkane
bbkane / time_it.cpp
Created July 31, 2015 20:34
Simple function to time different versions of a class
template<typename T>
int time_it()
{
using milliseconds_t = std::chrono::duration < int, std::milli >;
//start time
auto start = std::chrono::steady_clock::now();
//instantiate class
T class_to_time;
//do stuff to time it
@bbkane
bbkane / CMakeLists.txt
Last active August 29, 2015 14:27
Simple (no libraries or assets) Sandbox projects for CMake. For those one-off times you just want to try something.
# Author: Ben Kane
cmake_minimum_required(VERSION 3.1)
# Name the Project that holds all other projects
project(Sandbox)
# add warnings to all projects
if(MSVC)
add_compile_options(/W4 /wd4100)
#include <iostream>
#include <vector>
#include <string>
int main()
{
std::string i{"Hello"};
// static_assert(std::is_same<decltype(i), char>(), "Oops!");
std::vector<decltype(i)> v {i};
for(auto i: v) { std::cout << i << std::endl; }
@bbkane
bbkane / spyder.desktop
Created February 27, 2016 19:49
Spyder.desktop
[Desktop Entry]
Name=Spyder Python IDE
Comment=Edit text files
Exec=/home/ben/anaconda3/bin/spyder
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=/home/ben/.local/share/applications/spyder.png
Categories=GNOME;GTK;Utility;TextEditor;
#include <algorithm>
#include <cassert>
#include <chrono>
#include <iostream>
#include <vector>
#include <random>
// NOTE: All iterator concepts are experimental. I'm not going
// to concentrate on them
@bbkane
bbkane / pythonic_print.h
Last active January 30, 2018 04:43
Slow, fat, and convenient way to print from C++
#include <iostream>
#include <iterator>
#include <array>
#include <string>
// I think this will bloat binary size and be slower,
// but it's for convenient printing, which is worth it :)
// TODO: don't always call by value...
// Of course, I'm mostly passing ints and strings, so it's probably not too
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This is just to find out how firefox bookmarks.json files are structured
__author__ = "Benjamin Kane"
__version__ = "0.1.0"
from collections import Counter, defaultdict
from functools import reduce
@bbkane
bbkane / 12_azure_aaaa_mismatch_repro_log.log
Created January 6, 2020 19:49
12_azure_aaaa_mismatch_repro logs
This file has been truncated, but you can view the full file.
2020/01/06 11:46:07 [INFO] Terraform version: 0.12.18
2020/01/06 11:46:07 [INFO] Go runtime version: go1.12.13
2020/01/06 11:46:07 [INFO] CLI args: []string{"/usr/local/bin/terraform", "plan"}
2020/01/06 11:46:07 [DEBUG] Attempting to open CLI config file: /Users/bkane/.terraformrc
2020/01/06 11:46:07 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/01/06 11:46:07 [INFO] CLI command args: []string{"plan"}
2020/01/06 11:46:07 [TRACE] Meta.Backend: built configuration for "local" backend with hash value 73024536
2020/01/06 11:46:07 [TRACE] Preserving existing state lineage "f68ce643-ae51-dd97-2921-b4d60b6fc613"
2020/01/06 11:46:07 [TRACE] Preserving existing state lineage "f68ce643-ae51-dd97-2921-b4d60b6fc613"
2020/01/06 11:46:07 [TRACE] Meta.Backend: working directory was previously initialized for "local" backend