Skip to content

Instantly share code, notes, and snippets.

nuno-andre /
Created Feb 22, 2021
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
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
from pathlib import Path
import json
import os
# not project dirs, they only belong to the metarepo
nuno-andre /
Created Sep 29, 2019
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 / export.ps1
Last active Jun 26, 2020
Import scoop applications
View export.ps1
# 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 ( on keybase.
  • I have a public key ASBIskuCwqylesTbmSO0LQw7_SEE34onVHbpQGoCMzV9uAo

To claim this, I am signing this object:

nuno-andre / Identifier.cs
Last active Nov 17, 2018 — forked from FabienDehopre/Identifier.cs
Validate C# identifier name
View Identifier.cs
using System;
using System.Linq;
using System.Text.RegularExpressions;
public static class IdentifierExtensions
// definition of a valid C# identifier:
private const string FORMATTING_CHARACTER = @"\p{Cf}";
private const string CONNECTING_CHARACTER = @"\p{Pc}";
private const string DECIMAL_DIGIT_CHARACTER = @"\p{Nd}";
nuno-andre /
Created Nov 16, 2017
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 ='http://localhost:8000/', data=packb(data), headers=headers_msgpack)