Skip to content

Instantly share code, notes, and snippets.

View Thomascountz's full-sized avatar
💃
LGTM!

Thomas Countz Thomascountz

💃
LGTM!
View GitHub Profile
class BottleNumber
attr_reader :number, :state
def initialize(number, state: :FIXME)
@number = number
@state = state
end
# ...
end
# Turn on LightBulb
class LightBulb
attr_reader :state
def initialize
self.state = :off
end
def turn_on
self.state = :on
class LightBulb
attr_reader :state
def initialize
self.state = :off
end
def turn_on
self.state = :on
end
@Thomascountz
Thomascountz / Server.java
Created July 26, 2018 15:45
Simple Echoing Server in Java
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);
@Thomascountz
Thomascountz / ClientWorker.java
Last active July 26, 2018 15:53
Threaded Echoing Server in Java
import java.io.*;
import java.net.*;
public class ClientWorker implements Runnable {
private Socket clientSocket;
ClientWorker(Socket clientSocket){
this.clientSocket = clientSocket;
}
window.onload = function() {
document.getElementById("editor").focus();
};
const mockResponse = [{
"sentence_id": 0,
"text": "I love it here!",
"tones": [{
"score": 0.880435,
"tone_id": "joy",
dataset = [
{input: 1, output: 2},
{input: 2, output: 4},
{input: 3, output: 6},
]
def predict(x)
return x * 2
end
dataset = [
{input: 0.50, output: 56},
{input: 0.85, output: 119},
{input: 0.99, output: 140},
{input: 1.30, output: 190}
]
class LinearModel
def initialize(y_intercept, slope)
@y_intercept = y_intercept
@slope = slope
end
def predict(x)
return @slope * x + @y_intercept
end
end