Skip to content

Instantly share code, notes, and snippets.

@afrase
afrase / circle_processor.rb
Created February 2, 2022 17:05
Given a point and radius, generate a polygonal circle
# This class converts a point and a given radius into a polygonal circle.
# The error_distance is a parameter to the number of sides the polygon will have.
# The lower the number, the more sides it will have, and the more accurate the circle.
class CircleProcessor
TO_RADIANS = Math::PI / 180.0
MIN_NUM_SIDES = 4
MAX_NUM_SIDES = 1000
TO_METERS = 6_371_008.7714 # Earth's mean radius in meters.
def initialize(error_distance)
@afrase
afrase / resume.json
Last active September 12, 2023 19:16
{
"basics": {
"name": "Aaron Frase",
"label": "Senior Software Engineer at RVshare",
"image": "https://avatars.githubusercontent.com/u/3135411?v=4",
"email": "afrase91@gmail.com",
"phone": "",
"summary": "Self-taught programmer with a passion for writing clean, readable, and efficient code. Always looking to learn new things and better myself whether it's learning a new design pattern, programming language, or just the latest framework. Driven to wear many programming hats with expertise in creating everything from new applications to programming languages.",
"profiles": [
{
@afrase
afrase / distance_away_report.rb
Last active November 8, 2019 16:48 — forked from matthutchinson/distance_away_report.rb
Ruby script for the find distance between two points using haversine formula
RAD_PER_DEG = 0.017453293
Rmiles = 3956
def haversine_distance(lat1, lon1, lat2, lon2)
dlon = lon2 - lon1
dlat = lat2 - lat1
dlon_rad = dlon * RAD_PER_DEG
dlat_rad = dlat * RAD_PER_DEG

Keybase proof

I hereby claim:

  • I am afrase on github.
  • I am aaronfrase (https://keybase.io/aaronfrase) on keybase.
  • I have a public key whose fingerprint is 4EE0 AFCF 0CFE 0281 BAD7 4E10 252A C9D9 2330 E13C

To claim this, I am signing this object:

@afrase
afrase / latency.markdown
Created October 8, 2016 21:41 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@afrase
afrase / http_server.py
Created May 20, 2016 19:29
Python HTTP server using coroutines
# -*- coding: utf-8 -*-
import threading
from collections import deque
from functools import wraps
from select import select
from socket import socket, AF_INET, SOCK_STREAM
from urllib.request import urlopen
class TaskException(Exception):
#!/bin/bash
FORTUNES_BIN=$(which fortune)
COWSAY_BIN=$(which cowsay)
# on ubuntu you have to have `force_color_prompt=yes' set if you want to see
# all the pretty colors.
LOLCAT_BIN=$(which lolcat)
if [ -z "$FORTUNES_BIN" ] || [ -z "$COWSAY_BIN" ]; then
# just exit normally so we don't screw with the motd
@afrase
afrase / example_fix.java
Last active December 20, 2015 10:19
Coldfusion cfhttp certificate issue with subject alternative names
/**
* Check whether the name in the certificate matches the host
* we're talking to.
*/
private static void checkCert(X509Certificate cert, String host)
throws IOException
{
String name;
try
{