Skip to content

Instantly share code, notes, and snippets.

View damien-roche's full-sized avatar
💭
Working on private repos! :P

Damien damien-roche

💭
Working on private repos! :P
View GitHub Profile
# Working with Git
alias g='git'
alias gst='git status'
alias gc='git commit'
alias gca='git commit -a'
alias ga='git add'
alias gco='git checkout'
alias gb='git branch'
alias gm='git merge'
alias gd="git diff"
@damien-roche
damien-roche / _google-analytics.slim
Last active March 31, 2021 20:28
Slim Template Google Analytics (2018)
script{ async src="https://www.googletagmanager.com/gtag/js?id=YOURIDHERE" }
javascript:
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'YOURIDHERE');
@damien-roche
damien-roche / grok.md
Created March 22, 2022 14:13
Logstash grok for Heroku Postgres log sample

Given:

source=HEROKU_POSTGRESQL_EG addon=postgresql-perp-123 sample#current_transaction=541707859 sample#db_size=361264468527bytes sample#tables=50 sample#active-connections=80 sample#waiting-connections=0 sample#index-cache-hit-rate=0.99635 sample#table-cache-hit-rate=0.98647 sample#load-avg-1m=0.33 sample#load-avg-5m=0.355 sample#load-avg-15m=0.33 sample#read-iops=79.907 sample#write-iops=2.8729 sample#tmp-disk-used=609959936 sample#tmp-disk-available=72368832512 sample#memory-total=15612012kB sample#memory-free=128844kB sample#memory-cached=14176972kB sample#memory-postgres=334364kB sample#wal-percentage-used=0.06676170938635338

Pattern:

source=%{WORD:source} addon=%{NOTSPACE:addon} sample#current_transaction=%{NUMBER:current_transaction_sample} sample#db_size=%{NUMBER:db_size_bytes}bytes sample#tables=%{NUMBER:tables} sample#active-connections=%{NUMBER:connections} sample#waiting-connections=%{NUMBER:waiting_connections} sample#index-cache-hit-rate=%{NUMBER:index_cache_hit_rate} sample#tabl
@damien-roche
damien-roche / rubymethodlookup.md
Last active January 16, 2024 10:40
A Primer on Ruby Method Lookup

A Primer on Ruby Method Lookup

Method lookup is a simple affair in most languages without multiple inheritance. You start from the receiver and move up the ancestors chain until you locate the method. Because Ruby allows you to mix in modules and extend singleton classes at runtime, this is an entirely different affair.

I will not build contrived code to exemplify the more complicated aspects of Ruby method lookup, as this will only serve to confuse the matter.

When you pass a message to an object, here is how Ruby finds what method to call:

1. Look within singleton class