Skip to content

Instantly share code, notes, and snippets.

@pasystem
pasystem / gist:90e24bc91445448b94663e6d19da26fa
Created February 11, 2022 11:09 — forked from virhilo/gist:3077726
Counting business days between 2 dates
import unittest
from datetime import datetime, timedelta
def business_days(start, end):
"""
Calculating business days between two dates excluding weekends
:param start: First date
:param end: Second date
def test_api():
import json
import requests
from random import choice
from rest_framework.test import APIClient
from tws.sms.models import OTP
from apps.partners.models import GoodsCategory
api = APIClient()
@pasystem
pasystem / python-convert-dictionary-to-object
Created August 24, 2018 11:18 — forked from kkirsche/python-convert-dictionary-to-object
Convert a dictionary to an object (recursive) for python 3.
class DictionaryUtility:
"""
Utility methods for dealing with dictionaries.
"""
@staticmethod
def to_object(item):
"""
Convert a dictionary to an object (recursive).
"""
def convert(item):
@pasystem
pasystem / Install-nginx-with-http2-support.md
Created June 16, 2017 09:33 — forked from hollodotme/Install-nginx-with-http2-support.md
Install nginx with http2 support on ubuntu 14.04 LTS (Trusty)

How to install nginx (>= 1.9.5) with http2 support on Ubuntu 14.04 LTS (Trusty)

IMPORTANT: Backup your nginx site configs (usually under /etc/nginx/sites-available)!

Remove old nginx

Remove old nginx incl. nginx-common:

apt-get autoremove --purge nginx nginx-common
@pasystem
pasystem / dockercleanup.sh
Created March 3, 2017 04:39 — forked from toke/dockercleanup.sh
Remove old docker containers and images
# Remove old docker containers
docker rm $(docker ps --no-trunc -aq)
# Remove unreferenced images
docker images | grep "<none>" | awk '{print $3}' | xargs docker rmi
#OR
#alias dockercleancontainers="docker ps -a -notrunc| grep 'Exit' | awk '{print \$1}' | xargs -L 1 -r docker rm"