Skip to content

Instantly share code, notes, and snippets.

View st0012's full-sized avatar
🌴
I may be slow to respond.

Stan Lo st0012

🌴
I may be slow to respond.
View GitHub Profile
@st0012
st0012 / debugging_challenge.md
Last active August 29, 2022 07:35
Debugging Challenge

Introduction

This challenge tests if you can locate the cause of a Rails issue in 5 iterations (script execution). Although it's a Rails issue, prior knowledge on Rails is not required.

The 5 iterations limit may feel constraining, but it is intentional. If you can't locate the cause within the limitation, that's totally fine.

After the challenge, there's a simple questionnaire. If you can answer the questions, it'll help me prepare my talk for RubyKaigi. Any feedback will be appreciated 🙏

I recommend allocating 1.5 hr for the challenge and the questions

@st0012
st0012 / debugging-#45263.md
Last active August 21, 2022 23:00
Stan's debugging note for rails/rails#45263

Script

This is a bit different from the challenge's script because it's directly copied from the issue.

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
@st0012
st0012 / debug_queue.rb
Last active July 7, 2022 22:46
Monitor a queue's message inflow/outflow
require 'io/console/size'
# Usage: Replace a Queue.new with DebugQueue.new(Queue.new)
class DebugQueue < SimpleDelegator
def <<(*msg, trace: caller_locations(3, 3))
debug_print("<<", msg, trace)
super(*msg)
end

Uses

Hardware

  • 16-inch MBPR (2019) with 32 GB RAM customization
  • LG Ultrafine 4k 24-inch monitor
  • 11-inch iPad Pro (2018)

Editors & Terminal

  • Vim - for Ruby development
  • Goland - for Go development
module URLHelper
IP_HOST_REGEXP = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
HOST_REGEXP = /(^[^:]+:\/\/)?(\[[^\]]+\]|[^:]+)(?::(\d+$))?/
PROTOCOL_REGEXP = /^([^:]+)(:)?(\/\/)?$/
class << self
def url_for(options)
if options[:only_path]
path_for options
else
@st0012
st0012 / taipei_list.md
Last active July 27, 2019 15:45
Things to visit in Taipei

Places to go

  • Taipei 101
  • Tamsui
  • National Palace Museum
  • Shi-men Ting

Nigh markets

  • Tonghua Night Market - my favorite
    • There are some great bars nearby!
@st0012
st0012 / hs
Last active July 6, 2018 10:38
FLOLAC Prerequisites
myFst :: (a, b) -> a
myFst (a, b) = a
myOdd :: Int -> Bool
myOdd x = odd x
qs :: Ord a => [a] -> [a]
qs [] = []
qs (x:xs) = qs ys ++ [x] ++ qs zs
where
package main
func main() {
Start(os.Stdin, os.Stdout)
}
/*
This will behaves like:
>> 1 + 1
#=> 2
@st0012
st0012 / foo.rb
Last active October 4, 2016 08:33
class variable VS metaclass's instance variable
class Foo
@@bar = "123"
def bar
@@bar
end
class << self
def set_bar(bar)
@bar = bar
@st0012
st0012 / Gemfile
Created March 11, 2016 03:50 — forked from grantspeelman/Gemfile
Example Gemfile files preparing for the next rails upgrade
@next_upgrade ||= false
source 'https://rubygems.org'
if @next_upgrade
gem 'rails', '5.0.0.beta3'
gem 'rails-controller-testing' # https://github.com/rails/rails-controller-testing
else
gem 'rails', '~> 4.2.5.1'
end