Skip to content

Instantly share code, notes, and snippets.

@Gribouillis
Gribouillis / pycdump.py
Created November 16, 2021 19:56 — forked from anonymous/pycdump.py
Dump .pyc file (Python 3.5 version)
#
# read a .pyc file and pretty-print it
#
# copied from http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
# and updated to Python 3.5 (Nov 10th 2015)
@Gribouillis
Gribouillis / lace.py
Created December 28, 2020 12:57
Draw random squares in a rectangle
from collections import namedtuple
from random import randrange
Point = namedtuple('Point', 'x y')
Part = namedtuple('Part', 'inf sup subpart area')
def mincoord(point, other):
return Point(min(point.x, other.x), min(point.y, other.y))
def maxcoord(point, other):
@Gribouillis
Gribouillis / oocollage.py
Created July 3, 2020 20:43
Two functions to glue python objects together
#!/usr/bin/env python
# -*-coding: utf8-*-
# Terms of the MIT license, which apply to this software
# ========================================================
# Copyright (C) 2014 Eric Ringeisen
#
# 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,
@Gribouillis
Gribouillis / anyfloat.py
Last active December 17, 2023 21:07
Play with the IEEE 754 format in python
#!/usr/bin/env python
# -*-coding: utf8-*-
# Title: anyfloat.py
# Author: Gribouillis for the python forum at www.daniweb.com
# Created: 2012-05-02 06:46:42.708131 (isoformat date)
# License: Public Domain
# Use this code freely.
"""Conversion module between floating point representations.
@Gribouillis
Gribouillis / spreadsheet_to_dict.py
Last active December 29, 2021 22:11
Spreadsheet to dictionary
from collections import namedtuple
import pathlib
import pickle
import subprocess as sp
import tempfile
__version__ = '2019.01.16.2'
__all__ = ['spreadsheet_to_dict',]
WorksheetKey = namedtuple('WorksheetKey', "index name")
@Gribouillis
Gribouillis / slicer.py
Created December 16, 2018 21:43
Attempt of a DSL to extract parts from several files
from collections import deque
import io
import re
import sys
__version__ = '0.0.1'
def noop(arg):
pass
@Gribouillis
Gribouillis / inspectsqlite.py
Created December 5, 2018 13:25
print the structure of an sqlite database from python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Python 2 and 3
Created on Wed Jan 29 18:40:31 2014
name: inspectsqlite.py
@author: Gribouillis for the python forum at www.daniweb.com
@license: Public Domain
Use this code freely
"""
"""
History:
2018.11.25.19: argument path to as_dict(). New methods from_fs() from_dir()
2018.11.25 : bugfix in 'r' mode of openbin.
2018.10.01 : initial version
"""
import fs
import fs.base
import fs.errors
import fs.osfs
@Gribouillis
Gribouillis / umitconsole.py
Created February 4, 2018 20:14
Python 2 console in pygtk from the umit project (old)
#!/usr/bin/env python
#------------------------------------------------------------------------------
#
# Copyright (c) 1998 James Henstridge, 2006 Nicolas Rougier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.