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 Level | |
| # list of valid levels (skips 0) | |
| @@levels = [*(-8..-1)] + [*(1..8)] | |
| def self.all | |
| @@levels | |
| end | |
| # Always returns a valid level | |
| def self.next(current_level, levels_to_inc = 1) |
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
| defmodule A do | |
| def a(x), do: "hello #{x}" | |
| def a(nil), do: "found nil" | |
| def a(%{a: "hello"} = t), do: "found #{Map.get(t, :a)}" | |
| end | |
| A.a(nil) |
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 OddPunisher | |
| def initialize(numbers) | |
| @numbers = numbers | |
| clean | |
| end | |
| def clean | |
| @numbers.delete_if { |n| n.to_i.even? } | |
| end | |
| 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
| Reading = Struct.new(:date, :high, :low) do | |
| def mean | |
| (high + low) / 2.0 | |
| end | |
| 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 AnnualWeather | |
| Reading = Struct.new(:date, :high, :low) | |
| def initialize (file_name) | |
| @readings = [] | |
| CSV.foreach(file_name, headers: true) do |row| | |
| @readings << Reading.new(Date.parse(row[2]), | |
| row[10].to_f, | |
| row[11].to_f) |
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
| require('csv') | |
| class AnnualWeather | |
| def initialize (file_name) | |
| @readings = [] | |
| CSV.foreach(file_name, headers: true) do |row| | |
| @readings << { | |
| :date => Date.parse(row[2]), | |
| :high => row[10].to_f, |
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 SuperSilliness < SillyBase | |
| def m1 (x, y, z) | |
| super(1, 2) # Call with 1, 2. | |
| super(x, y) # Call with x, y. | |
| super x, y # Same as above. |
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 fix_heading(heading) | |
| heading.to_s.capitalize | |
| 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
| [[14486,14511],[5892,12757],[2380,13034],[2346,11946],[3868,11481],[3474,13444],[2654,13195],[13214,14086],[3216,13248],[2791,12750],[3820,13629],[5424,11206],[11736,4754],[11805,14026],[6269,13876],[2619,12882],[7366,13788],[12190,3343],[6184,13756],[10859,10328],[4749,9003],[7535,7973],[4691,13590],[6395,5887],[8361,2399],[4082,13449],[2719,13061],[4763,1380],[9932,10074],[6634,13679],[3311,8364],[3945,10251],[8921,13784]] |
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 React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import axios from 'axios'; | |
| // Necesitas crear el component como una clase | |
| class FetchDemo extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { |
NewerOlder