Skip to content

Instantly share code, notes, and snippets.

View patillacode's full-sized avatar
🍕
I'm generally a very pragmatic person: that which works, works. - Linus Torvalds

Patilla Code patillacode

🍕
I'm generally a very pragmatic person: that which works, works. - Linus Torvalds
View GitHub Profile
@patillacode
patillacode / __init__.py
Created March 7, 2024 11:18
Wagtail - Avoid Streamfields in Django migrations
import wagtail.fields
def deconstruct_without_block_definition(self):
name, path, _, kwargs = super(wagtail.fields.StreamField, self).deconstruct()
block_types = list()
args = [block_types]
return name, path, args, kwargs
@patillacode
patillacode / telegram_send.sh
Created November 30, 2023 19:52
telegram send mesage
#!/bin/bash
# credit to: jogerj (https://gist.github.com/dideler/85de4d64f66c1966788c1b2304b9caf1?permalink_comment_id=4327762#gistcomment-4327762)
TELEGRAM_BOT_TOKEN="botid:token"
CHAT_ID="1234567890"
send_telegram () {
title="$1"
timestamp="$(date -R)"
msg="$title\n$timestamp\n\n$(echo "$2" | sed -z -e 's|\\|\\\\|g' -e 's|\n|\\n|g' -e 's|\t|\\t|g' -e 's|\"|\\"|g')"
@patillacode
patillacode / asciinema_in_readme.sh
Created July 22, 2023 21:16
asciinema in your README
# generate asciinema (ctrl-D) to exit when done
asciinema rec -t my-demo
# convert asciinema into svg via svg-term (https://github.com/marionebl/svg-term-cli)
svg-term --cast=598561 --out examples/demo.svg --window
# add svg to your markdown file aka README
![asciinema](./examples/demo.svg)
@patillacode
patillacode / cap.sh
Last active November 23, 2023 21:35
#!/bin/bash
################################################################################
# cap - capture your screen
#
# This script allows you to capture your screen on Linux or macOS systems using
# the appropriate tools available on each platform. On Linux, it uses 'slop'
# and 'ffmpeg', while on macOS, it utilizes 'screencapture'. The script prompts
# you to select a desktop area for recording and saves the recording as an MP4/MOV
# file with customizable video quality.
@patillacode
patillacode / Set new NGINX config
Created April 4, 2021 04:06
For when I forget the steps to set a new config in NGINX
sudo cp /etc/nginx/sites-available/existing-config /etc/nginx/sites-available/new-config
sudo vi /etc/nginx/sites-available/new-config
sudo ln -s /etc/nginx/sites-available/new-config /etc/nginx/sites-enabled/
sudo /usr/sbin/nginx -s reload
git rebase -i -p 0ad14fa5
# editor will open, mark all the commits with "edit"/"e"
# walk through each commit
git commit --amend --author="John Doe <john@doe.org>" --no-edit
git rebase --continue
@patillacode
patillacode / feature on top of master
Created July 3, 2020 11:08
Reset your feature branch to the master state
# Switch to the master branch and make sure you are up to date.
git checkout master
git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
git pull
# Merge the feature branch into the master branch.
git merge feature_branch
# Reset the master branch to origin's state.
@patillacode
patillacode / plex_updater.sh
Created November 17, 2019 22:25
Small bash script that updates your Plex Media Server (Linux) automatically - with a nice output for when running manually!
#!/bin/bash
tput setaf 1 && tput bold
echo "Stopping the Plex server"
sudo service plexmediaserver stop
tput sgr0 && tput setaf 4
echo "Moving to /tmp/ ..."
cd /tmp/

Keybase proof

I hereby claim:

  • I am patillacode on github.
  • I am patillacode (https://keybase.io/patillacode) on keybase.
  • I have a public key ASDc90pWfK4Dq76XRSxknUQ_E1Cgws8TMj8B8mXkvApBiAo

To claim this, I am signing this object:

@patillacode
patillacode / loading.py
Created April 23, 2019 10:53
Python loading bar
def print_status_bar(number, number_of_pages):
percentage = int((number / number_of_pages) * 100)
progress = int((percentage * 20) / 100)
progress_msg = '#' * progress + '.' * (20 - progress)
msg = f' Processing [{progress_msg}] ({number}/{number_of_pages})'
print(msg, end='\r', flush=True)
# Use
number_of_pages = Page.objects.count()
for number, page in enumerate(Page.objects.all()):