== Javascript
~ » node
> console.log([1,2,3].map(function(n){n*2}))
[ undefined, undefined, undefined ]
> console.log([1,2,3].map(function(n){return n*2}))
[ 2, 4, 6 ]
== Ruby
| Math.floor(0.03 * 100) * 0.1 | |
| //>>> 0.30000000000000004 | |
| Math.floor(0.03 * 100) / 10 | |
| //>>> 0.3 |
== Javascript
~ » node
> console.log([1,2,3].map(function(n){n*2}))
[ undefined, undefined, undefined ]
> console.log([1,2,3].map(function(n){return n*2}))
[ 2, 4, 6 ]
== Ruby
| #!/usr/bin/env coffee | |
| queryString = require('querystring') | |
| util = require("util") | |
| parser = module.exports = (qs, sep, eq) -> | |
| sep = sep || '&' | |
| eq = eq || '=' | |
| params = {} |
| def tip(msg); puts; puts msg; puts "-"*100; end | |
| # | |
| # 30 Ruby 1.9 Tips, Tricks & Features: | |
| # http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
| # | |
| tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
| tip "Ruby 1.9 supports named captures in regular expressions!" |
| // try ruby-like mixin in javascript | |
| function mixin(object, name, fn) { | |
| var orignal = object[name]; | |
| object[name] = function() { | |
| try { | |
| this.super = orignal; | |
| return fn.apply(this, arguments); | |
| } finally { |
| org_rails_cmd=`which rails` | |
| function rails { | |
| if [ $# -eq 0 ];then | |
| $org_rails_cmd | |
| elif [ -e script/rails ]; then | |
| ./script/rails $@ | |
| elif [ $1 = 'c' ];then | |
| shift | |
| ./script/console $@ |
| require 'sass/plugin/rack' | |
| Sass::Plugin.options.merge!(:css_location => "./path/to/stylesheets") | |
| use Sass::Plugin::Rack | |
| run Rack::Directory.new(".") |
| local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
| local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}' | |
| local current_path='%{$terminfo[bold]$fg[blue]%}%c%{$reset_color%}' | |
| local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}' | |
| local git_branch='$(git_prompt_info)%{$reset_color%}' | |
| local current_time='%{$fg[yellow]%}%D{[%I:%M:%S]}%{$reset_color%}' | |
| local arrow="%{$fg_bold[red]%}$%{$reset_color%}" | |
| PROMPT="${current_dir} ${git_branch}${arrow} " |
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>Html5 video with jq.tmpl sample</title> | |
| <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script> | |
| <script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script> | |
| <script type="text/javascript"> | |
| $(document).ready(function () { |
| foobar = (x) -> not_exist | |
| foobar(1) |