Skip to content

Instantly share code, notes, and snippets.

View aesuli's full-sized avatar
🍕

Andrea Esuli aesuli

🍕
View GitHub Profile
@aesuli
aesuli / pip_guide.md
Last active May 19, 2021 14:09
A step-by-step guide on how to create a pip package
@aesuli
aesuli / repo-reset.md
Created November 23, 2020 15:38 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@aesuli
aesuli / markdown_doc
Created January 24, 2019 15:47 — forked from jiffyclub/markdown_doc
This script turns Markdown into HTML using the Python markdown library and wraps the result in a complete HTML document with default Bootstrap styling so that it's immediately printable. Requires the python libraries jinja2, markdown, and mdx_smartypants.
#!/usr/bin/env python
import argparse
import sys
import jinja2
import markdown
TEMPLATE = """<!DOCTYPE html>
<html>
@aesuli
aesuli / csr_to_pytorch_sparse.py
Last active November 3, 2022 03:06
csr matrix to pytorch sparse
import numpy as np
from scipy.sparse import csr_matrix
import torch
__author__ = 'Andrea Esuli'
Acsr = csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
print('Acsr',Acsr)
Acoo = Acsr.tocoo()
@aesuli
aesuli / gist:22fdca6a49299a8ac8d2dbe6517e5d9e
Created December 1, 2016 22:39 — forked from dsc/gist:3855240
Python argparse Cheatsheet
Arg Name or Optional Flags:
positional : str = "foo"
options : str = "-f", "--foo"
Standard:
action : str = [store], append, store_true, store_false, store_const, append_const, version
default : * = [None]
type : callable = [str], argparse.FileType(mode='wb', bufsize=0)
Exotic:
@aesuli
aesuli / Wikipedia_character_frequencies.txt
Last active December 5, 2022 05:39
Unicode character frequencies computed on dumps of all wikipedia languages
# Unicode character frequencies computed on dumps of all wikipedia languages (288)
# Dumps downloader: https://github.com/aesuli/wikipediatools
# Html converted to plain text: https://github.com/aesuli/wikipedia-extractor
#
# Andrea Esuli
# http://www.esuli.it/
#
#'char'<tab>ord(char)<tab>freq
' ' 32 6098823328
'e' 101 3226481962