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 / 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
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 / 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}}
@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 / 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 / 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 / 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 / LongestCharSeq.java
Last active January 8, 2016 19:45
Finds and returns the longest sequence of consecutive characters (as per ASCII) in given string.
public class LongestCharSeq {
public String findLongest(String s) {
StringBuffer result = new StringBuffer();
s.toLowerCase();
int lastChar = getAsciiVal(s.charAt(0)) - 1;
StringBuffer currentSeq = new StringBuffer();
for(int i = 0; i<s.length(); i++) {
@SIRHAMY
SIRHAMY / ZeroesToTheRight.java
Created January 8, 2016 05:40
Short method that takes in an integer array and moves all the zeroes to the right-most indices.
public static void zeroRightShift(int[] A) {
if(A == null) return;
int zeroPtr = A.length - 1;
while(zeroPtr >= 0) {
if(A[zeroPtr] != 0) break;
zeroPtr--;
}
@SIRHAMY
SIRHAMY / WhatsWrong.java
Created January 8, 2016 05:03
Little function used for debugging exercises.
public int x(String z) {
if(z.toLowerCase().equals("Airplane")) {
return 5;
} else if(z.toLowerCase().equals("Car")){
return 3;
} else if(z.toLowerCase().equals("Boat")){
return 3;
}
}