Skip to content

Instantly share code, notes, and snippets.

View Experiment5X's full-sized avatar

Adam Spindler Experiment5X

View GitHub Profile
@Experiment5X
Experiment5X / gist:4166386
Created November 29, 2012 02:26
Sick Drawing Stuff
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DrawingStuff
{
public partial class Form1 : Form
{
public Form1()
{
@Experiment5X
Experiment5X / mc02_fixer.c
Last active March 27, 2021 23:11
This is a short and simple program that will fix the 3 checksums at the top of some games published by EA for the Xbox 360 console. I know that both Dead Space 1 and 3 have the MC02 header, but I think a lot of other EA games do as well.
#include <stdio.h>
#include <stdlib.h>
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef struct
{
DWORD magic; // 0x4D433032, ASCII = "MC02"
DWORD fileLength;
@Experiment5X
Experiment5X / Word2Element.rb
Last active December 15, 2015 12:09
Word2Element will convert a string of text into elements from the periodic table whose symbols make up the string of text. Of course not all strings of text can be made into an elemental representation, so if it's impossible to convert the application will spit out "Not possible"
Element = Struct.new(:symbol, :name)
elements = []
def word2Element(w, builder, elements)
if w.length == 0
return builder
end
# check for 1 char symbol
#include <stdio.h>
#include <stdlib.h>
#include <sys/queue.h>
struct _Student
{
LIST_ENTRY(_Student) entries;
char name[20];
int age;
float gpa;
@Experiment5X
Experiment5X / EssayScrambler.cpp
Created May 17, 2013 20:34
EssayScrambler is a simple application that will take a text block, the bigger the better, and generate a 'random' text block based off of the input. The application will choose a seed word, and then pick the next word based off of the words that follow the seed word in the input. For example, let's say that the seed word is 'book' and in the in…
#include "EssayScrambler.h"
using namespace std;
EssayScrambler::EssayScrambler(const string &essayText) :
essayText(essayText)
{
parseText();
}
@Experiment5X
Experiment5X / sillyncurses.c
Created June 26, 2013 00:02
Just messing around with NCurses. Use wasd to move the x around the screen, pretty simple stuff.
#include <ncurses.h>
#define KEY_ESC 27
int main()
{
initscr();
keypad(stdscr, true);
// don't print out the text the user enters
noecho();
@Experiment5X
Experiment5X / arrays.c
Last active December 19, 2015 19:19
Sick code that rotates a 2D array.
#include <stdio.h>
void printThing(char array[3][3])
{
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
printf("%c", array[y][x]);
}
@Experiment5X
Experiment5X / 24.c
Last active December 19, 2015 19:19
Inspired by the show 24, I decided to try and re-create the famous clock in a linux terminal. To compile the app, you'll need to have ncurses installed, to do that use the following command in a debian environment. sudo apt-get install ncurses-dev Once that is installed, compilation is pretty straight-forward, paste the following into your termi…
#include <stdio.h>
#include <curses.h>
#include <time.h>
#define HORIZONTAL_BAR_LEN 3
#define VERTICAL_BAR_LEN 2
#define DIGIT_WIDTH ((HORIZONTAL_BAR_LEN * 2) + 5)
#define DIGIT_HEIGHT ((VERTICAL_BAR_LEN * 2) + 3)
@Experiment5X
Experiment5X / mul.c
Created July 21, 2013 04:41
Multiplying without the use of the * operator.
#include <stdio.h>
int mul(int a, int b)
{
if (b == 1)
return a;
else if (b == 0)
return 0;
return (a << 1) + mul(a, b - 2);
}
@Experiment5X
Experiment5X / phone.c
Created August 27, 2013 20:52
A simple program that will convert a string of numbers to the word equivalent. For example, if the user enters 12345 the program will output One, Two, Three, Four, Five. Be careful with this, there isn't a check to ensure the input buffer doesn't overflow.
#include <stdio.h>
#include <string.h>
#define CHAR_TO_INT(c) (c - 0x30)
int IsValidPhoneNumber(char *phoneNumber, int length)
{
for (int i = 0; i < length; i++)
if (CHAR_TO_INT(phoneNumber[i]) < 0 || CHAR_TO_INT(phoneNumber[i]) > 9)
return -1;