Skip to content

Instantly share code, notes, and snippets.

View noyobo's full-sized avatar
💭
I may be slow to respond.

noyobo noyobo

💭
I may be slow to respond.
  • Tuya
  • Hangzhou China
View GitHub Profile
@kmvan
kmvan / _document.tsx
Created June 2, 2022 02:52
Next 12 + React 18 _document.tsx
import Document, {
DocumentContext,
Head,
Html,
Main,
NextScript,
} from 'next/document'
import { CSSProperties, ServerStyleSheet } from 'styled-components'
import { AppContextProps } from 'YOUR APP CONTEXT'
interface PageDocumentProps {
@rikumi
rikumi / Boundary.tsx
Last active December 28, 2021 03:07
Remax Boundary
import { createPortal } from '@remax/runtime';
import React, { useEffect, useState } from 'react';
import NativeBoundary from './native-boundary';
const Boundary: React.FC = (props) => {
const { children } = props;
const [container, setContainer] = useState<any>();
useEffect(() => container?.applyUpdate());
return <>
@sindresorhus
sindresorhus / esm-package.md
Last active July 15, 2024 20:29
Pure ESM package

Pure ESM package

The package that linked you 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.
@alexkirsz
alexkirsz / ForceCaseSensitivityPlugin.js
Last active February 23, 2017 13:38
Force case sensitivity in webpack
/*
The MIT License (MIT)
Copyright (c) 2015 Alexandre Kirszenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTI
@juliocesar
juliocesar / for-loops.js
Created May 3, 2013 04:42
ES6 - for loops
// ES6 for loops
// =============
// Things in ES6 can be "iterable". Arrays are iterable by default.
var fruits = ['Apple', 'Banana', 'Grape'];
for (var fruit of fruits)
console.log('Fruit: ' + fruit);
@mjackson
mjackson / color-conversion-algorithms.js
Last active July 9, 2024 09:47
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@iambibhas
iambibhas / scopes.txt
Last active June 16, 2024 20:45
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@suziewong
suziewong / git.md
Last active February 19, 2023 05:38
Git的多账号如何处理? 1.同一台电脑多个git(不同网站的)账号 2.同一台电脑多个git(同一个网站的比如github的)多个账号

1.同一台电脑可以有2个git账号(不同网站的)

首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

host github
  hostname github.com
  Port 22

host gitlab.zjut.com

@benvium
benvium / smartReadFile.php
Created September 19, 2012 12:08
PHP File to allow seeking in HTML5 <audio> tag. NOTE: I did not write this, check links in code for credits.
<?php
/**
* Reads the requested portion of a file and sends its contents to the client with the appropriate headers.
*
* This HTTP_RANGE compatible read file function is necessary for allowing streaming media to be skipped around in.
*
* @param string $location
* @param string $filename
* @param string $mimeType
* @return void