Skip to content

Instantly share code, notes, and snippets.

View rpetrenko's full-sized avatar

Roman Petrenko rpetrenko

  • Santa Clara, CA
View GitHub Profile
# when adding values from $FROM to $T0
# print only those lines which are not found in $TO
# be carefull with partial match
FROM=$1
TO=$2
for x in `cat $FROM`;do
grep $x $TO > /dev/null;
ret=$?;
if [ $ret -ne 0 ];then
@rpetrenko
rpetrenko / system_info.sh
Last active June 21, 2022 23:07
linux helpfull commands
# number of ssh connections
netstat -tnpa | grep 'ESTABLISHED.*sshd'
# network interfaces with their max speed
for i in $(netstat -i|cut -f1 -d" "|tail -n+3);do echo "$i: $(ethtool "$i"|grep Speed|sed 's/Speed://g')";done
day people_details Pop Sick Dead Healthy Immune p_sick
1 +0000000000000000000 20 1 0 19 0 0.0500
2 +00+000+0+0000000+00 20 5 0 15 0 0.2500
3 +0+++0++0++0++0+0+++ 20 14 0 6 0 0.7000
4 ++++++++0+++++++++++ 20 19 0 1 0 0.9500
5 ++++++++++++++++++++ 20 20 0 0 0 1.0000
6 +++x++++++++++++++++ 19 19 1 0 0 1.0000
7 +++x++++++++++++++++ 19 19 1 0 0 1.0000
8 +++x++++++++++++x+++ 18 18 2 0 0 1.0000
9 +++x++++++++++++x+++ 18 18 2 0 0 1.0000
#!/bin/bash
# json should be any list of dictionaries with
# each item having the same keys
# example:
#[
# {
# "name": "server1.example.com",
# "online": true,
# },
@rpetrenko
rpetrenko / send_email.sh
Last active March 3, 2019 08:29
send email with html attachment (in linux)
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "Arguments: <email> <subject> <fname.html>"
exit 1
fi
mail --content-type=text/html --attach="$3" --subject "$2" $1 < /dev/null
@rpetrenko
rpetrenko / jupyter notebook header
Last active May 31, 2019 01:17
most commonly used imports for jupyter notebooks
# set width of cells to browser width
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
# for drawing inline
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib import style
style.use('fivethirtyeight')
tmux_conf_uri="https://gist.githubusercontent.com/rpetrenko/e209a2216b0a7a74ad0b0468b5bd51ff/raw/66f7d6e8706595304dfcc4a02727e231f5ec39a2/.tmux.conf"
if [ ! -f ~/.tmux.conf ]; then
curl $tmux_conf_uri > ~/.tmux.conf
fi
ruby -v
git --version
brew -v
@rpetrenko
rpetrenko / OSX UTC Time Zone
Created March 2, 2018 08:01 — forked from nick-desteffen/OSX UTC Time Zone
Set Time zone in OSX to UTC
sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime
@rpetrenko
rpetrenko / tmux-cheatsheet.markdown
Created June 9, 2017 03:51 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@rpetrenko
rpetrenko / .tmux.conf
Created March 13, 2017 02:54
tmux config
# for screen-like experience
set -g prefix C-j
# to use ctrl+a+a as in screen
bind-key C-j last-window
# modify pane splitting bindings
unbind %
bind | split-window -h
bind - split-window -v