Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Averbach zevaverbach

View GitHub Profile
@zevaverbach
zevaverbach / gist:0f3668cd2e3f42c6d2f152b97471461e
Created February 5, 2023 10:09
wp 6.1.1 response to POST
View gist:0f3668cd2e3f42c6d2f152b97471461e
{"id":5,"date":"2023-02-05T10:05:40","date_gmt":"2023-02-05T10:05:40","guid":{"rendered":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api","raw":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api"},"modified":"2023-02-05T10:05:40","modified_gmt":"2023-02-05T10:05:40","password":"","slug":"test-wp-api","status":"publish","type":"post","link":"https:\/\/myxomycete-principa.000webhostapp.com\/2023\/02\/test-wp-api","title":{"raw":"Test WP-API","rendered":"Test WP-API"},"content":{"raw":"This is my first post created using restAPI","rendered":"<p>This is my first post created using restAPI<\/p>\n","protected":false,"block_version":0},"excerpt":{"raw":"","rendered":"<p>This is my first post created using restAPI<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"permalink_template":"https:\/\/myxomycete-princip
@zevaverbach
zevaverbach / get_cs61a_vids.sh
Last active January 23, 2023 20:59
Download all the CS61A videos (UC Berkeley 2011)
View get_cs61a_vids.sh
# The lecture listing is here: https://archive.org/details/ucberkeley-webcast-PL3E89002AA9B9879E?sort=titleSorter
# NOTE: the URLs were obtained by running this in the JS console on each of the lecture pages:
# > copy(document.getElementsByClassName("item-download-options")[0].children[2].children[1].href)
cat vid_urls.txt | while read line; do echo $line | wget $line -O lecture_$(sed -E 's/.*Lecture%20([0-9]+).*/\1/').mp4; done
@zevaverbach
zevaverbach / plugins_to_try.txt
Last active December 16, 2021 14:07
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 December 1, 2021 12:17
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 November 8, 2021 11:45
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 October 27, 2021 11:06
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 October 14, 2021 20:16
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 20:12
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 April 7, 2021 15:40
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