This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | |
| <meta charset="utf-8"> | |
| <title>新北市 U-Bike 據點</title> | |
| <style> | |
| html, body { | |
| height: 100%; | |
| margin: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'json' | |
| require 'erb' | |
| class Webpage | |
| def call(env) | |
| locations = get_ubike | |
| content = ERB.new(File.read("map.html")) | |
| [200, {'Content-Type' => 'text/html'}, [content.result(binding)]] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | |
| <meta charset="utf-8"> | |
| <title>Complex icons</title> | |
| <style> | |
| html, body { | |
| height: 100%; | |
| margin: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'json' | |
| class Webpage | |
| def call(env) | |
| content = File.read("map.html").gsub("{{locations}}", get_ubike) | |
| [200, {'Content-Type' => 'text/html'}, [content]] | |
| end | |
| private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add_zero(n, digit = 0) | |
| "#{"0" * digit}#{n}"[-digit..-1] | |
| end | |
| puts add_zero(3, 5) #=> 00003 | |
| puts add_zero(13, 8) #=> 00000013 | |
| puts add_zero(43, 10) #=> 0000000043 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| greeting_and_do_something = Proc.new do |message| | |
| puts "Hello, #{message}" | |
| yield(message) if block_given? | |
| puts "wish you have a good time" | |
| message | |
| end | |
| # callback demo | |
| def trainingWithCompletion(&block) | |
| puts "training begin..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Cc | |
| def hello | |
| world | |
| end | |
| def world | |
| puts "world" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| week 01 環境設定 + 第一個 Rails 應用程式 | |
| week 02 HTML/CSS + 終端機指令 | |
| week 03 用 Git 來控制你的人生 | |
| week 04 Ruby for Rails, MVC | |
| week 05 View + Twitter Bootstrap | |
| week 06 Active Record | |
| week 07 好棒棒的套件介紹 | |
| week 08 寄發 email + 背景工作處理 | |
| week 09 會員系統 + 網站後台 + 商品上架 | |
| week 10 購物車 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module StateMachine | |
| module Integrations | |
| module ActiveModel | |
| public :around_validation | |
| end | |
| module ActiveRecord | |
| public :around_save | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% flash.each do |flash_type, message| %> | |
| <div class="alert alert-success alert-dismissible" role="alert"> | |
| <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
| <%= message %> | |
| </div> | |
| <% end %> |