Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
import { Request, Response, NextFunction } from "express"; | |
import { AsyncLocalStorage } from "node:async_hooks"; | |
import { PrismaClient } from '@prisma/client'; | |
const ASYNC_LOCAL_STORAGE = new AsyncLocalStorage(); | |
export const setContext = (callback: (req: Request) => any) => { | |
return (req: Request, _res: Response, next: NextFunction) => { | |
const context = callback(req); |
mkdir ~/vim | |
cd ~/vim | |
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim | |
# Compiled on Jul 20 2017 | |
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz | |
export VIMRUNTIME="$HOME/vim/runtime" | |
export PATH="$HOME/vim:$PATH" | |
cd - |
# brew install ntfs-3g | |
sudo mkdir /Volumes/NTFS | |
diskutil list | |
sudo ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other | |
rsync -v --progress ~/Downloads/something /Volumes/NTFS/ | |
sudo umount /Volumes/NTFS |
# gem install benchmark-ips | |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.warmup = 0 | |
x.report("threads") do | |
thread = Thread.new { puts 'thread' } | |
thread.join | |
end |
defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) }; | |
existing_indexes = Model.collection.indexes.map { |i| i['key'].keys }; | |
missing_indexes = defined_indexes - existing_indexes | |
# => [] | |
extra_indexes = existing_indexes - defined_indexes - [['_id']] | |
# => [] | |
################################################################################# |
curl -I -X OPTIONS \ | |
-H "Origin: http://EXAMPLE.COM" \ | |
-H 'Access-Control-Request-Method: GET' \ | |
http://EXAMPLE.COM/SOMETHING 2>&1 | grep 'Access-Control-Allow-Origin' |
openssl genrsa -out CAroot.key 2048 | |
openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below | |
openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt | |
cat CAroot.crt CAroot.key > CAroot.pem | |
openssl genrsa -out mongod.key 2048 | |
openssl req -new -key mongod.key -out mongod.csr | |
openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt | |
cat mongod.crt mongod.key > mongod.pem |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.
cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
#!/bin/sh | |
############################################################################### | |
# USAGE: | |
# > ansible_vault_merge.sh [-p PASSWORD_FILE VAULT_YAML_FILE | |
# This shell script handles conflicts generated by attempts to merge encrypted | |
# Ansible Vault files. Run this command to attempt a merge on the unencrypted | |
# versions of the file. If there are conflicts, you will be given a chance to |