Skip to content

Instantly share code, notes, and snippets.

module JSON
module Serializable
# Tells this class to decode JSON by using a field as a discriminator.
# - *field* must be the field name to use as a discriminator
# - *mapping* must be a hash or named tuple where each key-value pair
# maps a discriminator value to a class to deserialize
# - add into mapping default value if discriminator field optional
# For example:
dammer / Backtrace.log
Last active January 14, 2022 09:37
unmap: mprotect failed GC Dump
View Backtrace.log
10:06:10.506 GC #672 freed 918502688 bytes, heap 5931008 KiB (+ 0 KiB unmapped + 207936 KiB internal)
10:06:10.507 World-stopped marking took 2361 ms 242872 ns (1392 ms in average)
10:06:14.558 Bytes recovered before sweep - f.l. count = -31081728
10:06:14.650 In-use heap: 72% (843690 KiB pointers + 3471238 KiB other)
10:06:14.650 Immediately reclaimed 164581184 bytes, heapsize: 6073352192 bytes (0 unmapped)
10:06:14.723 Invalid memory access (signal 11) at address 0x0
10:06:14.723 unmap: mprotect failed at 0x7f57b285c000 (length 8192), errno= 12
10:06:14.723 unmap: mprotect failed
10:06:14.724 [0x55f351f54380] print_backtrace at /usr/share/crystal/src/exception/call_stack/
10:06:14.725 [0x55f351f54235] -> at /usr/share/crystal/src/
dammer /
Last active February 18, 2021 20:20
Using Tourmaline in Lucky
# Somewhere in src/handlers ...
require "tourmaline"
module Tourmaline
# Sample bot
class EchoBot < Tourmaline::Client
def echo_command(ctx)
dammer /
Created February 23, 2016 00:02 — forked from SaltwaterC/
OpenWrt support for Netgear WNR1000v2


As usual, use it at your own risk. I am not to be held responsible for your actions.

Supported devices: WNR1000v2 (tested by me), WNR1000v2-VC (provided by Comcast for free; tested by Douglas Fraser)

Notice: Upgrade WNR1000v2 to the latest factory firmware: Otherwise, the power LED may not behave properly.

You need to place the device into failsafe mode. For booting into failsafe mode, you need to power up the device while holding the reset button with a pin. The power LED should have an amber colour. Hold the button until it is starting to flash green. It starts to flash green after it flashes the amber LED for six times. After that, the device is in failsafe mode, accepting a firmware via its TFTP server. The device should respond to pings at, although the responses may be malformed.

dammer / ree-1.8.7-2011.03
Last active September 3, 2015 13:49 — forked from fgrehm/ree-1.8.7-2011.03
ruby-build REE definitions for Ubuntu 12.04
View ree-1.8.7-2011.03
How to install older versions of REE with rbenv on Ubuntu 12.04
Rbenv won't compile REE 2011.03 properly on Ubuntu 12.04, failing with an error in
If you want to keep tcmalloc functionality, you can do it like this:
Open ~/.rbenv/plugins/ruby-build/share/ruby-build/ree-1.8.7-2011.03
Replace the file's contents with those from fgrehm's gist
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential libreadline-dev git-core
# Install rbenv
git clone git:// /usr/local/rbenv
# Add rbenv to the path:
echo '# rbenv setup' > /etc/profile.d/
View gist:4705799
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total size(with indexes)"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC;
dammer / gist:4087910
Created November 16, 2012 14:53 — forked from kt103099/gist:3183125
View gist:4087910
Omniauth Facebook Error - Faraday::Error::ConnectionFailed
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, '<key from fb>', '<another key from fb>'
class SessionsController < ApplicationController
def create