Skip to content

Instantly share code, notes, and snippets.

View adamlaz's full-sized avatar

Adam Lazarus adamlaz

View GitHub Profile
@adamlaz
adamlaz / config.js
Created September 3, 2020 01:57 — forked from codediodeio/config.js
Snippets from the Firestore Data Modeling Course
import * as firebase from 'firebase/app';
import 'firebase/firestore';
var firebaseConfig = {
// your firebase credentials
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
@adamlaz
adamlaz / splitter.sh
Created February 15, 2021 21:10
Split up big csv files
#!/bin/bash
FILENAME=big-file.csv
HDR=$(head -1 $FILENAME)
split -l 400 $FILENAME xyz
n=1
for f in xyz*
do
if [ $n -gt 1 ]; then
echo $HDR > Part${n}.csv
fi
# Install Google Cloud SDK and Components
printHeading "Install Google Cloud SDK and Components"
printStep "Google Cloud SDK" "brew install --cask google-cloud-sdk"
printDivider
echo "✔ Prepping Autocompletes and Paths"
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"
printDivider
if [ -e ~/google-cloud-sdk ]; then
echo "✔ ~/google-cloud-sdk exists. Skipping"

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@adamlaz
adamlaz / ffmpeg-script.sh
Created January 4, 2023 14:15 — forked from lnikell/ffmpeg-script.sh
ffmpeg-web-optimized-vp9-h265
# Script accepts 5 parameters: input file, output folder, filename, -crf and number of pixels in width for scale options
# Validate that all parameters are passed
if [ $# -ne 5 ]; then
echo "Example usage: ffmpeg_crf.sh input.mp4 output-folder output-filename 3840 32"
exit 1
fi
# Validate that 5th parameter is a number within a range from 0 to 51
if [ $5 -lt 0 ] || [ $5 -gt 51 ]; then
@adamlaz
adamlaz / dataform.js
Created November 14, 2023 03:37
Dataform Helpers
const getSqlEventParam = (
paramName,
paramType = "string",
columnName = false
) => getUnnestParam(paramName, paramType, columnName);
const getSqlUserProperty = (
paramName,
paramType = "string",
columnName = false
@adamlaz
adamlaz / posthogOnGtmWithConsent.js
Created April 19, 2024 01:35
Use posthog via GTM in 'Consent Mode' with OneTrust & Elevar datalayer
'use strict';
(function() {
// Configuration constants
const POSTHOG_API_KEY = 'POSTHOG_API_KEY';
const POSTHOG_HOST = 'https://us.posthog.com';
// Checks if PostHog library is loaded, logs error if not
if (typeof posthog === 'undefined') {
console.error('PostHog library not loaded');