`
biyeah
  • 浏览: 200702 次
  • 来自: ...
社区版块
存档分类
最新评论
文章列表
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1683808 Rake简介 Rake和Make及Ant Rake的意思是Ruby Make,一个用ruby开发的代码构建工具。Rake的英文意思是耙子,一种很朴实的劳动工具。真的是很贴切,Rake正是一个功能强大、勤勤恳恳的劳动工具。 但是,为什么Ruby需要Rake? Ruby代码不需要编译,为什么需要Rake?其实,与其说Rake是一个代码构建工具,不如说Rake是一个任务管理工具,通过Rake我们可以得到两个好处: 以任务的方式创建和运行脚本 当然,你可以用脚本来 ...

[转]ruby中的闭包

    博客分类:
  • Ruby
原文: http://kenbeit.com/posts/87/ruby%E4%B8%AD%E7%9A%84%E9%97%AD%E5%8C%85 感谢作者的辛勤劳动。 # CLOSURES IN RUBY Paul Cantrell http://innig.net # Email: username "cantrell", domain name "pobox.com" # # 翻译: kenshin54 http://kenbeit.com # I recomm ...
    今天想在论坛回复个帖子,一看自己是新手,还不能回贴,需要完成论坛规则小测验,一点进去看,乖乖,里面有13道题目,大概看了下,如果要完成至少7、8分钟吧,真是抓狂。原来的回贴热情被打了回去,呵呵,算了吧,我也不想完成这个无聊的测验,以后当个潜水员吧,这个博客就当是学习的笔记。

javascript进阶1

参考:http://ejohn.org/apps/learn 答案在后面。 1、看下面的例子,能看得出输出什么? var a = 5; function runMe(a){ console.log("a = " + a);//a=? function innerRun(){ console.log("b = " + b);//b=? console.log("c = " + c);//c=? } var b = 7; innerRun(); var c = 8; } ...
先来看下基本的知识,对于一个函数的调用,方法有以下几种。 //下面的几种写法是等价的。 alert('something'); this.alert('something'); alert.call(this,'something'); alert.apply(this,['something']); 以实现数组中each的方法做为例子。 第一种方式: Array.prototype.each = function(callback){ for(var i = 0; i< this.length;i++){ callback(this[i]);//参数既为函数名,直 ...
首先安装prototype for nodejs 引用npm install prototype 看个例子 prototype = require 'prototype' Object.extend global, prototype (9).times (x)-> console.log x [1,2,3,4].each (x)-> console.log x Person = Class.create #定义一个类 initialize: (name)-> @name = name say: (message)-& ...
http://www.prototypejs.org/api/function/bind In JavaScript, functions are executed in a specific context (often referred to as “scope”). Inside the function the this keyword becomes a reference to that scope. Since every function is in fact a property of some object—global functions are properties o ...

ruby中实现闭包

    博客分类:
  • Ruby
ruby中实现闭包很简单 如果一个方法中返回一个procedure那就构成了一个闭包。 def func x = 0 ->{x += 1 ; p x} end proc = func proc[] #or proc.call() proc[] 输出: 1 2
排序算法(javascript版与ruby版) 合并排序 javascript版本: function merge(left, right){ var result = []; while (left.length > 0 && right.length > 0){ if (left[0] < right[0]){ result.push(left.shift());//把最小的最先取出,放到结果集中 } else { result.push(right.shift()); } } ...

ruby中星号的使用

    博客分类:
  • Ruby
ruby中星号的使用 1、数字乘法 2 * 3 = 6 2、幂 10**2 = 100 (星号之间不能有空格) 3、字符串扩展 'foo' * 2 = 'foofoo' 4、数组的扩展 [1,2,[3,[4,5]]]*2 = [1,2,[3,[4,5]],1,2,[3,[4,5]]] 5、创建数组  *a = 1,3,"as"     a = [1,3, "as"] 6、数组参数传入时的前缀 a= [1 , 2]     testFun(*a) == testFun(1 , 2) != testFun([1,2]) 7、还没发现..
原文http://www.cnblogs.com/rubylouvre/archive/2010/03/31/1701813.html 作者:司徒正美 ruby提供了强大的继承机制,有关继承的方法很多。最简单就是“<<”,但还可以对要继承的东西进行细分,是把它添加到类中呢,还是实例中,这正是本文要介绍的内容。 module Foo def foo puts 'heyyyyoooo!' end end class Bar include Foo end Bar.new.foo # heyyyyoooo! Bar.foo # NoMet ...
Ruby常用的内部变量 原文http://www.cnblogs.com/rubylouvre/archive/2009/07/23/1529237.html 作者:司徒正美 在ruby程序中,经常会看到一些以$开头的变量,这些不是指我们自己在程序中设置的全局变量,而是指系统内部已经设置好的变量,他们代表了一些特定的意思,下面搜集了一些常用的内部变量,用一些简单的代码说明他们代表的意思: 局部域: 在某一个线程作用域内才能有效,下列也可看做是线程内的局部变量。 PS:这边讲解的几个变量都是于正则匹配相关的,正则匹配过程的代码是一样的,这里不重复输入正则表达式匹配的代码,只在第一个例子里给出完整 ...
今天发现这个Underscore.js,文档说 http://documentcloud.github.com/underscore/ 引用Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby)。 提供了许多类似ruby风格的函数,这是我所喜欢的。 看几个例子。 安装 引用npm install underscore 在nodes.js ...

NowJS and Reconnects

NowJS and Reconnects 保留 原文http://blog.nowjs.com/ This particular feature has been highly anticipated by the NowJS community for some time. With the switch to Socket.IO 0.6.18, which now has built-in support for socket reconnecting, implementation of this feature was actually quite doable. We've teste ...
EventEmitter是nodejs核心的一部分。很多nodejs对象继承自EventEmitter,用来处理事件,及回调。来看API中的例子 var util = require("util"); var events = require("events");//EventEmitter通过events模块来访问 function MyStream() {//新建一个类 events.EventEmitter.call(this); } util.inherits(MyStream, events.EventEmitter); ...
Global site tag (gtag.js) - Google Analytics