Skip to content

Instantly share code, notes, and snippets.

View aleclarson's full-sized avatar

Alec Larson aleclarson

View GitHub Profile
import { route } from 'saus'
// Default route
route(() => import('./routes/UnknownPage'))
// Catch route
route('error', () => import('./routes/ErrorPage'))
//
// Matched routes
const reservedChars = /[\r\n,"]/
module.exports = function toCSV(header, rows) {
rows = rows.map(row => row.map(valueToString).join(','))
return [header.join(','), ...rows].join('\r\n') + '\r\n'
}
function valueToString(value) {
return value === undefined
? ''
From 92e2a0844b1e12b5d2ad9febbd76e3efa75d81bd Mon Sep 17 00:00:00 2001
From: aleclarson <alec.stanford.larson@gmail.com>
Date: Thu, 20 Dec 2018 12:34:32 -0500
Subject: [PATCH] ci: use semantic-release
---
.travis.yml | 19 +++++++++++++++++++
package.json | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 .travis.yml
// Search an array for nested arrays and inline them
const flatten = (arr, out = []) => {
arr.forEach(val => {
if (val == null) return
if (Array.isArray(val)) flatten(val, out)
else out.push(val)
})
return out
}
const debug = (name, val) => {
console.log(name, val)
return val
}
const debugFn = (name, fn) => {
return (...args) => {
console.log(name + ':arguments %O', args)
const result = fn(...args)
// Convert "translate(10px) rotate(0)" into ["translate", "rotate"]
// This helps interpolate strings of different arity.
const keyRegex = /(?:^| )([\w-]+)\(([^ ,]+(?:(?:,[ ]*|[ ]+)[^ ,)]+)*)\)/g
/**
* Create a specialized interpolator for strings like:
*
* "translate(...) rotate(...)"
*/
@aleclarson
aleclarson / runTopological.ts
Created June 10, 2019 02:21
Run an async action in topological order (dependencies run first)
export const runTopological = <T>(
packages: PackageJson[],
action: (pkg: PackageJson) => Promise<T>
): Promise<T[]> => {
const promises: Promise<T>[] = []
const run = (pkg: PackageJson, i: number) =>
promises[i] ||
(promises[i] = Promise.all(
Object.keys(pkg.dependencies || {}).map(name => {
const i = packages.findIndex(pkg => pkg.name === name)

<HotKey> for react-native-macos

There are two types of hotkeys: global and local.

  • Global hotkeys work even when the application is inactive.
  • Local hotkeys only work when the application is active.

The implementation for global hotkeys would be adapted from davedelong/DDHotKey.

The implementation for local hotkeys would use the RCTKeyCommands class that already exists.

// Adapted from: https://digitalbunker.dev/2020/09/13/understanding-gaussian-blurs/
function gaussianBlurMatrix(blurRadius: number) {
if (blurRadius !== Math.round(blurRadius) || blurRadius <= 0) {
throw Error('Blur radius must be a positive integer')
}
const kernel: number[] = []
const kernelWidth = 1 + 2 * blurRadius
const kernelSize = kernelWidth * kernelWidth
diff --git a/node_modules/react-update-url-on-scroll/lib/Manager.js b/node_modules/react-update-url-on-scroll/lib/Manager.js
index 6e8de9f..7cb49c4 100644
--- a/node_modules/react-update-url-on-scroll/lib/Manager.js
+++ b/node_modules/react-update-url-on-scroll/lib/Manager.js
@@ -18,11 +18,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var defaultConfig = {
affectHistory: false,
- debounce: 100,
keepLastAnchorHash: false,