Skip to content

Instantly share code, notes, and snippets.

View morninj's full-sized avatar

Joe Mornin morninj

View GitHub Profile
@morninj
morninj / cloze-from-text.txt
Created March 1, 2024 20:40
Generate Anki cloze deletion flashcard from text
Instructions:
Your task is to take text and generate a cloze deletion flashcard for Anki. Text to be deleted is enclosed in brackets like this:
This is the [text to be deleted].
There can be multiple deletions. Replace each deletion with the proper cloze deletion syntax for Anki with c1, c2, c3, etc. For example:
Input: "This is the [text] to be [deleted]."
@morninj
morninj / multicard-cloze-from-list.txt
Last active March 2, 2024 19:47
ChatGPT prompt to generate multiple cloze deletion flashcards from a list
Instructions:
Your task is to take a list of items and generate cloze deletion flashcards. There should be a separate flashcard for each list item. A "list item" is the complete line. There is one item per line.
The first line is a heading, followed by a newline. It is not part of the list. It may end with a colon. Do not create a cloze deletion for this.
Example list (one item per line):
***
@morninj
morninj / prisma-postgres-vercel.md
Last active October 16, 2023 22:22
Prisma with Postgres on Vercel

Prisma with Postgres on Vercel

Configure local Postgres databae

Install Postgres:

$ brew install postgresql

Start Postgres:

tRPC with Next.js

This gist explains how to set up tRPC in a Next.js 13 app. For the reasons explained here, this uses the Pages Router (pages/) instead of the App Router (app/). (tl;dr: As of October 2023, tRPC doesn't officially support the App Router, and it's possible but difficult to make it work.)

Install

Create a Next.js app with npx create-next-app@latest and these settings:

What is your project named? … my-app
@morninj
morninj / trpc-and-next13-with-app-router.md
Last active October 13, 2023 23:53
tRPC and Next.js 13 using App Router (not the Pages Router)

tRPC and Next.js 13 using the App Router (not the Pages Router)

Next.js 13 recommends using the App Router (app/) instead of the Pages Router (pages/). But tRPC doesn't officially support Next.js 13 (as of October 2023).

I spent a lot of time figuring out how to make tRPC work with the App Router. I succeeded, but decided that I'd prefer to wait until tRPC adds official support. So, for now, this gist is a collection of links that are related to this issue.

Instructions for using tRPC with the Pages Router are here.

Docs:

@morninj
morninj / ts-dev-workflow.md
Created October 8, 2023 20:10
TypeScript development workflow

TypeScript

Configuration

Install TypeScript globally (if it's not installed already):

$ npm install -g typescript

Save files with .ts instead of .js.

@morninj
morninj / .vimrc
Created November 9, 2022 01:50
.vimrc
syntax on
set background=dark
colorscheme solarized
" Hide gvim menus etc.
set guioptions-=m "menu bar
set guioptions-=T "toolbar
set guioptions-=r "scrollbar
" Sane copy and paste
@morninj
morninj / install-comodo-ssl-cert-for-nginx.rst
Created March 11, 2018 16:52 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@morninj
morninj / gist:242b3e54119c855d2d45087e2756c2dd
Created April 5, 2017 18:44
Ubuntu: remove old kernels and update packages
$ uname -r # get current kernel version; don't delete this one!
$ dpkg --list | grep linux-image # list installed kernels
$ sudo apt-get purge linux-image-x.x.x.x-generic # delete unused kernels; keep at least two
$ sudo update-grub2
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo reboot
https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu
https://askubuntu.com/questions/828809/cant-boot-after-apt-get-update-upgrade
@morninj
morninj / regex-examples.py
Last active October 12, 2016 18:46
Examples of common regular expression usage in Python
import re
# To test regexes, use https://regex101.com/
# Test if a string matches a pattern
string = 'News guy wept when he told us Earth was really dying'
regex = r'wept'
if re.search(regex, string):
print 'match'
else: