Skip to content

Instantly share code, notes, and snippets.

View JamieMason's full-sized avatar
💤
On a break from OSS for a couple of weeks

Jamie Mason JamieMason

💤
On a break from OSS for a couple of weeks
View GitHub Profile
@JamieMason
JamieMason / syncpack-dependents.json
Created September 26, 2023 10:02
Projects depending on https://github.com/JamieMason/syncpack, sorted by most stars
[
{ "org": "@pnpm", "repo": "pnpm/pnpm", "stars": 25486, "forks": 790 },
{ "org": "@mantinedev", "repo": "mantinedev/mantine", "stars": 21487, "forks": 1513 },
{ "org": "@BuilderIO", "repo": "BuilderIO/qwik", "stars": 18903, "forks": 1076 },
{ "org": "@microsoft", "repo": "microsoft/fluentui", "stars": 16391, "forks": 2540 },
{ "org": "@microsoft", "repo": "microsoft/pyright", "stars": 10898, "forks": 1172 },
{ "org": "@callstack", "repo": "callstack/linaria", "stars": 10805, "forks": 430 },
{ "org": "@woocommerce", "repo": "woocommerce/woocommerce", "stars": 8728, "forks": 10800 },
{ "org": "@electron", "repo": "electron/forge", "stars": 5816, "forks": 472 },
{ "org": "@altair-graphql", "repo": "altair-graphql/altair", "stars": 4828, "forks": 272 },
@JamieMason
JamieMason / user.conf
Created August 3, 2012 07:40
Apache .conf to disable caching for localhost
<Directory "/Users/jdog/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/jdog/Sites/
type GetFn = () => {
next(iteration: IteratorResult<any, any>): IteratorResult<any, any>;
};
function iterateOverSyncOrAsyncGenerator<T extends Iterable<any>>(getIterator: GetFn, gen: T): Iterable<any>;
function iterateOverSyncOrAsyncGenerator<T extends AsyncIterable<any>>(getIterator: GetFn, gen: T): AsyncIterable<any>;
function iterateOverSyncOrAsyncGenerator<T extends Iterable<any> | AsyncIterable<any>>(
getIterator: GetFn,
gen: T
): Iterable<any> | AsyncIterable<any> {
@JamieMason
JamieMason / get-in.js
Last active March 4, 2023 10:15
Access deeply nested value in JavaScript: get, getIn, deepGet, getDeep, pluckDeep, deepPluck, getNested, getProp, getDeepProp, getDescendant
const isWalkable = value => value !== null && typeof value !== 'undefined';
const getChild = (parent, child) => (isWalkable(parent) ? parent[child] : undefined);
const getIn = (descendants, origin) => descendants.split('.').reduce(getChild, origin);
import { R } from '@mobily/ts-belt';
/** Additional helpers for https://mobily.github.io/ts-belt/api/result */
export const $R = {
/**
* 1. Return an R.Ok<output[]> if every R.Result succeeds
* 2. Return an R.Error<Error> for the first failure encountered
*/
all<Input, Output = Input>(
getResult: (value: Input) => R.Result<Output, Error>,
@JamieMason
JamieMason / fp-ts-get-props.md
Last active February 8, 2023 10:54
fp-ts – Lodash's `_.get` and Ramda's `R.props` that returns an `Option`

fp-ts – Lodash _.get, Ramda R.props that returns an Option

A function like Lodash's _.get, Ramda's R.props, and Immutable.js's getIn, written in fp-ts.

import { Json } from 'fp-ts/lib/Json';
import { none, Option, some } from 'fp-ts/lib/Option';

export function getIn<T = Json>(props: string[], origin: unknown): Option<T> {
  let value: unknown = origin;
@JamieMason
JamieMason / github-bulk-mark-as-viewed.md
Created November 29, 2021 16:55
Tick "Viewed" on every file you've scrolled past on a GitHub Pull Request

GitHub PR bulk mark file as viewed

Tick "Viewed" on every file you've scrolled past on a GitHub Pull Request

// Tick "Viewed" on every file you've scrolled past on a
// GitHub Pull Request
$$('.js-reviewed-checkbox').forEach((el) => {
  if (!el.checked && window.scrollY > el.getBoundingClientRect().top) {
 el.click();
@JamieMason
JamieMason / AppContextProvider.tsx
Created February 10, 2020 22:40 — forked from adamkl/AppContextProvider.tsx
xState service layer
import React from "react";
import { createUserSessionService } from "services/UserSessionService";
import { createNavService } from "services/NavService";
// Wiring up our "IOC container"
const userSessionService = createUserSessionService();
// NavService depends on UserSessionService
const navService = createNavService(userSessionService);
@JamieMason
JamieMason / spotify-save-all-in-playlist.js
Last active November 19, 2022 06:08
This Script adds every song in the playlist you're currently viewing at https://play.spotify.com to "Your Music". Open your browser console and paste this script to run it.
/*
* This Script adds every song in the playlist you're currently
* viewing at https://play.spotify.com to "Your Music".
*
* Open your browser console and paste this script to run it.
*/
(function() {
// Check this web browser has all the functionality we need to do this task.
var hasQuerySelector = typeof document.querySelector === 'function';
@JamieMason
JamieMason / lazySingleton.js
Created March 1, 2011 08:27
JavaScript Singleton with lazy instantiation.
var ConstructorName = (function()
{
var singletonInstance = null;
function ConstructorName()
{
// presumably expensive instantiation/init code
}