Skip to content

Instantly share code, notes, and snippets.

View travisperson's full-sized avatar
🏠
Working from home

Travis Person travisperson

🏠
Working from home
View GitHub Profile
@travisperson
travisperson / functions.c
Created September 14, 2012 22:54
Stats of file.
#include "functions.h"
FILE * open_input_file (void)
{
FILE * input = NULL;
input = fopen("input.dat", 'r');
return input;
}
@travisperson
travisperson / struct.c
Created September 26, 2012 21:39
Storing both a double and a string in an array.
#include <string.h>
#include <stdio.h>
#define STRING 1
#define DOUBLE 2
typedef struct _my_data
{
int myDataType;
double myDouble;
@travisperson
travisperson / cpp_realloc.cpp
Created September 28, 2012 22:41
Realloc in C++ with new
#include <iostream>
class Test {
public:
int a,b,c;
Test() { a=b=c=10; }
};
int main() {
Test *t;
@travisperson
travisperson / timer.hpp
Created October 4, 2012 21:06
High Frequency Timer for windows
// High Frequency Timer
//
// This is a simple timer for windows.
//
// QueryPerformanceCounter
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx
//
// QueryPerformanceFrequency
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx
//
@travisperson
travisperson / for shortcut
Created October 5, 2012 22:12 — forked from whyrusleeping/for shortcut
My favorite Pre-processor hackery
#include <stdio.h>
#define to ; i <=
#define DO(range) for(int range; i++)
int main()
{
int arr[10];
DO(i = 0 to 9)
@travisperson
travisperson / preproc_fizzbuzz.c
Created October 5, 2012 23:03
Preprocessor fizzbuzz
// Requires -std=c99
#include <stdio.h>
#define divisible %
#define by
#define to ; i <=
#define when(mod, msg) \
if((i mod) == 0) \
{ \
printf(#msg); \
@travisperson
travisperson / arrays.c
Created October 9, 2012 04:14
Pointers
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int mynums[3];
int i =0;
/*
mynums[0] = 5;
@travisperson
travisperson / roll.c
Created October 16, 2012 04:30
Roll Dice
#include <stdio.h>
#include <stdlib.h>
void roll(int dice[5])
{
int i =0;
for ( i = 0; i < 5; i++ )
{
dice[i] = rand() % 6 + 1;
}
@travisperson
travisperson / poke.js
Created October 23, 2012 12:47
WSUTech-Bot Twilio Poke plugin
PubSub = require('../lib/pubsub/pubsub')
TwilioClient = require('twilio').Client
Twiml = require('twilio').Twiml
var creds = {
sid: 'xxxxxxxxxxxxxxxxxxxxxxxx',
authToken: 'xxxxxxxxxxxxxxxxxxxxxxx',
incoming: '+xxxxxxxxxxxx',
outgoing: '+xxxxxxxxxxxx',
hostname: 'xxxxxxxxxxx'
@travisperson
travisperson / FuckBoolean.h
Created October 29, 2012 15:31
FuckBoolean
typedef enum FuckBoolean
{
FUCK_NO, FUCK_YEAH
} FuckBoolean;