Skip to content

Instantly share code, notes, and snippets.

View LizardLeliel's full-sized avatar

Evan Larose LizardLeliel

  • Halifax, Canada
View GitHub Profile
@LizardLeliel
LizardLeliel / DynamicNodes.cpp
Last active August 29, 2015 14:09
A struct which can be used for linked lists which holds any data
#include <iostream>
#include <cstdlib>
struct dynamicNode {
void* data;
int type;
dynamicNode* next;
};
// I've uploaded this so I may self-reference it later
@LizardLeliel
LizardLeliel / SampleRuby.rb
Created November 7, 2014 17:42
I plan to show this small code to a friend soon, to show him ruby
# ==== Basics =====
#This is how you comment in Ruby! Think # is like a //
puts "Hello, World!"
#Equivalent to System.out.println("Hello, World!");
print "Type something in: "
#Equivalent to System.out.print("Type something in: ")\
@LizardLeliel
LizardLeliel / NegativeIndex.c
Last active August 29, 2015 14:08
Using p[-1], and getting defined behaviour
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int *p = (int*)malloc(sizeof(int)*2);
*p = 4;
++p;
*p = 2;
printf("%d", p[-1]); /* Prints 4 */
return 0;
}
@LizardLeliel
LizardLeliel / FunWithMemory.cpp
Last active August 29, 2015 14:08
Me playing arround with linked lists and other stuff
#include <iostream>
using namespace std;
// Note: I was a bit tired wrapping this up, so I could use a bit more code comments
// And I didn't clean up a few things to have "proper coding style", normally mixing
// variables beginning with capitals and what not
// Note2 (Wrotten after it was uploaded): it looks like I was dynamically adding nodes to the
// linked list wrong, they should be added at the head, not the tail.
// Also, I'll work on being consistent on my code style in next ones, I'll just leave things here
@LizardLeliel
LizardLeliel / DynamicLinkedList.cpp
Last active August 29, 2015 14:08
Dynamic Linked List
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
// Node struct
struct Node {
int data;
Node *next;
};
@LizardLeliel
LizardLeliel / LinkedList.cpp
Created October 28, 2014 22:43
Linked List demonstration
#include <iostream>
using namespace std;
int main()
{
// Node Structure
struct Node {
int data;
Node *next;
@LizardLeliel
LizardLeliel / Quine.cpp
Created October 14, 2014 17:48
A program that outputs its source code. The logic in this file is my own design; I didn't strictly follow code conventions for this exercise, hence the function named function.
#include <iostream>
#include <string>
using namespace std;
void function(string var, int flag);
int main(){
function(R"!(
#include <iostream>
@LizardLeliel
LizardLeliel / (a) RomanNumeralConversion.cpp
Last active August 29, 2015 14:07
This program takes a roman numeral string as a command-line parameter, and outputs its value as an integer. It does not check for the validity of the roman numeral, but it does not crash (non-roman numerals are treated as zeros; values less then the highest value to values on their right are treated as subtracted values (which is correct for iv,…
#include <stack>
#include <string>
#include <iostream>
#include "RomanConversionTools.hpp"
using namespace std;
int main (int argv, char* argc[]) {
// Examine arg count and exit if there's an incorrect parameter ammount
if (argv != 2) {
cout << "Wrong ammount of parameters" << endl;
@LizardLeliel
LizardLeliel / RubixSolver.vb
Last active August 29, 2015 14:01
A few sub procedures in Visual Basic using Visual Studio meant to solve a Rubix cube (where the Rubix cube is an instance of a cube class from the rubix cube module from another gist here. Cube is named "dub" in this program, for that was the easist to type)
'This sub procedure (which is linked to a wpf button in Visual Studio) solves a rubix cube by using
'Algorithms that prodecurally solve it.
'I put a lot of hours in it; taking most of my week evenings to code it, and taking time during class to write down pseudocode.
'However, I still manage to complete the entire code in just a week. However, despite it working as supsected (once
'I've got the final revision on it, I have not had it lock up once on proper cubes), there's still many things
'about the code that could be improved. I feel most of it's unfineness was a result in a pressure to finish it. However, some
'of the problems include:
'-The entire thing is nested in one big while statement. Although I originally had intentions for having it in
@LizardLeliel
LizardLeliel / RubixClasses.vb
Last active August 29, 2015 14:01
A module of the two classes that were used for building the rubix cube program for the Saint Mary University's 2014 hackathon competition.
'The two classes here were used in "The Interactive Rubix Cube", created by Evan Larose and Tristan Murphy,
'for the SMU 2014 hackathon
'All code comments below were included in the actual module
Module RubixClasses
'The sides represent each face of the Rubix Cube. They're used in the cube class before.
'They have a string variable to represent what colour they are, as well as
'a 3x3 array of string that represent each square on the side