Skip to content

Instantly share code, notes, and snippets.

@fillet54
fillet54 / machine.js
Last active June 6, 2020 07:22
Passthrough Without A Timeout Event
const MAX_RETRIES = 3
const retryExpired = (context, event) => context.retries >= MAX_RETRIES
const passthroughMachine = Machine({
id: 'passthrough',
initial: 'send_request',
context: {
retries: 0
},
states: {
import React, { useState } from "react";
import classNames from "classnames";
const getRoots = (data) => {
return Object.values(data).filter(node => node.isRoot === true)
}
const getChildNodes = (node, data) => {
if (!node.children) return [];
return node.children.map(path => data[path])
@fillet54
fillet54 / fast-git.sh
Last active July 6, 2022 07:24
Attempt for fast git status prompt for windows. Minimal use of git and subshells
fast_git_ps1()
{
local gitdir git_ps1
# Find git directory
local dir="$PWD"
while [ -n "$dir" ]; do
if [ -e "$dir/.git" ]; then
if [ ! -d "$dir/.git" ]; then
@fillet54
fillet54 / pe_image.py
Created October 10, 2022 06:47
Simple PE image format parsing
import struct
# Type to struct type
SECTION_SHORT_NAME = "8s"
DWORD = "I"
WORD = "H"
BYTE = "B"
# Image directory indices
IMAGE_DIRECTORY_ENTRY_EXPORT = 0 # Export Directory
from formatting import format_field
examples = [
('Simple Hex BCD', 0x12Ab, '04X', '{0-4}'),
('With Prefix', 0x12Ab, '04X', 'Version: {0-4}'),
('Constant String', 0x12Ab, '04X', 'Some note about this'),
('Add separators', 0x12Ab, '04X', '{0-2}.{2-4}'),
('Swap Words', 0x12Ab, '04X', '{2-4}.{0-2}'),
import os
import hashlib
import fnmatch
from pathlib import Path
from collections import namedtuple
def calculate_sha1(path, chunksize=8192):
"""Calculate sha1 hexdigest of file