Skip to content

Instantly share code, notes, and snippets.

View romach's full-sized avatar

Roman Cherepanov romach

View GitHub Profile
@romach
romach / multi-line-comment.py
Created April 10, 2017 21:43
Multi line comment
"""
This is
multiline
comment
"""
@romach
romach / math-operations.py
Created April 10, 2017 21:53
Math operations
# exponentiation
10 ** 2
@romach
romach / string-operations.py
Last active April 11, 2017 21:19
String operations
# Get letter by index
"Word"[0] => "W"
# Length
"Word".len() => 4
# To lower case
"Word".lower() => "word"
# To upper case
"Word".upper() => "WORD"
# Convert to string
str(2) => "2"
@romach
romach / copy-files-with-wildcard.sh
Created April 11, 2017 17:57
Copy files with wildcard
for file in binlog.*; do cp "$file" "/destination/${file}";done
@romach
romach / pipes.sh
Created April 11, 2017 20:51
Pipes
# reditect output to file
ls > output.sh
# redirect input from file
sort < file.txt
# redirect input and output
sort < unsorted.txt > sorted.txt
# pipeline
cat unsorted.txt | sort
@romach
romach / bash-history.sh
Last active April 11, 2017 20:58
Bash history
# from file
cat ~/.bash_history
# by command
history
# run command by number
!1234
# run last command
!!
# find command
Ctrl+r
@romach
romach / aliases.sh
Created April 11, 2017 21:03
Aliases
# show all aliases
alias
# create alias
alias la='ls -A'
# delete alias
unalias la
@romach
romach / convert-to-string.py
Created April 11, 2017 21:21
Convert to string
str(2.0)
@romach
romach / string-formatting.py
Created April 11, 2017 21:25
String formatting
name = "Roman"
print "Hello %s" % (name)
@romach
romach / print-current-time.py
Created April 11, 2017 21:31
Print current time
from datetime import datetime
now = datetime.now()
print now