Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Savov ivanistheone

View GitHub Profile
@ivanistheone
ivanistheone / mdnblinks.py
Last active Nov 21, 2021
This script generates links to mybinder and colab online Python environments you can use for any jupyter notebook hosted on in a GitHub repo.
View mdnblinks.py
@ivanistheone
ivanistheone / txt2mp3.sh
Last active Aug 25, 2021
This script converts a plain text file, e.g. article.txt into a mp3 audiobook using the MacOS text-to-speech accessibility command-line tool `say`. Adjust the `VOICE` and `RATE` parameters to customize to your liking. Note this requires running on MacOS.
View txt2mp3.sh
#!/usr/bin/env bash
set -e
# This script converts any text file into a mp3 audiobook using the MacOS
# text-to-speech accessibility command-line tool `say`.
# Adjust the `VOICE` and `RATE` parameters to customize to your liking:
VOICE="Alex"
RATE="295" # pretty fast
if [ $# -eq 0 ]; then
View kolibridb.py
#!/usr/bin/env python
"""
Helpers for downloding Kolibri databases and printing topic trees:
./kolibridb.py --channel_id=95a52b386f2c485cb97dd60901674a98
or to get the same result as HTML (assuming you have `pandoc` installed):
./kolibridb.py --channel_id=95a52b386f2c485cb97dd60901674a98 --htmlexport
View excerpt from ck-12 sraper.py
def retrieve_flex_book_lesson(item):
html_url = "/flx/get/perma/modality/lesson/{lesson_id}/{domain_id}?format=html".format(
lesson_id=item["handle"],
domain_id=item["domain"]["encodedID"],
)
dst = tempfile.mkdtemp()
try:
@ivanistheone
ivanistheone / samizdat-shell-help.bash
Last active Dec 17, 2020 — forked from kovetskiy/samizdat-shell-help.bash
help text for bas script based on ### comment + awk command
View samizdat-shell-help.bash
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@ivanistheone
ivanistheone / simple_chef_with_logging.py
Created Apr 2, 2020
Demo of common use of config.LOGGER in ricecooker for testing new colorlogs
View simple_chef_with_logging.py
#!/usr/bin/env python
from ricecooker.chefs import SushiChef
from ricecooker.classes.nodes import ChannelNode, TopicNode, DocumentNode
from ricecooker.classes.files import DocumentFile
from ricecooker.classes.licenses import get_license
from ricecooker.config import LOGGER
View build log on Mac OS X
(venv) probook:kiwix-build ivan$ ./kiwix-build.py --target-platform native_dyn
WARNING: kiwix-build has not been tested on MacOS platfrom.
Tests, bug reports and patches are welcomed.
[INSTALL PACKAGES]
- autoconf : SKIP
- automake : SKIP
- libtool : SKIP
- cmake : SKIP
- pkg-config : SKIP
SKIP, No package to install.
@ivanistheone
ivanistheone / README.md
Last active May 26, 2017
Proof of concept for combining command line arguments.
View README.md

Combining argparse parsers

This is a proof of concept for a command line interface (CLI) that is subclassable. TO use, create an instance of the class (or subclass) and call it's main method.

The only tricky part is that subclasses need to pass add_parser_help=False when calling the BaseCLI's __init__ method.

Using base.py by itself

@ivanistheone
ivanistheone / Intro to Python for people who know Java.md
Created Mar 28, 2017
A few tips for people interested in learning Python
View Intro to Python for people who know Java.md

Python for Java programmers

Part of what makes python readable is the absence of type information, the indentation-based block structure for code, and a few Python idioms, also known as "syntax sugar" if you will.

This tutorial assumes the reader is familiar with other programming languages like Java and shows some examples of Python coolness.

@ivanistheone
ivanistheone / README.md
Last active Mar 29, 2017 — forked from GGulati/Jarvis.py
Code that goes with blog post https://ggulati.wordpress.com/2016/02/24/coding-jarvis-in-python-3-in-2016/ —with modifications for Mac OS X.