Skip to content

Instantly share code, notes, and snippets.

@TheBuzzSaw
TheBuzzSaw / ForwardList.cpp
Created December 30, 2015 21:42
Singly linked list plus reversal
#include <iostream>
#include <memory>
using namespace std;
template<class T> struct Node
{
unique_ptr<Node<T>> nextNode;
T value;
};
@TheBuzzSaw
TheBuzzSaw / SimdMatrix.cpp
Created December 10, 2015 17:07
SIMD Matrix
#include <xmmintrin.h>
#include <iostream>
#include <iomanip>
#include <random>
#include <vector>
#include <sstream>
#include <chrono>
using namespace std;
union alignas(16) Float16
@TheBuzzSaw
TheBuzzSaw / BirthdayBuster.cpp
Created October 29, 2015 21:09
Math Truth!
#include <iostream>
#include <random>
#include <sstream>
using namespace std;
void RollDice(mt19937_64& mt, int n)
{
uniform_int_distribution<int> distribution(1, 30);
int matchCount = 0;
@TheBuzzSaw
TheBuzzSaw / switch.kpp
Last active September 14, 2015 18:00
K++ proposed switch syntax
/// Switch statements will use a structure closer to that of if-statements:
/// they are one line unless you use braces.
/// No more break statements. The _default_ behavior is breaking out of a block.
/// Fallthrough is achieved through either comma-separates lists or 'jump' keyword.
switch (value)
{
// One line style.
case (7) DoSomething();
@TheBuzzSaw
TheBuzzSaw / test_key.pub
Created August 12, 2015 20:22
Test Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjNzMK5n0vL9gHiqrN0UzTRjCoOx7Ir2axp65QkXmdLpbkKvFhSm21OmI967wkXf6MZkth8gZoufnTY31dIAhccihmf3NMnlVY9pIRx4+i+7juaZIRqlnKDUoWr0uyoLAKhtqRwjkVMvkuThvlkc+zQRd7S8OHyP0kwG3yPonwsPvPrXhSf1Eo1fAsNfLZWOHgm9QEXS3Ms+RPVIAa1M+S8FODXlEG9d9SfR0bEK81LB49i6bOs8zgCt1M5P7rmt2WBtVRbOvubjr25JUb9A5rdRn+b3kBlSgQpAzzUlbdzACdsN7V5K5u8AFeq+T/7zr3jKqUNeJ5iBJyHpV+jaHb kellyb@kellyb-xubuntu
@TheBuzzSaw
TheBuzzSaw / postgres-nonsense.cpp
Created July 11, 2015 01:41
The postgres API is gross...
#include <libpq-fe.h>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
PGconn* connection = PQconnectdb(
"host=localhost port=5432 dbname=swccg user=postgres");
if (PQstatus(connection) == CONNECTION_OK)
The greatest scientists of all time were invited to a conference ...
* Newton said he'd drop in.
* Descartes said he'd think about it.
* Ohm resisted the idea.
* Boyle said he was under too much pressure.
* Darwin said he'd wait to see what evolved.
* Pierre and Marie Curie radiated enthusiasm.
* Volta was electrified at the prospect
* Pavlov positively drooled at the thought.
void stackDump()
{
const unsigned char* n;
n = (const unsigned char*)&n;
cout << "fail function: " << (void*)fail << endl;
for (int i = 0; i < 64; ++i)
{
cout << '[' << i << "] " << (void*)n << " --";
@TheBuzzSaw
TheBuzzSaw / main.cpp
Created May 14, 2015 18:40
SQLite Cleanup
#include "sqlite3.h"
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <string>
#include <cstring>
using namespace std;
const char OneHalf[] = { (char)0xc2, (char)0xbd, 0x00 };
const char OneQuarter[] = { (char)0xc2, (char)0xbc, 0x00 };
@TheBuzzSaw
TheBuzzSaw / FizzBuzzScale.cpp
Created April 10, 2015 18:09
FizzBuzz solution that allows new multiples/words!
#include <iostream>
using namespace std;
struct Word
{
int n;
const char* text;
};
int main(int argc, char** argv)