Skip to content

Instantly share code, notes, and snippets.

@TheBuzzSaw
TheBuzzSaw / gist:1100411
Created July 22, 2011 20:56
Card Shuffle Program
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
using namespace std;
template<typename T>
class Deck
{
@TheBuzzSaw
TheBuzzSaw / api.lua
Created August 8, 2011 15:47
new API layout
-- DO NOT ALTER THIS FILE. IF YOU DO, AUSTRALIA WILL BE SWALLOWED UP BY A
-- VOLCANO, AND YOU WILL HAVE BAD KARMA FOR LIFE. OH, AND THE GAME WILL BREAK.
arg = nil
debug.debug = nil
debug.getfenv = getfenv
debug.getregistry = nil
dofile = nil
io = { write = wcLog }
loadfile = nil
@TheBuzzSaw
TheBuzzSaw / palindrome.cpp
Created December 12, 2011 05:18
MyPalindrome
#include <iostream>
using namespace std;
bool isPalindrome(const char* inText)
{
if (!inText || !*inText)
return false; // Empty strings fail. OK?
const char* a = inText - 1;
const char* b = inText;
@TheBuzzSaw
TheBuzzSaw / temps.cpp
Created December 24, 2011 19:29
Hunt for Temporaries
#include <iostream>
using namespace std;
class LoudMouth
{
public:
LoudMouth(int inName) : mName(inName)
{
cout << "constructed " << mName << " at " << (void*)this << endl;
}
@TheBuzzSaw
TheBuzzSaw / pointerz.cpp
Created January 13, 2012 03:13
weird pointer stuffz
int main(int argc, char** argv)
{
int stuff[] = { 1, 2, 3, 4, 5 };
int (*p)[5] = &stuff;
return 0;
}
@TheBuzzSaw
TheBuzzSaw / MemoryPool.hpp
Created February 20, 2012 00:45
MemoryPool #1
#ifndef MEMORYPOOL_HPP
#define MEMORYPOOL_HPP
#include <cstdlib>
#define SliceCount 64
class MemoryPool
{
public:
@TheBuzzSaw
TheBuzzSaw / gist:5695012
Created June 2, 2013 21:18
simple Linux assembly
.file "fun.cpp"
.section .rodata
.LC0:
.string "HERRO"
.text
.globl main
.type main, @function
main:
.LFB4:
.cfi_startproc
@TheBuzzSaw
TheBuzzSaw / Rational.k
Last active December 18, 2015 04:39
This is my first attempt at openly imagining my finished language (which I have temporarily dubbed K++). I've done it 100 times in my head, but I need to see it in reality.
import Core; // Bring in standard library.
export Sample; // Set the namespace/package for the code in this file.
class Rational
{
// Like C#, constant values are inherently 'static'.
public constant int32 MinDenominator = 1;
// Class member variables are always all private.
int32 _numerator = 0;
@TheBuzzSaw
TheBuzzSaw / Polygon.k
Last active December 18, 2015 05:19
Here, I will detail the use of inheritance.
import Core;
export Samples.Polygon;
// The keyword 'base' allows inheritance.
// It automagically marks the destructor as 'virtual'.
base class Polygon
{
int32 _edgeCount;
@TheBuzzSaw
TheBuzzSaw / gist:5889632
Created June 29, 2013 03:46
Sample Qt TCP Socket
#include "GameServer.hpp"
#include <QDataStream>
#include <QDebug>
GameServer::GameServer(QObject* parent) : QObject(parent)
{
_server = new QTcpServer(this);
connect(_server, SIGNAL(newConnection()), SLOT(onConnect()));
if (_server->listen(QHostAddress::Any, 8080))