Skip to content

Instantly share code, notes, and snippets.

@schmidt
schmidt / points.rb
Created May 30, 2022 08:33
Easier inheritance when implementing `==`
class Point
attr_reader :x
attr_reader :y
def initialize(x:, y:)
@x = x
@y = y
end
# def ==(other)

Keybase proof

I hereby claim:

  • I am schmidt on github.
  • I am schm (https://keybase.io/schm) on keybase.
  • I have a public key ASDw3eHBMuHacgyKSj2_G3zYvfDQgsFl-_LaQd2l35e6Tgo

To claim this, I am signing this object:

@schmidt
schmidt / test.rb
Created February 23, 2019 14:46
Meta programming challenge
class Class
def reader(*names)
names.each do |name|
module_eval <<~CODE
def #{name}
@#{name}
end
CODE
end
end
@schmidt
schmidt / rename-by-metadata.rb
Created October 20, 2017 21:11
Rename images following their proper creation date
#!/usr/bin/env ruby
require 'date'
require 'fileutils'
require 'exif' # brew install libexif; gem install exif
Dir['*.{JPG,jpg}'].each do |source|
time =
begin
@schmidt
schmidt / links.md
Created August 26, 2014 11:36
Secure Passwords
@schmidt
schmidt / web
Created October 13, 2008 13:37
Instant webserver for current dir. Fetches free port automatically.
#!/usr/bin/env ruby
require 'webrick'
require 'socket'
require 'timeout'
# code from http://stackoverflow.com/questions/517219/ruby-see-if-a-port-is-open/517638#517638
def port_in_use?(port)
begin