Skip to content

Instantly share code, notes, and snippets.

@beli-sk
beli-sk / profile_ssh_agent
Created July 17, 2014 18:19
Bash profile snippet for starting and reusing SSH agent on login
### Start SSH agent if not running
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo -n "Initialising new SSH agent... "
/usr/bin/ssh-agent -t 3600 | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo done
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}"
@beli-sk
beli-sk / tmux.conf
Last active March 4, 2019 11:42
My personal tmux config
#set -g status off
#set -g status-right "\"#{=32:pane_title}\""
setw -g mode-keys vi
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection-and-cancel
bind-key S setw synchronize-panes
@beli-sk
beli-sk / Debian pkg build
Last active August 29, 2015 14:04
Configure Debian package building environment
# for building packages
apt-get install build-essential devscripts debhelper
# for creating/editing packages
apt-get install dh-make quilt
cat >>~/.bashrc <<"_EOF"
DEBEMAIL="your.email.address@example.org"
DEBFULLNAME="Firstname Lastname"
export DEBEMAIL DEBFULLNAME
alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg"
@beli-sk
beli-sk / gvimrc.local
Last active July 31, 2023 08:21
My personal vim config
colorscheme evening
set columns=120 lines=35
"set guifont=Inconsolata\ 13

Keybase proof

for beli (https://keybase.io/beli) @keybase

with PGP fingerprint 05ED 7B6D 4DDA E43D DB92 1AEC A537 2D08 32D8 419D

{
    "body": {
        "key": {
@beli-sk
beli-sk / capacitor_discharge.gnuplot
Created May 18, 2015 15:25
Capacitor discharge plotted with gnuplot.
#!/usr/bin/gnuplot
U = 3.3
I = 2.2e-3
R = U/I
C = 10e-6
t = 0.01
set yrange [0:U]
set xrange [0:t]
plot U * exp(-x/(R*C))
pause -1
@beli-sk
beli-sk / pgsql_cheat_sheet.rst
Last active October 29, 2015 10:31
PostgreSQL cheat sheet

Show process list:

SELECT * FROM pg_stat_activity;

Show running processes:

SELECT pid,datname,query_start,state,query
FROM pg_stat_activity WHERE state <> 'idle';

Reload config:

@beli-sk
beli-sk / selinux-zabbix-fix.te
Last active January 18, 2016 08:41
Fix (workaround) for running zabbix agent/server under SELinux
# https://www.zabbix.com/forum/showthread.php?t=43550
policy_module(zabbix-fix, 1.3)
require {
type zabbix_agent_t;
type zabbix_t;
type ping_t;
type zabbix_tmp_t;
class tcp_socket name_connect;
}
@beli-sk
beli-sk / bash_oneliners.sh
Last active July 18, 2017 14:38
Useful CLI one-liners (Linux)
# Number of open file descriptors per process (replace 'httpd' with process name)
lsof -p $( echo `ps -o pid= -C httpd` | tr ' ' ',' ) | awk '{ print $2 }' | uniq -c
# Show swap usage per process, >=1000 kB
cat /proc/*/status | egrep -B30 '^VmSwap:[[:space:]]+[[:digit:]]{4,}' | egrep '^Name|^Pid|^VmSwap'
# generate password
head -c12 /dev/urandom | base64 | tr '+/' '_-' | tr -d '='
# days to web server certificate expiry
@beli-sk
beli-sk / apache-2.4_tls.conf
Last active December 4, 2015 15:57
HTTPS config
SSLCipherSuite ECDHE:DHE:HIGH:+SHA1:!MEDIUM:!LOW:!EXP:!aNULL:!eNULL:!PSK:!RC4
SSLHonorCipherOrder on
SSLProtocol all -SSLv3
<VirtualHost ...>
SSLEngine on
Header always set Strict-Transport-Security "max-age=15552000"
Header set Public-Key-Pins "pin-sha256=\"yiUxVRHwMNoXtZZS/RtgPr2bCNyc6L8IJrmTU80HSlA=\"; pin-sha256=\"XQIfp7PhqFyw93tHv86EhngOxSVVdZy0Dj1mFmI81PM=\"; max-age=15552000"
SSLUseStapling on
...