rails server -b $IP -p $PORT
rails generate scaffold product name:string photo:string description:text price:decimal is_available:boolean
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
// munged from https://github.com/simontime/Resead | |
namespace sead | |
{ | |
class Random | |
{ |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOXNHpude7f2rmW60Qx9/PINnJ/TETg/XqAdvEtjuj+6v1oGZD/oaF3nhG43ypSutaB12NTV4K+F6EUmmXVXk2rhzU6kCIP+pTmOE9cUpCvkW2SZtba0OKOpJGc5BS9BWuLp4mpYHuDcF5MSRH69zs3WCYrzbU5+i26uJ8Pr6vJVWwlCGrnnZ7WFTovrBW91clNvzewrDpyrtKfpEFe7VKIuu3hdcu7Q6WeHIQt+M/brESSzLca9aD/v0yRzCnZ+gvt14EceKMVg19ZqS21kyBQMPjXzF3VTYf7UdK87jjMqww9TR+AgiTsf9oy/npLnk3I4HnUWre4iUaljpXm8cF [email protected] |
def block_test(&b) | |
b.call | |
b.yield | |
b.() | |
b.[] | |
b.=== | |
end | |
block_test { puts "hi" } |
class A | |
def self.my_attr_accessor(attr) | |
define_method "#{attr}" do | |
instance_variable_get("@#{attr}") | |
end | |
define_method "#{attr}=" do |param| | |
instance_variable_set("@#{attr}", param) | |
end | |
end |
module ActiveRecord | |
class Base | |
def self.has_one(something) | |
define_method "#{something}=".to_sym do |new_value| | |
instance_variable_set("@#{something}", new_value) | |
end | |
define_method something.to_sym do | |
instance_variable_get("@#{something}") | |
end |
p [*1..5].map { |i| i * 2 } | |
p ([*1..5].map { |i| i * 2 }) | |
p [*1..5].map do |i| i * 2 end | |
p ([*1..5].map) do |i| i * 2 end | |
p ([*1..5].map do |i| i * 2 end) | |
def hello(x) | |
puts "hi" | |
if block_given? |
5.my_times do |i| | |
puts "#{i} hello" | |
end | |
# 或 | |
my_times(5) do |i| | |
puts "#{i} hello" | |
end | |
# 期望結果: |
class Product | |
# 實作 | |
end | |
class Cart | |
# 實作 | |
end | |
p1 = Product.new("ruby", 100) | |
p2 = Product.new("php", 200) |
<!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; |