Skip to content

Instantly share code, notes, and snippets.

View SCG82's full-sized avatar

SCG82

  • Southern California
  • 14:30 (UTC -07:00)
View GitHub Profile
@SCG82
SCG82 / generateUUID.js
Created March 27, 2022 12:34
Generate a 36-character (128-bit) Universally Unique IDentifier (v4)
/**
* Generate a 36-character (128 bit) Universally Unique IDentifier (v4)
* @param {Number} length [Optional] length of the output string (default = 36)
* @param {String} str [Optional] string to start with
*/
function UUID(length = 36, str = '') {
let a = 36 - length + str.length
while (a++ < 36) {
str +=
(a * 51) & 52
@SCG82
SCG82 / gifenc.sh
Created April 22, 2021 19:45
Create animated GIF from video file
#!/bin/bash
#*********************************************
# gifenc.sh *
# *
# developer: SCG82 (scg082+gifenc@gmail.com) *
#*********************************************
USAGE="Usage: $0 -w [output width] -n [select every nth frame] -d [dither algorithm: floyd_steinberg, sierra2, sierra2_4a, none] -s [start time hh:mm:ss] -e [end time hh:mm:ss] FILE"
VERSION=1.0
@SCG82
SCG82 / hdrtosdr.sh
Last active April 11, 2023 04:38
Convert HDR video to SDR with tone mapping (especially for iPhone 12)
#!/bin/bash
#************************************************
# hdrtosdr.sh *
# v1.0.0 *
# developer: SCG82 (scg082+mp4towebp@gmail.com) *
#************************************************
USAGE_S="Usage: $0 -s [start time hh:mm:ss] -e [end time hh:mm:ss] -w width -h height -p preset FILE"
USAGE="Usage (arguments are optional): $0 -s [start time hh:mm:ss] -e [end time hh:mm:ss] -w [output width] -h [output height] -p [preset: ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo] FILE"
@SCG82
SCG82 / obs-time-frame-resolution-mfc.lua
Last active February 20, 2024 09:39
Lua script for OBS to display current time, frame counter, resolution, target fps, broadcast type in a text source
script_ver = 2.7
obs = obslua
source_name = ""
last_text = ""
current_frame = 0
frame_rate = 0
time_format_string = ""
output_format_string = ""
@SCG82
SCG82 / obs-time-frame.lua
Last active January 8, 2021 20:35
Lua script for OBS to display current time and a frame counter in a text source
script_ver = 2.5
obs = obslua
source_name = ""
last_text = ""
current_frame = 0
time_format_string = ""
output_format_string = ""
@SCG82
SCG82 / measure_execution_time_of_code_block.cpp
Created November 10, 2020 09:35
Measure execution time of code block in C++
#include <chrono>
auto t1 = std::chrono::high_resolution_clock::now();
// code to measure
auto t2 = std::chrono::high_resolution_clock::now();
auto dur = t2 - t1;
cout << dur.count() / rtc::kNumNanosecsPerMicrosec;
@SCG82
SCG82 / Conductor.cc
Created February 24, 2020 23:56 — forked from mysteryjeans/Conductor.cc
WebRTC Conductor using custom Audio & Video source
#include "audiorenderer.h"
#include "videorenderer.h"
#include "audiocapturemodule.h"
#include "yuvframecapture.h"
#include "conductor.h"
#include "webrtc/api/test/fakeconstraints.h"
#include "webrtc/video_encoder.h"
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
@SCG82
SCG82 / AudioCaptureModule.cc
Created February 24, 2020 23:55 — forked from mysteryjeans/AudioCaptureModule.cc
WebRTC AudioDeviceModule implementation for custom source
/*
* libjingle
* Copyright 2012, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
@SCG82
SCG82 / build-webrtc.cmd
Last active October 31, 2020 14:19
Windows 10 WebRTC Build Script. Override defaults by setting env vars: BUILD_TYPE, WEBRTC_VERSION, BRANCH_NUMBER, WEBRTC_ARGS, WEBRTC_ROOT_DIR
@echo off
setlocal
set _WEBRTC_VERSION=86
set _BRANCH_NUMBER=4240
set _DEPOT_TOOLS_COMMIT=master
set ARGS_RELEASE="use_rtti=true is_debug=false use_custom_libcxx=false rtc_use_h264=true ffmpeg_branding=\"Chrome\" rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false"
set ARGS_DEBUG="use_rtti=true is_debug=true use_custom_libcxx=false rtc_use_h264=true ffmpeg_branding=\"Chrome\" enable_iterator_debugging=true rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false"
@SCG82
SCG82 / basic_client.cpp
Created April 30, 2019 09:51 — forked from zaphoyd/basic_client.cpp
An example of a basic WebSocket++ client that sends a message, waits for a response, then closes the connection
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
typedef websocketpp::client<websocketpp::config::asio_client> client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;