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
class X.Example extends X.Object | |
@proxyMethod "attachmentManager.manageAttachment" | |
# Equivalent to: | |
# manageAttachment: -> | |
# @attachmentManager.manageAttachment.apply(@attachmentManager, arguments) | |
@proxyMethod "delegate?.compositionDidChangeDocument" | |
# Equivalent to: | |
# compositionDidChangeDocument: -> | |
# @delegate?.compositionDidChangeDocument?.apply(@delegate, arguments) |
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
#!/usr/bin/env TEST=1 tclsh | |
proc let {block args} { | |
try { | |
set captured_vars [uplevel [list capture [block args]]] | |
set all_var_names [uplevel {info vars}] | |
foreach var [block args] value $args { | |
uplevel [list catch [list unset $var]] | |
uplevel [list set $var $value] |
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
require "tcl" | |
module Tcl | |
class ExprEvaluator | |
def initialize | |
@interp = Tcl::SafeInterp.new | |
commands = @interp.list_to_array(@interp._!(:info, :commands)) - %w(info set unset rename expr) | |
(commands + %w(rename)).each { |command| @interp._!(:rename, command, "") } | |
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
H:\Projects\sprockets>rake | |
C:/ruby/bin/ruby -Ilib;test "C:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_concatenation.rb" "test/test_environment.rb" "test/test_helper.rb" "test/test_pathname.rb" "test/test_preprocessor.rb" "test/test_secretary.rb" "test/test_source_file.rb" "test/test_source_line.rb" | |
(in H:/Projects/sprockets) | |
Loaded suite C:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader | |
Started | |
.E.F.EFFFFF..........E.E.EEEFFE......F............ | |
Finished in 2.922 seconds. | |
1) Error: | |
test_save_to(ConcatenationTest): |
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 extract_options_from(arguments) | |
arguments.values_at *(indexes_for(arguments) - argument_indexes_for(arguments)) | |
end | |
def extract_arguments_from(arguments) | |
arguments.values_at *argument_indexes_for(arguments) | |
end | |
def indexes_for(arguments) | |
(0...arguments.length).to_a |
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
var DateHelper = { | |
timeAgoInWords: function(from) { | |
return this.distanceOfTimeInWords(new Date(), from); | |
}, | |
distanceOfTimeInWords: function(to, from) { | |
var distance_in_seconds = ((to - from) / 1000); | |
var distance_in_minutes = (distance_in_seconds / 60).floor(); | |
if (distance_in_minutes <= 0) return "less than a minute"; |
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
# A library for downloading issues of Harpers from the archives. | |
# | |
# To use, log in to the archives from your web browser. Then set the | |
# HARPERS_ARCHIVE_COOKIE environment variable to the value of the .harpers.org | |
# "archive" cookie, which you can find by visiting the following URL while on | |
# the Harpers website: | |
# | |
# javascript:prompt("HARPERS_ARCHIVE_COOKIE",document.cookie.match(/(?:;|^)\s*archive=(.+?)(?:;|$)/)[1]) | |
# | |
# Example: |
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
module Tcl | |
class << self | |
# Returns a well-formed Tcl list from the given array of strings. | |
def array_to_list(array) | |
array.map { |element| string_to_word(element.to_s) }.join(" ") | |
end | |
# Returns a well-formed Tcl word from the given string. | |
def string_to_word(string) | |
should_be_braced?(string) ? brace_string(string) : escape_string(string) |
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
#!/usr/bin/env macruby | |
# % gdb macruby ns_url_protocol_test.rb | |
# | |
# (gdb) run ns_url_protocol_test.rb http://www.google.com/ | |
# Starting program: /usr/local/bin/macruby ns_url_protocol_test.rb http://www.google.com/ | |
# | |
# received 4900 bytes | |
# | |
# Program exited normally. |
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
token Op {'/' || '*' || '+' || '-'}; | |
token Value { \d+[\.\d+]? }; | |
token Item { <Value> || <Op> }; | |
token Expr { [<ws> <Item> <ws>]+ }; | |
sub do_op($lhs, $rhs, $op) { | |
given $op { | |
when '*' { $lhs * $rhs } | |
when '+' { $lhs + $rhs } | |
when '-' { $lhs - $rhs } |
OlderNewer