Skip to content

Instantly share code, notes, and snippets.

View hlcfan's full-sized avatar

Alex Shi hlcfan

View GitHub Profile
@hlcfan
hlcfan / README.md
Created October 22, 2019 04:03 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

Keybase proof

I hereby claim:

  • I am hlcfan on github.
  • I am hlcfan (https://keybase.io/hlcfan) on keybase.
  • I have a public key ASBItcWT-vAFzuqdVlm5DOVH0Nk65rnCk8Opi98Jayx3Xwo

To claim this, I am signing this object:

@hlcfan
hlcfan / ruby-tls-doctor.txt
Created July 27, 2018 06:49
Ruby TLS doctor
# Openssl version
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
# Ruby installation args
ruby -r rbconfig -e 'puts RbConfig::CONFIG["configure_args"]'
# Full scan
ruby -ropen-uri -e 'eval open("https://git.io/vQhWq").read'
# Simple test
@hlcfan
hlcfan / active_record_log_subscriber.rb
Created March 30, 2017 12:34
Log which line caused a query
module LogQuerySource
def debug(*args, &block)
return unless super
backtrace = Rails.backtrace_cleaner.clean caller
relevant_caller_line = backtrace.detect do |caller_line|
!caller_line.include?('/initializers/')
end
@hlcfan
hlcfan / gist:369a0673a36f6c3d99fc3bccfd1d729f
Created July 13, 2016 06:33
Output how much memory used
# gem 'get_process_mem'
def print_usage(description)
mb = GetProcessMem.new.mb
puts "#{ description } - MEMORY USAGE(MB): #{ mb.round }"
end
def print_usage_before_and_after
print_usage("Before")
yield
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
def display_errors
error_elements = [ ]
self.errors.each do |error|
if error.downcase.include?("display name")
error_elements << :display_name
elsif error.downcase.start_with?("first name")
error_elements << :first_name
elsif error.downcase.start_with?("last name")
error_elements << :last_name
elsif error.downcase.start_with?("user name")