Skip to content

Instantly share code, notes, and snippets.

View SIRHAMY's full-sized avatar
🐷
Loading...

Hamilton Greene SIRHAMY

🐷
Loading...
View GitHub Profile
@SIRHAMY
SIRHAMY / P5ResizeProblem.js
Created January 9, 2016 20:58
Example problem and solution for P5.js image quality issues arising from multiple calls to resize.
var exImg;
function preload() {
exImg = loadImage("COMPUTER/FAKE.png");
}
function setup() {
exImg.resize((windowHeight/exImg.height) * exImg.width, windowHeight);
}
@SIRHAMY
SIRHAMY / simulator.cpp
Created February 16, 2016 04:13
Euler Midpoint Step Example
void Simulator::midpointStep(Eigen::Vector3d particle) {
Eigen::Vector3d halfTimeStepChangeV = { 0, (mTimeStep * 0.5) * -9.8, 0 };
particle.mVelocity[1] += halfTimeStepChangeV[1];
particle.mPosition[1] += (mTimeStep * particle.mVelocity[1]);
}
@SIRHAMY
SIRHAMY / url_parse.py
Created February 24, 2016 01:25
Parsing URL Code - Cause why not?
# -----------------------------------------------
# This project should be completed using the
# Python programming language.
#
# Problem:
#----------
# Please parse the following URL into parts:
# http://www.vandyhacks.org/dostuff/now
#
@SIRHAMY
SIRHAMY / package.json
Created February 26, 2016 01:48
Bad package.json - Trailing comma
{
"name": "fullstackreduxtutorialserver",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --recursive",
"test:watch": "npm run test -- --watch"
},
"babel": {
@SIRHAMY
SIRHAMY / template.html
Created March 8, 2016 17:55
Use Mustache to insert field into template
{{#tooltipText}}
<span title="This is the tooltip text: {{tooltipText}}"></span>
{{/tooltipText}}
Eigen::MatrixXdd m(5,4); //Creates a Matrix with 5 rows and 4 columns
std::cout << "Rows: " << m.rows() << ", Cols: " << m.cols() << std::endl;
//The above should print "Rows: 5, Cols: 4"
@SIRHAMY
SIRHAMY / quatValToConsole.cpp
Created March 17, 2016 00:11
Example showing how to print the vals of an Eigen::Quaterniond to the console
Eigen::Quaterniond myQuaternion = someFuncThatReturnsQuaternionVals(exampleParam); //The Quaternion to print
std::cout << "Debug: " << "myQuaternion.w() = " << myQuaternion.w() << std::endl; //Print out the scalar
std::cout << "Debug: " << "myQuaternion.vec() = " << myQuaternion.vec() << std::endl; //Print out the orientation vector
@SIRHAMY
SIRHAMY / quaternionMultiplicationExample.cpp
Created March 17, 2016 01:04
Example of quaternion on quaternion multiplication using the C++ Eigen library.
Eigen::Quaterniond MyWorld::quatMult(Eigen::Quaterniond q1, Eigen::Quaterniond q2) {
Eigen::Quaterniond resultQ;
resultQ.setIdentity();
resultQ.w() = q1.w() * q2.w() - q1.vec().dot(q2.vec());
resultQ.vec() = q1.w() * q2.vec() + q2.w() * q1.vec() + q1.vec().cross(q2.vec());
return resultQ;
}
@SIRHAMY
SIRHAMY / quaternionAdditionExample.cpp
Created March 18, 2016 01:39
Example showing how to add two Eigen::Quaterniond values
Eigen::Quaterniond myQuaternion; //This is the quaternion we want to store the result in
//These are the two quaternions we'll be adding together
Eigen::Quaterniond q1 = initializeMyQuaternion(exampleParam); //We'll say it initializes to some random, valid vals
Eigen::Quaterniond q2 = initializeMyQuaternion(exampleParam2);
//Perform the addition
myQuaternion.w() = q1.w() + q2.w(); //Add the scalar portion
myQuaternion.vec() = q1.vec() + q2.vec(); //Add the vector portion
@SIRHAMY
SIRHAMY / table.css
Last active March 23, 2016 19:04
Vertically align TD tag in HTML Table
td {
vertical-align: bottom;
}