Skip to content

Instantly share code, notes, and snippets.

View cr3a7ure's full-sized avatar

Goutis Dimitrios cr3a7ure

View GitHub Profile
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@cr3a7ure
cr3a7ure / simplehttp.service
Created May 21, 2022 13:03 — forked from funzoneq/simplehttp.service
A systemd file for a python SimpleHTTPServer
[Unit]
Description=Job that runs the python SimpleHTTPServer daemon
Documentation=man:SimpleHTTPServer(1)
[Service]
Type=simple
WorkingDirectory=/tmp/letsencrypt
ExecStart=/usr/bin/python -m SimpleHTTPServer 80 &
ExecStop=/bin/kill `/bin/ps aux | /bin/grep SimpleHTTPServer | /bin/grep -v grep | /usr/bin/awk '{ print $2 }'`
@cr3a7ure
cr3a7ure / select_codeblock_markdown.md
Last active October 28, 2022 20:17
vimscript select code block inside markdown

I wanted to visual select code blocks inside markdown files, so I wrote this pretty simple script. Someone might find it useful. You can change the symbols as you like in searchpos, but this only works for multiple lines.

function! InsideTicks()
    call searchpos('`', 'b')
    normal! jv
    call searchpos('`', 'W')
 normal! be
@cr3a7ure
cr3a7ure / dkr
Created January 9, 2023 17:46 — forked from gilchris/dkr
docker command shortcut
#!/bin/bash
function fzf_container() {
docker container ls -a | fzf -m | awk '{print $1}'
}
function fzf_running_container() {
docker ps | fzf -m | awk '{print $1}'
}
function container() {
I have Lua script that manipulates cookies and headers based at GET parameters.
This script didnt work well at one location, strangely the ngx.var.args was empty with ordinary request.
The trick was that in location we have:
location /x/ {
header_filter_by_lua_file /etc/nginx/lua/referrer_cookie.lua;
rewrite ^/x/(.*) /$1 break;
try_files $uri /x/index.htm;
@cr3a7ure
cr3a7ure / split_pdfs.sh
Created January 31, 2025 17:03
Split every PDF in a directory per X number of pages
#!/bin/bash
# Split PDF files into multiple files with a specified number of pages.
# Usage: ./split_pdf.sh [increment] [directory]
#
increment=${1:-5}
directory=${2:-"."}
for file in "$directory"/*; do