Skip to content

Instantly share code, notes, and snippets.

@duien
duien / fizz_buzz.rb
Created January 31, 2013 18:33
Assignment for the first Rails Girls meetup
# Write a program that prints the numbers from 1 to 100. But for multiples of
# three print 'Fizz' instead of the number and for the multiples of five print
# 'Buzz.' For numbers which are multiples of both three and five print
# 'FizzBuzz.'
def fizz_buzz( limit = 100 )
1.upto(limit) do |i|
print "Fizz" if i % 3 == 0
print "Buzz" if i % 5 == 0
print i if i%3 != 0 and i%5 != 0

Data Munging

Adapted from CodeKata.

Last month, James showed us how to parse CSV. Here's a chance to practice, and to try something more like a real-world programming problem. You'll want to check out the CSV class in Ruby's standard library to help you.

Part One: Weather Data

In weather.csv you’ll find daily weather data for Morristown, NJ for June 2002. Download this file, then write a program to output the day number with the smallest temperature spread. The day number is in a column labeled Dy, the max temperature is MxT and the min temperature is MnT.

require 'term/ansicolor'
class String
include Term::ANSIColor
end
class Task
attr_accessor :status, :text, :indent_level
def to_formatted_string
"#{indent}- #{formatted_status} #{text}"

Transition plan for dashboard v2 models

Current state of things

  • There’s a dashboard v2 model that combines most functionality of standard and collection dashboards
  • There’s a v2 API namespace that uses new dashboard models
  • Those models can’t be associated with a collection yet
  • Most collection code is in place but commented out
  • Metric widgets can only be used by v2 dashboards
  • The /pin endpoint does not support NRQL widgets

The plan

  • Spend some time playing with the v2 dashboard models and see what needs fixing up
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Brilliant</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
grand-central-ui@1.0.0 /Users/ehyland/Code/Go/src/source.datanerd.us/tools/grand-central/app
├─┬ array-includes@3.0.2
│ ├─┬ define-properties@1.1.2
│ │ ├── foreach@2.0.5
│ │ └── object-keys@1.0.11
│ └─┬ es-abstract@1.7.0
│ ├─┬ es-to-primitive@1.1.1
│ │ ├── is-date-object@1.0.1
│ │ └── is-symbol@1.0.1
│ ├── function-bind@1.1.0

Keybase proof

I hereby claim:

  • I am duien on github.
  • I am duien (https://keybase.io/duien) on keybase.
  • I have a public key ASCCiqcEJdd6wxN8PjxXBDUimnN-DLX3Kslfq0xIz_-WeAo

To claim this, I am signing this object:

@duien
duien / animals.txt
Created August 25, 2023 17:46
Metazooa Animal List
aardvark
alligator
alpaca
anaconda
anemone
anteater
antelope
arctic fox
armadillo
atlas moth