This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" | |
Implement iterate_while function and a peekable generator. | |
Allows easier branching in the processing of the generator. | |
This answers the question: | |
How can you pass a generator to another function, such that it consumes only part of it? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sounddevice as sd | |
import soundfile as sf | |
import numpy as np | |
import pydub | |
def record_audio(filename="recording.mp3", samplerate=44100): | |
# Initialize recording flag | |
recording = True | |
# Create array to store audio data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mistune | |
from mistune.renderers.markdown import MarkdownRenderer | |
from pygments import highlight | |
from pygments.lexers import get_lexer_by_name, MarkdownLexer | |
from pygments.formatters import Terminal256Formatter | |
def markdown_stream_generator(): | |
text = """ | |
# Main Heading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import argparse | |
import subprocess | |
parser = argparse.ArgumentParser('Tool to merge list of mkv files with mka files using mkvmerge.\n'\ | |
'The audio files should contain the matching video file name.') | |
parser.add_argument('input_video_path', help='The path where to find the mkv files') | |
parser.add_argument('input_audio_path', help='The path where to find the mka files') | |
parser.add_argument('output_path', help='The path where to save the merged files') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import mkdir | |
import pandas as pd | |
import sys | |
import argparse | |
import pathlib | |
parser = argparse.ArgumentParser(description="Split CSV documents") | |
parser.add_argument('input_filepath', | |
help="The input csv file you want to split") | |
parser.add_argument( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python3 convert.py input_file.pdf output_file.pdf | |
""" | |
import pdf2image | |
import io | |
from PyPDF2 import PdfFileReader, PdfFileWriter | |
import sys | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --audio-track= using 1 here, as my video files have audio, but in different language, so after adding the second audio, it's index will become 1 (it's 0 based) | |
vlc --audio-track=1 \ | |
video_file_path_1 \ | |
:input-slave=external_audio_path_1 \ | |
video_file_path_2 \ | |
:input-slave=external_audio_path_2 | |
#... You can continue this command for as many files you want | |
# This way you can start VLC with all your files already linked and easily move to next/previous episodes, instead of manually doing "Advanced Open File", specifying the external audio file and changing the track to the new one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
class Node: # Trie node | |
def __init__(self, val=""): | |
self.mem = [None] * 26 | |
self.count = 0 | |
self.val = val | |
def register_word(root, word): | |
node = root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EnhancedLinkedListNode: | |
def __init__(self, a, b, c): | |
self.a = a | |
self.b = b | |
self.c = c | |
self.next = None | |
self.prev = None | |
def remove(self): | |
if self.prev: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EnhancedLinkedListNode: | |
def __init__(self, a, b, c): | |
self.a = a | |
self.b = b | |
self.c = c | |
self.next = None | |
self.prev = None | |
def remove(self): | |
if self.prev: |
NewerOlder