Skip to content

Instantly share code, notes, and snippets.

@cnleo
cnleo / README.md
Created December 19, 2024 02:11 — forked from weisjohn/README.md
how to turn a keyframe animation into an animated png using phantomjs, imagemagick, and apngasm

jumping through hoops

A wonderfully warm winter day. Everything was perfect. Lofty visions of CSS3 animations dazzled my eyes. Nay, what's this? A browser from years ago appears. What's that you say? It doesn't support keyframes? Ghast. Make an animated gif! Oh, wait, we need transparency? Make an animated png!

This is the final outcome (sans history) of half a day spent to ensure experience parity on a super old (Opera 9.8) browser that we absolutely have to support.

It took hours, and it wasn't probably worth it, but I learned so much, and in the end it works pretty well.

technique

@cnleo
cnleo / stretchvideo.js
Created July 11, 2023 18:05 — forked from arpruss/stretchvideo.js
Bookmarklet to change aspect ratio of html5 video
document.dispatchEvent(new Event('mobi.omegacentauri.killStretchVideoEvent'));
var vid = document.getElementsByTagName('video');
if (vid.length == 0) {
alert("No video elements found in this page.");
}
else {
var mode = prompt("Enter one of these:\n"+
"(a) horizontal,vertical : a pair of scale ratios\n"+
"(b) horizontal:vertical : the correct aspect ratio for a badly encoded video\n", "1,1");
import json
import urlfetch
url_format = 'https://api.nightbot.tv/1/logs?columns%5B0%5D%5Bdata%5D=createdAt&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=user.displayName&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=false&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=message&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=false&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=desc&start={}&length=100&search%5Bvalue%5D=&search%5Bregex%5D=false'
offset = 0
all_messages = []
while True:
response = urlfetch.get(
@cnleo
cnleo / ChromeContentScript.js
Created March 19, 2022 18:33 — forked from insin/ChromeContentScript.js
Chrome Extension compatibility for Greasemonkey's GM_getValue and GM_setValue
// Request settings from the extension's localStorage and kick things off
chrome.extension.sendRequest({type: "getprefs"}, function(response)
{
cachedSettings = response;
init();
});
@cnleo
cnleo / ffmpeg combine files.sh
Created September 6, 2021 12:22 — forked from NapoleonWils0n/ffmpeg combine files.sh
ffmpeg: combine seperate audio and video files into a single video
#!/bin/sh
# ffmpeg combine seperate audio and video files into a single video
# copy the audio and video tracks
ffmpeg -i audio.aiff -i video.mov -acodec copy -vcodec copy -f mp4 avcombined.mp4
# encode the audio as aac and copy the video track without encoding it. if its the h264 codec
ffmpeg -i audio.aiff -i video.mov -acodec libfaac -ac 2 -ar 48000 -ab 160k -vcodec copy -f mp4 avcombined.mp4
@cnleo
cnleo / Youtube_Livestream_Parts_download.py
Created September 5, 2021 15:57 — forked from cheadrian/Youtube_Livestream_Parts_download.py
Download Youtube Live streamed video from the start or selected time
#With the help of this script you can download parts from the Youtube Video that is live streamed, from start of the stream till the end
import urllib.request
import os
#E.G: "https://r4---sn-gqn-p5ns.googlevideo.com/videoplayback?expire=1603041842& ..... 2.20201016.02.00&sq="
#The sound link should contain: &mime=audio in it.
#Here's an example from NASA LIVE:
#VIDEO: https://r5---sn-gqn-p5ns.googlevideo.com/videoplayback?expire=1603165657&ei=eQmOX8TeFtS07gO1xLWwDA&ip=79.115.11.159&id=DDU-rZs-Ic4.1&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160&source=yt_live_broadcast&requiressl=yes&mh=PU&mm=44%2C29&mn=sn-gqn-p5ns%2Csn-c0q7lnsl&ms=lva%2Crdu&mv=m&mvi=5&pl=20&initcwndbps=1350000&vprv=1&live=1&hang=1&noclen=1&mime=video%2Fmp4&gir=yes&mt=1603143920&fvip=5&keepalive=yes&fexp=23915654&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Clive%2Chang%2Cnoclen%2Cmime%2Cgir&sig=AOq0QJ8wRQIgQMnxy1Yk3HLTpqbOGmjZYH1CXCTNx6u6PgngAVGi4EQCIQDWyaye-u_KGyVQ0HRUsyKVaAzyXbmzDqOGVGpIyP7VtA%3D%3D&lspa
@cnleo
cnleo / 2fa
Created April 5, 2020 04:01 — forked from MineRobber9000/2fa
2-factor authentication terminal app in Python
#!/usr/bin/env python
import os, os.path, stat, sys, base64
# TOTP lib inlined
import time, hmac, base64, hashlib, struct
def pack_counter(t):
return struct.pack(">Q", t)