Skip to content

Instantly share code, notes, and snippets.

@0xack13
0xack13 / avl_tree.py
Created December 18, 2020 14:31 — forked from girish3/avl_tree.py
AVL tree implementation in python
#import random, math
outputdebug = False
def debug(msg):
if outputdebug:
print msg
class Node():
def __init__(self, key):
@0xack13
0xack13 / 2pc.py
Created December 22, 2020 15:29 — forked from affo/2pc.py
Implementation of 2 Phase Commit protocol
'''
Implementation of 2 Phase Commit as explained at Wikipedia:
https://en.wikipedia.org/wiki/Two-phase_commit_protocol
'''
import random, logging, time
from threading import Thread, Semaphore, Lock
_fmt = '%(user)s:%(levelname)s >>> %(message)s'
logging.basicConfig(format=_fmt)
LOG = logging.getLogger(__name__)
@0xack13
0xack13 / couchbase-php-2pc-simple.php
Created December 22, 2020 15:44 — forked from daschl/couchbase-php-2pc-simple.php
Simple Couchbase PHP 2PC Implementation
<?php
/**
* Simple two-phase commit for PHP couchbase.
*
* Michael Nitschinger (@daschl, 2012)
*
* Additional Remarks
* ------------------
* - The Couchbase extension makes it currently pretty hard to write easy readable code when dealing with
* CAS (compared to the ruby adapter). This could certainly be improved with closures. I also found that
#!/usr/bin/env python
"""
A script to serialize and deserialize Binary Trees in Python
"""
class Node(object):
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
@0xack13
0xack13 / regex.py
Created December 29, 2020 13:09 — forked from ThiefMaster/regex.py
import sys
class ParseError(ValueError):
pass
class Regex(object):
def __init__(self, tree):
self.tree = tree
@0xack13
0xack13 / Morph.cs
Created January 4, 2021 16:49 — forked from badamczewski/Morph.cs
Text Morphing in WPF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace WPFAnimations
@0xack13
0xack13 / BitSet.cs
Created January 4, 2021 16:49 — forked from badamczewski/BitSet.cs
BloomFilter Source Code
using System;
using System.Collections.Generic;
using System.Text;
namespace ProbabilisticDataStructures.DataStructures
{
public class BitSet
{
private ulong[] bitset;
public int Size { get; private set; }
@0xack13
0xack13 / heap
Created January 5, 2021 02:30 — forked from kolauren/heap
Simple heap with heapsort
// Heapsort with Java
// Heap properties:
// Left child of h[i] is h[2i + 1] (given 2i + 1 < h.size)
// Right child of h[i] is h[2i + 2] (given 2i + 2 < h.size)
// parent of h[i] is h[(i-1)/2] (given i > 0)
public class Heap {
int[] heap;
int size;
@0xack13
0xack13 / DuckInterface.md
Created January 5, 2021 08:18 — forked from byme8/DuckInterface.md
DuckInterface

DuckInterface

I was playing with new .Net 5 and the Source Generator lately and got an idea that it is possible to add "duck typing" support to C#. I would say it is purely academic(no one will use it in production I hope), but it is fun stuff so I decided to try.

The nuget package with results you can find here

Nuget

The repository is here: https://github.com/byme8/DuckInterface

@0xack13
0xack13 / DuckInterface.md
Created January 5, 2021 08:18 — forked from byme8/DuckInterface.md
DuckInterface

DuckInterface

I was playing with new .Net 5 and the Source Generator lately and got an idea that it is possible to add "duck typing" support to C#. I would say it is purely academic(no one will use it in production I hope), but it is fun stuff so I decided to try.

The nuget package with results you can find here

Nuget

The repository is here: https://github.com/byme8/DuckInterface