" Created compiled js file
function! s:Coffee2Js()
let current_coffee = expand('%')
let filename = substitute(expand('%:t'), ".coffee$", "", "")
exec('! coffee -co /tmp ' . current_coffee)
exec('split /tmp/' . filename . '.js')
endfunction
"
" Register a new command `C2J` for compile coffee to a js file
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" RENAME CURRENT FILE | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%'), 'file') | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! |
# When using a JavaScript loop to generate functions,
# it's common to insert a closure wrapper in order to ensure that loop variables are closed over,
# and all the generated functions don't just share the final values.
# CoffeeScript provides the do keyword,
# which immediately invokes a passed function, forwarding any arguments.
for filename in list
do (filename) ->
fs.readFile filename, (err, contents) ->
- http://slid.es/tonyq/website-performance/
- profiling
- check Front end network log
- slow query
- Look Hotest page first
- google analysis
- content > Site Speed > Page Timings 檢查常態時間
Gem for testing
group :development, :test do
gem 'rspec-rails', '~> 2.12.0'
# Auto testing
gem 'guard-rspec'
gem 'guard-spork'
gem 'ruby_gntp'
gem 'rb-fsevent', '~> 0.9.1'
# Returns a hash of attributes that can be used to build a User instance
attrs = FactoryGirl.attributes_for(:user)
# Passing a block to any of the methods above will yield the return object
FactoryGirl.create(:user) do |user|
user.posts.create(attributes_for(:post))
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
jQuery -> | |
$('#student_query_string').autocomplete | |
source: "/admin/autocomplete" | |
select: (event, ui)-> | |
location.href = '/admin/students/' + ui.item.uid | |
open: (event, ui)-> | |
$(".autocomplete_avatar").each (index, elem)-> | |
$(elem).attr("src", $(elem).data('src')) | |
.data( "ui-autocomplete" )._renderItem = ( ul, item )-> | |
$( "<li>" ).append( "<a><img class='autocomplete_avatar' data-src='" + item.avatar + "' src='<%= asset_path('fallback/thumb_default_avatar.png') %>'><span>" + item.name + "</span></a>" ).appendTo( ul ) |
- require
- tty
- singleton
- OptionParser
- http://apidock.com/ruby/OptionParser
- exec allows you to transform the current process into any other process, and never return
- exec doesn't close any open file descriptors or do any memory cleanup
- All of the methods described below are base THIS theme
fork + exec
- Passing a string to exec, it will start up a
shell
and pass the string to shell - Passing a array to exec, it will
skip
the shell and set up the array directly as ARGV tonew process
- General you want to avoid passing a string unless you really need to. Pass an array when possible
- running code through the shell can raise security concerns