Skip to content

Instantly share code, notes, and snippets.

View douMax's full-sized avatar
😼

Lingxiao Wang douMax

😼
View GitHub Profile
@douMax
douMax / tasks.json
Last active February 21, 2018 13:19
json data
{title: "每天日语十分钟",
description: "",
start: "2018-2-1",
end: "2018-2-22",
members: [{id: 1, nickname:"走路兜风", avatar:"", wechat_ref:""},{id: 1, nickname:"走路兜风", avatar:"", wechat_ref:""}]}
rails new YOUR-APP-NAME-GOES-HERE --skip-turbolinks --skip-spring -d postgresql -T
cd YOUR-APP-NAME-GOES-HERE
rails g scaffold PostOrSomething title:string content:text author:string # add other fields here as needed
rails db:drop # make sure there is no existing DB to cause conflicts
rails db:create
rails db:migrate
rails g controller pages app # create a new controller with a single app action, where your app lives
# edit config/routes.rb to add the correct route line for "pages#app"
rails s # good to go!
@places = Place.where('lower(name) like ?', "%#{params[:q].downcase}%").all
number_to_currency(1234567890.50) # => $1,234,567,890.50
number_to_currency(1234567890.506) # => $1,234,567,890.51
number_to_currency(1234567890.506, precision: 3) # => $1,234,567,890.506
number_to_currency(1234567890.506, locale: :fr) # => 1 234 567 890,51 €
number_to_currency("123a456") # => $123a456
number_to_currency("123a456", raise: true) # => InvalidNumberError
number_to_currency(-1234567890.50, negative_format: "(%u%n)")
# => ($1,234,567,890.50)
@douMax
douMax / product_form_buy_it_now_buttons.liquid
Last active December 12, 2022 13:02
Product form with buy it now buttons
{%- form 'product',
product,
id: any_unique_form_id,
class: 'form',
novalidate: 'novalidate',
data-type: 'add-to-cart-form'
-%}
<input