Skip to content

Instantly share code, notes, and snippets.

View jonz94's full-sized avatar
🤯
But first, we need to talk about Parallel Universes

jonz94 jonz94

🤯
But first, we need to talk about Parallel Universes
  • Taipei, Taiwan
View GitHub Profile
@jonz94
jonz94 / auth.ts
Created July 15, 2024 12:25
create-t3-app: next-auth login with YouTube channel account via YouTube OAuth for YouTube Data API v3
// src/server/auth.ts
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { DrizzleAdapter } from '@auth/drizzle-adapter'
import { getServerSession, type DefaultSession, type NextAuthOptions } from 'next-auth'
import { type Adapter } from 'next-auth/adapters'
import { env } from '~/env'
import { db } from '~/server/db'
@jonz94
jonz94 / has-dynamic-island.ts
Created October 25, 2022 08:07
Check if current device has dynamic island using `@capacitor/device` plugin.
import { Device } from '@capacitor/device';
import { isPlatform } from '@ionic/angular';
const hasDynamicIsland = async () => {
if (!isPlatform('iphone')) {
return false;
}
const { model: identifier } = await Device.getInfo();
@jonz94
jonz94 / clean-up-psreadline-history.ps1
Created May 18, 2022 20:44
Clean up PSReadLine history file (with backup)
$historyPath = (Get-PSReadLineOption).HistorySavePath
$directory = (Get-Item $historyPath).DirectoryName
$basename = (Get-Item $historyPath).Basename
$extension = (Get-Item $historyPath).Extension
$timestamp = (Get-Date).ToString("yyyy-MM-ddTHH-mm-ssZ")
$backupPath = "$directory\$basename-$timestamp-backup$extension"
Copy-Item $historyPath $backupPath
@jonz94
jonz94 / merge-pdf.ts
Created April 25, 2022 06:44
merge multiple base64 format PDFs into single PDF File Object
import { PDFDocument } from 'pdf-lib';
async mergeMultiplgePdf(base64Pdfs: string[]): Promise<File> {
const pdfDoc = await PDFDocument.create();
for (base64Pdf of base64Pdfs) {
const url = `data:application/pdf;base64,${base64Pdf}`;
const donorPdfBytes = await fetch(url).then((res) => res.arrayBuffer());
const donorPdfDoc = await PDFDocument.load(donorPdfBytes);
@jonz94
jonz94 / auto-pr.ps1
Created December 7, 2021 13:35
minor tweaks of scoop's `bin/auto-pr.ps1`
<#
.SYNOPSIS
Updates manifests and pushes them or creates pull-requests.
.DESCRIPTION
Updates manifests and pushes them directly to the master branch or creates pull-requests for upstream.
.PARAMETER Upstream
Upstream repository with the target branch.
Must be in format '<user>/<repo>:<branch>'
.PARAMETER App
Manifest name to search.
#!/bin/sh
set -e
# available styles: "fixed", "fixed-slab", "mono", "mono-slab", "term", "term-slab", "gothic", "ui"
style="mono"
# available orthographies: "cl", "hc", "j", "k", "sc", "tc"
orthography="tc"
@jonz94
jonz94 / wsl-v1-uname-output.md
Created November 8, 2021 11:58
WSL version 1 uname output
jonz94@jonzWin11WS:~$ uname --help
Usage: uname [OPTION]...
Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order,
                             except omit -p and -i if unknown:
  -s, --kernel-name        print the kernel name
  -n, --nodename           print the network node hostname
  -r, --kernel-release     print the kernel release
@jonz94
jonz94 / get-latest-git-tag-of-a-github-repo.md
Last active October 29, 2021 10:07
Get latest git tag of a github repository
@jonz94
jonz94 / surfingkeys-settings.js
Last active October 25, 2021 20:54
Surfingkeys Settings by jonz94
// disable on these sites
const sites = [
/en.key-test.ru/,
/github.com/,
/hey.com/,
/mail.protonmail.com/,
/monkeytype.com/,
/ssh.cloud.google.com/,
/tetr.io/,
/twitter.com/,
@jonz94
jonz94 / 0-patch-scoop-nerd-fonts-manifests.md
Last active October 24, 2021 00:04
Patch https://github.com/matthewjberger/scoop-nerd-fonts manifests to allow font installation for non-admin user

Tools

  • git (scoop install git)
  • busybox for sed command (scoop install busybox)
  • nodejs version 14 (scoop bucket add versions; scoop install nodejs14)

Setup