Skip to content

Instantly share code, notes, and snippets.

View aparajita's full-sized avatar

Aparajita Fishman aparajita

View GitHub Profile
@aparajita
aparajita / docgen-format.mjs
Created June 29, 2022 17:43
Reformats output from @capacitor/docgen to suit my stylistic tastes
import fs from 'fs'
function indexFixer(match, index) {
// 1. Remove bullets
// 2. Remove code format from method names
// 2. Add extra \n before Interfaces
const fixedIndex = index
.replace(/^\* /ugm, '')
.replace(/\[`(.+)`\](.+)/ug, '[$1]$2')
.replace(/\[Interfaces\]/u, '\n[Interfaces]')
0 verbose cli [
0 verbose cli '/Users/aparajita/.fnm/node-versions/v15.0.1/installation/bin/node',
0 verbose cli '/Users/aparajita/.fnm/node-versions/v15.0.1/installation/bin/npm',
0 verbose cli 'publish',
0 verbose cli '--ignore-scripts',
0 verbose cli '--publish-branch',
0 verbose cli 'main',
0 verbose cli '--dry-run'
0 verbose cli ]
1 info using npm@7.0.3
@aparajita
aparajita / upgrade-node.sh
Last active May 27, 2023 21:32
Shell script to install the latest Node version using fnm, pnpm and jq
#!/bin/bash
localVersion=$(fnm ls | sort | tail -1 | perl -ne 'if (/.*(v\d+\.\d+\.\d+)/) { print "$1" }')
remoteVersion=$(fnm ls-remote | grep -E '.*v\d+\.\d+\.\d+' | tail -n 1 | perl -ne 'if (/^.*(v\d+\.\d+\.\d+)/) { print "$1" }')
if [[ "$remoteVersion" != "$localVersion" ]]; then
read -r -n 1 -p "Version $remoteVersion is available. Install it? [Y/n] " shouldInstall
echo
case "$shouldInstall" in
@aparajita
aparajita / notarize.sh
Last active June 1, 2021 05:40
Script to notarize a 4D plugin
#!/usr/bin/env bash
#
# $1 - Source plugin path, must be on a local filesystem
#
# DEPENDENCIES
#
# This script relies on jq, a JSON parser. You can download
# it at https://stedolan.github.io/jq, or install via package
# managers such as brew or apt.
export default class AppDelegate extends UIResponder { // eslint-disable-line
applicationPerformFetchWithCompletionHandler(application, completionHandler) {
console.log('App is running in background')
// Check for new data
const newData = true
// If new data exists, initiate a local notification
if (newData) {
// Let the OS know that there were new data and complete the task
@aparajita
aparajita / hosts
Created February 23, 2019 19:03
hosts file entries to block Facebook
# Block facebook!
0.0.0.0 static.ak.fbcdn.net
0.0.0.0 www.connect.facebook.net
0.0.0.0 www.facebook.com
0.0.0.0 www.fbcdn.com
0.0.0.0 www.fbcdn.net
0.0.0.0 www.graph.facebook.com
0.0.0.0 www.login.facebook.com
0.0.0.0 www.s-static.ak.facebook.com
0.0.0.0 www.static.ak.connect.facebook.com
@aparajita
aparajita / yarnls.js
Last active March 2, 2018 18:50
yarnls.js: The missing yarn command. Lists only the top level packages in the current directory.
#!/usr/bin/env node
'use strict';
const child_process = require('child_process');
const format = require('util').format;
const fs = require('fs');
const path = require('path');
function parseOptions() {
@aparajita
aparajita / npmls.js
Last active January 4, 2020 00:07
npmls: A (much) better npm listing tool
#!/usr/bin/env node
"use strict";
const child_process = require("child_process");
const fs = require("fs");
const help = `Usage: npmls.js [-gh|--help] [filter...]
** Requires Node >= 4 **
@aparajita
aparajita / A4D_Init.txt
Last active August 29, 2015 14:26
A4D_Init method
`METHOD: A4D_Init{(inStartWebServer)}
`
`Part of Active4D, the ultimate 4D web environment
`Copyright © Aparajita Fishman, All Rights Reserved
C_BOOLEAN($1;$inStartWebServer)
If (Count parameters=0)
$inStartWebServer:=True
Else
#!/usr/bin/env python
import codecs
import os
from os.path import join
import re
import sys
if len(sys.argv) < 3: