Skip to content

Instantly share code, notes, and snippets.

View ZouYouShun's full-sized avatar
🏠
Working from home

Alan Zou ZouYouShun

🏠
Working from home
View GitHub Profile
@loilo
loilo / idb-backup-and-restore.md
Last active April 29, 2024 06:40
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'
@codediodeio
codediodeio / print.js
Last active February 9, 2024 14:11
print
export const print = (v) => {
const el = document.createElement('h3');
el.innerText = '🔵 ' + v;
document.body.appendChild(el);
}
@doggy8088
doggy8088 / Angular 17 Dev Setup.md
Last active April 22, 2024 23:59
Angular 17 開發環境說明

Angular 17 開發環境說明

為了能讓大家能夠順利的建立起 Angular 17 開發環境,以下是需要安裝的相關軟體與安裝步驟與說明。

Angular LOGO

[ 作業系統 ]

  • Windows 10 以上版本
  • Mac OS X 10.6 以上版本
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@parmentf
parmentf / GitCommitEmoji.md
Last active May 18, 2024 12:54
Git Commit message Emoji
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@paulirish
paulirish / what-forces-layout.md
Last active May 19, 2024 03:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@jpetitcolas
jpetitcolas / uncamelize.js
Created January 8, 2013 06:45
How to uncamelize a string in Javascript? Example: "HelloWorld" --> "hello_world"
/**
* Uncamelize a string, joining the words by separator character.
* @param string Text to uncamelize
* @param string Word separator
* @return string Uncamelized text
*/
function uncamelize(text, separator) {
// Assume separator is _ if no one has been provided.
if(typeof(separator) == "undefined") {