This file contains 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 BottleNumber | |
attr_reader :number, :state | |
def initialize(number, state: :FIXME) | |
@number = number | |
@state = state | |
end | |
# ... | |
end |
This file contains 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
# Turn on LightBulb | |
class LightBulb | |
attr_reader :state | |
def initialize | |
self.state = :off | |
end | |
def turn_on | |
self.state = :on |
This file contains 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 LightBulb | |
attr_reader :state | |
def initialize | |
self.state = :off | |
end | |
def turn_on | |
self.state = :on | |
end |
This file contains 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 java.io.*; | |
import java.net.*; | |
public class Server { | |
public static void main(String[] args) throws IOException { | |
int port = 5000; | |
ServerSocket serverSocket = new ServerSocket(port); | |
System.out.println("Listening on port " + port); |
This file contains 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 java.io.*; | |
import java.net.*; | |
public class ClientWorker implements Runnable { | |
private Socket clientSocket; | |
ClientWorker(Socket clientSocket){ | |
this.clientSocket = clientSocket; | |
} |
This file contains 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
window.onload = function() { | |
document.getElementById("editor").focus(); | |
}; | |
const mockResponse = [{ | |
"sentence_id": 0, | |
"text": "I love it here!", | |
"tones": [{ | |
"score": 0.880435, | |
"tone_id": "joy", |
This file contains 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
dataset = [ | |
{input: 1, output: 2}, | |
{input: 2, output: 4}, | |
{input: 3, output: 6}, | |
] |
This file contains 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 predict(x) | |
return x * 2 | |
end |
This file contains 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
dataset = [ | |
{input: 0.50, output: 56}, | |
{input: 0.85, output: 119}, | |
{input: 0.99, output: 140}, | |
{input: 1.30, output: 190} | |
] |
This file contains 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 LinearModel | |
def initialize(y_intercept, slope) | |
@y_intercept = y_intercept | |
@slope = slope | |
end | |
def predict(x) | |
return @slope * x + @y_intercept | |
end | |
end |