Skip to content

Instantly share code, notes, and snippets.

View cad0p's full-sized avatar

Pier Carlo Cadoppi cad0p

  • EMS - Energia e Mobilità Sostenibile
  • Dublin, Ireland
  • 06:36 (UTC)
View GitHub Profile
@cad0p
cad0p / TextExer-cad0p.agda
Last active March 31, 2022 08:49
A testing suite for Exercise 5: Agda of AFP 2022 at UU
module TestExer-cad0p where
import Exercise
open Exercise
--- PREREQUISITES -----
-- You need to add this line at the top of Exercise.agda :
import json
import matplotlib.pyplot as plt
def plot_polygon(coord):
xs, ys = zip(*coord) # create lists of x and y values
plt.figure()
plt.plot(xs, ys)
plt.show()
@cad0p
cad0p / memoize_python_recursion.md
Created April 11, 2021 23:11
Python Decorator to avoid recursion limit on recursive functions

I built a decorator with the memoize idea: it will take care of your system recursion limit, and avoid it by splitting calculation in batches that are as large as the system can offer. It will also of course remember all the values for easy retrieval

Short working version:

import sys
from math import floor, ceil

def memoize(f):
    memo = [None]
@cad0p
cad0p / Text Substitutions plist to csv.py
Created March 14, 2021 04:27
How to convert mac text substitutions from plist to csv for export to apps like text expander and atext
with open('./TextSubstitutions.plist', 'rb') as _plist:
with open('./TextSubstitutions.csv', 'w') as _csv:
plistfile = plistlib.load(_plist)
csvfile = csv.DictWriter(_csv, fieldnames=['shortcut', 'phrase'])
csvfile.writeheader()
for data in plistfile:
csvfile.writerow(data)