Skip to content

Instantly share code, notes, and snippets.

import string
import sys
import requests
import whois
from nltk import tokenize
BOOKFILE = sys.argv[1]
OUTPUTFILE = BOOKFILE + '.possible-domains.txt'
@ruphy
ruphy / GPT3.js
Last active November 2, 2023 23:41
GPT3() function for Google Sheets
// SPDX-License-Identifier: MIT
//
// This code will add a GPT3() function in your Google Sheets
// This code is originally inspired from https://twitter.com/fabianstelzer/status/1572926883179778050
// To use it, insert your API key below, open Google Sheets -> Extensions -> Apps Script -> Copy & Paste this -> Save
//
// Usage: =GPT3(prompt, max_tokens (default=15), model (default=davinci))
// Example usage: =GPT3("Once upon a time,", 1000, "davinci")
var API_KEY = "your-API-key";
library(tidycensus)
library(tidyverse)
us_county_density <- get_decennial(
geography = "county",
variables = "P1_001N",
year = 2020,
geometry = TRUE,
keep_geo_vars = TRUE
)
@thomaswilburn
thomaswilburn / tcaer.md
Created May 9, 2022 15:23
React but make it imperative

What if React was imperative instead of being functional?

When you write JSX, it compiles down to nested calls to createElement() (or the equivalent, I don't know if that's still the function React uses). Because this ends up being a single recursive function call, you can only use value expressions inside the code--that's why you have to map() when you loop, and you have to use ternaries instead of actual conditional statements.

Over time, the React team's thinking about architecture has clearly shifted a lot, to the point now where hook functions create implicit, hidden state that's preserved in the order of the function calls. What if JSX worked this way? What if when you wrote a template, instead of a single function call with nested expressions, it used imperative, IMGUI-like function calls instead? In that case, the raw code might look something like this:

template(html => {
  var { footer, a, button, text, div, ul, li } = html;
  div`.outer`;
@tennantje
tennantje / convert_olm_to_eml.py
Last active December 21, 2023 18:21
Convert Outlook for Mac (OLM) to EML files as PST conversion tools are expensive
# MIT LICENSE
# Copyright 2021 Jeremy Tennant
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWA
@iTrooz
iTrooz / main.py
Last active January 5, 2024 00:57
reMarkable 2 splash.dat converter
#!/usr/bin/env python3
"""
This script aims at converting an image to the custom format used by Remarkable 2
After running this script, move the output "splash.dat" file to /var/lib/uboot in the rM2 device
I tried this with PNG images but I guess other formats should work too since I use PIL
Syntax: ./main.py <file> [-x xOffset] [-y yOffset]
(-x and -y are the offsets of the image on the screen. If not set, the image will be centered on the screen)
Input images may need to be rotated 90 degrees before converting them
Licence: MPL 2.0
"""
@mildsunrise
mildsunrise / blobs.py
Last active May 16, 2024 07:22
Logic to work with Android KeyMaster blobs and Vold
#!/usr/bin/env python3
'''
keymaster blob logic.
Offers:
- low-level blob encoding and decoding
- loading softkeymaster blobs
- performing cryptographic operations (emulating KeyMaster) on a loaded blob
- CLI tool for parsing softkeymaster blobs and performing operations with them
@rdmurphy
rdmurphy / TOOLS.md
Last active April 19, 2022 18:07
Ryan's favorite command line tools

My favorite command line tools (2021-09-09)

I wrote this in response to Gurman's tweet. I remember answering in News Nerdery, but it was sadly lost to the void. :(

The CSV Swiss-army knife that trumps all others. Written in Rust, so it's absurdly fast in a way that's still kind of shocking.

@hervenivon
hervenivon / contacts-extractor.py
Created June 25, 2021 12:35
Outlook Mac `olm` archive contact extractor
#!/usr/bin/env python
import re
import sys
import xml.etree.ElementTree as ET
from collections import Counter
from zipfile import ZipFile
messageRe = re.compile('.*message_[0-9]{5}\.xml')
@slifty
slifty / git-commit-edit-alias.md
Last active December 12, 2023 17:42
Git alias to edit a commit

A git alias to edit the content of a commit

This git alias allows you to remove specific changes from a past commit / from git history and place those changes into your working directory, outside of your git history.

For example, maybe a code reviewer has identified a few files or lines that belong in their own commit or pull request. This helps you do git commit surgery on specific commits without needing to manually re-play.

git edit {commithash}

(e.g. git edit HEAD would edit the most recent commit or git edit c52b7bfe12c2f6082a69ea339eeec95a20532fa5 would edit a specific commit)