Skip to content

Instantly share code, notes, and snippets.

View pakkinlau's full-sized avatar
🚩
Focusing

Pak Kin LAU pakkinlau

🚩
Focusing
View GitHub Profile
@pakkinlau
pakkinlau / repo environment DevOps.ipynb
Last active July 28, 2024 04:48
In this article, we will explore the ideal way to manage coding environments and coding projects using Python virtual environments and Git hooks. Managing your development environment effectively ensures consistency across different setups and enhances collaboration within teams. We will automate the setup and maintenance of these environments a…
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pakkinlau
pakkinlau / print_pytorch_geometric_data_info.ipynb
Created July 16, 2024 03:59
print_pytorch_geometric_data_info.ipynb aims to print out PyTorch Graph Data flexibly
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pakkinlau
pakkinlau / poe-langchain.py
Created May 27, 2024 19:21
poe-langchain. Adapting LLM that we can access on `poe`, into langchain's `llm` eco-system.
from langchain_core.language_models.llms import BaseLLM
from poe_api_wrapper import PoeApi
from pydantic import BaseModel, Field
class PoeApiAdapter(BaseLLM):
tokens: dict
bot: str
auto_proxy: bool = Field(default=False)
class Config:
- source: https://www.youtube.com/watch?v=LY7YmuDbuW0&list=PLUl4u3cNGP61O7HkcF7UImpM0cR_L2gSw
---
- 2 books that are writing to new real analysis learner:
- Proofs: a long-form mathematics textbook https://www.doc88.com/p-21973918406856.html
-
---
### Learning objectives
- 1. By proving the theorems, we practice how to deploy the related definitions and axioms
@pakkinlau
pakkinlau / print_dir_tree.py
Created December 23, 2023 10:47
recursively prints text that contain a tree structure representing the folders and files in a given directory. It provides insights to LLM or human developer into the structure of a package.
import os
def print_tree(directory, indent=''):
files = os.listdir(directory)
files.sort() # Sort files alphabetically
for file in files:
path = os.path.join(directory, file)
if os.path.isfile(path):
# Print file name with proper indentation
@pakkinlau
pakkinlau / compress_concate.py
Created November 23, 2023 20:32
This script can be a handy tool for managing and manipulating large video files, especially when you need to stitch together and compress several clips into one video. Please note that this script assumes that the input video files are in .avi format and their names follow the "MOVI####.avi" pattern. Also, the output video is in .avi format with…
import os
import moviepy.editor as mpy
import glob
def compress_video(video_path, output_path, video_bitrate="1000k"):
clip = mpy.VideoFileClip(video_path)
# Compress video
clip.write_videofile(output_path, codec='mpeg4', bitrate=video_bitrate)
def concatenate_videos(videos_path, output_path):
@pakkinlau
pakkinlau / Migrate_to_public_space.ipynb
Created October 31, 2023 18:29
This Python script facilitates the management of two spaces: a creation space (a large and private area for work) and a publication space (a smaller area for selected items ready for publishing). Users can specify a list of items to migrate from the creation space to the publication space, streamlining the publishing process.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pakkinlau
pakkinlau / downloadYT_clipping.py
Created October 28, 2023 17:35
A python script that download a video with chopping. Only videoID and time periods are needed to be provided to run the script.
from pytube.cli import on_progress
from pytube import YouTube
import os
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
def download_with_cut(link, target_folder=None, time_ranges=None):
yt = YouTube(
link, on_progress_callback=on_progress, use_oauth=True, allow_oauth_cache=True
)
@pakkinlau
pakkinlau / downloadYT_whole.py
Created October 28, 2023 17:34
A python script that download a video without chopping. Only videoID is needed to be provided to run the script.
from pytube.cli import on_progress
from pytube import YouTube
import os
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
def download(link, target_folder=None):
yt = YouTube(
link, on_progress_callback=on_progress, use_oauth=True, allow_oauth_cache=True
)
@pakkinlau
pakkinlau / gpt2md.py
Created October 28, 2023 17:31
A python script that convert the mathematics LaTeX format that you can copy from ChatGPT, into the LaTeX format that markdown (such as Obsidian) can display.
"""
This script automatically converts the output of GPT-3 to markdown format.
Future: convert this script to be a chrome extension.
For linux users, they might need to install `xclip` or `xsel` to find clipboard mechanism.
`sudo apt-get install xclip`: Install xclip
"""