Skip to content

Instantly share code, notes, and snippets.

View shazron's full-sized avatar
😆

Shazron Abdullah shazron

😆
View GitHub Profile
@shazron
shazron / delete_all_actions.sh
Last active March 19, 2024 12:17
Deleting all actions in a Adobe Runtime namespace
# install jq: https://jqlang.github.io/jq/
# list all packages
aio rt package list --json | jq '.[] | .name'
# for each package name, delete the package recursively
aio rt package delete "MY_PACKAGE_1" --recursive
@shazron
shazron / stringify-parse-test.js
Created February 22, 2024 06:22
JSON.stringify / parse tests for state
let store = {}
/** @private */
function put (key, value) {
store[key] = JSON.stringify(value)
}
/** @private */
function get (key) {
const value = store[key]
@shazron
shazron / blob.buffer.utils.js
Created October 30, 2023 01:38
blob2buffer and buffer2blob
const { Blob } = require('node:buffer');
/**
* Converts a Buffer to a Blob.
*
* @param {Buffer} buffer the Buffer to convert
* @returns {Blob} the converted Buffer as a Blob
*/
function buffer2blob(buffer) {
if (buffer instanceof Buffer === false) {
@shazron
shazron / .zshrc
Created September 21, 2023 14:18
iTerm2 - show current folder name in tab title
if [ $ITERM_SESSION_ID ]; then
precmd() {
echo -ne "\033]0;${PWD##*/}\007"
}
fi
@shazron
shazron / Google Ad Privacy Settings.md
Last active September 9, 2023 17:16
Google Ad Privacy Preferences json settings

Google Ad Privacy Settings (JSON)

Sept 10th 2023

Location

  1. In Google Chrome, go to chrome://settings/adPrivacy
  2. In Windows, make sure Chrome is closed, and load the file %LOCALAPPDATA%\Google\Chrome\User Data\Default\Preferences in a text editor and format it as JSON.

Chrome Ad Privacy Notice

@shazron
shazron / index.cjs
Last active August 28, 2023 01:57
OpenWhisk - how to use an EcmaScript Module (ESM) in node.js
// ///////////////////////////////////////////////////////////////////
// index.cjs - this is exported in the manifest for Openwhisk Deploy
// Only supported in Node 14+ (dynamic import)
async function cjsMain(params) {
const { default: esmMain } = await import('./index.mjs')
return esmMain(params)
}
exports.main = cjsMain
@shazron
shazron / github-search-substring-in-repo.js
Created March 30, 2023 08:50
Search for a substring in a Github Repo. Generated by ChatGPT-4.
const searchSubstringInRepo = async (owner, repo, substring) => {
const repoApiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/master?recursive=1`;
const headers = {
'Accept': 'application/vnd.github+json',
'Authorization': 'token YOUR_PERSONAL_ACCESS_TOKEN'
};
try {
const response = await fetch(repoApiUrl, { headers });
if (!response.ok) {
@shazron
shazron / gist:943736
Created April 27, 2011 04:55
About XCode 4 Project Template (How To Create Custom Project Template)
From: http://snipt.net/yonishin/about-xcode-4-project-template
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
Examples:
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate
@shazron
shazron / create-macos-monterey.sh
Created June 30, 2022 12:20
Create a macOS Monterey .iso file from the .app installer
# adapted from https://osxdaily.com/2020/07/20/how-convert-macos-installer-iso/
hdiutil create -o /tmp/Monterey -size 13700m -volname Monterey -layout SPUD -fs HFS+J
hdiutil attach /tmp/Monterey.dmg -noverify -mountpoint /Volumes/Monterey
sudo /Applications/Install\ macOS\ Monterey.app/Contents/Resources/createinstallmedia --volume /Volumes/Monterey --nointeraction
hdiutil detach /volumes/Install\ macOS\ Monterey
@shazron
shazron / url-join-path.js
Last active May 13, 2022 03:13
alternative to url-join or proper-url-join node modules
const path = require('path')
const assert = require('assert')
function urlJoinPath(url, pathToAdd) {
const u = new URL(url)
u.pathname = path.posix.join(u.pathname, pathToAdd)
return u.href
}
let result1 = urlJoinPath('https://foo.bar/a/b', 'recordlogin')