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 / example_schema.json
Created July 22, 2016 19:22
IBM Graph example schema
{
"propertyKeys": [
{"name": "name", "dataType": "String", "cardinality": "SINGLE"},
{"name": "verified", "dataType": "Boolean", "cardinality": "SINGLE"},
{"name": "tweet", "dataType": "String", "cardinality": "SINGLE"},
{"name": "sentiment", "dataType": "String", "cardinality": "SINGLE"},
{"name": "tone", "dataType": "String", "cardinality": "SINGLE"},
{"name": "hashtag", "dataType": "String", "cardinality": "SINGLE"},
{"name": "numTimes", "dataType": "Integer", "cardinality": "SINGLE"},
{"name": "time", "dataType": "String", "cardinality": "SINGLE"}
@SIRHAMY
SIRHAMY / requests_json.py
Created July 19, 2016 20:35
Access keys from requests module's JSON response
import requests
#initial request
r = requests.get(requestUrl)
#Extract JSON
rJson = r.json()
#Get keywords key from response JSON
keywords = rJson.get('keywords')
@SIRHAMY
SIRHAMY / SinglyLinkedListReverser.java
Created May 19, 2016 22:22
Simply Singly Linked List reverser in Java.
public class Reverser {
public Node reverseSLL(Node head) {
//To reverse:
//A -> B -> C
//A <- B <- C
//Save B's pointer to C
//Set B's pointer to A/where we came from
//Save pointer to B
import time
import tweetpony
self.twitAPI = tweetpony.API(consumer_key = env.TWITTER_CONSUMER_KEY,
consumer_secret = env.TWITTER_CONSUMER_SECRET,
access_token = env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret = env.TWITTER_ACCESS_TOKEN_SECRET)
#Abstract minefeed so you can recall it if there's an error
def mineFeed(self, twitterID):
import json
#This is going to fetch our lines one-by-one
#Useful for super-huge files
class JSONFetcher():
def __init__(self, fileName):
self.fileName = fileName + '.json'
def fetch(self):
print("fetching...")
@SIRHAMY
SIRHAMY / progressbar.html
Created March 24, 2016 19:49
Dynamically change Twitter Bootstrap Progress Bar color with JQuery
<div id="progressbar"
class="progress-bar progress-bar-custom
progress-bar-striped-custom"
role="progressbar"
aria-valuenow="70" aria-valuemin="0"
aria-valuemax="100" style="width: 70%;">
Progress Bar Text
</div>
@SIRHAMY
SIRHAMY / README.txt
Last active March 24, 2016 03:42
Sample bits of a custom striped Twitter Bootstrap progress bar
Sample code for a striped Twitter Bootstrap progressbar with stripes
See the codepen at: http://codepen.io/SIRHAMY/pen/zqwEwv
@SIRHAMY
SIRHAMY / table.css
Last active March 23, 2016 19:04
Vertically align TD tag in HTML Table
td {
vertical-align: bottom;
}
@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 / 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;
}