Skip to content

Instantly share code, notes, and snippets.

View richard-flosi's full-sized avatar

Richard Flosi richard-flosi

  • Remote, US
View GitHub Profile
@richard-flosi
richard-flosi / github-pull-request-review-check-all.js
Created May 22, 2024 20:14
Check all Viewed checkboxes on GitHub Pull Request
/* Run this in the JavaScript Console in your Browser on a GitHub Pull Request to mark all the files as Viewed */
while (true) {
document.querySelector("input[type=checkbox]:not([checked]).js-reviewed-checkbox").click();
await new Promise(r => setTimeout(r, 2000));
}
@richard-flosi
richard-flosi / pin-dev-dependencies-to-current-version.zsh
Created May 21, 2024 13:38
Pin current devDependencies versions
#!/bin/zsh
# For each package name
for PACKAGE in `npm pkg get devDependencies | jq 'keys[]' | tr -d '"'`
do
echo "Found ${PACKAGE}" &&
# Get the current installed version
VERSION=`npm ls ${PACKAGE} --depth 0 --json | jq --arg package ${PACKAGE} '.dependencies.[$package].version' | tr -d '"'` &&
echo "Current version ${VERSION}" &&
@richard-flosi
richard-flosi / pin-dependencies-to-current-version.zsh
Created May 21, 2024 13:36
Pin current dependencies versions
#!/bin/zsh
# For each package name
for PACKAGE in `npm pkg get dependencies | jq 'keys[]' | tr -d '"'`
do
echo "Found ${PACKAGE}" &&
# Get the current installed version
VERSION=`npm ls ${PACKAGE} --depth 0 --json | jq --arg package ${PACKAGE} '.dependencies.[$package].version' | tr -d '"'` &&
echo "Current version ${VERSION}" &&
@richard-flosi
richard-flosi / async-generator.js
Created February 23, 2022 21:49
Example of *yield to pass proxy to another function compared to awaiting each next() value and applying a transformation before yielding
// When you just need to pass through the value yield from another generator function use:
yield* generatorFunction();
// When you need to manipulate each yielded value
const generator = generatorFunction();
let next = await generator.next();
while (!next.done) {
let value = next.value;
// TODO apply any transformations to value here
yield value;
@richard-flosi
richard-flosi / build.sh
Created July 14, 2020 00:08
Build Script to Deploy Flutter Web app on Netlify
#!/bin/bash
# Get flutter
git clone https://github.com/flutter/flutter.git
FLUTTER=flutter/bin/flutter
# Configure flutter
FLUTTER_CHANNEL=master
FLUTTER_VERSION=v1.17.0
$FLUTTER channel $FLUTTER_CHANNEL
@richard-flosi
richard-flosi / operations.js
Created April 27, 2020 19:49
serverless express-openapi over netlify functions
const usersApi = require("./users");
module.exports = {
// /users
"post-users": usersApi.post,
"get-users": usersApi.get,
// /users/{userId}
"get-users-userId": usersApi.get,
"patch-users-userId": usersApi.patch,
"delete-users-userId": usersApi.delete,
@richard-flosi
richard-flosi / flutter-netlify-build.sh
Last active July 1, 2023 21:15
Netlify Build command script to deploy a Flutter Web App
#!/bin/sh
FLUTTER_BRANCH=`grep channel: .metadata | sed 's/ channel: //g'`
FLUTTER_REVISION=`grep revision: .metadata | sed 's/ revision: //g'`
git clone https://github.com/flutter/flutter.git
cd flutter
git checkout $FLUTTER_BRANCH
git pull origin $FLUTTER_BRANCH
git checkout $FLUTTER_REVISION
cd ..
@richard-flosi
richard-flosi / star-wars-planets.html
Last active January 17, 2024 07:58
Web Component using Custom Element, Shadow DOM, fetch, async/await, and the Star Wars API
<html>
<head>
<script>
customElements.define("star-wars-planets", class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
static get observedAttributes() { return ["loading", "planets"]; }
@richard-flosi
richard-flosi / trilateration.js
Last active April 12, 2021 04:09
JavaScript Trilateration
// Created by Derrick Cohodas (dav-)
// Based on the Python example by StackExchange user wwnick from http://gis.stackexchange.com/a/415/41129
// Requires the Mathjs library - http://mathjs.org/
var math = require('mathjs')
/**
* Represents a coordinate with a distance
* @param {Number} lat Latitude
@richard-flosi
richard-flosi / assertions-compareScreenshot.js
Created August 27, 2014 14:25
Nightwatch with Visual Regression testing
// assertions/compareScreenshot.js
var resemble = require('resemble'),
fs = require('fs');
exports.assertion = function(filename, expected) {
var screenshotPath = 'test/screenshots/',
baselinePath = screenshotPath + 'baseline/' + filename,
resultPath = screenshotPath + 'results/' + filename,
diffPath = screenshotPath + 'diffs/' + filename;