Skip to content

Instantly share code, notes, and snippets.

exAspArk

Block or report user

Report or block exAspArk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@exAspArk
exAspArk / macos+ntfs
Last active Oct 4, 2019
Mount writable NTFS disk with osxfuse + ntfs-3g
View macos+ntfs
sudo mkdir /Volumes/NTFS
diskutil list
sudo /usr/local/bin/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 Sep 23, 2017
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 Aug 24, 2017
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 Aug 2, 2017 — 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 Oct 18, 2019
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 Oct 19, 2019
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 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

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.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@exAspArk
exAspArk / gpg-import-and-export-instructions.md
Created Mar 27, 2017 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys
View gpg-import-and-export-instructions.md

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.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
# or, instead of backing up trustdb...
@exAspArk
exAspArk / ansible_vault_merge.sh
Last active Feb 24, 2017 — forked from benzado/vault-merge.sh
A shell script for merging encrypted Ansible vault files in a git repository
View ansible_vault_merge.sh
#!/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
You can’t perform that action at this time.