Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
@Raynos
Raynos / scanner.sh
Created October 24, 2024 15:10 — forked from andyrbell/scanner.sh
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:*",
"route53domains:*",
"cloudfront:ListDistributions",
"elasticloadbalancing:DescribeLoadBalancers",

I attempted to use parcel to bundle a commonJS project.

Example code

For example

const assert = require('assert')

const MyWebComponent = require('./my-web-component')
@Raynos
Raynos / mutex.js
Last active June 9, 2020 15:43
PromiseLock or Mutex ?
/**
* A PromiseLock like object.
*
* Used to ensure that we only do one thing at a time on a shared resource.
*
* For example, with async iterator:
*
* this.readLock = new Mutex()
* this.readLock.do(async () => {
* const data = await itr.next();
@Raynos
Raynos / also-broken.cjs
Created May 28, 2020 10:20
Cannot require ESM
const isPromise = import('./third-party-is-promise.mjs')
console.log(typeof isPromise)
console.log('then method', typeof isPromise.then)
export class ValidationFail {
readonly validateErr: string
readonly ok: false
constructor(validateErr: string) {
this.validateErr = validateErr
this.ok = false
}
}
export class ValidationSuccess<T> {
$ npm pack @pre-bundled/[email protected] | wc -l
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled%2ftape 13ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled%2ftape 5ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled/tape/-/tape-5.0.0.tgz 3ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/@pre-bundled/tape/-/tape-5.0.0.tgz 59ms (from cache)
npm notice
npm notice 📦 @pre-bundled/[email protected]
npm notice === Tarball Contents ===
npm notice 17B pre-bundled/node_modules/dotignore/test/.1-ignore
npm notice 468B .editorconfig
1 import fs, { readFileSync } from 'fs';
2 import { syncBuiltinESMExports, createRequire } from 'module';
3
4 const require = createRequire(import.meta.url)
5 const { readFileSync: readFileSync2 } = require('fs')
6
7 var ref = readFileSync
8
9 console.log('import', readFileSync)
10 console.log('var ok ?', ref)
class DataTableExample extends DataTable {
computeRowValues (row) {
return [
row.message,
new Date(row.timestamp).toGMTString()
]
}
computeRowHeaders () {
'use strict'
const pino = require('pino')
const os = require('os')
const { modes } = require('./logger.js')
/**
* This class gives an improved interface for pino
*