Skip to content

Instantly share code, notes, and snippets.

View hirawatt's full-sized avatar
🌴
Focusing

vishal hirawat hirawatt

🌴
Focusing
View GitHub Profile
@BrianLincoln
BrianLincoln / YTMLikesToPlaylist.md
Last active July 15, 2024 17:56
YouTube Music Likes to Playlist

Copy Likes to a playlist in YouTube Music

This is a very hacky solution to copy Liked songs to a playlist since YTM still doesn't have the functionality. I'm using this to copy songs out of YTM to another service, then unsubscribing. Thus, I won't be maintaining it (or ever using it again). It will only work while the YTM interface is the same as it is today (3/6/21) and will break once they make updates.

Steps to use:

  1. Create a new playlist
  2. Go to your Likes page (in chrome, on a desktop or laptop). Scroll to the bottom so all songs are loaded
  3. Open Chrome's dev tools (F12 on windows), go to the console
  4. Paste the script below. Edit the first line, replace "YOUR_PLAYLIST_NAME" with your playlist's name
  5. Press enter
from zipfile import ZipFile
from io import BytesIO
zipObj = ZipFile("sample.zip", "w")
# Add multiple files to the zip
zipObj.write("checkpoint")
zipObj.write("model_hyperparameters.json")
# close the Zip File
zipObj.close()
@m-radzikowski
m-radzikowski / script-template.sh
Last active July 13, 2024 13:20
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@treuille
treuille / fancy_cache.py
Last active June 5, 2021 16:15
Workaround: Adding ttl and sesssion uniqueness to @st.cache
import streamlit as st
import streamlit.ReportThread as ReportThread
from streamlit.server.Server import Server
import time
import functools
import random
import string
# Copied from tvst's great gist:
@tvst
tvst / session_id.py
Last active May 18, 2023 12:05
Hack to get a session-specific ID in Streamlit. See https://discuss.streamlit.io/t/session-specific-caching/271
import streamlit.ReportThread as ReportThread
from streamlit.server.Server import Server
def get_session_id():
# Hack to get the session object from Streamlit.
ctx = ReportThread.get_report_ctx()
this_session = None
@tvst
tvst / SessionState.py
Last active April 14, 2024 20:24
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active July 25, 2024 06:56
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 29, 2024 14:14
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@kapillamba4
kapillamba4 / pacman.md
Created November 15, 2017 07:57
ArchLinux Pacman Cheatsheet

Update package list

sudo pacman -Syy

Update and upgrade all

sudo pacman -Syu

Install specific package

sudo pacman -S pkgname

Find available packages