Skip to content

Instantly share code, notes, and snippets.

View ktolstikhin's full-sized avatar
🤘
Rock and roll.

Konstantin Tolstikhin ktolstikhin

🤘
Rock and roll.
View GitHub Profile
@damilolaolatunji
damilolaolatunji / logger.go
Created August 12, 2022 12:02
Extending the Go log package with log levels
// Adapted from https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/13.4.html
package logger
import (
"log"
"os"
)
const (
LevelTrace = iota
@Himura2la
Himura2la / Grafana Alert Template.md
Last active May 16, 2024 15:46
How to use Grafana Alerts with the Telegram
  • Template name: telegram.message
  • Content:
    {{ define "alert_list" }}{{ range . }}{{ .Labels.alertname }}
    {{ range .Annotations.SortedPairs }}<strong>{{ .Name }}</strong>: {{ .Value }}
    {{ end }}| {{ if gt (len .GeneratorURL) 0 }}<a href="{{ .GeneratorURL }}">source</a> | {{ end }}{{ if gt (len .SilenceURL) 0 }}<a href="{{ .SilenceURL }}">silence</a> | {{ end }}{{ if gt (len .DashboardURL) 0 }}<a href="{{ .DashboardURL }}">dashboard</a> | {{ end }}{{ if gt (len .PanelURL) 0 }}<a href="{{ .PanelURL }}">panel</a> |{{ end }}
    —
    {{ end }}{{ end }}
    {{ define "telegram.message" }}
    

{{ if gt (len .Alerts.Firing) 0 }}FIRING!!!

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active July 16, 2024 21:02
set -e, -u, -o, -x pipefail explanation
@borgstrom
borgstrom / human_time_duration.py
Created May 9, 2018 04:00
Python: Convert seconds (duration) to human readable string
TIME_DURATION_UNITS = (
('week', 60*60*24*7),
('day', 60*60*24),
('hour', 60*60),
('min', 60),
('sec', 1)
)
def human_time_duration(seconds):
@william8th
william8th / .tmux.conf
Last active July 4, 2024 11:36
Tmux open new pane in same directory
# Set the control character to Ctrl+Spacebar (instead of Ctrl+B)
set -g prefix C-space
unbind-key C-b
bind-key C-space send-prefix
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
@levsthings
levsthings / docker-ce-ubuntu-17.10.md
Last active April 13, 2023 21:05
Install Docker CE on Ubuntu 17.10

Installing Docker CE on Ubuntu 17.10 Artful Aardvark

As of 20/10/2017, a release file for Ubuntu 17.10 Artful Aardvark is not available on Download Docker.

If you are used to installing Docker to your development machine with get-docker script, that won't work either. So the solution is to install Docker CE from the zesty package.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@chris-marsh
chris-marsh / print_table.py
Created October 13, 2017 14:55
PyQt5 - Print paginated QTableWidget
from PyQt5 import QtWidgets, QtCore, QtPrintSupport, QtGui
class Window(QtWidgets.QWidget):
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle(self.tr('Document Printer'))
self.table = QtWidgets.QTableWidget(200, 5, self)
for row in range(self.table.rowCount()):
for col in range(self.table.columnCount()):
@javilobo8
javilobo8 / download-file.js
Last active July 1, 2024 23:21
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@nikhita
nikhita / update-golang.md
Last active July 6, 2024 12:23
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@ulyssesr
ulyssesr / nginx.conf
Last active March 2, 2024 06:05
Nginx RTMP Setup
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;