Skip to content

Instantly share code, notes, and snippets.

@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

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:

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
<?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>

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
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}"

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.

@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
@duien
duien / glitch_time.js
Created September 2, 2011 22:18
Glitch Date/Time calculation in JavaScript
function time_to_glitch(time){
var year, day_of_year, month_and_day, month, day_of_month, hour, minute, sec, ts ;
sec = Number(time) - 1238562000;
// there are 4435200 real seconds in a game year
// there are 14400 real seconds in a game day
// there are 600 real seconds in a game hour
// there are 10 real seconds in a game minute
year = Math.floor(sec / 4435200);
@duien
duien / gist:818746
Created February 9, 2011 16:24
builder fail
ruby-1.8.7-p302 > require 'builder'
=> true
ruby-1.8.7-p302 > xm = Builder::XmlMarkup.new
=> <inspect/>
ruby-1.8.7-p302 > xm.title('yada')
=> "<inspect/><title>yada</title>"
ruby-1.8.7-p302 > puts xm
TypeError: Builder::XmlMarkup#to_ary should return Array
from (irb):5:in `puts'
from (irb):5