Skip to content

Instantly share code, notes, and snippets.

@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@subfuzion
subfuzion / curl.md
Last active April 16, 2025 09:14
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@pobsuwan
pobsuwan / rabbitmq-cluster.md
Last active November 14, 2024 22:45
How to config rabbitmq server cluster [3 nodes]

How to config rabbitmq server cluster [3 nodes]

Edit /etc/hosts

vi /etc/hosts
192.168.10.157  rabbitmq-1
192.168.10.159  rabbitmq-2
192.168.10.161  rabbitmq-3
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 17, 2025 13:02
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@sidja
sidja / get_instance_tag_with_instance_id.py
Created May 17, 2017 08:45
Using Python and Boto3 to get Instance Tag information with instance id
import boto3
def get_instance_name(fid):
"""
When given an instance ID as str e.g. 'i-1234567', return the instance 'Name' from the name tag.
:param fid:
:return:
"""
ec2 = boto3.resource('ec2')
ec2instance = ec2.Instance(fid)
@musale
musale / remove.sh
Created June 20, 2017 14:46
Remove and re-install node on arch linux
sudo pacman -Rsc -n nodejs
sudo pacman -Sy nodejs
sudo pacman -Sy npm
@StevenACoffman
StevenACoffman / _MicroService Proxy Gateway Solutions.md
Last active July 15, 2024 05:12
Microservice Proxy/Gateway Solutions

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to be the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to separate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from March 2, 2019

Originally, I had included some other solution

@jcipriano
jcipriano / latency.sh
Created July 11, 2017 21:49
Shell script that uses curl to measure latency for a given URL.
#!/bin/bash
# parse command line options
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--url)
target_url="$2"
@kulakowka
kulakowka / git-rev.js
Created January 24, 2019 12:50
Getting a commit hash in node.js
const git = require("git-rev-sync");
console.log(git.short());
// 75bf4ee
console.log(git.long());
// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef
console.log(git.branch());
// master
@bodhi
bodhi / Dockerfile
Created May 22, 2019 00:18
Burn git commit SHA into docker image
FROM golang:1.12 AS build
COPY ./main.go .
# ARG here is to make the sha available for use in -ldflags
ARG GIT_SHA
# -ldflags "-X main.sha=${GIT_SHA}" allows main.sha to be set at build time
RUN go build -ldflags "-X main.sha=${GIT_SHA}" -o /app
FROM scratch