Skip to content

Instantly share code, notes, and snippets.

from typing import List
def is_prime(x: int) -> bool:
if x > 1:
for i in range(2, int(x / 2) + 1):
if (x % i) == 0:
return False
break
else:
return True
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
@rahulwa
rahulwa / fluentd-prod-sample-config.md
Last active May 9, 2019 20:25
Fluentd some sample config used in prod
<source>
  @type tail
  path /var/log/assignment_server.out.log*
  pos_file /var/run/td-agent/td-agent_position.pos
  tag prod.allocation
  path_key tailed_path
  rotate_wait 5
  read_from_head true
  refresh_interval 60
@rahulwa
rahulwa / desired_capacity.md
Created April 18, 2019 20:14
Found a solution for maintaining autoscaling’s `desired_capacity` in terraform, need to use`External Data Source` with a script

Content of scripts/test.sh:

#!/bin/bash

# Exit if any of the intermediate steps fail
set -e

# jq will ensure that the values are properly quoted
# and escaped for consumption by the shell.
eval "$(jq -r '@sh "ASG_NAME=\(.asg_name) REGION=\(.region) DC=\(.desired_capacity)"')"
@rahulwa
rahulwa / gist:7b017b303e4acc22be698e6f156229a1
Created February 19, 2019 17:41 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.
$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@rahulwa
rahulwa / kafka-cheat-sheet.md
Last active November 20, 2018 08:43 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Create the topic

unset JMX_PORT; bin/kafka-topics.sh --zookeeper X:2181 --create --topic NAME --replication-factor 3 --partitions 3

Purge a topic

--- MEMORY RELATED
--- wal_buffer
SHOW wal_buffers;
SELECT name,setting,unit,current_setting(name) FROM pg_settings WHERE name='wal_buffers';
--- unix: `getconf PAGE_SIZE``getconf _PHYS_PAGES` ... Linux: `ipcs -l` `sysctl kernel.sem`
--- initial parameters of PostgreSQL: https://pgtune.leopard.in.ua/#/
create extension pg_buffercache;
\dx pg_buffercache
--- pg_buffercache has several columns
--- bufferid, the block ID in the server buffer cache
@rahulwa
rahulwa / pyconfig.py
Created June 5, 2018 17:51
Wrapper over Consul in Python for configuration management.
import requests
import os
import logging
import sys
import json
import base64
class Conf:
'''
Wrapper on top of consul api to facilitates configuration for Application.
★ Install of core/ffmpeg/3.3.2/20170710172745 complete with 0 new packages installed.
crawler-development: Resolved dependency 'core/ffmpeg' to /hab/pkgs/core/ffmpeg/3.3.2/20170710172745
crawler-development: WARN
crawler-development: WARN The following runtime dependencies have more than one version
crawler-development: WARN release in the full dependency chain:
crawler-development: WARN
crawler-development: WARN * core/gmp ( core/gmp/6.1.0/20170513202112 core/gmp/6.1.2/20170526062114 )
crawler-development: WARN
crawler-development: WARN The current situation usually arises when a Plan has a direct
crawler-development: WARN dependency on one version of a package (`acme/A/7.0/20160101200001`)