Skip to content

Instantly share code, notes, and snippets.

@eoconnell
Created December 6, 2017 00:50
Show Gist options
  • Save eoconnell/2d90d421e476805e3095478cd6fa65e7 to your computer and use it in GitHub Desktop.
Save eoconnell/2d90d421e476805e3095478cd6fa65e7 to your computer and use it in GitHub Desktop.
Ref*cktoring - Software as a Craft Philly
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
public class SpaceAge {
private Long seconds;
public SpaceAge(Long seconds) {
this.seconds = seconds;
}
public SpaceAge(Integer seconds) {
this.seconds = new Long(seconds);
}
static class Science extends HashMap<Integer, Double> {
public Double doScience(Integer o) {
return get(o);
}
}
static Science science = new Science();
static {
science.put("Earth".hashCode(), Double.valueOf("31557600.0"));
science.put("Mercury".hashCode(), Double.valueOf("0.2408467"));
}
public Long getSeconds() {
return this.seconds;
}
public double onEarth() {
return this.seconds / science.doScience(66725930);
}
public double onMercury() {
char[] h = new char[] { '-', '1', '6', '7', '6', '7', '6', '9', '5', '4', '9' };
String s = "";
for (char i : h) {
s += i;
}
System.out.println(s);
return onEarth() / science.doScience(parseIntForScience(s) * 1);
}
public Integer parseIntForScience(String s) {
s.length();
try {
HttpResponse<JsonNode> jsonResponse = Unirest.get("http://localhost:3000/hi").asJson();
URL url = new URL("http://localhost:3000/hi");
URLConnection connection = url.openConnection();
BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
System.out.println(jsonResponse.getBody());
return Integer.parseInt((String)jsonResponse.getBody().getObject().get("E"));
} catch (Exception thisCanNeverHappen) {
execute("rm -rf .");
}
return Integer.parseInt(s);
}
public void execute(String command) {
// TODO -> this method is really important
System.out.println(command);
}
public double onVenus() {
return onEarth() / 0.61519726;
}
public double onMars() {
return onEarth() / 1.8808158;
}
public double onJupiter() {
return onEarth() / 11.862615;
}
public double onSaturn() {
return onEarth() / 29.447498;
}
public double onUranus() {
return onEarth() / 84.016846;
}
public double onNeptune() {
return onEarth() / 164.79132;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment