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 / CsvReader.linq
Created August 8, 2018 15:35
LinqPad (C#) CSV Parser
// readPath goes here
const string licenseCsvPath = @"C:\some\path";
// writePath goes here
const string writeSqlpath = @"C:\some\path";
var sqlString = new StringBuilder();
sqlString.Append(
@"INSERT INTO dbo.myTable
@SIRHAMY
SIRHAMY / RegExCounter.js
Created May 29, 2018 22:11
Count the number of occurrences of a Regex match on a given webpage.
var minNumberOfOccurrencesToPrint = 3; // Min number of occurrences you care about
var documentHtml = document.documentElement.outerHTML; // Grab HTML
var occurrences = (documentHtml.match(/YourRegexGoesHere/g) || []); // Search page for occurrences, use regexpal.com to test your regex
var wordCounter = {};
for (let match of occurrences) {
if(match in wordCounter) {
wordCounter[match] += 1;
} else {
wordCounter[match] = 1;
@SIRHAMY
SIRHAMY / JwtTokenCreator.cs
Created March 22, 2017 18:22
Example of how to use Microsoft's System.IdentityModel.Tokens.Jwt to create a JWT Token
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Linq
using System.Text;
using Microsoft.IdentityModel.Tokens;
public class JwtTokenCreator
{
private readonly JwtSecurityTokenHandler _jwtSecurityTokenHandler;
@SIRHAMY
SIRHAMY / gtltexample.html
Created September 18, 2016 04:49
React/JSX: Put greater than and less than symbol in HTML
<div>{"<"} Less than, {">"} greater than </div>
var insertGreeting = function(Reader) {
if(Reader.isNew()) {
return (
"Hi, my name's Hamilton. I'm entering my last " +
"semester at Georgia Tech where I'm majoring in " +
"Computer Science. For the past year, I've made " +
"it a habit to publish my accomplishments and " +
"aspirations at the end of each semester. I use " +
"it, primarily, to track my progress with respect " +
"to my short-term goals and long-term growth. " +
@SIRHAMY
SIRHAMY / app.js
Created July 26, 2016 19:51
Example app.js to run react-router on a Node and Express web server
// This application uses express as its web server
// for more info, see: http://expressjs.com
var express = require('express');
const path = require('path')
// create a new express server
var app = express();
// serve the files out of ./public as our main files
@SIRHAMY
SIRHAMY / create_vertex.json
Created July 25, 2016 21:51
Showing how to use LIST properties in IBM's GraphDB
{ "label": "post",
"properties":
{
"title":"Use LIST properties on IBM GraphDB",
"text": "This is how you do it"
}
}
@SIRHAMY
SIRHAMY / USAGE.txt
Created July 25, 2016 21:50
IBM GraphDB - Update a vertex property, selecting vertex by vertex ID.
Here, you hit the vertex endpoint, supplying VERTEX_ID in the URL.
DOCUMENTATION: https://ibm-graph-docs.ng.bluemix.net/api.html#vertex-apis
Currently, something like:
-HTTP: POST
-URL: https://ibmgraph-alpha.ng.bluemix.net/$APIURL/$GRAPHNAME/vertices/$VERTEXID
-BODY: update_vertex_property.json
@SIRHAMY
SIRHAMY / ibm_graphdb_vertex_creation_example.json
Created July 25, 2016 18:36
Example of JSON to create a new vertex in IBM's GraphDB
{ "label": "user",
"properties":
{
"name":"SIRHAMY",
"email": "sirhamy@sirhamy.com"
}
}
@SIRHAMY
SIRHAMY / ibm_graphdb_gremlin_example.json
Created July 25, 2016 18:32
Example JSON object that can be used to run gremlin script on IBM's GraphDB
{
"gremlin": "def g = graph.traversal(); g.V(4208)"
}