Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Gough (He/Him) aarongough

View GitHub Profile
View app_test.rb
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,
View stack_trace
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
View sexp_benchmark.rb
require 'benchmark'
require 'sexpistol'
require 'sxp'
class Lexer
def initialize(str)
@str = str
@p = 0
end
View sexp_benchmark.rb
require 'benchmark'
require 'sexpistol'
require 'sxp'
class Lexer
def initialize(str)
@str = str
@p = 0
end
View sexp_benchmark.rb
require 'benchmark'
require 'sexpistol'
require 'sxp'
example_sexp = <<-EOD
((display "This is a test string!")
(define test (lambda () (begin
(display (== 1 1))
View s-expression-parser.rb
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]
View system_benchmark.rb
# 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'
View rage_lexer_run_example.rb
run_lexer("test = -100")
#=> [{:value=>"test", :name=>:identifier}, {:value=>"=", :name=>:assignment_operator}, {:value=>"-100", :name=>:integer_literal}]
View ragel_lexer.rb
=begin
%%{
machine simple_lexer;
integer = ('+'|'-')?[0-9]+;
float = ('+'|'-')?[0-9]+'.'[0-9]+;
assignment = '=';
identifier = [a-zA-Z][a-zA-Z_]+;
View ragel_lexer_only.rl
%%{
machine simple_lexer;
integer = ('+'|'-')?[0-9]+;
float = ('+'|'-')?[0-9]+'.'[0-9]+;
assignment = '=';
identifier = [a-zA-Z][a-zA-Z_]+;
main := |*