Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@sacreman
sacreman / gist:4453493
Created January 4, 2013 15:32
haproxy config
global
log 127.0.0.1 local2 info
pidfile /var/run/haproxy.pid
stats socket /var/run/haproxy.stat mode 600 level admin
#debug
defaults
mode http
log global
@SIN-777
SIN-777 / mysql_total_memory_usage_calculation.sql
Created June 5, 2012 05:10
mysql total memory usage calculation query
-- copied from: http://mogmet.blog20.fc2.com/blog-entry-55.html
select @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH as GLOBAL_BUFFER_SIZE, @@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE as THREAD_BUFFER_SIZE, @@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFFER_SIZE + @@GLOBAL.READ_BUFFER_SIZE + @@GLOBAL.JOIN_BUFFER_SIZE + @@GLOBAL.READ_RND_BUFFER_SIZE) * @@GLOBAL.MAX_CONNECTIONS AS TOTAL_MEMORY_SIZE, (@@GLOBAL.KEY_BUFFER_SIZE + @@GLOBAL.INNODB_BUFFER_POOL_SIZE + @@GLOBAL.INNODB_LOG_BUFFER_SIZE + @@GLOBAL.INNODB_ADDITIONAL_MEM_POOL_SIZE + @@GLOBAL.NET_BUFFER_LENGTH + (@@GLOBAL.SORT_BUFFER_SIZE + @@GLOBAL.MYISAM_SORT_BUFF
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@mjf
mjf / pinyin2utf8.sed
Created May 13, 2012 23:41
pinyin2utf8.sed -- Convert US-ASCII Pinyin to UTF-8
#! /bin/sed -f
# pinyin2utf8.sed -- Convert US-ASCII Pinyin to UTF-8
# Copyright (C) 2012 Matous J. Fialka (mjf), <http://mjf.cz/>
# Released under the terms of The MIT License
#
# DESCRIPTION
# Script converts all occurences of US-ASCII encoded Pinyin text
# enclosed by the solidus characters pairs to UTF-8 encoded text.
#
@hunner
hunner / escctrlcaps.pke
Created March 21, 2012 21:54
caps->ctrl->esc->caps
clear Lock
clear Control
keycode 9 = Caps_Lock NoSymbol Caps_Lock NoSymbol Caps_Lock
keycode 37 = Escape NoSymbol Escape NoSymbol Escape
keycode 66 = Control_L NoSymbol Control_L NoSymbol Control_L
add Lock = Caps_Lock
add Control = Control_L Control_R
@nogweii
nogweii / sysctl.changed.conf
Created February 22, 2012 20:30
A massive collection of various sysctl files, designed for drop-in CCDC fixing
fs.file-max = 65535
fs.inode-max = 32768
fs.suid_dumpable = 0
kernel.core_uses_pid = 1
kernel.exec-shield = 1
kernel.maps_protect = 1
kernel.msgmax = 65536
kernel.msgmnb = 65536
kernel.panic = 30
kernel.panic_on_oops = 30
@mjf
mjf / record.sh
Last active May 3, 2018 13:03
Record and replay shell sessions using script(1) and scriptreplay(1)
#! /bin/sh
# Record - record shell session using script(1)
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
RECORD_PATH="$HOME/.typescripts/%Y/%m/%d"
RECORD_FILE='%H%M%S'
RECORD_TIMING_FILE="$RECORD_FILE.timing"
@mjf
mjf / junos_strip_comments.c
Created September 2, 2011 00:25
Simple FSM to strip Juniper configuration comments
/**
* Strip Juniper Comments
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License
*/
#include <stdio.h>
enum {
ASCII_NUL = '\000',
@mjf
mjf / ascii2xterm
Created July 22, 2011 13:52
Transform ASCII-art tables into XTerm-art tables
#! /bin/sed -f
# Transform ASCII-art tables into XTerm-art tables
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Horizontal and vertical line crossing
s/-|-/-^[(0^On^[(B-/g
# Top side and vertical line crossing
@mjf
mjf / bup
Created July 21, 2011 11:50
Posix shell script to connect two shell commands by bi-directional pipe
#! /bin/sh
# Posix shell script to connect two shell commands by bi-directional pipe
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if [ $# -ne 2 ]
then
printf -- 'Usage: bip COMMAND COMMAND\n'
exit 0