This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var file_path = "/Users/stevezelaznik/src/gnar/aarp-foundation-pta/app/javascript/src/tools/mn-2023/tables/renters_refund_table.csv" | |
var fs = require("fs"); | |
var Papa = require("papaparse"); | |
var sourceText = fs.readFileSync(file_path).toString(); | |
function hydrateType(types, cell, column_index) { | |
const type = typeof cell | |
switch(type) { | |
case 'string': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext, createContext } from "react"; | |
const NestedHeaderContext = createContext<number>(2); | |
type HxCallback = (component: typeof Hx) => React.ReactNode; | |
type HxProps = { | |
children: React.ReactNode; | |
[x: string]: any; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function equalize_widths(table) { | |
var col_count = [...table.querySelectorAll('thead > tr > th')].length; | |
var total_table_width = 0; | |
for (let i=0; i<col_count; i++) { | |
let elements = [...table.querySelectorAll(`thead > tr > th:nth-child(${i+1}), tbody > tr > td:nth-child(${i+1})`)]; | |
let max_column_width = elements.reduce(function(acc, el) { | |
let computedStyle = window.getComputedStyle(el); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec/expectations' | |
=begin | |
# Example use case in a test suite: | |
# Make sure to have defined a factory in factory-bot for "job_application" | |
describe JobApplication, type: :model do | |
it { is_expected.to enforce_uniqueness_of(:uuid) } | |
end | |
=end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
# THIS IS A WORK IN PROGRESS | |
# NOT READY FOR PRODUCTION | |
# YOU'VE BEEN WARNED | |
class PostgresEncryptionSerializer | |
VALID_DATA_PATTERN = /\\x([0-9a-fA-F]{4})+/ | |
def self.load(binary_encrypted_data) | |
if binary_encrypted_data.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function find_existing_files() { | |
# This prevents me from shooting myself in the foot when I'm | |
# grepping for a pattern and forget to include "-l" before | |
# using xargs to open the files in sublime | |
for filepath in $@; do | |
if [ -f $filepath ]; then | |
echo $filepath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "@hotwired/stimulus" | |
// Connects to data-controller="active-link" | |
export default class extends Controller { | |
static values = { | |
activeClass: { type: String, default: 'active' } | |
} | |
connect() { | |
this._syncActive(document.location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections.abc import MutableSet | |
class SingleEntrySet(MutableSet): | |
"""\ | |
I created this class for debugging. It works like a regular set but it | |
raises an error if it tries to add an item that is already present. | |
""" | |
__slots__ = ("__items",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class memoized_property: | |
def __init__(self, method): | |
self.__method = method | |
prefix = method.__qualname__.rsplit(".")[0].replace(".", "__") | |
self.__name = '_%s__%s' % (prefix, method.__name__) | |
def __get__(self, obj, objtype=None): | |
if obj is None: | |
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import csv | |
import io | |
import json | |
import pdb | |
import sys | |
from collections import OrderedDict | |
NewerOlder