Skip to content

Instantly share code, notes, and snippets.

@ascendbruce
ascendbruce / regex_gsub.rb
Created July 15, 2014 06:03
gsub regex replace part
content = "這是標題之前<h1>這是標題</h1>這是標題之後"
content.gsub(/\<h1(.*)\<\/h1\>/, '<h2\1</h2>')
=> "這是標題之前<h2>這是標題</h2>這是標題之後"
# 重點在於 match 時的 () 包起來的東西變成 \1 (但必須用單引號 '' 才有效)
@ascendbruce
ascendbruce / duplication.rb
Created June 29, 2014 13:03
code club #4 候選題目
module Timer
def times(env)
value_s = env['interval']
if value_s == nil
raise "interval missing"
end
value = Integer(value_s)
if value <= 0
raise "interval should be > 0"
@ascendbruce
ascendbruce / equipment.md
Last active June 7, 2023 01:28
軟體工程師裝備建議

最後編輯 2020-11-01

列舉的種類基本上是生產力、健康相關,或是好用的工程師潮流精品(?)

這些是我偏好或想要的裝備,歡迎留言提供其他推薦裝備、發問為何要用或不用某個裝備、品牌。

免費的工具軟體雖然也很重要,但不在這邊討論,有興趣請查看 我的 Mac 環境設定

電腦周邊設備

@ascendbruce
ascendbruce / gist:c4a823b3202d7ed6f80e
Created June 14, 2014 12:17
Terminal & mac say stopwatch for interval training
class Notifier
def initialize(voice)
@voice
end
def sprint
say "sprint"
puts %(
###### ######## ######## #### ## ## ########
## ## ## ## ## ## ## ### ## ##
#!/usr/bin/env ruby -w
require 'csv'
# 1. Create a class with same initialization arguments as BIGMETHOD
# 2. Copy & Paste the method's body in the new class, with no arguments
# 3. Replace original method with a call to the new class
# 4. Apply "Intention Revealing Method" to the new class. Woot!
class FormatterNew
def initialize(file_name)
@ascendbruce
ascendbruce / unicode_spaces.rb
Created May 7, 2014 06:06
Unicode special space characters as ruby method name
# encoding: utf-8
# inspired by http://jsbin.com/nuhinuda/1/edit
def  
"U+2004 THREE-PER-EM SPACE"
end
def  
"U+2005 FOUR-PER-EM SPACE"
@ascendbruce
ascendbruce / gist:10584882
Created April 13, 2014 13:46
KKBOX 授權擁有的動漫卡通音樂 集中帖 第一頁 (markdown)

整理自 KKBOX 討論區的「KKBOX 授權擁有的動漫卡通音樂 集中帖」的第一頁(討論串樓主整理的)

需注意後面零星的歌單並沒有整理到這裡

這個 gist 是整理到 ACG Music (Taiwan) 前整理用 temp。

「鋼之鍊金術師」

《劇場版 主題曲》Link-L'Arc-en-Ciel(彩虹樂團)

@ascendbruce
ascendbruce / 0_reuse_code.js
Created January 2, 2014 03:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@ascendbruce
ascendbruce / gist:7558475
Created November 20, 2013 06:03
用 request-log-analyzer 分析 rails 的 log

先安裝 request-log-analyzer gem,建議把 log 檔抓到自己電腦來做分析。

gem i request-log-analyzer

分析某一個 log 檔

request-log-analyzer log/production.log --output HTML --file tmp/log_report.html

指定多個 log 檔