Skip to content

Instantly share code, notes, and snippets.

@rahilsondhi
rahilsondhi / serializer_benchmarks.rb
Created March 27, 2020 00:44 — forked from aishfenton/serializer_benchmarks.rb
Performance comparison of different ruby serializer methods
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'json'
require 'msgpack'
require 'oj'
def encode(msg, format)
@rahilsondhi
rahilsondhi / README.md
Last active August 31, 2016 08:57
How to fix Last.fm Mac client crashes

So your Last.fm Mac client is crashing...

Use launchd to check every minute that Last.fm is running. If it's not, then start it up.

  1. Create com.USERNAME.lastfm.plist in $HOME/Library/LaunchAgents
  2. Create lastfm.sh in ~
  • Don't forget to chmod +x ~/lastfm.sh
  1. Inform launchd about the new plist by doing cd $HOME/Library/LaunchAgents && launchctl load com.USERNAME.lastfm.plist
$; curl http://dockyard.com/ -vvv
* Trying 104.237.147.46...
* Connected to dockyard.com (104.237.147.46) port 80 (#0)
> GET / HTTP/1.1
> Host: dockyard.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.9.13
@rahilsondhi
rahilsondhi / import_production_mysql.sh
Last active August 29, 2015 14:07
Sync/import a production MySQL database with development using SSH tunnels when the production database is within a private network. Autoclose the SSH tunnel after a fixed duration.
#!/bin/bash
# This script depends on autossh (brew install autossh) (http://www.harding.motd.ca/autossh/)
# Variables
LOCAL_MYSQL="mysql -u root db_name"
REMOTE_APP_SERVER="app1.example.com" # You should be able to SSH here, and it should be able to access REMOTE_MYSQL_HOST
REMOTE_MYSQL_HOST="db1.example.com" # This server can be within a private network, put REMOTE_APP_SERVER should be able to access it
REMOTE_USERNAME="db_username"
REMOTE_PASSWORD="db_password"