Skip to content

Instantly share code, notes, and snippets.

View netrusov's full-sized avatar
👽

Alexander netrusov

👽
View GitHub Profile
@pmarreck
pmarreck / email_header_parser.rb
Last active August 4, 2023 09:36
Superfast email header parser in Ruby, using regular expressions. This solution is 250 times faster than using the "Mail" gem. :O Time with my regex: 0.063965 seconds Time with Mail gem: 16.327161 seconds Note that I included some encoding-fix code. YMMV and encoding fixes are all debatable or fail in some corner case.
require 'ap'
require 'mail'
# String monkeypatch
# This is one of many possible "encoding problem" solutions. It's actually an intractable problem
# but you'd have to read "Gödel, Escher, Bach" to understand why...
class String
def clean_utf8
# self.force_encoding("UTF-8").encode("UTF-16BE", :invalid=>:replace, :replace=>"?").encode("UTF-8")
unpack('C*').pack('U*') if !valid_encoding?
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active October 17, 2025 03:36
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname