Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Averbach zevaverbach

View GitHub Profile
@zevaverbach
zevaverbach / plugins_to_try.txt
Last active Dec 16, 2021
vim plugins to try (from this talk https://www.youtube.com/watch?v=434tljD-5C8 by Jess Archer)
View plugins_to_try.txt
airline.vim
arduino.vim
coc.vim
commentary.vim
context-commentstring.vim
dispatch.vim
dracula.vim
editorconfig.vim
eunuch.vim
exchange.vim
@zevaverbach
zevaverbach / copy_urls_from_reminders.kmmacros
Last active Dec 1, 2021
A Keyboard Maestro macro to copy the URLs from an Apple Reminders list to a text file.
View copy_urls_from_reminders.kmmacros
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>CreationDate</key>
<real>657286652.24957097</real>
<key>Macros</key>
@zevaverbach
zevaverbach / partition.py
Created Nov 8, 2021
Partition a list in Python 3.7
View partition.py
from typing import Dict, Tuple, Any, List
def make_tuple_partitions(
unique_values: List[Any], num_partitions: int
) -> Dict[Tuple[int, int], Tuple[Any, Any]]:
"""
Given a list of values, return a dictionary with (the_index, the_index + 1) as the keys
and (chunk_start_value, chunk_end_value) as the values such that the chunks are equal
or close to equal in size.
@zevaverbach
zevaverbach / convert_sqlalchemy_model_to_table_str.py
Created Oct 27, 2021
Some spaghetti to produce a SQLAlchemy Table *string* from a SQLA model.
View convert_sqlalchemy_model_to_table_str.py
import re
from black import format_str, FileMode
def convert_tablemapping_to_table_object(model) -> str:
schema_name = model.__table_args__["schema"].lower()
table_repr = repr(model.__table__)
header_str, *columns = table_repr.split("Column(")
# from https://stackoverflow.com/a/4145486/4386191
@zevaverbach
zevaverbach / battlesnake_typed_dicts.py
Created Oct 14, 2021
TypedDicts for Battlesnake /move endpoint
View battlesnake_typed_dicts.py
from dataclasses import dataclass
from types import TypedDict, Annotated, Literal
class Squad(TypedDict):
allowBodyCollisions: bool
sharedElimination: bool
sharedHealth: bool
sharedLength: bool
View gist:02c6a4d4675ca614cc9e1f699559a05c
// Copyright 2013 Soundslice LLC. License: BSD.
/* HTML example: ****************
<figure class="vid">
<video preload>
<source src="/videos/help/playhead.mp4" type="video/mp4">
<source src="/videos/help/playhead.webm" type="video/webm">
</video>
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p>
@zevaverbach
zevaverbach / imapflow.d.ts
Created May 16, 2021
ImapFlow Type Declaration File -- not complete
View imapflow.d.ts
declare module "imapflow" {
type SequenceString = string;
export interface FetchQueryObject {
uid?: boolean;
flags?: boolean;
bodyStructure?: boolean;
envelope?: boolean;
internalDate?: boolean;
size?: boolean;
@zevaverbach
zevaverbach / notes.md
Last active Apr 7, 2021
Reading notes from "Software and Systems Security for CompTIA CySA+" on Pluralsight
View notes.md

Software and Systems Security for CompTIA CySA+

Examining the Software Development Lifecycle (SDLC)

  • ignored instructor's advice to set up penetration testing VMs

Phases

Planning

  • the most important phase
  • done by the most senior team members, with input from customers
@zevaverbach
zevaverbach / pre-commit
Created Dec 29, 2020
A Python script and a pre-commit hook that calls it for validating all the HTML files in a directory (recursively) on commit.
View pre-commit
# this goes in your local Git repo at .git/hooks/pre-commit
#!/bin/sh
errors=0
for i in $(find . -type f -name "*.html")
do
printf "$i:\n"
validate $i
exit_status=$?
if [ "${exit_status}" -ne 0 ];
@zevaverbach
zevaverbach / .gitignore
Last active Jun 11, 2020
.gitignore for Python and PyCharm
View .gitignore
.idea/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so