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
framework 'cocoa' | |
class Application | |
def applicationDidFinishLaunching(notification) | |
frame = NSRect.new(NSPoint.new(100, 100), NSSize.new(300, 300)) | |
@main_window = NSWindow.alloc.initWithContentRect( | |
frame, | |
:styleMask => (NSTitledWindowMask | NSClosableWindowMask), | |
:backing => NSBackingStoreBuffered, |
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
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable @__instance__ not initialized | |
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable @inheritable_attributes not initialized | |
unknown: warning: instance variable __attached__ not initialized | |
unknown: warning: instance variable __attached__ not initialized | |
unknown: warning: instance variable __attached__ not initialized |
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 'benchmark' | |
require 'sexpistol' | |
require 'sxp' | |
class Lexer | |
def initialize(str) | |
@str = str | |
@p = 0 | |
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
require 'benchmark' | |
require 'sexpistol' | |
require 'sxp' | |
class Lexer | |
def initialize(str) | |
@str = str | |
@p = 0 | |
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
require 'benchmark' | |
require 'sexpistol' | |
require 'sxp' | |
example_sexp = <<-EOD | |
((display "This is a test string!") | |
(define test (lambda () (begin | |
(display (== 1 1)) |
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_string_literals( string ) | |
string_literal_pattern = /"([^"\\]|\\.)*"/ | |
string_replacement_token = "___+++STRING_LITERAL+++___" | |
# Find and extract all the string literals | |
string_literals = [] | |
string.gsub(string_literal_pattern) {|x| string_literals << x} | |
# Replace all the string literals with our special placeholder token | |
string = string.gsub(string_literal_pattern, string_replacement_token) | |
# Return the modified string and the array of string literals | |
return [string, string_literals] |
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
# Benchmark this system's performance from a developer's perspective. | |
# | |
# * Configure and compile Ruby | |
# * Run the test suite of several medium sized Ruby applications | |
# * Run the database-heavy test-suite of a Rails application | |
# * Test the launch times of several common applications | |
class DeveloperBenchmark | |
require 'fileutils' |
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
run_lexer("test = -100") | |
#=> [{:value=>"test", :name=>:identifier}, {:value=>"=", :name=>:assignment_operator}, {:value=>"-100", :name=>:integer_literal}] |
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
=begin | |
%%{ | |
machine simple_lexer; | |
integer = ('+'|'-')?[0-9]+; | |
float = ('+'|'-')?[0-9]+'.'[0-9]+; | |
assignment = '='; | |
identifier = [a-zA-Z][a-zA-Z_]+; | |
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
%%{ | |
machine simple_lexer; | |
integer = ('+'|'-')?[0-9]+; | |
float = ('+'|'-')?[0-9]+'.'[0-9]+; | |
assignment = '='; | |
identifier = [a-zA-Z][a-zA-Z_]+; | |
main := |* |