Skip to content

Instantly share code, notes, and snippets.

@nuno-andre
nuno-andre / pronunciation.md
Last active October 18, 2022 11:34
How to pronounce...
term [IPA][I] [respelling][r] notes
[ASIC][asic] /ˈeɪsɪk/ [source][asic]
[Bash][B] /bæʃ/ bash [source][B-1]
[CAPTCHA][cap] /kæp.tʃə/ kap-TCHA [source][cap]
[cout][c] see-out [✓ source][c-1]
[char][ch] /tʃɑr/ tchar [source][ch-1]
[deque][dq] /:dek/ deck
[etcd][e] /ˈɛtsiːdiː/ ET-see-dee [✓ source][e-1]
[fsck][f] fisk [✓ source][f-1], [alt][f-2]
@nuno-andre
nuno-andre / tld_url_parse.py
Created February 22, 2021 11:44
Retrieve a URL's eTLD (effective top-level domain) and its operator from the Public Suffix List
"""
Retrieve a URL's eTLD (effective top-level domain) and its operator
from the Public Suffix List
https://wiki.mozilla.org/Public_Suffix_List
"""
from functools import cached_property
from urllib.parse import urlparse
from typing import Optional
from io import StringIO
#!/usr/bin/env python3
"""
.code-workspace generator
https://github.com/microsoft/vscode/issues/45177#issuecomment-528254048
"""
from pathlib import Path
import json
import os
# not project dirs, they only belong to the metarepo
@nuno-andre
nuno-andre / heidi_decode.py
Created September 29, 2019 21:31
Decode HeidiSQL hashed passwords
def heidi_decode(enc):
enc, shift = enc[:-1], int(enc[-1])
return ''.join(chr(int(enc[i:i+2], 16) - shift)
for i in range(0, len(enc), 2))
@nuno-andre
nuno-andre / export.ps1
Last active October 3, 2023 13:24
Import scoop applications
# export applications
scoop export | sls '([A-Za-z0-9\-\_]+)' |% {
$_.matches.groups[1].value } > apps.txt
# export used buckets
$buckets = scoop export | sls '\[([A-Za-z0-9\-\_]+)\]' |% {
$_.matches.groups[1].value } | select -unique
<# or all installed buckets
$buckets = scoop bucket list
"""
Extract block and inline comments, docstrings and
no-op'd string literals from Python code.
"""
from tokenize import tok_name, tokenize, TokenInfo
import itertools
import ast
TokenInfo.is_type = lambda t, tok_type: tok_name[t.type] == tok_type

Keybase proof

I hereby claim:

  • I am nuno-andre on github.
  • I am nunoandre (https://keybase.io/nunoandre) on keybase.
  • I have a public key ASBIskuCwqylesTbmSO0LQw7_SEE34onVHbpQGoCMzV9uAo

To claim this, I am signing this object:

@nuno-andre
nuno-andre / Identifier.cs
Last active November 17, 2018 16:55 — forked from FabienDehopre/Identifier.cs
Validate C# identifier name
using System;
using System.Linq;
using System.Text.RegularExpressions;
public static class IdentifierExtensions
{
// definition of a valid C# identifier: http://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx
private const string FORMATTING_CHARACTER = @"\p{Cf}";
private const string CONNECTING_CHARACTER = @"\p{Pc}";
private const string DECIMAL_DIGIT_CHARACTER = @"\p{Nd}";
@nuno-andre
nuno-andre / client.py
Created November 16, 2017 01:21
Sanic + MessagePack
import requests
from json import dumps, loads
from msgpack import packb, unpackb
data = {'say': 'hello, world!'}
headers_msgpack = {'Content-Type': 'application/msgpack'}
headers_json = {'Content-Type': 'application/json'}
r = requests.post('http://localhost:8000/', data=packb(data), headers=headers_msgpack)
print(unpackb(r.content))