Skip to content

Instantly share code, notes, and snippets.

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')
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() {
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();
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);
latencyAvg = getLatencyAvg();
loadAvg = getLoadAvg();
uptimeAvg = getUptimeAvg();
IOWaitAvg = getIOWaitAvg();
latencyAvg = ((latencyAvg) / (500));
loadAvg = ((loadAvg) / (10));
uptimeAvg = uptimeAvg/1000;
uptimeAvg = ((uptimeAvg) / (3600));
/* globals React */
const shallow = require('enzyme').shallow;
const expect = require('chai').expect;
const setup = require('static/bundles/test/componentSetup');
const courseViewGradeData = require('static/bundles/ondemand/components/__fixtures__/CourseViewGrade.mock');
const courseMaterialData = require('static/bundles/author-grade/stores/__tests__/fixtures/courseMaterialData.newGradeWeights.js');
const beforeEachLoadPromisedObject = require('static/bundles/phoenix/test/lib/beforeEachLoadPromisedObject');
#unpythonic code in idiom_tests_copy.py:
result = []
for i in range(10):
s = i ** 2
result.append(s)
print(sum(result))
from redbaron import RedBaron
import json
with open("the_unidiomatic_python_file.py", "r") as source_code:
red = RedBaron(source_code.read())
red
del red[1]
-bash-4.2$ ./pf -x 1024 -y 1024 -z 100 -np 10000
VIDEO SEQUENCE TOOK 12.033136
XE: 512.549820
YE: 512.463238
0.718951
XE: 510.455943
YE: 513.535434
2.177538
XE: 508.490030
YE: 514.503280
-bash-4.2$ ./pf -x 32 -y 32 -z 100 -np 10000
VIDEO SEQUENCE TOOK 0.028908
XE: 16.549820
YE: 16.463238
0.718951
XE: 14.455943
YE: 17.535434
2.177538
XE: 12.490030
YE: 18.503280