Skip to content

Instantly share code, notes, and snippets.

@SimeonC
SimeonC / input.scss
Created August 23, 2023 02:19
Generated by SassMeister.com.
$alpha: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
:root {
--pending-key: 0 0 0px 8px rgb(171, 67, 255) inset;
--error-key: 0 0 0px 40px rgb(255, 58, 58) inset;
}
@each $letter in $alpha {
body:has( [data-testid="tile"][data-state="tbd"][aria-label$=#{to-upper-case($letter)}]:not([data-animation="flip-in"])) [aria-label="Keyboard"] [data-key=#{$letter}] {
box-shadow: var(--pending-key);
@SimeonC
SimeonC / generateCarbonIconsTypeDefinitions.mjs
Last active May 18, 2022 02:17
A script to generate typescript types for @carbon/icons-react v11
import fs from 'fs';
import path from 'path';
import carbonIcons from '@carbon/icons-react';
const fileContent = `${Object.keys(carbonIcons).reduce(
(result, iconName) =>
`${result} declare export const ${iconName}: ComponentType;\n`,
`/* this file is generated, recommend adding to prettier and eslint ignore and committing to git. DO NOT EDIT */
declare module '@carbon/icons-react' {
@SimeonC
SimeonC / github.com.js
Last active March 25, 2022 03:02
Mark as viewed and jump to next unviewed file in Github Pull Requests review
// change the following two key combos as you like
// this key combo will mark the current focused file as viewed and jump to the next unviewed file
const viewedAndNextKey = "ctrl-alt-meta-shift-v";
// this key combo will just jump to the next unviewed file
const nextKey = "ctrl-alt-meta-shift-w";
const modifiers = ["ctrl", "alt", "meta", "shift"];
const viewedAndNextKeyParts = viewedAndNextKey.split("-");
const nextKeyParts = nextKey.split("-");
@SimeonC
SimeonC / GitlabToGithubMigration.md
Last active December 20, 2021 02:34
Scripts for migrating Gitlab content to Github

The above scripts require the following environment variables defined to use.

  • GITLAB_TOKEN a personal access token for gitlab
  • GITHUB_TOKEN a personal access token for github with all repo scopes
  • GITLAB_REPO the id of the Gitlab project as in the Settings > General page of the Gitlab project
  • GITHUB_REPO the 'owner/repository' string of the GitHub repository as in the url; https://github.com/owner/repository
@SimeonC
SimeonC / cypress-plugins-index.ts
Created August 16, 2021 02:15
Cypress Component testing with Dazzle (Insert in cypress/plugins/index.ts)
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
@SimeonC
SimeonC / i18nextLanguageJson.ts
Last active January 3, 2024 15:56
Using Webpack code-split "backend" for i18next translations. Note that your withTranslations/useTranslations must use namespaces or include a default namespace or the read function doesn't get called
// Used for one JSON file for each language containing all namespaces
i18next.use({
type: 'backend',
read<Namespace extends keyof typeof en>(
language: LocaleCode,
namespace: Namespace,
callback: (
errorValue: unknown,
translations: null | typeof en[Namespace]
) => void
@SimeonC
SimeonC / pagix.d.ts
Last active February 26, 2021 09:47
Pagix type definitions
declare module 'pagix' {
export function between(num: number, min: number, max: number): number;
export function range(from: number, to: number): number[];
export interface PagixOptions {
/**
* total of records to paginate
*/
records: number;
/**
@SimeonC
SimeonC / machine.js
Created November 24, 2020 09:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@SimeonC
SimeonC / machine.js
Last active November 25, 2020 08:09
Generated by XState Viz: https://xstate.js.org/viz
const shopLoadingMachine = Machine({
id: 'shop-loading',
initial: 'entry',
context: {
shopSettings: null
},
states: {
entry: {
on: {
LOAD: {
@SimeonC
SimeonC / ShopsContext.jsx
Last active July 25, 2018 10:43
React-Cosmos Context proxy
import React, { createContext } from 'react';
import { getDisplayName } from '@ts-react-utils/hoc';
export const { Provider, Consumer } = createContext([]);
export function withShops(WrappedComponent) {
const withShopsComponent = (props) => (
<Consumer>
{(shops) => <WrappedComponent {...props} shops={shops} />}
</Consumer>