View useDebounceEffect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react" | |
function useDebounceEffect(effect: () => void, deps: unknown[], delay: number) { | |
useEffect(() => { | |
const timeout = setTimeout(() => { | |
effect() | |
}, delay) | |
return () => { | |
clearTimeout(timeout) | |
} | |
}, [...(deps || []), delay]) |
View react-rxjs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from "react" | |
import { BehaviorSubject, Observable, filter, shareReplay } from "rxjs" | |
export function createSignal<T>(initialValue?: T) { | |
const v$ = new BehaviorSubject<T | undefined>(initialValue) | |
const setValue = (v: T) => { | |
v$.next(v) | |
} | |
return [v$, setValue] as [BehaviorSubject<T>, (v: T) => void] |
View jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
clearMocks: true, | |
reporters: [ | |
"default", | |
["jest-junit", { outputDirectory: "coverage", outputName: "report.xml" }], | |
["jest-silent-reporter", { useDots: true }], | |
], | |
coverageReporters: ["clover", "json", ["lcov", {}], ["text", { skipFull: true }]], | |
collectCoverageFrom: ["src", "!**/*.d.ts", "!**/node_modules/**"], | |
moduleNameMapper: { |
View variables.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@use 'sass:math' | |
$dd-width: 375px | |
$ratio: math.div(1, 10) | |
@function strip-unit($number) | |
@if type-of($number) == 'number' and not unitless($number) | |
@return math.div($number, ($number * 0 + 1)) | |
@return $number |
View yargs.sample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import path from 'path' | |
import yargs from 'yargs/yargs' | |
import fs from 'fs/promises' | |
import figlet from 'figlet' | |
import chalk from 'chalk' | |
import init from './command-init' | |
import packageJSON from '../package.json' | |
import { setLevel, Level } from 'utils/logger' | |
import { GlobalOptions } from 'command-init/types' |
View golang-env.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Covert Goland env to .env format | |
* e.g. | |
* Let's say we have env `ENV=production` and `DB=some-db-url` configured in Golang. It will be the following format when it is copiled from the conf. | |
* ENV=production;DB=some-db-url | |
* But the popular env format `.env` use the following format: | |
* ENV=production | |
* DB=some-db-url | |
*/ |
View deploy-web-to-s3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: tekton.dev/v1beta1 | |
kind: Task | |
metadata: | |
name: deploy-web-to-s3 | |
namespace: default | |
spec: | |
params: | |
- name: build_command | |
type: string | |
default: npm build |
View AsWebComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useCallback } from 'react' | |
import { render } from 'react-dom' | |
function Others() { | |
return <div>other will be rendered inside shadow tree</div> | |
} | |
class RendereComponent extends HTMLElement { | |
connectedCallback() { | |
const shadowRoot = this.attachShadow({ mode: 'open' }) |
View rss-feeds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
categories: | |
- category: tech | |
feeds: | |
- http://rachelbythebay.com/w/atom.xml | |
- http://feeds.feedburner.com/ruanyifeng | |
- http://blog.samaltman.com/posts.atom | |
- https://dave.cheney.net/feed/atom |
View .npmrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// saved at root of repo, or global | |
registry = https://registry.npm.taobao.org | |
sass_binary_site = https://npm.taobao.org/mirrors/node-sass/ | |
electron_mirror = https://npm.taobao.org/mirrors/electron/ |
NewerOlder