Skip to content

Instantly share code, notes, and snippets.

View crespire's full-sized avatar

Simmon Li crespire

View GitHub Profile
@crespire
crespire / delim.rb
Created August 16, 2024 15:55 — forked from meagar/delim.rb
Join/Split with arbitrary single-char dlimiter
def join(strings, delimiter)
raise ArgumentError, "Invalid delimiter \"\\\"" if delimiter == "\\"
strings.map do |s|
s.gsub(/(\\|#{Regexp.escape(delimiter)})/, '\\\\\1')
end.join(delimiter)
end
@crespire
crespire / batch_pluck.rb
Last active August 13, 2024 19:41
Pluck in batches
# Assuming Rails AR is available
# This should let us pluck stuff from a big collection in batches
# We add the load: true option if we want to load the relaion beforehand.
# Because we are plucking anyway, we don't need to preload
# See: https://github.com/rails/rails/issues/47462
Model.where(some_id: 15).in_batches do |relation|
relation.pluck(:attr1, :attr2).each do |row|
# stuff
end
  1. Add https://github.com/SamSaffron/memory_profiler to development gems
  2. Update the bundle
  3. Add require "memory_profiler" to config/environments/development.rb
  4. Where you want to do a memory report, use an inline start/stop and Rails.logger.debug the report

The Minaswan::Interview

Session Format: Talk

Abstract

White-boarding is not nice. An unpaid take home project is not nice. We decided to apply the Ruby community motto "Matz is nice and so we are nice," to our enterprise technical interview process. Come learn what changes we made, how we enlisted support of other rubyists and non-rubyists alike, and how you can too.

Details

The current state of interviewing is not nice

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

@crespire
crespire / README.md
Last active February 17, 2023 00:49 — forked from grantland/README.md
NextBus API