Skip to content

Instantly share code, notes, and snippets.

View Kif11's full-sized avatar
🐁
Expanding digital frontier

Kirill Kovalevskiy Kif11

🐁
Expanding digital frontier
View GitHub Profile
@Kif11
Kif11 / append_to_sudoers.sh
Last active June 14, 2017 22:28
Safe way to append a line to your sudoers file
# This is a safe way to append a line to your sudoers file
# The validation will be performed with "visudo -c"
# before replacing the sudoers file
if [[ -z $1 ]]; then echo "No line provided to append"; return 1; fi
# Include directive to be appended to sudoers file
include_line=$1
su_bac_file="/var/tmp/sudoers.bac"
@Kif11
Kif11 / platform
Created February 1, 2017 00:20
Get current OS
platform = {'linux2': 'linux', 'darwin': 'mac', 'win32': 'windows'}[sys.platform]
@Kif11
Kif11 / current-script-directory.py
Last active August 31, 2016 06:57
Get current script directory
script_dir = os.path.dirname(os.path.realpath(__file__))
@Kif11
Kif11 / import-logging.py
Last active August 31, 2016 06:57
Simple logger import and config
import logging
logging.basicConfig(format='%(levelname)s: %(message)s')
log = logging.getLogger(__file__)
log.setLevel(logging.INFO)
@Kif11
Kif11 / run-util.sh
Last active August 31, 2016 06:57
Bash script to facilitade Python module dependency instalation and environment configuration
#!/usr/bin/env bash
# Get this scrip directory
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set basic environmental variables
export PYTHONPATH="$PYTHONPATH:$CURDIR/lib/python2.7/site-packages"
# Dependencies
DEPENDENCIES=(\
@Kif11
Kif11 / header.py
Last active August 31, 2016 06:56
Python file header comment
#!/usr/bin/env python
# author: Kirill Kovalevskiy
# e-mail: kovalewskiy@gmail.com