This file contains hidden or 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
unsorted = %w{11 17 2 200 201 205 209 21 213 217 218 220 223 227 228 232 240 248 2X 3 307 313 320 33 35 354 35M 39 41 45 451 453 454 455 456 460 461 462 463 47 470 471 472 473 477 500 501 509 513 516 517 519 520 523 525 527 534 54 550 6 603 604 606 608 612 613 616 62 625 626 627 630 640 645 667 670 675 701 703 704 72 750 805 806 807 809 811 821 822 830 831 832 833 834 836 842 850 853 862 880 9 901 902 919 920 951 952 954 960 962 990 992 F400 F401 F514 F518 F546 F547 F556 F570 F578 F590 F618 F628 F638 F868 F94} | |
sorted = %w{2 2X 3 6 9 11 17 21 33 35 35M 39 41 45 47 54 62 72 200 201 205 209 213 217 218 220 223 227 228 232 240 248 307 313 320 354 451 453 454 455 456 460 461 462 463 470 471 472 473 477 500 501 509 513 516 517 519 520 523 525 527 534 550 603 604 606 608 612 613 616 625 626 627 630 640 645 667 670 675 701 703 704 750 805 806 807 809 811 821 822 830 831 832 833 834 836 842 850 853 862 880 901 902 919 920 951 952 954 960 962 990 992 F400 F401 F514 F518 F546 F547 F556 F570 F578 F590 F618 F628 F638 F868 |
This file contains hidden or 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
[83] pry(main)> reader.objects[2].instance_of? Hash | |
=> true | |
[84] pry(main)> reader.objects.select { |x| x.instance_of? Hash } | |
=> [] |
This file contains hidden or 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 display_name | |
name = self.name | |
name = "N/A" if name.blank? or name.nil? | |
name | |
end |
This file contains hidden or 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 Contract < ActiveRecord::Base | |
belongs_to :contract_type | |
has_many :contract_terms | |
def display_name | |
"#{self.contract_type.name}: #{self.person_name}" | |
end | |
def person_name | |
# todo: this seems inefficient, do we want to throw important metadata in the |
This file contains hidden or 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 Contract < ActiveRecord::Base | |
# attr_accessible :title, :body | |
belongs_to :contract_type | |
has_many :contract_terms | |
def display_name | |
"#{self.contract_type.name}: #{self.person_name}" | |
end |
This file contains hidden or 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
p() { cd ~/projects/$1; } | |
_p() { _files -W ~/projects -/; } | |
compdef _p p |
This file contains hidden or 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
self.dateFormat = [[NSDateFormatter alloc] init]; | |
[self.dateFormat setDateFormat:@"d MMMM YYYY"]; | |
NSLog(@"now formatted = %@", [self.dateFormat dateFromString:@"5 August 2012"]); |
This file contains hidden or 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
import arcpy | |
from arcpy import env | |
env.workspace = "C:\UtahAddressModel\SouthJordan_July2012" | |
rows = arcpy.UpdateCursor("SJC_AddressPts") | |
for row in rows: | |
if row.getValue("TYPE") == "CHURCH": | |
row.setValue("TYPE_D", "REL") |
This file contains hidden or 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
knight = Knight.new(0, 0) | |
memo = Array.new | |
1.upto(100000) do |x| | |
knight.move | |
knight.move until knight.position == [0, 0] | |
puts x if x % 100 == 0 | |
memo << knight.count | |
knight.count = 0 | |
end |
This file contains hidden or 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 ruby | |
class Knight | |
attr_accessor :x, :y, :count | |
def initialize(x, y) | |
@x, @y, @count = x, y, 0 | |
end | |
def position |