Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / server.ts
Created July 19, 2023 22:30
TypeScript Node.js Express server example cors
import cors from 'cors'
import express from 'express'
const app = express()
const port = process.env.PORT || 8000
app.enable('trust proxy')
app.use(cors())
app.use(express.json({ limit: '500kb' }))
app.use(express.urlencoded({ extended: false, limit: '500kb', parameterLimit: 50 }))
@miguelmota
miguelmota / tmux.txt
Created June 30, 2023 04:29
tmux copy/paste default key bindings instructions
`prefix+[` to enter copy mode
navigate to the start or the end of text selection with arrow keys
press `control+space` to start selection
move to opposite end of text to copy with arrow keys
press `control+w` to copy selected text
in the same tmux session, paste with `prefix+]`, to paste into vim, paste with prefix+] in vim insert mode
@miguelmota
miguelmota / instructions.sh
Created June 12, 2023 18:13
SSH remove all cached keys from agent
ssh-add -D
@miguelmota
miguelmota / clone_private.sh
Last active June 7, 2023 21:24
git clone private repo using personal token
# generate token here: https://github.com/settings/tokens
git clone https://ghp_123...XYZ@github.com/myorg/myrepo.git
@miguelmota
miguelmota / workflow.yml
Created June 2, 2023 17:47
Github action run on pull request merge
name: hello-world
on:
pull_request:
types: [closed]
jobs:
my-job:
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
@miguelmota
miguelmota / metabaseQuery.js
Created May 24, 2023 15:30
Node.js metabase raw sql query dataset
const body = {
database: databaseInteger,
type: 'native',
native: {
query: rawSqlQuery,
},
}
const res = await fetch('https://metabase.example.com/api/dataset', {
method: 'POST',
headers: {
@miguelmota
miguelmota / dependencies.sh
Created May 18, 2023 00:32
ARch linux list packages that a package depends on
pactree -r <package-name>
@miguelmota
miguelmota / main.go
Created May 12, 2023 21:17
Go golang uint64 to bytes, bytes to uint64
// You can edit this code!
// Click here and start typing.
package main
import (
"fmt"
"math/big"
)
func main() {
@miguelmota
miguelmota / instructions.sh
Created May 2, 2023 04:10
bspwm window scaling fix
vim ~/.Xresources
# edit or add
Xft.dpi: 120
# then restart bspwm
@miguelmota
miguelmota / notes.txt
Created April 20, 2023 20:01
Linux printer debugging
make sure `cups-browsed` is running
open cups with `open http://localhost:631/`