Skip to content

Instantly share code, notes, and snippets.

Edward McEnrue emcenrue

View GitHub Profile
View gist:7a453b604be3ab2161cbe0506d091b1a
try {
long startTime = System.currentTimeMillis();
int port = 8000;
InetAddress server = InetAddress.getByAddress("8.8.8.8".getBytes());
DatagramSocket socket = new DatagramSocket(port);
byte[] buf = new byte[1024];
DatagramPacket ping = new DatagramPacket(buf, buf.length, server, port);
View gist:c4a5e04eacc1745b46f7ed7b3ebdbabd
try {
int port = 8000;
InetAddress address = InetAddress.getByName("8.8.8.8");
DatagramSocket socket = new DatagramSocket();
socket.setSoTimeout(2000);
socket.connect(address, port);
for(int i = 0; i < NUM_TRIALS; i++){
String str = "PING " + i + " \n";
byte[] buf = new byte[1024];
buf = str.getBytes();
View gist:91778bf54140023d1ccd4d661c85c674
public static void main(String[] args) {
MyScanner in = new MyScanner();
}
// -----------MyScanner class for faster input----------
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
View gist:e5c3b35504647aaf671d98d87006806d
def start_instance_elections(instance_ids):
session = boto3.session.Session(profile_name='default')
ec2_resource = session.resource('ec2')#high level resource level
key = paramiko.RSAKey.from_private_key_file('/home/edward/workspace/waka/mykeypair.pem')
Port = 22
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print('starting election on instances')
View gist:6d5d41ea5a4716cad167
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar
network interface: name:eth0 (eth0)
network interface: name:lo (lo)
start
Gossiping: []
{"address":"172.31.31.206","heartbeat":1458921462576,"generation_time":1458921455000,"status":"NORMAL"}
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found.
at org.json.JSONObject.get(JSONObject.java:471)
at org.json.JSONObject.getString(JSONObject.java:717)
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:46)
View gist:bcaee52642764a2f6a20
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar
start
Gossiping: []
{"address":"172.31.31.206","heartbeat":1458921136784,"generation_time":1458921132782,"status":"NORMAL"}
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found.
at org.json.JSONObject.get(JSONObject.java:471)
at org.json.JSONObject.getString(JSONObject.java:717)
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:46)
at com.tbdcomputing.network.Flock$2.onNodeDiscovered(Flock.java:62)
at com.tbdcomputing.network.discovery.NetworkDiscoveryReceiver.run(NetworkDiscoveryReceiver.java:39)
View gist:763f802458c19b6b5d68
ubuntu@ip-172-31-31-206:~$ java -jar flock.jar
start
Gossiping: []
Exception in thread "Thread-0" org.json.JSONException: JSONObject["id"] not found.
at org.json.JSONObject.get(JSONObject.java:471)
at org.json.JSONObject.getString(JSONObject.java:717)
at com.tbdcomputing.network.gossip.GossipNode.<init>(GossipNode.java:45)
at com.tbdcomputing.network.Flock$2.onNodeDiscovered(Flock.java:62)
at com.tbdcomputing.network.discovery.NetworkDiscoveryReceiver.run(NetworkDiscoveryReceiver.java:39)
at com.tbdcomputing.network.Flock$3.run(Flock.java:144)
View gist:aab9517eb2bee9e8e800
import xml.etree.ElementTree as ET
from math import sqrt
import json
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import os
import io
os.chdir('/home/edward/workspace/school/context_slices')
os.getcwd()
View gist:af7635dff152c494ce35
public static int[] diff(Node head, int height){
if(head.left == null && head.right == null){
int[] base = new int[2];
base[0] = 0;
base[1] = 0;
}
int[] left = new int[2];
left[0] = Integer.MAX_VALUE;
You can’t perform that action at this time.