Skip to content

Instantly share code, notes, and snippets.

@exAspArk
exAspArk / vim-heroku.sh
Created August 3, 2020 13:30 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
View vim-heroku.sh
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 / macos+ntfs.sh
Last active December 23, 2019 13:49
Mount writable NTFS disk with osxfuse + ntfs-3g
View macos+ntfs.sh
# 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 / combine video+audio
Last active September 23, 2017 20:34
Combine video and audio files
View combine video+audio
ffmpeg -i videoplayback.mp4 -i videoplayback.mp3 -c copy -map 0:0 -map 1:0 -shortest result.mp4
@exAspArk
exAspArk / processes_vs_threads.rb
Created August 24, 2017 15:46
Compare Process vs Thread creation / deletion time
View processes_vs_threads.rb
# 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
View diff_mongoid_indexes.rb
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 / gist:7db2544ab08990f5709a48186be7edbf
Created August 2, 2017 14:29 — forked from jjb/gist:7389552
Ruby 2.1 memory configuration
View gist:7db2544ab08990f5709a48186be7edbf

This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted.

All the relevant code is in https://github.com/ruby/ruby/blob/trunk/gc.c

RUBY_HEAP_MIN_SLOTS

default: 10000

The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps).

(todo: figure out how big a slot is. i think the answer can be infered from this code.)

@exAspArk
exAspArk / curl.sh
Last active April 26, 2023 08:43
Test CORS with cURL
View curl.sh
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'
@exAspArk
exAspArk / self-signed-ssl-mongo.sh
Last active May 12, 2023 04:02
Self-signed SSL Certificate with OpenSSL on MacOS | MongoDB
View self-signed-ssl-mongo.sh
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
@exAspArk
exAspArk / web-servers.md
Created May 16, 2017 16:36 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md
@exAspArk
exAspArk / gpg-import-and-export-instructions.md
Created March 27, 2017 20:33 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys
View gpg-import-and-export-instructions.md