Skip to content

Instantly share code, notes, and snippets.

@friendzis
friendzis / day3-1.py
Last active December 6, 2023 04:53
AoC 2023
import typing, enum
import pprint
class TokenType(enum.Enum):
SYMBOL='symbol'
PART='part'
class Token():
def __init__(self, type: TokenType, position: typing.Union[int, tuple], value: typing.Union[int, str]):
self.type = type

Keybase proof

I hereby claim:

  • I am friendzis on github.
  • I am friendzis (https://keybase.io/friendzis) on keybase.
  • I have a public key whose fingerprint is 8BE7 07C1 DD1A 8D1D 2E04 040F 9824 5812 E5F2 D64E

To claim this, I am signing this object:

@friendzis
friendzis / embed.c
Created June 25, 2015 09:41
C code embedding
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 5; i++)
{
<% int i = 0; printf("%d\t", i); %>
printf("%d\n", i);
}
@friendzis
friendzis / TimePlot.py
Created May 7, 2014 11:19
Simple implementation of TimeAxisItem and test program
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from PySide.QtCore import QTime, QTimer
from collections import deque
t = QTime()
t.start()
data = deque(maxlen=20)
@friendzis
friendzis / textOnPath
Last active August 29, 2015 13:57
Modified textOnPath to center text on path and rotate letter based on path direction
// Based on http://stackoverflow.com/a/19122486/478725
// Text is rotated to be read begin -> end
// Variable width fonts will still be a bit off center
var angle = function(v1, v2) {
ang = Math.atan2(v2.y - v1.y, v2.x - v1.x);
return {
radians: ang,
degrees: ang * 180 / Math.PI
};