Skip to content

Instantly share code, notes, and snippets.

View samson-sham's full-sized avatar
🏠
Working from home

Samson Sham samson-sham

🏠
Working from home
View GitHub Profile
.playbutton {
position: absolute;
z-index: 10;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
box-sizing: content-box;
display: block;
}
.playbutton::before {
@samson-sham
samson-sham / toLowerCase.js
Last active July 19, 2023 13:27
AWS => CDK config conversion
const medialiveJSON = require('./config.json');
const isObject = (o) => typeof o === 'object' && !Array.isArray(o);
// Not considering N-levels array
const lower = (obj) => Object.fromEntries(Object.entries(obj).map(([k,v]) => ([`${k[0].toLowerCase()}${k.slice(1)}`,isObject(v) ? lower(v) : Array.isArray(v) ? v.map(vv => isObject(vv) ? lower(vv) : vv) : v])));
console.log(JSON.stringify(lower(medialiveJSON), null, 4));
@samson-sham
samson-sham / install-ffmpeg-with-decklink-support-ubuntu-18.04-server.md
Created November 9, 2022 08:37 — forked from macpit/install-ffmpeg-with-decklink-support-ubuntu-18.04-server.md
Compiling and installing `ffmpeg` with Decklink support on Ubuntu 18.04 Server
@samson-sham
samson-sham / makePDF.mjs
Created September 8, 2022 07:47
make JPGs to PDF
import PDFDocument from 'pdfkit';
import fs from 'fs';
const pageProp = {
size: 'A4',
layout: 'landscape',
autoFirstPage: false,
};
const doc = new PDFDocument(pageProp);
doc.pipe(fs.createWriteStream('./document.pdf'));
// JavaScript
const webdav = require('webdav-server').v2;
const server = new webdav.WebDAVServer({
port: 1900
});
server.afterRequest((arg, next) => {
// Display the method, the URI, the returned status code and the returned message
console.log('>>', arg.request.method, arg.requested.uri, '>', arg.response.statusCode, arg.response.statusMessage);
@samson-sham
samson-sham / codecommit.md
Last active June 2, 2022 02:29
Setup AWS CodeCommit

Create AWS IAM User

  • Create IAM User, select exisiting policy with respective CodeCommit permission

Create SSH credential

  • AWS CodeCommit SSH does not support ED25519 cryptography, has to use RSA
ssh-keygen -t rsa -b 4096 -C "why-dont-support-ed25519"
@samson-sham
samson-sham / dllm.sh
Last active May 6, 2022 05:57
stop microsoft autoupdate
$ plutil -p /Library/LaunchAgents/com.microsoft.update.agent.plist ~
{
"Disabled" => 0
"Label" => "com.microsoft.update.agent"
"MachServices" => {
"com.microsoft.update.xpc" => 1
}
"ProgramArguments" => [
0 => "/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/Microsoft Update Assistant.app/Contents/MacOS/Microsoft Update Assistant"
1 => "--launchByAgent"

Blackmagic hyperdeck

  • Framerate has to be the same
  • Supports ProRes 422, ProRes 422 HQ
  • Only root files can be listed
  • Telnet Port 9993
  • Only reads files which are the same format as it capture (ProRes / DNxHD), capture format is configured via software
  • Verified by AJA FS-HDR
    • if playback HLG content, HyperDeck is outputting HLG EOTF signal through SDI
    • if playback PQ content, HyperDeck does not output PQ EOTF signal, and has to manually configure HDR through Menu
  • ProRes video can be played if encoded with Davinci Resolve
// https://hongkongfp.com/2022/03/02/taiwan-leader-urges-countries-not-to-turn-a-blind-eye-to-military-aggression
new authoritarian world might be characterized by a return to 19th-century power politics and 20th-century blitzkrieg, with strong-men autocrats unleashing their militaries to crush neighbouring countries and threatening total destruction as means of coercion.
tanks barrelling through towns, homes pulverized by shelling, missiles crashing into high-rise apartment buildings, plumes of smoke rising from destroyed infrastructure, people cowering underground and half a million refugees - so far - fleeing to neighbouring countries.
If latest threats are any indication, the new authoritarian world being ushered into existence by China and its autocratic allies apparently includes preparations to use nuclear weapons.
Russian invasion of Ukraine juxtaposed alongside Chinese foreign ministry officials' mealy-mouthed parroting of Russia's justifications for the attack, along with their flat-out refusals to
@samson-sham
samson-sham / cleaup.sh
Last active March 24, 2024 01:07
Git Operations
# Completely clean up git, including git history
git reflog expire --expire=now --expire-unreachable=now --all
git gc --prune=now
# These commands are mentioned by others as well, but I have no ideas what they are...
git fsck --unreachable
git fsck --unreachable --no-reflogs
git gc --aggressive