Skip to content

Instantly share code, notes, and snippets.

View bbkane's full-sized avatar
🤜

Benjamin Kane bbkane

🤜
View GitHub Profile
@bbkane
bbkane / MarkovChain.py
Last active November 14, 2023 10:13
MarkovChain in SQL + Python
import contextlib
import sqlite3
CREATE_TABLES_SQL = """
CREATE TABLE IF NOT EXISTS word
(
id INTEGER NOT NULL,
word TEXT UNIQUE NOT NULL,
number INTEGER DEFAULT 1,
PRIMARY KEY (id)
@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 <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 / 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)
@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 / 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:
# Just unzip SDL2 zip file into CMAKE_SOURCE_DIR
# This doesn't work with VS2015
cmake_minimum_required(VERSION 3.1)
project(sdl2test)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
#find_package(SDL2 REQUIRED)
#message(status $ENV{SDL2DIR})
@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([])