Skip to content

Instantly share code, notes, and snippets.

View SiegeSailor's full-sized avatar
🎯
Focusing

JinYu Zhang SiegeSailor

🎯
Focusing
View GitHub Profile
@SiegeSailor
SiegeSailor / indexedDB.js
Created August 2, 2021 13:49 — forked from underground/indexedDB.js
Very simple indexed DB wrapper class for javascript
export default class IndexedDB {
constructor(dbName, dbVersion, stores) {
this.db;
this.dbName = dbName;
this.dbVersion = dbVersion;
this.stores = stores;
}
openDB(callback=(()=>{})) {
if (!window.indexedDB) {
@SiegeSailor
SiegeSailor / removeDuplicatesFromSortedArray.ts
Created July 19, 2021 16:22
Remove Duplicates from Sorted Array.
function removeDuplicates(nums: number[]): number {
if (nums.length == 0) return 0;
let current = 0;
for (let index = 0; index <= nums.length - 1; index++){
if (nums[current] !== nums[index]){
current++;
nums[current] = nums[index]
}
}
@SiegeSailor
SiegeSailor / gitlab-ci.yml
Created July 2, 2021 10:20
GitLab CI for publishing a private package.
image: node:13.10.1
stages:
- deploy
deploy:
stage: deploy
only: ['tags']
script:
- echo CI_PROJECT_ID $CI_PROJECT_ID
@SiegeSailor
SiegeSailor / package.json
Last active July 2, 2021 08:58
GitLab private package package.json configruation.
{
"name": "@group/project",
"private": false,
"repository": {
"type": "git",
"url": "https://gitlab.example.tw/group/project"
},
"version": "1.0.0",
"publishConfig": {
"@group:registry": "https://gitlab.example.tw/api/v4/projects/1/packages/npm/"
@SiegeSailor
SiegeSailor / gitlab-ci.yml
Created July 1, 2021 11:01
Demonstrate how to use envsubst in CICD.
image: node:13.10.1
stages:
- build
build:
before_script:
- apt-get update; apt-get install gettext-base git -y
script:
- mv .env .env.tmp; envsubst < .env.tmp > .env
@SiegeSailor
SiegeSailor / package.json
Last active July 1, 2021 09:13
Use env-cmd in NPM scripts.
{
"scripts": {
"host-uat": "env-cmd -f .env.uat npm run build && firebase deploy --only hosting:uat",
"host-prod": "env-cmd -f .env.production npm run build && firebase deploy --only hosting:production"
}
}
@SiegeSailor
SiegeSailor / README.md
Created April 4, 2021 06:46
An entity for react-router-dom to pass router props to components directly under Switch.

Overview

An entity for react-router-dom to pass router props to components directly under Switch.

Example

import { RouteProps } from 'react-router-dom';

interface IEntrance extends RouteProps {}
@SiegeSailor
SiegeSailor / README.md
Last active April 4, 2021 06:48
A React Hook to extract the desired element's real time property.

Overview

A React Hook to extract the desired element's real time property.

Example

import React from 'react';

import useElement from './use-element';
@SiegeSailor
SiegeSailor / phaser-sprite-event.md
Created March 8, 2021 03:10
Example using Phaser sprite events.

Overview

Example using Phaser sprite events.

Example

import * as Phaser from 'phaser';

enum ImageKey {
@SiegeSailor
SiegeSailor / BEM.ts
Last active May 27, 2021 11:42
Create and maintain classes with BEM.
/**
* Create and maintain classes with [BEM](http://getbem.com/).
* @since Feature
*/
export default class BEM {
private _block: string;
private elementArray: string[];
private modifierArray: string[];
private _record: { [element: string]: string[] };