diff --git a/360macdev-Denver-2010/SudokuSolverRB/SudokuPuzzleWindowController.rb b/360macdev-Denver-2010/SudokuSolverRB/SudokuPuzzleWindowController.rb index ff3557f..8e584f9 100755 --- a/360macdev-Denver-2010/SudokuSolverRB/SudokuPuzzleWindowController.rb +++ b/360macdev-Denver-2010/SudokuSolverRB/SudokuPuzzleWindowController.rb @@ -15,9 +15,9 @@ class SudokuPuzzleWindowController < NSWindowController attr_accessor :cell_4_0, :cell_4_1, :cell_4_2, :cell_4_3, :cell_4_4, :cell_4_5, :cell_4_6, :cell_4_7, :cell_4_8 attr_accessor :cell_5_0, :cell_5_1, :cell_5_2, :cell_5_3, :cell_5_4, :cell_5_5, :cell_5_6, :cell_5_7, :cell_5_8 attr_accessor :cell_6_0, :cell_6_1, :cell_6_2, :cell_6_3, :cell_6_4, :cell_6_5, :cell_6_6, :cell_6_7, :cell_6_8 - attr_accessor :cell_7_0, :cell_7_1, :cell_7_2, :cell_7_3, :cell_7_4, :cell_7_5, :cell_7_6, :cell_7_7, :cell_7_8 - attr_accessor :cell_8_0, :cell_8_1, :cell_8_2, :cell_8_3, :cell_8_4, :cell_8_5, :cell_8_6, :cell_8_7, :cell_8_8 - + attr_accessor :cell_7_0, :cell_7_1, :cell_7_2, :cell_7_3, :cell_7_4, :cell_7_5, :cell_7_6, :cell_7_7, :cell_7_8 + attr_accessor :cell_8_0, :cell_8_1, :cell_8_2, :cell_8_3, :cell_8_4, :cell_8_5, :cell_8_6, :cell_8_7, :cell_8_8 + def puzzle cells = [] 0.upto(8) do |x| @@ -49,7 +49,7 @@ def next_state(state, x, y) state[x][y] = 0 false end - + def valid_cell?(state, x, y) # check in col and row 0.upto(8) do |i| @@ -68,11 +68,11 @@ def valid_cell?(state, x, y) true end - + def solve(sender) pp puzzle $count = 0 - next_state(@puzzle, 0, 0) + next_state(@puzzle, 0, 0) pp "Solved in #{$count} steps" pp puzzle end diff --git a/360macdev-Denver-2010/SudokuSolverRB/Tests/stub_test.rb b/360macdev-Denver-2010/SudokuSolverRB/Tests/stub_test.rb index 3f3cf20..eb1d398 100755 --- a/360macdev-Denver-2010/SudokuSolverRB/Tests/stub_test.rb +++ b/360macdev-Denver-2010/SudokuSolverRB/Tests/stub_test.rb @@ -6,11 +6,11 @@ class SimpleTest < Test::Unit::TestCase def setup puts 'setup called' end - + def teardown puts 'teardown called' end - + def test_fail assert false, 'Assertion was false.' end diff --git a/360macdev-Denver-2010/TestRuby/Testruby.app/Contents/Resources/lib/application.rb b/360macdev-Denver-2010/TestRuby/Testruby.app/Contents/Resources/lib/application.rb index 7b20114..f11b1b1 100644 --- a/360macdev-Denver-2010/TestRuby/Testruby.app/Contents/Resources/lib/application.rb +++ b/360macdev-Denver-2010/TestRuby/Testruby.app/Contents/Resources/lib/application.rb @@ -6,7 +6,7 @@ class Application include HotCocoa - + def start application :name => "Testruby" do |app| app.delegate = self @@ -16,27 +16,27 @@ def start end end end - + # file/open def on_open(menu) end - - # file/new + + # file/new def on_new(menu) end - + # help menu item def on_help(menu) end - + # This is commented out, so the minimize menu item is disabled #def on_minimize(menu) #end - + # window/zoom def on_zoom(menu) end - + # window/bring_all_to_front def on_bring_all_to_front(menu) end diff --git a/360macdev-Denver-2010/TestRuby/config/build.yml b/360macdev-Denver-2010/TestRuby/config/build.yml index db06951..e27b2dc 100644 --- a/360macdev-Denver-2010/TestRuby/config/build.yml +++ b/360macdev-Denver-2010/TestRuby/config/build.yml @@ -4,5 +4,5 @@ version: "1.0" icon: resources/HotCocoa.icns resources: - resources/**/*.* -sources: +sources: - lib/**/*.rb diff --git a/360macdev-Denver-2010/TestRuby/lib/application.rb b/360macdev-Denver-2010/TestRuby/lib/application.rb index 7b20114..f11b1b1 100644 --- a/360macdev-Denver-2010/TestRuby/lib/application.rb +++ b/360macdev-Denver-2010/TestRuby/lib/application.rb @@ -6,7 +6,7 @@ class Application include HotCocoa - + def start application :name => "Testruby" do |app| app.delegate = self @@ -16,27 +16,27 @@ def start end end end - + # file/open def on_open(menu) end - - # file/new + + # file/new def on_new(menu) end - + # help menu item def on_help(menu) end - + # This is commented out, so the minimize menu item is disabled #def on_minimize(menu) #end - + # window/zoom def on_zoom(menu) end - + # window/bring_all_to_front def on_bring_all_to_front(menu) end diff --git a/nsconf2011/CoreDataSample/MainWindowController.rb b/nsconf2011/CoreDataSample/MainWindowController.rb index b1f43c3..c2be95b 100755 --- a/nsconf2011/CoreDataSample/MainWindowController.rb +++ b/nsconf2011/CoreDataSample/MainWindowController.rb @@ -7,28 +7,28 @@ class MainWindowController < NSWindowController attr_accessor :number_label - + def windowDidLoad - + puts "Window: #{self.window}" self.window.title = "My Sample Core Data Application" - + end - + def createObject(sender) person = Person.createEntity #magicalrecord helper - + person.first_name = "first name: #{count}" person.last_name = "last name: #{count}" person.age = (rand * 100).round - + NSManagedObjectContext.defaultContext.save #magicalrecord helper - + count = Person.numberOfEntities - + self.number_label.stringValue = count.to_s end - + def managedObjectContext NSManagedObjectContext.defaultContext end diff --git a/nsconf2011/CoreDataSample/SampleAppDelegate.rb b/nsconf2011/CoreDataSample/SampleAppDelegate.rb index b619045..9a1b24d 100755 --- a/nsconf2011/CoreDataSample/SampleAppDelegate.rb +++ b/nsconf2011/CoreDataSample/SampleAppDelegate.rb @@ -14,5 +14,5 @@ def applicationDidFinishLaunching(notification) wc.window.makeKeyAndOrderFront(self) end - + end \ No newline at end of file diff --git a/nsconf2011/CoreDataSample/SampleDataModel/_Person.m b/nsconf2011/CoreDataSample/SampleDataModel/_Person.m index b5492db..a618d36 100644 --- a/nsconf2011/CoreDataSample/SampleDataModel/_Person.m +++ b/nsconf2011/CoreDataSample/SampleDataModel/_Person.m @@ -28,7 +28,7 @@ - (PersonID*)objectID { + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; - + if ([key isEqualToString:@"ageValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"age"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; diff --git a/nsconf2011/CoreDataSample/Tests/stub_test.rb b/nsconf2011/CoreDataSample/Tests/stub_test.rb index 3f3cf20..eb1d398 100755 --- a/nsconf2011/CoreDataSample/Tests/stub_test.rb +++ b/nsconf2011/CoreDataSample/Tests/stub_test.rb @@ -6,11 +6,11 @@ class SimpleTest < Test::Unit::TestCase def setup puts 'setup called' end - + def teardown puts 'teardown called' end - + def test_fail assert false, 'Assertion was false.' end diff --git a/nsconf2011/mandelbrot/MandelbrotView.rb b/nsconf2011/mandelbrot/MandelbrotView.rb index f5794f5..7bd8d7a 100755 --- a/nsconf2011/mandelbrot/MandelbrotView.rb +++ b/nsconf2011/mandelbrot/MandelbrotView.rb @@ -8,52 +8,52 @@ require 'dispatch' class MandelbrotView < NSView - + def awakeFromNib @max_iterations = 1000 @scale = 1.4 end def drawRect(rect) - + self.computeMandelbrotInRect(rect, atLocation:[-1,0], scale:@scale) end def computeMandelbrotAtPoint(point, center:center, inRect:bounds, iterations:iterations, scale:scale) - + xscaled = point[0]/(bounds.size.width/scale) + (center[0] - scale/2.0) yscaled = point[1]/(bounds.size.height/scale) + (center[1] - scale/2.0) - + x = xscaled y = yscaled - + (0..iterations).each { |i| # puts "x #{x} y #{y} -> iteration #{i}" return i if (x ** 2 + y ** 2) > 4 - + xtemp = x ** 2 - y ** 2 + xscaled y = 2 * x * y + yscaled x = xtemp } iterations - + end - + def selectColor(value) colorValue = value / @max_iterations color = NSColor.colorWithCalibratedWhite(colorValue, alpha:1) color.set end - + def computeMandelbrotInRect(plane, atLocation:location, scale:scale) context = NSGraphicsContext.currentContext.graphicsPort - + startTime = Time.now puts "Starting draw #{startTime}" (location[1]..plane.size.height).each do |y| (location[0]..plane.size.width).each do |x| - + value = computeMandelbrotAtPoint([x, y], center:location, inRect:plane, iterations:@max_iterations, scale:@scale ) selectColor value @@ -63,7 +63,7 @@ def computeMandelbrotInRect(plane, atLocation:location, scale:scale) end endTime = Time.now puts "Ended draw #{endTime}: took #{endTime - startTime} seconds" - + end - + end diff --git a/nsconf2011/mandelbrot/Tests/stub_test.rb b/nsconf2011/mandelbrot/Tests/stub_test.rb index 3f3cf20..eb1d398 100755 --- a/nsconf2011/mandelbrot/Tests/stub_test.rb +++ b/nsconf2011/mandelbrot/Tests/stub_test.rb @@ -6,11 +6,11 @@ class SimpleTest < Test::Unit::TestCase def setup puts 'setup called' end - + def teardown puts 'teardown called' end - + def test_fail assert false, 'Assertion was false.' end