Skip to content

Instantly share code, notes, and snippets.

@vovaprog
vovaprog / git-blame-colored.py
Last active January 26, 2024 20:38
git blame colored output. Outputs different authors in different colors. Also colorizes C++ and Python code.
#!/usr/bin/python
import sys
import subprocess
import re
import time
from termcolor import colored
import keyword
import math
@vovaprog
vovaprog / Spinlock.h
Created September 5, 2016 15:06
simple c++ spinlock
#ifndef SIMPLE_SPINLOCK_H
#define SIMPLE_SPINLOCK_H
#include <atomic>
class Spinlock
{
public:
Spinlock()
{
@vovaprog
vovaprog / TransferRingBuffer.h
Last active September 8, 2016 10:51
ring buffer to use with sockets
#ifndef TRANSFER_RING_BUFFER_H
#define TRANSFER_RING_BUFFER_H
class TransferRingBuffer
{
public:
TransferRingBuffer() = default;
TransferRingBuffer(int size): bufSize(size)
{
@vovaprog
vovaprog / open_file_write_exclusive.py
Last active October 28, 2016 08:24
create or open file for exclusive write
import os
import errno
import fcntl
def open_file_write_exclusive(file_name):
"""
If file is available - returns file object.
If file is locked - returns None.
If error occured - throws error.
Truncates opened file.
@vovaprog
vovaprog / git-blame-colored-pygments.py
Created October 28, 2016 15:49
git blame colored output. syntax highlighting with pygments.
#!/usr/bin/python
import sys
import subprocess
import re
import time
from termcolor import colored
import math
import pygments
from pygments.lexers import CppLexer, PythonLexer