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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
{ | |
"suggest.noselect": false, | |
"coc.preferences.formatOnSaveFiletypes": [ | |
"javascript", | |
"typescript", | |
"typescriptreact", | |
"json", | |
"javascriptreact", | |
"typescript.tsx", | |
"graphql" |
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu1BRFhnEOYgYjY3QEtJUVdaudwNiH2fpFuAgxTzL8XQoBA1xbuJhsMREpPNkcdz+f2RIObNFrMhUmOb7Nt9aScOFL3iLp36lRxgSfBeuYkzM8INDhxqhAYZFMDCsnLFbopJ3KNv0jCsf54TahGKVgMBv8MCUwSi/TFCv5tOvmFwJxKOohbQNKqB9uC0WYRfomhxFOjuRJRhWIuRx8BhP0Sr694nUM+YeRtv4xU+VSYV7rEHCr2Tlu4IvkGUL2WNdxzthSfPzp3469/TYAct56FIhOTu7dUvK3cTYy8xR6eWAwnylb31iLOg3IJwuNuHs6G/2aQhfE9NuzWu7bG3DD azi@Azi-MBP.local |
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
經常會用到的 has_many, validate_presence_of,attr_reader...etc | |
- ClassMethods 和 InstanceMethods | |
class Contest < ActivieRecord::Base | |
has_many :votes | |
has_many :entites | |
validate_presence_of :title | |
end | |
class Book |
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
in Rails2.X | |
Person.find(:all, :conditions => [ "category IN (?) and name = ?", categories, parmas[:name]], :limit => 50, :order => "created_at DESC") | |
Person.where(category: categories, name: params[:name]) | |
.order('created_at DESC') | |
.limit(50) | |
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
something *args do |*items| | |
... | |
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
module CheckedAttributes | |
def attr_checked(attr, &validate) | |
define_method "#{attr}" do | |
eval("@attr") | |
end | |
define_method "#{attr}=" do |v| | |
if validate | |
raise 'Invalid attribute' unless validate.call(v) |
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
class PatentJob | |
def run | |
update_patents(parse(download_file)) | |
end | |
def download_file | |
temp = Tempfile.new('patents') | |
tempname = temp.path | |
temp.close | |
Net::FTP.open(config.host, config.login, config.password) do |ftp| |
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
class Warehouse | |
attr_accessor :amount | |
attr_accessor :sale_cnt | |
attr_accessor :item_name | |
def initialize | |
@item_name = "item_#{rand(100)}" | |
@amount = rand(100) | |
@sale_cnt = rand(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
def ff | |
a = 1 | |
def my_method | |
puts "My Method: #{local_variables.inspect}" | |
end | |
my_method | |
lab = lambda do | |
puts "Lambda #{local_variables.inspect}" |
NewerOlder