- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
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
| # app/validators/reserved_name_validator.rb | |
| class ReservedNameValidator < ActiveModel::EachValidator | |
| RESERVED_NAMES = %w{ | |
| about account add admin api | |
| app apps archive archives auth | |
| blog | |
| config connect contact create | |
| delete direct_messages downloads | |
| edit email | |
| faq favorites feed feeds follow followers following |
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
| # $Id: vim-keys.conf,v 1.2 2010/09/18 09:36:15 nicm Exp $ | |
| # | |
| # vim-keys.conf, v1.2 2010/09/12 | |
| # | |
| # By Daniel Thau. Public domain. | |
| # | |
| # This configuration file binds many vi- and vim-like bindings to the | |
| # appropriate tmux key bindings. Note that for many key bindings there is no | |
| # tmux analogue. This is intended for tmux 1.3, which handles pane selection | |
| # differently from the previous versions |
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
| var pcap = require('pcap'), // npm install pcap | |
| tcp_tracker = new pcap.TCP_tracker(), | |
| pcap_session = pcap.createSession('en1'); // Change to your interface | |
| pcap_session.on('packet', function (raw_packet) { | |
| var packet = pcap.decode.packet(raw_packet); | |
| tcp_tracker.track_packet(packet); | |
| }); | |
| tcp_tracker.on('http response body', function(session, http, data) { |
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
| #!/usr/bin/env ruby | |
| PRESUMPTIVE_RAILS_ROOT = "/data/[APP_NAME]/current" | |
| LOG_PATH = "/data/[APP_NAME]/shared/log/delayed_job_singleton.log" | |
| Dir.chdir PRESUMPTIVE_RAILS_ROOT | |
| require 'home_run' | |
| require "rubygems" | |
| require "bundler/setup" |
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
| describe "GET current" do | |
| before do | |
| @request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}" | |
| get :current, :format => 'js' | |
| end | |
| it { should respond_with(:success) } | |
| it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") } | |
| it { should render_template('notices/current') } | |
| 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
| require 'eventmachine' | |
| require 'evma_httpserver' | |
| class MyHttpServer < EM::Connection | |
| include EM::HttpServer | |
| def post_init | |
| super | |
| no_environment_strings | |
| 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
| !!! 5 | |
| %html | |
| %head | |
| %title= "Your Website" | |
| %meta{ :content => "", :name => "description" } | |
| %meta{ :content => "", :name => "author" } | |
| %meta{ :content => "3 days", :name => "revisit-after" } | |
| %link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" } | |
| %link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" } | |
| %link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" } |
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
| $ git branch -r --merged | | |
| grep origin | | |
| grep -v '>' | | |
| grep -v master | | |
| xargs -L1 | | |
| awk '{split($0,a,"/"); print a[2]}' | | |
| xargs git push origin --delete |
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
| # == Schema Information | |
| # | |
| # Table name: posts | |
| # | |
| # id :integer(4) not null, primary key | |
| # title :string(255) | |
| # author :text | |
| # content :text | |
| # state :text | |
| # type :text |