Skip to content

Instantly share code, notes, and snippets.

View rbrito's full-sized avatar
☹️
Having (YET another) kidney stone surgery in a few days...

Rogério Brito rbrito

☹️
Having (YET another) kidney stone surgery in a few days...
View GitHub Profile
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@matthieuheitz
matthieuheitz / djvu2pdf.sh
Last active June 12, 2023 12:47
djvu2pdf, a conversion script using ocrodjvu and pdfbeads
#!/bin/bash
# Method found here https://askubuntu.com/a/122604/423332
# Dependencies:
# On ubuntu, you can install ocrodjvu and pdfbeads with:
# sudo apt install ocrodjvu
# gem install pdfbeads
# The path and filename given can only contain ascii characters
/*
* ctx_time Copyright (C) 2018 Matteo Croce <mcroce@redhat.com>
* a tool measure the context switch time in clock cycles
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
@agentcooper
agentcooper / 0.README.md
Last active April 9, 2024 19:27
Telegram chat backup/export

How to use

  1. Login to https://web.telegram.org
  2. Copy-paste contents of telegram-scripts.js into JS console
  3. Run showContacts() to get the list of contacts with ids
  4. Run saveChat(userId) where userId is the id from step 3

Process can take a while, check console for progress. Occasionall FLOOD_WAIT errors are expected. Once done, browser will download the JSON file.

Motivation

@otsaloma
otsaloma / remove-duplicate-subs
Last active June 25, 2017 22:37
Remove duplicate subtitles with aeidon
#!/usr/bin/env python3
import aeidon, sys, time
if len(sys.argv) < 2:
print("Usage: {} SUBTITLE_FILE...".format(__file__))
raise SystemExit(1)
for fname in sys.argv[1:]:
print("{}:".format(fname))
project = aeidon.Project()
project.open_main(fname, "utf_8")
before = len(project.subtitles)
@meagtan
meagtan / galois.c
Last active May 2, 2023 08:53
Quick implementation of Galois fields
/*
* The following is an implementation of the finite field GF(2^8) as bit vectors of length 8, where the nth bit represents the
* coefficient of the nth power of the generator in each element, and the generator satisfies the minimal polynomial
* x^8 + x^4 + x ^3 + x^2 + 1 in the prime field Z_2, in which addition is equivalent to XOR and multiplication to AND.
* The elements of GF(2^8) thus represent polynomials of degree < 8 in the generator x. Addition in this field is simply
* bitwise XOR, but multiplication requires the elimination of powers of x <= 8.
*/
#include <stdio.h>
#include <stdint.h>
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active April 18, 2024 08:54
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@bishboria
bishboria / springer-free-maths-books.md
Last active March 22, 2024 11:19
Springer made a bunch of books available for free, these were the direct links
@vlakoff
vlakoff / convert_lz4_header.php
Last active August 13, 2021 23:17
Convert from Mozilla's LZ4 format to LZ4 v1.3
<?php
/**
* Convert from Mozilla's LZ4 format to LZ4 v1.3
*
* @link https://searchfox.org/mozilla-central/source/toolkit/components/lz4/lz4.js
* @link https://lz4.software.informer.com/1.3/
*
* @param string $input File content in Mozilla's LZ4 format
* @return string File content converted to LZ4 v1.3
@HandyMenny
HandyMenny / zram_combined_benchmark
Last active October 13, 2021 17:05
zram benchmark
~ # /tmp/zramtest3.sh test6 /tmp/ffmpeg-1\:2.6.1-1-x86_64.pkg.tar
zram test6 Sat Apr 4 09:50:06 GMT 2015
comp_algorithm [lzo] lz4 snappy
real 0m 0.20s 0.20s 0.24s avg: 0.214s
real 0m 1.45s 1.42s 1.42s avg: 1.430s
compr_data_size 30504972 30504968 30504947 30504962
comp_algorithm lzo [lz4] snappy