Skip to content

Instantly share code, notes, and snippets.

View tmplt's full-sized avatar

Viktor Vilhelm Sonesten tmplt

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <locale.h>
#include <termios.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <stdbool.h>
#include <unistd.h>
@tmplt
tmplt / data.csv
Created February 15, 2018 20:52
Histogram with two insets, zooming into sub-domains
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
0.0 0
0.0010420332355816227 0
0.0020840664711632454 0
0.003126099706744868 0
0.004168132942326491 0
0.005210166177908113 0
0.006252199413489736 0
0.007294232649071359 0
0.008336265884652982 0
0.009378299120234603 0
@tmplt
tmplt / README.md
Last active February 9, 2017 00:58
C++ levenshtein edit distance

When working on fuzzywuzzy I required a C++ implementation of the Levenshtein edit distance. I found different ways to implement this, so I took a bit of everything, and tried to simplify it as much as I could.

Majority of credit goes to Martin Ettl, for his submission on Rosetta Code.

Licese

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or

@tmplt
tmplt / 0_README.md
Last active June 5, 2016 01:09
Programming-fit Report Preamble
@tmplt
tmplt / wallpapers.sh
Created September 27, 2015 21:37
bash script to get get random wallpapers on two screens every 45m
#!/bin/sh
WALLPATH_BIG=/home/tmplt/.wallpapers/big/
WALLPATH_SMALL=/home/tmplt/.wallpapers/small/
while true; do
# Choose a random wallpaper for the big screen
WP_BIG=$(find $WALLPATH_BIG -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
shuf -n1 -z)
@tmplt
tmplt / diword.cpp
Created June 7, 2015 20:09
Enter a word, and get it in diamond-form
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
if (argc < 2) return 1;
@tmplt
tmplt / preamble.tex
Created May 11, 2015 13:51
LaTeX assignment template
\documentclass[12pt]{article}
\usepackage[margin = 1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[utf8]{inputenc}
\usepackage[<lang>]{babel}
\usepackage{fancyhdr}
\setlength{\headheight}{15pt} % for better header hight thing, removes LaTeX error
\pagestyle{fancy}
@tmplt
tmplt / c++.sublime-build
Created July 9, 2014 15:16
Compile C++11 in Sublime Text 2/3
{
"cmd": ["g++", "${file}", "-std=c++0x", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
@tmplt
tmplt / references
Created July 8, 2014 17:53
legal and illegal references
int i = 1024, i2 = 2048; // i and i2 are both ints
int &r = i, r2 = i2; // r is a reference bound to i; r2 is an int
int i3 = 1024, &ri = i3; // i3 is and int; ri i a reference bound to i3
int &r3 = i3, &r4 = i2; // both r3 and r4 are references
int &refVal4 = 10; // error: initializer must be an object
double dval = 3.14;
int &refVal4 = dval; // error: initiazlier must be an int object
@tmplt
tmplt / globals_locals
Created July 6, 2014 12:55
explicitly requests a global name over a local one
using namespace std;
int reused = 42; // global scope
int main()
{
int unique = 0; // block/local scope
// output #1: uses global reused; prints "42 0"
cout << reused << " " << unique << endl;
int reused = 0; // new, local name, hides (currently overrides?) global name
// output #2: uses local reused; prints "0 0"