Skip to content

Instantly share code, notes, and snippets.

@schaitanya
schaitanya / logstash.conf
Created May 7, 2018 20:31 — forked from magicdude4eva/logstash.conf
Port25 / PowertMTA Logstash / Graylog configuration
################################################################################
## Port25 Logstash configuration
##
## Logging configuration:
##
## <acct-file /var/log/pmta/acct.csv>
## delete-after 60d
## move-interval 5m
## max-size 500M
## records d,b,r,t,tq,f,rb,rs
import "strings"
// strs := []string{"flower", "flow", "flight"} -> fl
// strs := []string{"c", "acc", "ccc"} -> ""
func longestCommonPrefix(strs []string) string {
if len(strs) < 1 {
return ""
}
prefix := strs[0]
package main
// You are given a string, s, and a list of words, words, that are all of the same length.
// Find all starting indices of substring(s) in s that is a concatenation of each word
// in words exactly once and without any intervening characters.
// s := "barfoothefoobarman"
// words := [2]string{"foo", "bar"}
// Output: [0,9]
func main() {
func rotate(nums []int, k int) {
k %=len(nums)
reverse(nums, 0, len(nums)-1)
reverse(nums, 0, k-1)
reverse(nums, k, len(nums)-1)
}
func reverse(nums []int, start, end int) {
package main
import "fmt"
func main() {
fmt.Println(containsDuplicate([]int{1, 2, 3, 4}))
}
func containsDuplicate(nums []int) bool {
ret := make(map[int]bool, len(nums))
func singleNumber(nums []int) int {
i := 0
for _, v := range nums {
i ^= v
}
return i
}
@schaitanya
schaitanya / install-docker.md
Created October 19, 2020 14:37 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
class RangeLock {
int n;
volatile ConcurrentHashMap<String, ReentrantLock> m;