Skip to content

Instantly share code, notes, and snippets.

@romiras
romiras / concurrent_workers_demo.rb
Last active November 4, 2021 08:06
Workers with Concurrent::Future in Ruby
require 'concurrent'
require 'benchmark'
max = 20 # number of tasks to process
n_workers = 4 # number of concurrent workers
results = [] #
lambda = -> (iter, i) { results << ('%04d' % i); d = rand(0.005)+0.001; puts("Iteration #{iter}. sleep %.3f" % d); sleep(d) }
workers = Array.new(n_workers, lambda)
iter = 0
@romiras
romiras / Gemfile
Created May 8, 2019 07:31
EventMachine async URL fetcher
source "https://rubygems.org"
gem 'eventmachine'
gem 'em-http-request'
@romiras
romiras / dictionary-gnu-sort-bd.txt
Last active January 1, 2020 10:56 — forked from klauspost/dictionary-sorted.txt
Brotli dictionary - printed escaped - sorted with "sort -bd" (with dictionary order, ignoring blanks), a tool from GNU coreutils
"<!--"
"><!--"
"||[];"
"--><!--"
"--></"
"----"
"!--<"
"//--></"
"//-->"
"...</"
@romiras
romiras / Readme.md
Last active June 9, 2020 21:05
EBK backup extraction scripts

How to use

Assumed you have files with extension .ebk stored by Kies.

Prerequisites

Install Ruby 2.3 or later

Example for running in Bash terminal. Linux is not mandatory for running Ruby program.

@romiras
romiras / rezip.py
Created January 14, 2017 12:43
ReZip - tool for recompression Zip files, used to efficiently store in SCM
#!/usr/bin/env python3
"""Read zip format file from stdin and write new zip to stdout.
With the --store option the output will be an uncompressed zip.
Uncompressed files are stored more efficiently in VCS.
Example:
python rezip.py --store < file.docx > file.flat.docx
Based on https://github.com/costerwi/rezip
@romiras
romiras / simple_fuzzy_match.rb
Created December 30, 2016 12:54
Simple function for fuzzy string match
require 'active_support/all' # mb_chars
def simple_fuzzy_match(s1, s2)
levenshtein_distance( normalize_str(s1), normalize_str(s2) ) < 2
end
def normalize_str(s)
s.
mb_chars. # convert to multibyte string (ActiveSupport::Multibyte::Chars) - required in Ruby version below 2.4
downcase. # lower case for all characters
@romiras
romiras / Makefile.win
Created January 13, 2016 13:16
TestDLL.exe - console program for testing DLL dependencies. Usage: testdll.exe libcairo-2.dll
# Project: TestDLL
# Makefile created by Dev-C++ 5.5.1
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"C:/Program Files/Development/Dev-Cpp/MinGW32/lib" -L"C:/Program Files/Development/Dev-Cpp/MinGW32/mingw32/lib" -static-libstdc++ -static-libgcc
INCS = -I"C:/Program Files/Development/Dev-Cpp/MinGW32/include"
@romiras
romiras / my.conf
Created October 20, 2015 09:06
Redmine, DokuWiki, ownCloud - powered by NGINX with PHP5-FPM & Passenger
upstream php-handler {
server 127.0.0.1:9000;
# server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name example.com localhost;
root /var/www;
@romiras
romiras / linux-bak-full.sh
Created July 16, 2015 08:29
Full system backup with dar
#!/bin/bash
# Full system backup with dar. Refer to http://dar.linux.free.fr/doc/Tutorial.html
## Configuration
# path to store dar backup files
Storage=/mnt/disk/backup/Linux
# name of system
SysName=Ubuntu_`. /etc/os-release; echo ${VERSION_ID/*, /}`
@romiras
romiras / gpipeview.c
Created May 11, 2015 14:58
GTK+ pipe viewer
/*
Simple GTK+ pipe viewer
Contributors: Romiras
Based on paned.c
LICENSE: GNU GPLv3
*/
#include <stdio.h>
#include <unistd.h>
#include <gtk/gtk.h>