Skip to content

Instantly share code, notes, and snippets.

@exAspArk
exAspArk / curl.sh
Last active March 30, 2025 14:43
Test CORS with cURL
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'
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']]
# => []
#################################################################################
@exAspArk
exAspArk / processes_vs_threads.rb
Created August 24, 2017 15:46
Compare Process vs Thread creation / deletion time
# 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
@exAspArk
exAspArk / macos+ntfs.sh
Last active March 30, 2025 14:42
Mount writable NTFS disk with osxfuse + ntfs-3g
# 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
@exAspArk
exAspArk / vim-heroku.sh
Created August 3, 2020 13:30 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
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 -
@exAspArk
exAspArk / prisma-context.ts
Last active April 14, 2025 01:13
Prisma Extension with Express.js HTTP Request Context
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);