Skip to content

Instantly share code, notes, and snippets.

@benlinton
benlinton / multiple_mysql_versions_for_development.md
Last active August 15, 2025 21:37
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.

@raecoo
raecoo / benchmark-hash-key-amount.rb
Last active January 5, 2016 07:06
Interesting…Once the Hash key amount more than 6, the performance will decrease exponentially.
require 'benchmark'
ITERATIONS = 1000000
def run(array, bench)
bench.report("#{array.count} keys") do
ITERATIONS.times { Hash[array] }
end
end

Go编码规范指南

##序言

看过很多方面的编码规范, 可能每一家公司都有不同的规范, 这份编码规范是写给我自己的, 同时希望我们公司内部同事也能遵循这个规范来写Go代码.

如果你的代码没有办法找到下面的规范, 那么就遵循标准库的规范, 多阅读标准库的源码, 标准库的代码可以说是我们写代码参考的标杆.

格式化规范

@manuelmeurer
manuelmeurer / _etc_monit.d_mysql
Last active January 10, 2021 21:38
Monit config files
check process mysql
with pidfile /var/run/mysqld/mysqld.pid
start program = "/usr/sbin/service mysql start" with timeout 60 seconds
stop program = "/usr/sbin/service mysql stop" with timeout 60 seconds
if totalmem > 400 MB for 5 cycles then alert
if totalmem > 600 MB for 5 cycles then restart
if cpu > 50% for 5 cycles then alert
if cpu > 90% for 5 cycles then restart
if 3 restarts within 5 cycles then timeout
@maxivak
maxivak / send_data-send_file-remote-images-download
Created January 1, 2013 23:34
Rails. Download remote image as attachment in browser
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"