Skip to content

Instantly share code, notes, and snippets.

View arya-oss's full-sized avatar
💭
I may be slow to respond.

Rajmani Arya arya-oss

💭
I may be slow to respond.
View GitHub Profile
@arya-oss
arya-oss / prom-k8s-request-limits.md
Created July 4, 2023 05:36 — forked from max-rocket-internet/prom-k8s-request-limits.md
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) /
@arya-oss
arya-oss / Popular RegEx.md
Created April 1, 2018 15:12
RegExp Cheatsheet
@arya-oss
arya-oss / hacks.md
Created February 3, 2018 04:10
Ubuntu 16.04 Hacks

Synaptics Touchpad click enable

gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true 
[user]
name = rajmani1995
email = rajmani1995@gmail.com
[credential]
helper = cache --timeout=3600
[alias]
aliases = config --get-regexp '^alias\\.'
br = branch
branch-name = rev-parse --abbrev-ref HEAD
ci = commit -m
@arya-oss
arya-oss / nginxproxy.md
Created December 25, 2017 07:00 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@arya-oss
arya-oss / form.php
Created December 21, 2016 12:25
Dynamic option form adding
<?php
if (isset($_POST) && !empty($_POST['name'])) {
var_dump($_POST);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
@arya-oss
arya-oss / powmod.py
Created December 4, 2016 13:14
Calculate a^b mod n, used in cryptography
def powmod(a,b,n):
'''
calculates a^b mod n
:a base number
:b power
:n A prime number
'''
c = 0
f = 1
k = b.bit_length()
$rating = 4;
$courseNumber = 1;
/* Author: Aneesh Makala
* Course Number starts from 0 to no. of courses
* Click on course feedback and then select a subject
* Open Dev Tools and goto COnsole Tab and Paste this script
*/
$scope = angular.element('[ng-controller=feedbackCourses]').scope();
for($i = 0; $i< $scope.course[$courseNumber].question.course.length; $i++){
@arya-oss
arya-oss / design_pattern_filesystem.ruby
Created November 16, 2016 19:59
FileSystem Design Patterns in Ruby
=begin
Purpose. File system with 8 GoF patterns
Composite --------------- directories that contain files, each of which could be a directory
Proxy ------------------- Unix logical link
Chain of Responsibility - pointer back to the parent directory to create
"fully qualified path name"
Iterator ---------------- use iterator to control the traversal of a Composite
@arya-oss
arya-oss / FastaInputFormat.java
Created November 14, 2016 06:22 — forked from jflatow/FastaInputFormat.java
Hadoop FASTA reader
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0