Skip to content

Instantly share code, notes, and snippets.

View sreeram-venkitesh's full-sized avatar
☸️
kubectl scale --replicas=0 deployment/sreeram

Sreeram Venkitesh sreeram-venkitesh

☸️
kubectl scale --replicas=0 deployment/sreeram
View GitHub Profile
@VarunSriram99
VarunSriram99 / prepare-commit-msg
Last active July 4, 2023 14:21
Pre-commit hook to prefix the jira issue number to commit message using bash
#!/bin/sh
# Get current branch name
branch_name="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)"
# Replace or add the board name abbreviations here
jira_abbreviations=("JIRA_BOARD_ABBREVIATION")
# Check if current branch is a feature branch i.e. starts with a ticket number
check_is_issue_branch () {
for abbrv in "${jira_abbreviations[@]}"
let rects = [];
function visualize(analyser) {
analyser.fftSize = 2048;
var bufferLength = analyser.fftSize;
var dataArray = new Uint8Array(bufferLength);
function run() {
analyser.fftSize = 2048;
var bufferLengthAlt = analyser.frequencyBinCount;
@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active May 17, 2024 08:02
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@bradtraversy
bradtraversy / myscript.sh
Last active May 26, 2024 20:35
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@troyharvey
troyharvey / deployment.yml
Last active May 9, 2024 10:55
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@peterhurford
peterhurford / git-101-exercises.md
Last active July 29, 2023 04:30
Git 101, with Exercises

Git 101, with Exercises

Git is the key tool we use to allow multiple people to work on the same code base. Git takes care of merging everyone's contributions smoothly. Hence, learning how to use Git is critical to contributing to open source.

Exercises

Exercise 1: Go through the Try Git Guide

Exercise 2: Learn How to file a github issue.

@peterhurford
peterhurford / readable-code.md
Last active May 16, 2024 12:15
How do you write readable code?: 13 Principles

How do you write readable code?: 13 Principles

"Programs should be written for people to read, and only incidentally for machines to execute." -- Structure and Interpretation of Computer Programs

"How would you define good code? [...] After lots of interviews we started wondering if we could come out with a definition of good code following a pseudo-scientific method. [...] The population is defined by all the software developers. The sample consists of 65 developers chosen by convenience. [...] The questionnaire consists in a single question: “What do you feel makes code good? How would you define good code?”. [...] Of those, the most common answer by far was that the code has to be Readable (78.46%), almost 8 of each 10 developers believe that good code should be easy to read and understand." -- "What is Good Code: A Scientific Definition"

@peterhurford
peterhurford / parallelization.md
Created October 17, 2015 22:04
How does code get parallelized?

Computer code is a series of executed statements. Frequently, these statements are executed one at a time. If one part of your code takes a long time to run, the rest of your code won't run until that part is finished.

However, this isn't how it has to be. We can often make the exact same code go much faster through parallelization, which is simply running different parts of the computer code simaltaneously.

Asynchronous Code

The first example of this is asynchronous code. The idea here is that many times you do things like send a call to another computer, perhaps over the internet, using an API. Normally, code then has to simply wait for the other computer to give it a response over the API. But asynchronous code can simply keep on going and then the API call returns later.

This makes code harder to reason about and handle because you don't know when the API call will return or what your code will be like when it returns, but it makes your code faster because you don't have to wait arou

@peterhurford
peterhurford / open-source.md
Last active February 5, 2022 08:51
What is on an open source project website?: Five case studies

What is on an open source project website?: Five case studies

Looking at Rails, Angular, jQuery, Prediction.io, and Redis pages to find commonalities.

Lessons Learned

  • Layout matters. A nice layout inspires trust in your project.
  • Layout is similar. All the sites had a top bar with the prominent navigation. All the main pages had introductory text.
  • GitHub Issues is used ubiquitously for bug tracking.
  • IRC seems important for communities. Gitter seems like a good choice.