https://medium.freecodecamp.org/how-to-publish-a-pyton-package-on-pypi-a89e9522ce24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget | |
$ cd /usr/local/src | |
$ wget http://download.mono-project.com/sources/mono/mono-3.2.8.tar.bz2 | |
$ tar jxf mono-3.2.8.tar.bz2 | |
$ cd mono-3.2.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.db import models | |
from itertools import chain | |
from datetime import datetime, timedelta | |
class EventManager(models.Manager): | |
def all(self, *args, **kwargs): | |
qs = super(EventManager, self).all(*args, **kwargs).filter() | |
return qs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import urllib3 | |
class Valute: | |
def __init__(self, node): | |
self.node = node | |
for n in node.iter(): | |
if "ID" in n.attrib: | |
self.id = n.attrib["ID"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_namedtuple_choices(name, choices_tuple): | |
"""Factory function for quickly making a namedtuple suitable for use in a | |
Django model as a choices attribute on a field. It will preserve order. | |
Usage:: | |
class MyModel(models.Model): | |
COLORS = get_namedtuple_choices('COLORS', ( | |
(0, 'BLACK', 'Black'), | |
(1, 'WHITE', 'White'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""From https://fazle.me/auto-generating-unique-slug-in-django/""" | |
from django.db import models | |
from django.utils.text import slugify | |
class Article(models.Model): | |
title = models.CharField(max_length=120) | |
slug = models.SlugField(max_length=140, unique=True) | |
content = models.TextField() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeMixin: | |
# Assuming that you want to trigger the task on save: | |
def save(self, *args, **kwargs): | |
ret = super().save(*args, **kwargs) | |
some_task.apply_async(( | |
self.__class__.__name__, | |
self.pk, | |
)) | |
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
class InputFilter(admin.SimpleListFilter): | |
template = 'admin/input_filter.html' | |
def lookups(self, request, model_admin): | |
# Dummy, required to show the filter. | |
return ((),) | |
def choices(self, changelist): |
I using https://github.com/lukas2511/dehydrated for automate updation ssl certs on hosts
- Create new user for handle letsencrypt ssl certs
sudo adduser --system --home /opt/dehydrated dehydrated
OlderNewer