This file contains 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
Vim Tips: | |
**g-** | |
There are a lot of better answers already given (".", "*", and "%" are far more useful), but I vote for "g-" because it is relatively new and feels like magic. Somehow, it always seems to go to the exact text state I want. | |
Basically, if you make a lot of edits, then undo them, then make one more edit, then decide you want the first set of edits back, most editors can't do it. Emacs can, but it's a pain. g- in Vim will usually take you straight there. {not in Vi} | |
This file contains 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
foo_call_back = lambda { |param1, param2| puts "#{param1} #{param2}"} | |
def new_foo(num1, num2, callback) | |
result = num1 + num2 | |
if callback && callback.lambda? | |
callback.call(result, " is the result") | |
end | |
end |
This file contains 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
function fooCallBack(param1, param2) { | |
window.alert(param1 + param2); | |
} | |
function newFoo(num1, num2, callback) { | |
var result = num1 + num2; | |
if(callback && typeof callback === 'function') { | |
callback(result, ' is the result'); | |
} | |
} |
This file contains 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
def new_foo(num1, num2, foo) | |
result = num1 + num2 | |
puts result | |
if foo && foo.lambda? | |
foo.call | |
end | |
end | |
new_foo(2, 3, lambda { puts "my callback executed"}) |
This file contains 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
function newFoo(num1, num2, callback) { | |
var result = num1 + num2; | |
window.alert(result); | |
if(callback && typeof callback === 'function') { | |
callback(); | |
} | |
} | |
newFoo(12412, 11, function(){ | |
alert('my callback executed'); |
This file contains 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
def new_foo(num1, num2, foo) | |
result = num1 + num2 | |
puts result | |
if foo | |
foo.call | |
end | |
end | |
new_foo(2, 3, lambda { puts "my callback executed"}) |
This file contains 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
function newFoo(num1, num2, callback) { | |
var result = num1 + num2; | |
window.alert(result); | |
if(callback) { | |
callback(); | |
} | |
} | |
newFoo(12412, 11, function(){ | |
alert('my callback executed'); |
This file contains 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
foo = lambda { |arg| puts arg } | |
def new_foo(num1, num2, foo) | |
result = num1 + num2 | |
foo.call(result) | |
end | |
new_foo(2, 3, foo) | |
This file contains 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
function foo(arg) { | |
window.alert(arg); | |
} | |
function newFoo(num1, num2, foo) { | |
var result = num1 + num2; | |
return foo(result); | |
} | |
newFoo(30, 11, foo); |
This file contains 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
is = { true => 'Yes', false => 'No' } | |
is[10 > 5] #=> "Yes" | |
is[20 == 25] #=> "No" |