Skip to content

Instantly share code, notes, and snippets.

View jarrettmeyer's full-sized avatar

Jarrett Meyer jarrettmeyer

View GitHub Profile
@jarrettmeyer
jarrettmeyer / ObjectToDictionaryHelper.cs
Created January 27, 2011 15:53
C# convert an object to a dictionary of its properties
public static class ObjectToDictionaryHelper
{
public static IDictionary<string, object> ToDictionary(this object source)
{
return source.ToDictionary<object>();
}
public static IDictionary<string, T> ToDictionary<T>(this object source)
{
if (source == null)
@jarrettmeyer
jarrettmeyer / Enable_OLE_Automation.sql
Last active April 6, 2024 07:42
Demonstrates how to send an HTTP request with SQL Server using OLE Automation.
EXEC sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
@jarrettmeyer
jarrettmeyer / insert_data.py
Last active April 8, 2022 07:10
Inserting data into HBase with Python
#!/usr/bin/env python
"""
Insert data into HBase with a Python script.
To create the table, first use the hbase shell. We are going to create a
namespace called "sample_data". The table for this script is called "rfic",
as we will be inserting Request for Information Cases from the City of
Indianapolis.
@jarrettmeyer
jarrettmeyer / world-map.js
Created March 25, 2020 18:37
Creating a world map in D3.js
// Set width, height, and viewBox dimensions.
const width = 1600;
const height = 900;
const viewBox = [0, 0, width, height];
// Create a D3 reference to the SVG element.
const svg = d3.select("#world-map")
.attr("viewBox", `${viewBox}`);
// Download the topology file.
@jarrettmeyer
jarrettmeyer / setup.md
Last active October 5, 2019 19:46
Macbook setup

The very basics

Install Homebrew, and let it manage everything.

brew cask install iterm2
brew cask install google-chrome
@jarrettmeyer
jarrettmeyer / extensions.md
Last active September 24, 2019 11:02
VSCode Extensions
@jarrettmeyer
jarrettmeyer / query.js
Last active March 14, 2019 15:49
Getting URL query values
// Get the parameters after the question mark.
let search = new URLSearchParams(window.location.search);
// Get the token and make sure it matches.
let token = search.get("token");
if (token !== "hello-world") {
// The token did not match what we expected. Get rid of everything out of the body and stop the program.
let body = document.getElementsByTagName("body")[0];
body.style.backgroundColor = "black";
body.innerHTML = '<p style="color: darkred;font-size: 36px;margin: 16px;">Forbidden!</p>';
# Import libraries. You don't really need tidyverse, I just like working with tibbles.
library(RPostgreSQL)
library(tidyverse)
record_count = 1000
min_date = "2015-01-01"
max_date = "2018-12-31"
actions = c("Button click", "Fetch data", "Page load", "Refresh")
users = c("Allen", "Brian", "Charlie", "Dave", "Evan")
// Define constants.
const width = 800;
const height = 500;
const padding = { top: 20, bottom: 20, left: 20, right: 20 };
// Define our SVG canvas.
let svg = d3.select("svg");
let width = +svg.attr("width") - padding.left - padding.right;
let height = +svg.attr("height") - padding.top - padding.bottom;
// Define our constants
const width = 600;
const height = 400;
const borderWidth = 10;
const ballRadius = 10;
const drawInterval = 1;
const speedMultiplier = 1;
// Define the SVG "canvas". This is where we will create our drawing.
let svg = d3.select("#tabletop")