Skip to content

Instantly share code, notes, and snippets.

View franjohn21's full-sized avatar

Francis John franjohn21

  • San Francisco, CA
View GitHub Profile
@franjohn21
franjohn21 / astria.ts
Last active November 8, 2022 15:22
TS code to interact with Astria API
import { FormData } from 'formdata-node';
import fetch from 'node-fetch-commonjs';
// set to `false` to use production mode
const USE_FREE_TIER = true;
const ASTRIA_API_KEY = '';
const train = () => {
const formData = new FormData();
node_modules/
dist/
package-lock.json
@franjohn21
franjohn21 / index.js
Last active November 1, 2018 20:43
Move dependencies to devDependencies
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const pkg = require(path.join(process.cwd(), 'package.json'));
const whitelist = ['babel-polyfill', '@babel/polyfill'];
const devDependencyPatterns = [
'@nerdwallet/nw-app-build',
/babel/,
@franjohn21
franjohn21 / subet.sh
Last active December 18, 2020 13:31
Most performance font subsetting options via `pyftsubset`
// For definition of each option: https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/subset/__init__.py#L39
pyftsubset path/to/existing/font.otf \
--unicodes-file=path/to/unicode/file.txt \
--flavor=woff2 \
--layout-features='' \
--no-hinting \
--desubroutinize \
--name-IDs='' \
--drop-tables+=GSUB \
--with-zopfli
@franjohn21
franjohn21 / generate-inverse-unicode-range.js
Created September 19, 2017 05:20
Inverse of critical unicode-range
const CharacterSet = require('characterset')
const critical = CharacterSet.parseUnicodeRange('U+00-A0,U+A9,U+AE,U+B2-B3,U+B9,U+2013-2014');
const all = CharacterSet.parseUnicodeRange('U+0000-FFFF');
const inverseOfCritical = all.difference(critical)
console.log(inverseOfCritical.toHexRangeString())
// => U+A1-A8,U+AA-AD,U+AF-B1,U+B4-B8,U+BA-2012,U+2015-FFFF
@franjohn21
franjohn21 / gist:ff5ef09affa424d88298
Last active August 29, 2015 14:16
Example deferred, angular dependency injection
.when('/splash/:splash_id',
{
controller: 'splashController',
templateUrl: '/partials/splashlist.html',
resolve: {
latlong: ["$q","$rootScope", "splashFactory",function($q, $rootScope, splashFactory) {
var deferred = $q.defer();
getLocation(deferred, $rootScope, splashFactory);
return deferred.promise;
}]