Skip to content

Instantly share code, notes, and snippets.

View ryparker's full-sized avatar
🍊

Ryan Parker ryparker

🍊
View GitHub Profile
@ryparker
ryparker / jest-reporter-interface.ts
Last active October 7, 2021 21:51
Create custom Jest reporters using this interface. Template repo available here: https://github.com/ryparker/jest-reporter-template
import {
AggregatedResult,
Config,
Context,
Reporter,
ReporterOnStartOptions,
Test,
TestResult,
} from '@jest/reporters'
@ryparker
ryparker / jest-circus-environment-interface.ts
Last active July 28, 2020 05:10
Create custom Jest Circus environments using this interface. Template repo available here: https://github.com/ryparker/jest-circus-environment-template
import NodeEnvironment from 'jest-environment-node';
import type { Config, Circus } from '@jest/types';
import type {EnvironmentContext} from '@jest/environment';
export default class CircusEnvironment extends NodeEnvironment {
testPath?: string;
docblockPragmas?: Record<string, string | string[]>;
constructor(config: Config.ProjectConfig, context: EnvironmentContext) {
super(config);
@ryparker
ryparker / LambdaConstants.java
Created July 28, 2020 23:06 — forked from seeebiii/LambdaConstants.java
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
@ryparker
ryparker / append-char-to-dirs.sh
Created October 14, 2020 20:41
Append char to matching dirs
#!/bin/bash
echo "start"
for fp in `find src/__tests__ -type d`; do
D="$(basename $fp)"
newFp=''
if [[ "${D}" == "GET" ]]; then
newFp="${fp:0:(${#fp}-3)}_${D:(-3)}"
// 1. Any live cell with fewer than two live neighbors dies, as if caused by under-population.
// 2. Any live cell with two or three live neighbors lives on to the next generation.
// 3. Any live cell with more than three live neighbors dies, as if by over-population..
// 4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
const input = [
[0, 0, 1],
[0, 0, 0],
@ryparker
ryparker / Fastfile
Last active March 25, 2021 21:28
Fastlane `Bump` lane
desc "Bumps the version and build number on the project"
desc "#### Example:"
desc "```\nfastlane ios bump version:2.0.1 build_number:23\n```"
desc "#### Options"
desc " * **`version`**: The version to set in the Info.plist (`CFBundleShortVersionString`)"
desc " * **`build_number`**: The build number to set in the Info.plist (`CFBundleVersion`)"
desc ""
lane :bump do |options|
# Prompt version number
version = nil
@ryparker
ryparker / Fastlane
Created April 13, 2021 20:36 — forked from jukben/Fastlane
Fastlane – example how to increment versions based on package.json
# ios
match(...)
package = load_json(json_path: "../package.json")
increment_version_number(version_number: package["version"])
increment_build_number(build_number: ENV["CIRCLE_BUILD_NUM"] || 1)
# android
package = load_json(json_path: "../package.json")
@ryparker
ryparker / purging-old-artifacts-with-github-api.md
Created April 20, 2021 19:43 — forked from lelegard/purging-old-artifacts-with-github-api.md
Purging old artifacts with GitHub Actions API

With GitHub Actions, a workflow can publish artifacts, typically logs or binaries. As of early 2020, the life time of an artifact is hard-coded to 90 days (this may change in the future). After 90 days, an artifact is automatically deleted. But, in the meantime, artifacts for a repository may accumulate and generate mega-bytes or even giga-bytes of data files.

It is unclear if there is a size limit for the total accumulated size of artifacts for a public repository. But GitHub cannot reasonably let multi-giga-bytes of artifacts data accumulate without doing anything. So, if your workflows regularly produce large artifacts (such as "nightly build" procedures for instance), it is wise to cleanup and delete older artifacts without waiting for the 90 days limit.

Using the Web page for the "Actions" of a repository, it is possible to browse old workflow runs and manually delete artifacts. But the procedure is slow and tedious. It is fine to delete one selected artifact. It is not for a regular cleanup. We need

@ryparker
ryparker / esm-package.md
Created September 9, 2021 15:17 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.