Skip to content

Instantly share code, notes, and snippets.

View flrntpt's full-sized avatar

flrnt flrntpt

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flrntpt
flrntpt / python_format_partial.ipynb
Created May 11, 2019 18:01
Python Partial Format
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flrntpt
flrntpt / git_cheatsheet.md
Last active September 4, 2018 14:00
Git cheatsheet

Git reflog (history of all operations)

git reflog

Git reset (can be --soft, --mixed (default) or --hard)

git reset
@flrntpt
flrntpt / python_path.py
Created August 17, 2018 13:11
Update python path
import os
from pathlib import Path
import sys
p = Path(os.getcwd())
index = p.parts.index('YOUR_ROOT_FOLDER')
posix_path = Path().joinpath(*p.parts[:index + 1])
sys.path.insert(1, str(posix_path))
@flrntpt
flrntpt / README.md
Created August 15, 2018 13:24
Benchmark for fastest way to get most frequent value (mode) of a NumPy ndarray

Python 3.6

@flrntpt
flrntpt / convert.py
Created January 15, 2018 14:07
Convert docx to txt
import argparse
import xml.etree.ElementTree as ET
from zipfile import ZipFile
def docx_to_str(filepath):
""" Load a docx file and return its content """
DOC_XML = 'word/document.xml'
TEXT_TAG = '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}t'
@flrntpt
flrntpt / git-cheatsheet.md
Created December 2, 2017 17:04
Git cheatsheet

Diff with vim

git difftool --tool=vimdiff

@flrntpt
flrntpt / copy-and-rename.sh
Created November 22, 2017 14:08
Copy and rename
#!/bin/bash
for i in {0..8}
do
for j in {1..4}
do
newvalue=$(($i + (9 * $j)))
cp "def$i" "def$newvalue"
done
done
@flrntpt
flrntpt / macos_install.sh
Last active August 11, 2017 13:40
MacOS install script
#!/bin/bash
# Setup install for MacOS
list=(reattach-to-user-namespace vim tmux wakeonlan wget z gnu-sed)
cask_list=(iterm2 dashlane docker sublime-text emacs anaconda google-chrome \
evernote slack telegram vlc)
# Install Homebrew if not already installed
which -s brew
if [[ $? != 0 ]] ; then
@flrntpt
flrntpt / docker-cheatsheet.md
Last active March 31, 2018 22:23
docker-cheatsheet

Cheatsheet for Docker

Basic commands

docker -v (docker version)
docker ps -a (list containers)

Clean volumes

Remove - r for MacOS

docker volume ls -qf dangling=true | xargs -r docker volume rm