Skip to content

Instantly share code, notes, and snippets.

View aholmes's full-sized avatar

Aaron Holmes aholmes

View GitHub Profile
// ==UserScript==
// @name Remove Custom Subreddit Themes
// @namespace http://aaronholmes.net/
// @version 0.1
// @description Remove custom subreddit themes from every subreddit
// @author Aaron Holmes
// @match https://www.reddit.com/r/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
@aholmes
aholmes / Program.cs
Last active February 29, 2016 23:43
Comparison of FP and OOP approaches to benchmark a simple operation. https://www.reddit.com/r/javascript/comments/48alyu/functional_programming_for_javascript_people/d0inhqq
using System;
using System.Diagnostics;
using System.Linq;
namespace ConsoleApplication3
{
class Program
{
static int add(int x , int y)
{
@aholmes
aholmes / Async_Sync_Performance_comparison.cs
Created July 15, 2016 16:00
A comparison of performance between async/sync in C#
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
namespace AsyncPerf
{
class Program
{
const int MAXRUNS = 10000000;
@aholmes
aholmes / robinhood-cost-basis.js
Last active March 27, 2021 21:42
Get your cost basis from you Robinhood order history page at https://robinhood.com/account/history?type=orders
/*
Scroll all the way down on https://robinhood.com/account/history?type=orders
Paste this into the dev console
`totals` holds your overall cost basis for each position you've held
Do note that this is just a quick bang out and likely isn't 100% correct
*/
const headers = Array.from(document.querySelectorAll('[data-testid="rh-ExpandableItem-buttonContent"]')).map(e => e.querySelectorAll('h3, h3 ~ span'))
const action_regex = /(.+?) (Market|(Stop )?Limit|(\$\d+ (Call|Put) (\d+\/\d+\/\d+))) (Buy|Sell)/
@aholmes
aholmes / flask_cookie.py
Last active January 22, 2022 00:38 — forked from babldev/decode_flask_cookie.py
Decrypt and encrypt Flask session cookies
@aholmes
aholmes / main.py
Created January 26, 2022 21:48
Behavior of @register in Python
import os
import threading
from multiprocessing import Pool
from atexit import register
from sys import exit
from typing import Union
@register
def term():
print("TERM!")
@aholmes
aholmes / random_bitmap.py
Last active April 12, 2022 16:59
Generate a random black-and-white bitmap.
from math import trunc
from struct import pack
from typing import List
from random import random
def main():
# some hard-coded image attributes
# the width and height are 50 pixels
img_width = 50
@aholmes
aholmes / parsertiming.linq
Created October 11, 2022 00:22
Roslyn parser timing
void Main()
{
var file = @"path to file";
var sw = new Stopwatch();
sw.Start();
var fileContent = File.ReadAllText(file);
sw.Stop();
Console.WriteLine($"Time to read file: {sw.Elapsed.TotalMilliseconds}ms");
const int iterations = 10000;
import cProfile
from functools import wraps
from logging import Logger
from random import choice
from string import ascii_letters
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any, Callable
@aholmes
aholmes / consoleWrapper.cs
Created November 22, 2022 16:35
Wrapper for System.Console in C#
namespace aholmes.Writer
{
/// <summary>
/// Wraps System.Console
/// </summary>
public class ConsoleWrapper : IConsole
{
/// <inheritdoc/>
public void Write(string value) => Console.Write(value);
/// <inheritdoc/>