Skip to content

Instantly share code, notes, and snippets.

@akamhy
akamhy / cli.py
Last active June 3, 2023 04:59
VideoHash CLI interface
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
#
# In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
@akamhy
akamhy / youtube_playlist_length.sh
Last active March 5, 2023 16:15
Bash Script to get YouTube Playlist Length / Duration right in Your terminal.
#!/bin/bash
# Check if curl is installed
if ! [ -x "$(command -v curl)" ]; then
echo "Error: curl is not installed. Please install curl and try again." >&2
exit 1
fi
# Check if jq is installed
if ! [ -x "$(command -v jq)" ]; then
@akamhy
akamhy / huffman.py
Created January 20, 2023 09:49
Compress The Data - Huffman Coding
import heapq
from collections import defaultdict
def huffman_encoding(data_list):
"""
Huffman encoding algorithm.
"""
freq_table = defaultdict(int)
for data in data_list:
@akamhy
akamhy / AllGitRepositoryCommitters.md
Created January 24, 2022 09:35
List all committers to a git repository (on the working branch)

List all committers to a git repository (on the working branch)

git log --reverse --format="%aN <%aE>" | cat | sort -u

Example:

akamhy at device in ~/projects/yt-dlp on master
$ git log --reverse --format="%aN <%aE>" | cat | sort -u
@akamhy
akamhy / 2hrvideo.md
Created October 11, 2021 07:32
2 hour count up video
We couldn’t find that file to show.
@akamhy
akamhy / youtube_playlist_duration.py
Created October 11, 2021 05:33
YouTube PlayList Duration from command-line
import re
import requests
def playlist_data(search_string):
end_point = "https://ytplaylist-len.herokuapp.com"
params = {"search_string": search_string.strip()}
text = requests.post(end_point, data=params).text
number_of_videos = (
re.search(r"<p>No of videos : ([0-9]*?)</p>", text).group(1).strip()
@akamhy
akamhy / example_cdx.py
Last active January 5, 2021 04:00
Cdx Pagination API, wildcard search
from waybackpy import Cdx # waybackpy >= 2.3.3
url = "https://www8.gsb.columbia.edu/cbs-directory/detail/*"
user_agent = "Your-apps-user-agent"
cdx = Cdx(url=url, user_agent=user_agent)
snapshots = cdx.snapshots()
for snapshot in snapshots:
print(snapshot.archive_url)

Keybase proof

I hereby claim:

  • I am akamhy on github.
  • I am akamhy (https://keybase.io/akamhy) on keybase.
  • I have a public key ASCQISpjHRJMMwcajs32CvkN7FFDEferofdHpVrMxh--wQo

To claim this, I am signing this object: