Skip to content

Instantly share code, notes, and snippets.

View gera2ld's full-sized avatar
👽
what can I say

Gerald gera2ld

👽
what can I say
View GitHub Profile
@gera2ld
gera2ld / Dockerfile
Last active June 19, 2023 09:41
Docker deployment for cryptpad
View Dockerfile
FROM node:16-alpine
# git is required by bower
RUN apk add --no-cache git curl \
&& mkdir /cryptpad
WORKDIR /cryptpad
COPY entry-point.sh /
VOLUME /cryptpad
EXPOSE 3000
@gera2ld
gera2ld / csv-parse.ts
Last active May 12, 2023 14:59
CSV parser
View csv-parse.ts
export function parseCsv(input: string, delimiter = ',') {
const scanQuoteEnd = (i: number) => {
for (; i < input.length; i += 1) {
const c = input[i];
if (c === '"') {
if (input[i + 1] === '"') i += 1;
else break;
}
}
if (!input[i]) throw new Error('Quote is expected');
@gera2ld
gera2ld / xbelmd.ts
Last active March 22, 2023 03:47
XBEL to Markdown converter
View xbelmd.ts
import { parse as parseArgs } from "https://deno.land/std@0.175.0/flags/mod.ts";
import { parse, stringify } from "https://deno.land/x/xml/mod.ts";
const INDENT_SIZE = 2;
interface IBookmark {
"@id": number;
"@href": string;
title: string;
}
@gera2ld
gera2ld / README.md
Last active October 30, 2022 03:18
微博终结者
View README.md

微博终结者

一键删除所有微博。

用法

@gera2ld
gera2ld / tiddly2doku.ts
Created January 13, 2022 16:19
Import Markdown from TiddlyWiki to DokuWiki
View tiddly2doku.ts
#!/usr/bin/env -S deno run -A
/**
* Import Markdown from TiddlyWiki to DokuWiki
*/
const encoder = new TextEncoder();
const decoder = new TextDecoder();
const tiddlerDir = Deno.env.get('TIDDLER_DIR');
const dokuDir = Deno.env.get('DOKU_DIR');
@gera2ld
gera2ld / base64.js
Last active September 7, 2023 14:39
Base64 encoder / decoder with unicode support
View base64.js
// See https://github.com/gera2ld/js-lib
@gera2ld
gera2ld / brew-clean.sh
Created October 28, 2020 05:36
Clean unused packages installed by Homebrew
View brew-clean.sh
expected=(
# paste packages to keep here
aria2
deno
fzf
yarn
)
brew_clean() {
while
@gera2ld
gera2ld / app.svelte
Created September 27, 2020 16:15
Clipboard svelte component
View app.svelte
<script>
import Clipboard from './clipboard.svelte';
</script>
<Clipboard let:copy let:copied text="some text">
{#if copied}
<span>Copied</span>
{:else}
<button {copy}>Copy</button>
{/if}
@gera2ld
gera2ld / katex.md
Last active July 9, 2023 07:23
Markmap demo
View katex.md
markmap
extraJs
npm:katex/dist/contrib/mhchem.min.js
  • katex
    • $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$
  • $\ce{N2 + 3H2 -&gt;[Fe] 2NH3}$
@gera2ld
gera2ld / html2pdf.js
Created August 1, 2020 09:08
Create PDF from HTML via Puppeteer
View html2pdf.js
const fsPromises = require('fs').promises;
const puppeteer = require('puppeteer');
async function main() {
const browser = await puppeteer.launch({
headless: true,
args: ['--proxy-server=socks5://127.0.0.1:2020'],
});
const page = await browser.newPage();
await page.goto('https://gera2ld.space', { waitUntil: 'networkidle0' });