Skip to content

Instantly share code, notes, and snippets.

@ivanyu
ivanyu / LogFormatter.java
Last active January 28, 2020 16:11
ZooKeeper transaction log decoder
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@ivanyu
ivanyu / build.sbt
Created January 17, 2015 17:15
Simple build.sbt with Akka
name := "project-name"
version := "1.0"
scalaVersion := "2.11.4"
resolvers ++= Seq(
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
@ivanyu
ivanyu / matrix_fib.py
Last active January 18, 2023 20:33
Fibonacci number in O( log N ) operations.
import time
import random
class MatrixFibonacci:
A = [[1, 1],
[1, 0]]
def __init__(self):
self.__memo = {}
class UnicodeWriter:
"""A CSV writer which will write rows to CSV file "f",
which is encoded in the given encoding.
The standard `csv` module isn't able to handle Unicode. We can "cheat" it.
Firstly, we encode it into plain UTF-8 byte string and write into the
memory buffer (`StringIO`). Then we convert created CSV data back into
Unicode and write to the target file.
"""
@ivanyu
ivanyu / pysmtpd.sh
Last active December 14, 2015 08:09
Run Python debugging SMTP server
python -m smtpd -n -c DebuggingServer localhost:1025