Skip to content

Instantly share code, notes, and snippets.

@saschalalala
saschalalala / _dnf
Created June 8, 2015 08:49
zsh completion file for dnf
#compdef dnf
# Main dispatcher
_dnf()
{
local curcontext="$curcontext" state lstate line
_arguments -s \
'(- *)'{-h,--help}'[show the help message]' \
'(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \
@saschalalala
saschalalala / decorators.py
Created June 3, 2017 15:24
telegram_bot decorators
def admin_only(func):
def check_permissions(*args, **kwargs):
bot = args[0]
update = args[1]
admin_ids = list(Player.objects.filter(gm=True).values_list('telegram_id', flat=True))
current_user = update.message.from_user
if current_user.id not in admin_ids:
update.message.reply_text("You are not allowed to do this, Troubleshooter. This incident will be reported")
message = "The user {} just entered a forbidden command.".format(current_user)
log_channel_id = Game.objects.get(pk=1).channel_id
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models
from django.utils.translation import ugettext_lazy as _
from .managers import UserManager
class User(AbstractBaseUser, PermissionsMixin):
"""
User model, extends `django.contrib.auth.models.AbstractBaseUser`
var cookieconsent_wrapper = function() {
console.log("I am running");
// Stop from running again, if accidently included more than once.
if (window.hasCookieConsent) return;
window.hasCookieConsent = true;
/*
Constants
*/
@saschalalala
saschalalala / console.py
Last active October 13, 2021 11:18
Patched rich console.py print function
def print(
self,
*objects: Any,
sep: str = " ",
end: str = "\n",
style: Optional[Union[str, Style]] = None,
justify: Optional[JustifyMethod] = None,
overflow: Optional[OverflowMethod] = None,
no_wrap: Optional[bool] = None,
emoji: Optional[bool] = None,