Skip to content

Instantly share code, notes, and snippets.

@DusanBrejka
DusanBrejka / fluent-ffmpeg-custom-args.js
Last active Sep 20, 2021
node-fluent-ffmpeg - Execute Custom FFMPEG arguments hack
View fluent-ffmpeg-custom-args.js
/*
As at the time of writing this Fluent ffmpeg-API for node.js has not been updated
for years and still does not support custom FFMPEG attributes, the only solutions
are either forking it or resorting to hacks like this one...
Please use it only when fluent does not support more complex arguments
(like generating multi-rendition HLS with all playlists in a single command)
NOTE: this does not support 'progress' event, but you can do it easily by
parsing 'stderr' event with extractProgress method from fluent-ffmpeg/lib/options.js
@odbol
odbol / json_lines.js
Created Aug 27, 2019
Parse JSON Lines file in the browser with Javascript. http://jsonlines.org/
View json_lines.js
function parseJsonLines(file) {
let results = [];
for (let i = 0; i < file.length;) {
const end = file.indexOf('\n', i);
if (end < 0) {
end = file.length;
}
const currentLine = file.substring(i, end);
@mayneyao
mayneyao / notion2blog.js
Last active Sep 20, 2022
Notion.so > Personal Blog | custom domain + disqus comment
View notion2blog.js
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@alixnovosi
alixnovosi / load-alttp-randomizer-spoilers.py
Last active Apr 15, 2020
OBS Studio Python script to load ALttP Randomizer JSON spoilers and process them into OBS text elements.
View load-alttp-randomizer-spoilers.py
# Copyright (c) 2019, Andrew Michaud
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@hinchliff
hinchliff / c7n_run.py
Created Apr 19, 2019
Run a Cloud Custodian policy file from a Python script. Most useful perhaps to be able to run Cloud Custodian from AWS Lambda.
View c7n_run.py
import os
import logging
from c7n.commands import run
from c7n.config import Config
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# Capture our current directory
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@Hegemege
Hegemege / hue_shift.py
Last active Jul 17, 2022
OBS Hue Shift over Time
View hue_shift.py
# How to use this script in OBS:
# You need Python 3.6 installed
# 1. Open OBS > Tools > Scripts
# 2. Copypaste the Python 3.6 install directory into Python Settings tab.
# 3. Download this file onto your computer and put it somewhere safe
# 4. Add the script to the list of Loaded Scripts by clicking the + at the bottom left
# 5. Select the script from the list and select the correct output source you want to apply the effect to.
# If you can't find the correct source, scroll to the bottom of the file to see if your source is filtered out
# The source you selected must have a Color Correction filter, that has been renamed to "Hue Shift".
# The script won't work otherwise. I couldn't figure out how to list all the filters in a dropdown because
@devdbrandy
devdbrandy / app.js
Created Dec 5, 2018
Simple Express API
View app.js
/* eslint-disable */
const express = require('express');
const app = express();
app.use(express.json());
const db = {
users: [
@kerbeh
kerbeh / greenscren.md
Created Sep 25, 2018
Greenscreen chroma key with FFmpeg
View greenscren.md

##FFmpeg greenscreen process

ffmpeg -hwaccel videotoolbox -i background.jpg -i out.mp4 -filter_complex "[1:v]colorkey=0x34d454:0.3:0.15[ckout];[0:v][ckout]overlay[despill];[despill] despill=green[colorspace];[colorspace]format=yuv420p[out]" -map "[out]" output.mp4

###Explanation

*hwaccel enable hardware accelartion profile videotoolbok is avlaiable on my mac for this codec *-i is the input, the greenscreen video is second and the background image is first *-filter_complex chains up the filters in a string *colorkey provides the color of the green screen in hex, the threshold to match (higher is more) and the blend (higher is more)

@rbw
rbw / part_of_day.py
Last active Jul 27, 2022
Get part of day (morning, afternoon, evening, night) in Python3.6+
View part_of_day.py
#!/usr/bin/env python3
def get_part_of_day(h):
return (
"morning"
if 5 <= h <= 11
else "afternoon"
if 12 <= h <= 17
else "evening"
View README.md

chrome-headless-fetch-charset.js

Fetch pages using a headless chromium browser, and returns the detected charset.

Input file format

Text file, one URL per line

Output file format