Skip to content

Instantly share code, notes, and snippets.

def solution(A):
highest_distance = 0
earliest_seen = {}
for index, value in enumerate(A):
if earliest_seen.get(value):
distance = index - earliest_seen[value] + 1
if distance > highest_distance:
highest_distance = distance
else:
earliest_seen[value] = index + 1
@AMeng
AMeng / spinnaker-pipeline.json
Created September 29, 2017 00:30
Spinnaker Pipeline Example
{
"app": {
"instance_type": "m4.large",
"app_description": "Edge Forrest Demo application"
},
"asg": {
"min_inst": 2,
"max_inst": 5
}
}
@AMeng
AMeng / datadog-alert.yaml
Created September 28, 2017 22:12
DataDog Alert Example
- name: EC2 CPU Utilization
query: avg(last_1h):avg:aws.ec2.cpuutilization by {host} > 95
message: EC2 CPU utilization is {{comparator}} {{threshold}} on host {{host.ip}}.
@AMeng
AMeng / jenkins-job.groovy
Last active September 28, 2017 22:04
Jenkins Job DSL Example
job('example-job') {
wrappers {
colorizeOutput()
preBuildCleanup()
}
logRotator {
numToKeep(10)
}
steps {
shell('./gradlew clean build')
@AMeng
AMeng / ec2ip.py
Created May 4, 2016 15:45
Find EC2 Private IPs from DNS or ELB Name or Tag Name
#!/usr/bin/env python
from argparse import ArgumentParser
from boto.ec2 import EC2Connection
from boto.ec2.elb import ELBConnection
from socket import gethostbyname
from sys import argv
class NodeLookup:
#!/usr/bin/env python
import time
import os
from boto import utils, connect_ec2
ELASTIC_IPS = os.environ['ELASTIC_IPS'].split(', ')
NUMBER_OF_TRIES = 5
metadata = utils.get_instance_metadata()

Keybase proof

I hereby claim:

  • I am ameng on github.
  • I am ameng (https://keybase.io/ameng) on keybase.
  • I have a public key whose fingerprint is 89A4 7625 D774 878B 63E1 35ED 84F1 2958 A261 3F08

To claim this, I am signing this object:

@AMeng
AMeng / startup.md
Last active December 7, 2016 18:09
Ubuntu starting commands

Basic stuff:

sudo apt-get update -y
sudo apt-get install -y bundler curl git guake network-manager-openvpn network-manager-openvpn-gnome openvpn python python-dev python-virtualenv ruby shellcheck virtualbox vagrant vim xclip

Slack:

sudo apt-add-repository -y ppa:rael-gc/scudcloud
sudo apt-get update -y
@AMeng
AMeng / .pythonrc
Last active August 29, 2015 14:07
import json
import sys
import os
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
data := make(map[string]string)
data["a"] = "a"
data["b"] = "b"
data["c"] = "c"
data["d"] = "d"