Skip to content

Instantly share code, notes, and snippets.

@brasic
brasic / memorize_mysql
Last active January 6, 2023 04:49
transfer a codespaces dev mysql instance to tmpfs.
#!/usr/bin/env ruby
# frozen_string_literal: true
require "fileutils"
module MemorizeMysql
WD = "/var/lib"
MYSQL = "/var/lib/mysql"
def self.call
@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

@wteuber
wteuber / encrypt_decrypt.rb
Last active April 3, 2024 13:07
Simply encrypt and decrypt Strings in Ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: