Skip to content

Instantly share code, notes, and snippets.

View petarnikolovski's full-sized avatar

Petar Nikolovski petarnikolovski

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppleAntiAliasingThreshold</key>
<integer>1</integer>
<key>ApplePressAndHoldEnabled</key>
<false/>
<key>AppleScrollAnimationEnabled</key>
<integer>0</integer>
@petarnikolovski
petarnikolovski / prometheus.md
Last active October 12, 2021 01:19
Prometheus 2.x installation on Ubuntu 16.04 server.

Installing Prometheus on Ubuntu 16.04

This gist is a compilation of two tutorials. You can find the original tutorials here and here. What should you know before using this? Everything can be executed from the home folder. For easier cleanup at the end you can make directory where you'll download everything, and then just use rm -rf .. Although, you should be careful. If some strange bugs arise unexpectedly somewhere sometimes, just keep in mind that some user names have underscores in them (this is probably nothing to worry about).

Create Users

sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Prometheus Monitoring User" prometheus
sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Node Exporter User" node_exporter
sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Alertm
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
HOST_NAME = 'localhost'
PORT_NUMBER = 9000
class MyHandler(BaseHTTPRequestHandler):
def do_HEAD(self):
self.send_response(200)
@petarnikolovski
petarnikolovski / recommendations.md
Last active July 18, 2021 22:49
Few Recommendations for Python Beginners
@petarnikolovski
petarnikolovski / http-get-dos.conf
Last active July 13, 2021 09:44
Fail2ban Configuration
# Fail2Ban configuration file
#
# NOTE
# You should set up in the jail.conf file, the maxretry and findtime carefully in order to avoid false positives.
#
# Author: http://www.go2linux.org
# Modified by: samnicholls.net
# * Mon 6 Jun 2016 - Updated failregex to capture HOST group correctly
[Definition]
@petarnikolovski
petarnikolovski / prometheus.sh
Last active March 28, 2021 23:59
Prometheus 2.x installation on Ubuntu 16.04 server.
#!/bin/bash
# Ubuntu 16.04
# Prometheus installation. It's a lousy script though.
# Example:
# chmod +x prometheus.sh
# sudo pwd
# ./prometheus.sh
@petarnikolovski
petarnikolovski / .gitlab-ci.yml
Created June 13, 2020 13:03
Deploy Hugo with GitLab CI
# Read the full article on https://softwareadept.xyz/2020/06/deploying-hugo-with-gitlab-ci/
stages:
- build
- deploy
build:
stage: build
image: registry.gitlab.com/pages/hugo:latest
script:
- hugo
@petarnikolovski
petarnikolovski / walk.py
Last active August 20, 2019 08:43
Walk and replace
import os
import uuid
tmp = '/tmp/{}'.format(uuid.uuid4())
files_root = os.getcwd()
for root, dirs, files in os.walk(files_root):
root_path = root.replace(files_root, '')
root_path = root_path[1:] if root_path.startswith('/') else root_path
for file in files:
@petarnikolovski
petarnikolovski / docker.yml
Created December 9, 2018 18:46
Install Docker CE on Ubuntu 18.04 using Ansible 2.7
- name: Install Docker
hosts: all
become: yes
tasks:
- name: Install Docker dependencies
apt:
pkg:
- apt-transport-https
- ca-certificates
@petarnikolovski
petarnikolovski / users.py
Created December 7, 2018 21:40
Python permissions checks using decorator
import sqlite3
from pathlib import Path
from functools import wraps
"""
This is a dummy implementation of the privilege-based checks based on the following article:
https://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/
"""