Skip to content

Instantly share code, notes, and snippets.

View ruslanmv's full-sized avatar
😃

Ruslan Magana Vsevolodovna ruslanmv

😃
View GitHub Profile
@ruslanmv
ruslanmv / synchrony_tutorial.ipynb
Created September 22, 2020 18:13 — forked from jcheong0428/synchrony_tutorial.ipynb
Synchrony tutorial notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ruslanmv
ruslanmv / README.md
Created December 16, 2020 17:17 — forked from taylorpaul/README.md
Installing Tensorflow on CENTOS 6.8 Cluster without Root Access

Environment:

OS: CENTOS 6.8 (No root access)

GCC: locally installed 5.2.0 (Cluster default is 4.4.7)

Bazel: 0.4.0-2016-11-06 (@fa407e5)

Tensorflow: v0.11.0rc2

CUDA: 8.0

@ruslanmv
ruslanmv / Python-Athena-Conn.py
Created December 25, 2021 10:19
Connecting Python with Athena via pyathena
import pyathena
import pandas as pd
## Directly by panda
athena_conn = pyathena.connect(aws_access_key_id=os.environ['ATHENA_USER'], ##credentials of aws_access_key_id
aws_secret_access_key=os.environ['ATHENA_PASSWORD'], ##credentials of aws_secret_access_key
s3_staging_dir='s3://aws-athena-query-results-<your-details>', ##where the athena query result saved - checked in S3 ,
region_name='eu-west-1') ##the region you set for Athena
df = pd.read_sql("SELECT * FROM tutorial.wbcdata LIMIT 10", athena_conn)
@ruslanmv
ruslanmv / vscode-python-snippets.json
Created December 25, 2021 10:21
Python Snippets to set-up in Visual Code
{
"Header": {
"prefix": "header",
"body": [
"'''",
"#FILE: $1",
"Project: $WORKSPACE_NAME",
"-------------------",
"By: Anh Dang",
"Date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
@ruslanmv
ruslanmv / Python-read-data.py
Created December 25, 2021 10:23
Handy Tricks to explore DB/Athena
-- Search for a columns in DB
SELECT COLUMN_NAME AS "ColumnName",
TABLE_NAME AS "TableName",
TABLE_SCHEMA
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE 'cashfac_id'
ORDER BY TABLE_NAME,
COLUMN_NAME;
-- List all columns one table
@ruslanmv
ruslanmv / Python-Zip-tricks.py
Created December 25, 2021 10:25
Tricks with Zip in Python
## Tuple:
# Capture arbitrarily long list
values = 1,2,3,4,5
a, b, *rest = values
# Discard the rest
a, b, *_ = values
## Zip:
# "pairs" up the elements of list
seq1 = ['foo','bar','baz']
@ruslanmv
ruslanmv / Python-Dict-tricks.py
Created December 25, 2021 10:26
Tricks with Dictionaries in Python
# Categorizing to dicts
words = ['apple', 'bat', 'bar', 'atom', 'book']
by_letters = {}
for word in words:
letter = word[0]
by_letters[letter] = by_letters.get(letter, 0) + 1
value = by_letters[letter]
print('Letter: {} - Count: {}'.format(letter, value))
@ruslanmv
ruslanmv / Python-Zip-tricks.py
Created December 25, 2021 10:27
Tricks with Zip in Python
## Tuple:
# Capture arbitrarily long list
values = 1,2,3,4,5
a, b, *rest = values
# Discard the rest
a, b, *_ = values
## Zip:
# "pairs" up the elements of list
seq1 = ['foo','bar','baz']
@ruslanmv
ruslanmv / Python-Functions-tricks.py
Created December 25, 2021 10:28
Tricks with Functions in Python: Object-functions, lambda, TryCatch, Currying (Partial)
## Functions -----------
## Multiple return
def f():
a = 5
b = 6
c = 7
return a, b, c
a, b, c = f()