Skip to content

Instantly share code, notes, and snippets.

View tcsavage's full-sized avatar
🦡

Tom Savage tcsavage

🦡
View GitHub Profile
// My dream interaction with the Win32 API.
#include <iostream>
#include <windows.h>
#define WIN32_SIMPLE
int main (int argc, char* argv[])
{
SIMPLEWINDOW* wnd = CreateSimpleWindow(x, y, w, h, title, fullscreenFlag);
@tcsavage
tcsavage / CMakeLists.txt
Created January 31, 2010 18:25
This source code defines the following: - A generic data class for integer, floating point, string and collection types - A data collection class for generic data objects - Access operator for collections (period '.' separated paths) - Functions for split
project (dataAPI)
# Set Debug Mode
ADD_DEFINITIONS(-g)
find_package(Lua51 REQUIRED)
include_directories(${LUA_INCLUDE_DIR})
set(LIBS ${LIBS} ${LUA_LIBRARIES})
@tcsavage
tcsavage / Animation.cs
Created April 27, 2011 17:21
Keyframe animation helper class
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace PuzzleGame
{
/// <summary>
/// Keyframe animation helper class.
/// </summary>
public class Animation
{
@tcsavage
tcsavage / reverse.hs
Created February 13, 2012 16:58
Simple Haskell script for UNIX-like systems. Commented for education.
#! /usr/bin/runhaskell
module Main where
-- As with many programming languages, the main function is the entry point for execution.
main :: IO ()
main = do -- "do notation" is a way of sequencing functions in haskell to simulate imperitive programming.
inp <- getContents -- Here we bind the resulting thunk from getContents to the name 'inp'.
putStrLn $ reverse inp -- Here we reverse the evaluated value of 'inp' and send it to stdout.
@tcsavage
tcsavage / gist:2002113
Created March 8, 2012 17:09
enumliststring.cs
string outputString = "";
foreach (var e in enumList)
{
outputString += e.ToString() + ", ";
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.DataSource = Enum.GetValues(typeof(MyEnum));
@tcsavage
tcsavage / req.php
Created July 11, 2012 11:03
Get HTTP request headers
<?php
header("Content-type: text/plain");
foreach (apache_request_headers() as $k => $v)
{
echo("$k: $v\n");
}
?>
@tcsavage
tcsavage / setup.sh
Created July 19, 2012 01:01
Pangolin setup
#! /bin/bash
# Clone the repo
git clone https://github.com/tcsavage/pangolin.git .
# Ensure we're on uopcomputing
git checkout uopcomputing
# Setup config
cp config.sample.php config.php
{-# LANGUAGE OverloadedStrings #-}
module BlazeHelpers where
import Text.Blaze ((!))
import Text.Blaze.Html5
import qualified Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5.Attributes as A
import Text.Blaze.Renderer.Pretty
-- | Instantiates the WebCore singleton with a set of configuration parameters.
initialize :: Config -> IO ()
initialize conf
| conf == defaultConfig = awe_webcore_initialize_default
| otherwise = go conf
where
go :: Config -> IO ()
go = do
-- Operating in the (->) monad.
a <- fmap fromBool pluginsEnabled