Skip to content

Instantly share code, notes, and snippets.

@irmen
irmen / generators.ipynb
Last active November 7, 2021 18:29
generators example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@irmen
irmen / cube3d.asm
Created January 28, 2019 22:28
cube3d.p8 generated assembly
start .proc
; src line: 24 cube3d.p8
lda #<$21
ldy #>$21
sta start_rz
sty start_rz+1
start_prog8_anonymous1___back
; src line: 26 cube3d.p8
@irmen
irmen / unicycle.py
Created February 7, 2018 21:25
import graph plotter
import argparse
import os
import ast
import graphviz
def gather_files(path, recurse=True):
print("Gather source files ({0})...".format("recursively" if recurse else "nonrecursively"))
if not os.path.isfile(os.path.join(path, "__init__.py")):
raise ValueError("The path you provided was not the root of a package (there's no __init__.py)")
@irmen
irmen / numpadmadness.py
Last active August 24, 2017 19:54
Tkinter numeric keypad events madness
import sys
import time
import tkinter
class NumpadmadnessWindow(tkinter.Tk):
def __init__(self):
super().__init__()
l = tkinter.Label(self, text="Click here and type keys on your Numpad.\nObserve event codes on standard output.")
l.pack(padx=50, pady=50)
@irmen
irmen / # pypy - 2016-11-15_20-50-35.txt
Created November 15, 2016 19:55
pypy on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for pypy on macOS 10.11.6
Build date: 2016-11-15 20:50:35
@irmen
irmen / testmandel.py
Created September 20, 2016 20:00
complex number calculation test program
from __future__ import print_function, division
import time
import sys
if sys.version_info < (3, 0):
range = xrange
def mandel():
res_x = 100
res_y = 100
@irmen
irmen / rekenbox.fsx
Created July 31, 2014 23:17
rekenbox fsharp
#light
#r @"..\packages\MathNet.Numerics.FSharp.3.1.0\lib\net40\MathNet.Numerics.FSharp.dll"
module IntegerDemo =
let reeks = [20..50]
let kwadraten = [ for x in reeks -> (x, x*x)]
let derdemacht x =
x*x*x
@irmen
irmen / audit.py
Created July 4, 2014 17:07
Auditing import hook to see who is importing what and when
"""
this code prints something like this:
Hello I'm about to import a module.
2014-07-04 19:01:12,321 [irmen@Neptune] importing /cgi
2014-07-04 19:01:12,323 [irmen@Neptune] importing /urlparse
2014-07-04 19:01:12,328 [irmen@Neptune] importing /mimetools
[... and some more modules...]
Bye.
# server:
import Pyro4
Pyro4.config.COMMTIMEOUT = 5.0 # seconds
class TestDisconnect(object):
def ping(self):
"""ping method used to check connection, no-op"""
pass
def echo(self, arg):
import collections
words = open("linuxwords.txt").read().split()
words = [w.lower() for w in words if w.isalpha()]
mnem = {
2: "ABC",
3: "DEF",
4: "GHI",
5: "JKL",