Skip to content

Instantly share code, notes, and snippets.

@git-thinh
git-thinh / ffmpegTee.js
Created June 19, 2025 09:50 — forked from toshvelaga/ffmpegTee.js
ffmpeg to stream live video using tee muxer
const ffmpegTee = (youtube, twitch, facebook) => {
return [
'-i',
'-',
// select first stream intended for output
'-map',
'0',
// video codec config: low latency, adaptive bitrate
'-c:v',
'libx264',
@git-thinh
git-thinh / ffmpeg.js
Created June 19, 2025 09:49 — forked from toshvelaga/ffmpeg.js
stream to twitch and youtube RTMP destinations using FFmpeg
const ffmpeg = child_process.spawn('ffmpeg', [
// the input
'-i',
'-',
// video codec config: low latency, adaptive bitrate,
// list of presets: https://trac.ffmpeg.org/wiki/Encode/H.264
// tune zerolatency is good for fast encoding and low-latency streaming
// g:v 60 ==> https://www.reddit.com/r/ffmpeg/comments/redaa2/while_livestreaming_to_youtube_using_ffmpeg_i_get/
'-c:v',
@git-thinh
git-thinh / index.html
Created June 16, 2025 07:38 — forked from hubgit/index.html
Render the text of a PDF with PDF.js
<!doctype html>
<meta charset="utf-8">
<title>Render the text of a PDF with PDF.js</title>
<style>
.page-container {
box-shadow: 0 1px 3px #444;
position: relative;
font-size: 1px;
line-height: 1;
// A BASIC Node server
// Routing Requests
const http = require("http");
const url = require("url");
const server = http.createServer(function(req, res) {
//console.log(req.url);
let parsedURL = url.parse(req.url, true);
let path = parsedURL.pathname;
@git-thinh
git-thinh / static_server.js
Created June 11, 2025 02:42 — forked from aolde/static_server.js
Simple web server in Node.js. This fork added mime types for common file types.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888,
mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"png": "image/png",
@git-thinh
git-thinh / alpine-modal.html
Created October 17, 2024 06:17 — forked from w3collective/alpine-modal.html
Modal dialog with Alpine.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Alpine.js Modal Dialog</title>
<style>
[x-cloak] {
display: none !important;
}
@git-thinh
git-thinh / background.js
Created July 29, 2024 14:29 — forked from muralikg/background.js
puppeteer screen capture demo. Currently records 10 second video. Change the timeout in background.js with your own logic to stop the recording when necessary. Try with `node export.js`
/* global chrome, MediaRecorder, FileReader */
chrome.runtime.onConnect.addListener(port => {
let recorder = null
port.onMessage.addListener(msg => {
console.log(msg);
switch (msg.type) {
case 'REC_STOP':
console.log('Stopping recording')
if (!port.recorderPlaying || !recorder) {
@git-thinh
git-thinh / cloudflareworker-verifyjwt.js
Created June 23, 2024 02:02 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/
@git-thinh
git-thinh / pdf2img.html
Created June 16, 2024 10:34 — forked from imolorhe/pdf2img.html
pdf to image using pdf.js
<html>
<body>
<script type="text/javascript" src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<script type="text/javascript">
var url = "https://docs.google.com/document/export?format=pdf&id=1ML11ZyyMpnAr6clIAwWrXD53pQgNR-DppMYwt9XvE6s&token=AC4w5Vg7fSWH1Hq0SgNckx4YCvnGPaScyw%3A1423618416864";
var pages = [], heights = [], width = 0, height = 0, currentPage = 1;
var scale = 1.5;
function draw() {
@git-thinh
git-thinh / pdf2img.html
Created June 16, 2024 10:34 — forked from imolorhe/pdf2img.html
pdf to image using pdf.js
<html>
<body>
<script type="text/javascript" src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<script type="text/javascript">
var url = "https://docs.google.com/document/export?format=pdf&id=1ML11ZyyMpnAr6clIAwWrXD53pQgNR-DppMYwt9XvE6s&token=AC4w5Vg7fSWH1Hq0SgNckx4YCvnGPaScyw%3A1423618416864";
var pages = [], heights = [], width = 0, height = 0, currentPage = 1;
var scale = 1.5;
function draw() {