Skip to content

Instantly share code, notes, and snippets.

View wildjcrt's full-sized avatar
🦀
have a nice day!

Jerry Lee wildjcrt

🦀
have a nice day!
View GitHub Profile
@wildjcrt
wildjcrt / test.rb
Created June 25, 2014 01:16 — forked from tka/test.rb
sql = "select *, (select count(books.id) from books where books.authorsid=authors.id) as books_count from authors "
authors = Author.find_by_sql(sql)
authors.first.books_count
@wildjcrt
wildjcrt / gist:33155bada4eb6817625a
Last active August 29, 2015 14:03
railsbridge 隨身碟內容
>> a = [1, 2, 3, 4, 5, 1, 2]
=> [1, 2, 3, 4, 5, 1, 2]
>> a.compact.size
=> 5
>> a.compact!.size
NoMethodError: undefined method `size' for nil:NilClass
from (irb):14
from /Users/wildjcrt/.rvm/rubies/ruby-2.1.3/bin/irb:11:in `<main>'
@wildjcrt
wildjcrt / 0_reuse_code.js
Last active August 29, 2015 14:10
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

Keybase proof

I hereby claim:

  • I am wildjcrt on github.
  • I am wildjcrt (https://keybase.io/wildjcrt) on keybase.
  • I have a public key whose fingerprint is RETU RN T HIS. PGP. GET_ FING ERPR INT( ); }

To claim this, I am signing this object:

<%= render_table(@products,
[
["ID", lambda { |p| p.id }],
["名稱", lambda { |p| p.name }],
["動作", lambda { |p|
link_to("Show", admin_product_path(p)) + ' | ' +
link_to("Edit", edit_admin_product_path(p)) + ' | ' +
link_to("Delete", admin_product_path(p), :confirm => "Are you sure?", :method => :delete )}]
],
:class_name => "table"
<%= render_table(@games,
[
["ID", lambda { |p| p.id }],
["遊戲名稱", lambda { |p| p.name }],
["標籤", lambda { |p| p.tag_list.join(" | ") }],
["動作", lambda { |p|
add_to_favorites_status_bar(p) + ' | ' +
unless current_user
link_to("Show", game_path(p)) + ' | ' +
end
<%= render_table(@games,
[
["ID", lambda { |p| p.id }],
["遊戲名稱", lambda { |p| p.name }],
["標籤", lambda { |p| p.tag_list.join(" | ") }],
["動作", lambda { |p|
if current_user
add_to_favorites_status_bar(p) + ' | ' +
link_to("Show", game_path(p)) + ' | ' +
link_to("Edit", edit_game_path(p)) + ' | ' +
<%= render_table(@games,
[
["ID", lambda { |p| p.id }],
["遊戲名稱", lambda { |p| p.name }],
["標籤", lambda { |p| p.tag_list.join(" | ") }],
["動作", lambda { |p| index_table(p)}]
],
:class_name => "table")
%>
wget http://hackmysql.com/scripts/mysqlsla
chmod +x mysqlsla-2.03
sudo ./mysqlsla-2.03 /var/log/mysql/mysql-slow.log
# 預設會列出 top 10 的 slow quires
# 可以帶參數 --top 13 修改列出的項目數量
# 通常網路上都說從 top 1, 2, 3 的 slow quires 去修
# 是對增進效能最有幫助的!