Skip to content

Instantly share code, notes, and snippets.

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

Terrance Smith musicm122

🏠
Working from home
View GitHub Profile
@musicm122
musicm122 / TreeNav.cs
Created July 13, 2014 00:24
Simple Traversing Nodes in a Tree Example
void Main()
{
List<string> vals = "1 2 3 4 5".Split(' ').ToList<string>();
vals.Dump();
Node tree = new Node();
NodeExt.RecurseSet(tree,vals);
//tree.Dump();
tree.GetRightMostNode().Dump();
var sb = new StringBuilder();
@musicm122
musicm122 / TheTokenizer.cs
Created July 12, 2014 22:02
TheTokenizer
public static List<string> Tokenize(string expression)
{
//essentiall replaces double quotes with &quot; and apostrophys with "&apos;"
//I prefer dealing with searching for &quot; then " as they tend to be a pain in the regex
var tempExpression = System.Security.SecurityElement.Escape(expression);
string doubleQuote = "&quot;";
//looks for an optional not and whitespace then an expression starting with a quote
//and ending with a quote" our representation of a string
//followed by whitespace and an optional logical operation that identifies the
@musicm122
musicm122 / ConditionParserWorkflow.cs
Created July 12, 2014 21:38
ConditionParserWorkflow
void Main()
{
//The user input expression
var expression = "\"java\" and \"SQL\" and \"C#\" or \"VB.NET\"";
//The collection of tokens that we will use to evaluate the logic in the expression
var tokens = Tokenize(expression);
//tokens.Dump();
//Our evaluated representation of the tokens; We can use this to
@musicm122
musicm122 / ConditionParser.cs
Created July 12, 2014 21:36
Outline of how the Lexing and parsing process is going to go down.
void Main()
{
//The user input expression
var expression = "\"java\" and \"SQL\" and \"C#\" or \"VB.NET\"";
//The collection of tokens that we will use to evaluate the logic in the expression
var tokens = Tokenize(expression);
//tokens.Dump();
//Our evaluated representation of the tokens; We can use this to
@musicm122
musicm122 / validation.js
Last active August 29, 2015 13:57
Javascript Validation regex
var hasLowercase = function (val) {
var patt = new RegExp(/([a-z]+)/g);//checks for 1 or more a-z characters.
return patt.test(val);
};
var hasUppercase = function (val) {
var patt = new RegExp(/([A-Z]+)/g);//checks for 1 or more A-Z characters.
return patt.test(val);
};
@musicm122
musicm122 / UserRespawnFix.cs
Last active December 27, 2015 12:49
Awesomely Hacky user respawn location code.
/// <summary>
/// Restores the player to the starting point to try the level again.
/// </summary>
public void StartNewLife()
{
//First try at default start position
Player.Position= start;
//get the distance from the player the enemies need to be
var playerRange = Enumerable.Range((int)Player.Position.X - 3, (int)Player.Position.X + 3);
@musicm122
musicm122 / prince1.js
Created October 22, 2013 22:00
prince1 to post
var Musician = {
FirstName:"Prince",
MiddleName:"Rogers",
LastName:"Nelson",
StageName:"Prince"
}
@musicm122
musicm122 / prince2.js
Created October 22, 2013 21:59
prince2 post
var Musician = {
FirstName:"Prince",
MiddleName:"Rogers",
LastName:"Nelson",
StageName:"Prince"
}
Musician.StageName ="The Artist Formerly know as "+Musician.StageName;
Musician.StageName ="Jamie Starr";
Musician.StageName ="Christopher";
Musician.StageName ="Alexander Nevermind";
@musicm122
musicm122 / PhysicsEdgeActor.cpp
Created September 28, 2013 22:35
around line 213 of b2dJson.cpp case b2Shape::e_edge: { b2EdgeShape* edge = (b2EdgeShape*)shape; vecToJson("vertex1", edge->m_vertex1, fixtureValue["edge"]); vecToJson("vertex2", edge->m_vertex2, fixtureValue["edge"]); if ( edge->m_hasVertex0 ) fixtureValue["edge"]["hasVertex0"] = true; if ( edge->m_hasVertex3 ) fixtureValue["edge"]["hasVertex3"]…
#include "PhysicsEdgeActor.h"
PhysicsEdgeActor::PhysicsEdgeActor(void)
{
this->_shapeType = SHAPETYPE_EDGE;
this->_edge = b2EdgeShape();
PhysicsActor::SetShapeType(SHAPETYPE_EDGE);
}
@musicm122
musicm122 / RubeLoader.cpp
Created September 25, 2013 01:35
Rube json Loader for Angel2d. adapted from SFML example code example @ https://www.iforce2d.net/rube/?panel=loaders
#include "StdAfx.h"
#include "RubeLoader.h"
#include "rubestuff/b2dJsonImage_OpenGL.h"
using namespace std;
//--Comparer
bool compareImagesByRenderOrder_ascending(const b2dJsonImage_OpenGL* a, const b2dJsonImage_OpenGL* b)
{
return a->renderOrder < b->renderOrder;