Skip to content

Instantly share code, notes, and snippets.

View petarnikolovski's full-sized avatar

Petar Nikolovski petarnikolovski

View GitHub Profile
@petarnikolovski
petarnikolovski / deprovision.sh
Last active August 10, 2024 13:04
Update host ubuntu from a live CD
#!/bin/bash
# Run with `sudo`
MOUNTED_DISK=$1
umount ${MOUNTED_DISK}/run
umount ${MOUNTED_DISK}/sys
umount ${MOUNTED_DISK}/dev/pts
umount ${MOUNTED_DISK}/dev
umount ${MOUNTED_DISK}/proc
<?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 / .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/
"""
@petarnikolovski
petarnikolovski / corsdevserver.py
Created July 25, 2018 15:48 — forked from igniteflow/corsdevserver.py
A simple CORS compliant web server in Python, useful for development (with @alex-moon)
import BaseHTTPServer
import cgi
from pprint import pformat
PORT = 6969
FILE_TO_SERVE = 'path/to/your/response/content.json'
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""
@petarnikolovski
petarnikolovski / server.py
Created July 25, 2018 15:33 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
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 / http-get-dos.conf
Last active October 16, 2024 09:59
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]