Skip to content

Instantly share code, notes, and snippets.

View kharnam's full-sized avatar

Sergey Kharnam kharnam

View GitHub Profile
@kharnam
kharnam / ansible-summary.md
Created August 10, 2018 00:08 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@kharnam
kharnam / count_lines_numbers.sh
Created April 2, 2018 19:32
Count the number of lines in all the files in the directory
find . -name '*.py' | xargs wc -l
find . -name '*.sh' | xargs wc -l
find . -name '*.*' | xargs wc -l
@kharnam
kharnam / yum_operate_from_specific_repo.sh
Created February 27, 2018 21:05
Yum operate from specific repo
yum --disablerepo="*" --enablerepo="ius" install rsyslog4
@kharnam
kharnam / osx_install_git_autocomplete.sh
Created January 23, 2018 04:26
Making Git autocompletion working on OSx (no terminal restart required)
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash && echo "source ~/.git-completion.bash" >> ~/.bash_profile && source ~/.bash_profile
@kharnam
kharnam / python_case_switch_replacement.py
Last active January 19, 2018 02:57
Python case-switch replacement
# Source -- SOF
# https://stackoverflow.com/questions/11479816/what-is-the-python-equivalent-for-a-case-switch-statement
# https://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python
# --------------------------
def f(x):
return {
'a': 1,
'b': 2
}.get(x, 9) # 9 is default if x not found
@kharnam
kharnam / brew-perms.sh
Last active September 13, 2018 02:42 — forked from jaibeee/brew-perms.sh
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# Execute under NON-ROOT user!
# allow admins to manage homebrew's local install directory
sudo chown -R $(whoami) $(brew --prefix)/*
sudo chmod -R g+w $(brew --prefix)/*
# Might be an optional!
@kharnam
kharnam / update_python_entirely.sh
Created April 5, 2017 19:46
Updating installed Python entirely
PASSWORD="<your_linux_password>" && cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && echo $PASSWORD | sudo -S python get-pip.py && echo $PASSWORD | sudo -S pip install --upgrade pip && echo $PASSWORD | sudo -S yum install -y gcc python-devel openssl-devel && echo $PASSWORD | sudo -S pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -I {} -n1 sh -c "echo $PASSWORD | sudo -S pip install -U {}"
@kharnam
kharnam / gist:ff7662ced2e0abce605fbe8abf7cd4f1
Created April 5, 2017 19:44
Opening all yum repositories at once
cd /etc/yum.repos.d/; for file in `ls`;do mv $file `echo $file | sed 's/\.orig$//'`; done
xfce4-panel --quit ; pkill xfconfd ; rm -rf ~/.config/xfce4/panel ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml ; xfce4-panel;
@kharnam
kharnam / gist:2488548
Created April 25, 2012 09:38
Delete all files in directory except today's modified.
find . -type f -mtime +0 -delete