Skip to content

Instantly share code, notes, and snippets.

View rainbowbird's full-sized avatar

rainbowbird rainbowbird

View GitHub Profile
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@rainbowbird
rainbowbird / introduction_to_git_.md
Last active February 29, 2020 04:21
Introduction to Git

Part 1

3 conceptual areas of a Git repository

  • Working Truee
  • Staging Area (Index)
  • History

diff of working tree and staging area

git diff
  • Fast tabular data I/O
  • Time series operations
  • Data alignment
  • Missing data handling
  • Groupby operations
  • Hierachical indexing
  • Merging and joining
  • Pivot tables
  • Data summary, statistics
@rainbowbird
rainbowbird / closures.py
Created February 22, 2020 13:11
Python closures and "currying"
def outer(out_arg):
def inner(inner_arg):
return inner_arg + outer_arg
return inner
func = outer(10)
func(5)
func.__closure__
@rainbowbird
rainbowbird / decorator.py
Created February 22, 2020 13:05
Python decorators - Application of closures
import functools
def decorator(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
print('decorator was here')
return func(*args, **kwargs)
return new_func
@decorator
@rainbowbird
rainbowbird / coroutines_generators.py
Created February 22, 2020 12:52
Pipelining Chaining Commands - Coroutines with generators
"""Use coroutines to sum log file data with different log levels.
log file content:
ERROR: 78
DEBUG: 72
WARN: 99
CRITICAL: 97
FATAL: 40
FATAL: 33
CRITICAL: 34
@rainbowbird
rainbowbird / generators_pipeline.py
Last active February 22, 2020 12:47
Pipelining - Chaining Commands
"""Use generator to sum log file data on the fly
- Generators make good pipelines
- Useful for workflow problems
- Example parsing of a log file
log file content:
12
34
56
78
90
@rainbowbird
rainbowbird / Python3.7-Build.txt
Created January 17, 2020 07:58 — forked from jfcherng/Python3.7-Build.txt
Python 3.7 Build on Ubuntu 16.04
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _lzma
_sqlite3 _ssl _tkinter
readline zlib _uuid
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
sudo apt install libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev sqlite3 libsqlite3-dev openssl libssl-dev tcl8.6-dev tk8.6-dev libreadline-dev zlib1g-dev uuid-dev
@rainbowbird
rainbowbird / .hgrc
Created December 1, 2019 03:15 — forked from victor-torres/.hgrc
configuring meld merge tool in mercurial
[ui]
merge = meld
[extensions]
extdiff =
[merge-tools]
meld.args = $local $base $other --output=$output
@rainbowbird
rainbowbird / install-packages.sh
Last active January 8, 2020 04:16 — forked from Musinux/install-packages.sh
VNC xstartup for unity
#!/bin/bash
sudo apt-get install vnc4server ubuntu-desktop
sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal