Skip to content

Instantly share code, notes, and snippets.

View gucheen's full-sized avatar

Cheng Gu gucheen

View GitHub Profile
@gucheen
gucheen / landing.html
Created January 26, 2024 02:03
b.guchengf.me landing
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Be Bold Creative Strategic</title>
<style>
* {
font-family: sans-serif;
@gucheen
gucheen / pinboard-json-to-netscape-html.js
Created August 15, 2023 13:34
convert pinboard json data to standard netscape html bookmarks
import fs from 'fs'
const rawFile = 'bookmarks.json'
const outputHTML = 'bookmarks.html'
const pinboardData = JSON.parse(fs.readFileSync(rawFile).toString())
fs.writeFileSync(outputHTML, `<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
It will be read and overwritten.
@gucheen
gucheen / index.html
Created March 17, 2021 03:07
BrowserView-dragging-problem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title>
<style>
*,
*::after,
*::before {
@gucheen
gucheen / format-amount.ts
Created January 26, 2021 09:50
morden-elegant-way-to-format-currency-in-js
const amountFormatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'CNY' })
/**
* 1234567.12 to 1,234,567.12
* @param amount
*/
export const formatAmount = (amount: number): string => {
if (typeof amount === 'undefined') {
return ''
}
@gucheen
gucheen / fix-hugo-md-file-time.js
Created January 21, 2021 06:15
fix hugo md files' time by its created time
// hugo list all > posts.csv
/*
When you export your markdown files from other application or system,
Files' created time will be incorrect.
This script fix these time by its date from hugo front matter.
works by `touch` command
*/
const fs = require('fs')
const path = require('path')
@gucheen
gucheen / fnm-arm64.sh
Last active December 2, 2021 16:58
fnm: install arm64 version of node from homebrew bottles
#!/bin/bash
# assume that you have installed homebrew, wget and fx(https://github.com/antonmedv/fx)
# do all things in /tmp
mkdir -p /tmp/fnm-node;
pushd /tmp/fnm-node;
# clean tmp
rm -fr ./*;
mkdir fnm;
@gucheen
gucheen / typecho2hugo.js
Created January 13, 2021 02:06
export sqlite typecho posts to hugo. depends on del and better-sqlite3
const path = require("path");
const fs = require('fs');
const del = require('del');
const Database = require('better-sqlite3');
const db = new Database('typecho.db', { verbose: console.log, readonly: true });
const tmpFolder = path.resolve(__dirname, 'typecho2hugo');
if (fs.existsSync(tmpFolder)) {
del.sync(path.resolve(tmpFolder, '*'));
@gucheen
gucheen / change-git-profile.sh
Created August 28, 2020 09:09
easily change git profile
alias git_as_gucheng='git config user.name "Cheng Gu" && git config user.email "guchengf@gmail.com" && git config user.signingKey xxxxx'
@gucheen
gucheen / douyu-dark.css
Created April 9, 2020 14:32
douyu-dark.css
@-moz-document domain("www.douyu.com") {
.layout-Player-toolbar,
.layout-Player-asideMain,
.layout-Player-announce,
.ChatRank-rankWraper,
.FansRankInfo,
.ChatTabContainer-titleWraper--tabLi,
.ChatTabContainer-titleWraper--tabLi.is-active,
.layout-Player-barrage,
.PlayerToolbar-signCont {
interface ModernOrgTreeOptions {
container: HTMLElement;
nodes?: NodeList;
parentPosition?: string;
childPosition?: string;
}
export class ModernOrgTree {
parentsPositions = {};
svg;