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 / 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 / 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 / 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
...
@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;
}

Keybase proof

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

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

{
    "body": {
        "key": {
# show commit tree (possibly append --all for all branches)
git log --graph --oneline --decorate
# save previous as an alias and then just use 'git tree'
git config --global alias.tree "log --graph --oneline --decorate"
# restoring lost commit (e.g. after git reset --hard HEAD~1)
git fsck --lost-found
# or
git reflog
git merge <hash>
@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 / Disable gnome-keyring-ssh
Last active September 7, 2018 08:54
Disable Gnome Keyring SSH agent in (X)Ubuntu
# Disable Gnome Keyring SSH agent in Ubuntu
# To allow using ssh-agent from OpenSSH, mainly because
# gnome-keyring does not like EC-type SSH keys
# as regular user (for which to disable):
systemctl --user mask gnome-keyring-ssh.service
pam-auth-update
# and disable "GNOME Keyring Daemon..."
# which probably also disables automatic keyring unlocking on login