Skip to content

Instantly share code, notes, and snippets.

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
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}'),
@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
@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
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 / 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: {
@fillet54
fillet54 / machine.js
Last active June 6, 2020 18:03
Passthrough as implemented
const MAX_RETRIES = 3
const retryExpired = (context, event) => context.retries >= MAX_RETRIES
const passthroughMachine = Machine({
id: 'passthrough',
initial: 'send_request',
context: {
retries: 0
},
#!/usr/bin/python
import sys, getopt, time, re, random, os, socket
int_len = len(str(0xFFFFFFFFFFFFFFFF))
def run_client(host, port):
count = 0
order = 0
dropped = 0
@fillet54
fillet54 / bitbucket-cloud-menu.user.js
Created January 24, 2016 20:15
Userscript to add links to Bitbucket Cloud's app switcher menu to make it consistent with other Atlassian Products
// ==UserScript==
// @name Bitbucket Cloud Menu
// @namespace http://philgomez.com
// @include https://bitbucket.org/*
// @version 1.2
// ==/UserScript==
//
function runWithJQuery(callback) {
var script = document.createElement("script");
@fillet54
fillet54 / sample.groovy
Created January 10, 2016 10:14
Mapping CSV to Other Formats
def sampleSpecCSV = '''field name, description, units, range
Item1, The first item, feet, 100..200
Item2, The second item, meters, 1000.000..2000.000
Item3, Enumeration field, enum, MANUAL:AUTOMATIC
Item4, Some string, string(10),
'''
def fieldMappingCSV = '''field name, path, units, enum mapping
Item1, field1, feet,
Item2, nested1.field1, feet,