Skip to content

Instantly share code, notes, and snippets.

@hubgit
hubgit / deno-web-streams.ts
Last active December 10, 2023 22:31
Reader and Writer web streams for Deno
import { TextLineStream } from 'https://deno.land/std@0.153.0/streams/mod.ts'
// const input = await jsonLinesReader('input.jsonl.gz')
// const output = await jsonLinesWriter('output.jsonl.gz')
// for await (const item of input) {
//// do something
// await output.write(item)
// }
@hubgit
hubgit / rsync-backup.sh
Created August 31, 2020 07:22
rsync dry run with stats to summarise a backup of a remote server
rsync -avzh --progress --dry-run --stats -e ssh example:/ . --exclude=/backups --exclude=/boot --exclude=/build --exclude=/dev --exclude=/dump --exclude=/initrd --exclude=/latest --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/nonexistent --exclude=/proc --exclude=/run --exclude=/selinux --exclude=/srv --exclude=/sys --exclude=/tmp
@ypresto
ypresto / .zshrc
Created May 31, 2020 18:29
Fix "SSL certificate problem: certificate has expired" issue in homebrew
# Add this snippet to your .zshrc, .bashrc or etc.
# https://security.stackexchange.com/a/232446/235706
export CURL_SSL_BACKEND=secure-transport
# https://github.com/Homebrew/brew/issues/6274#issuecomment-507937736
export HOMEBREW_NO_ENV_FILTERING=1
@hubgit
hubgit / Queue.ts
Created August 12, 2019 13:25
A queue
type QueueItem = () => Promise<void>
export class Queue {
private items: QueueItem[] = []
private running: boolean = false
public add = (item: QueueItem): void => {
this.items.push(item)
@nathandem
nathandem / pdf.py
Last active February 7, 2022 08:23
Arbitrary header/footer integration in Weasyprint PDF pages
from weasyprint import HTML, CSS
class PdfGenerator:
"""
Generate a PDF out of a rendered template, with the possibility to integrate nicely
a header and a footer if provided.
Notes:
------
@hubgit
hubgit / urlsearchparams.js
Created July 27, 2018 20:36
URLSearchParams
(() => {
// build
const params = new URLSearchParams()
params.append('q', 'bar')
params.append('n', 5)
// stringify
// const url = `https://example.com/resources?${params.toString()}`
const location = new URL('https://example.com/resources')
/*
# Clean UI programming in a vacuum
This app was written for Chapter 19 in the 3rd edition of Eloquent
JavaScript—it aims to demonstrate modern UI programming without
depending on a specific framework or library.
Its convention is that components have an interface like this:
```
@simonw
simonw / datasette-polar-bears.md
Last active January 17, 2022 21:16
Datasette for Polar Bears
@milankorsos
milankorsos / redux-actions.ts
Last active November 10, 2022 10:58
Correct TypeScript typing example for Redux Thunk actions
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};
@max-mapper
max-mapper / index.txt
Created August 10, 2017 21:51
crossref type=dataset dois resolved by domain frequency
379490 referenceworks.brillonline.com
377682 doi.apa.org
244045 primarysources.brillonline.com
189587 f1000.com
106769 www.iucnredlist.org
78961 www.e-enlightenment.com
67194 doi.namesforlife.com
20335 www.degruyter.com
17940 www.icpsr.umich.edu
17044 www.scivee.tv