A Pen by thanos vassilakis on CodePen.
This file contains hidden or 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 hashlib | |
| from functools import wraps | |
| from django.core.cache import cache | |
| from django.utils.encoding import force_text, force_bytes | |
| def cache_memoize( | |
| timeout, | |
| prefix='', |
This file contains hidden or 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
| sudo apt-get update -y | |
| sudo apt-get upgrade -y | |
| wget -qO - http://packages.confluent.io/deb/3.2/archive.key | sudo apt-key add - | |
| sudo add-apt-repository "deb [arch=amd64] http://packages.confluent.io/deb/3.2 stable main" | |
| sudo apt-get update && sudo apt-get install confluent-platform-oss-2.11 | |
| sudo apt-get install librdkafka-dev | |
| ldconfig -p | grep librdkafka |
This file contains hidden or 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
| #resive the volue using EC2 tools. | |
| rm /var/log/somediskhog/*.log.? | |
| growpart /dev/xvda 1 | |
| lsblk | |
| resize2fs /dev/xvda1 | |
| lsblk |
This file contains hidden or 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
| sudo docker rm `sudo docker ps -a | cut -f 1 -d " "` |
This file contains hidden or 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
| function (key, values, rereduce) { | |
| if (rereduce) { | |
| var results = { | |
| 'sum': values.reduce(function(a, b) { return a + b.sum }, 0), | |
| 'min': values.reduce(function(a, b) { return Math.min(a, b.min) }, Infinity), | |
| 'max': values.reduce(function(a, b) { return Math.max(a, b.max) }, -Infinity), | |
| 'count': values.reduce(function(a, b) { return a + b.count }, 0), | |
| 'sumsqr': values.reduce(function(a, b) { return a + b.sumsqr }, 0) | |
| }; | |
| for(var i = 0; i < values.length; i++) { |
This file contains hidden or 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
| # A custom django has_group conditional tag | |
| # usage: | |
| # | |
| # {% if request.user|has_group:"Manager" %} {% endif %} | |
| # | |
| # Developer: Thanos Vassilakis, 2002 | |
| import re, string | |
| from django import template |
This file contains hidden or 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 -*- | |
| # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 | |
| import sys, logging, socket, types, os, string, cPickle, struct, time | |
| class NTEventLogHandler(logging.Handler): | |
| """ | |
| A handler class which sends events to the NT Event Log. Adds a | |
| registry entry for the specified application name. If no dllname is |
This file contains hidden or 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 atexit | |
| @atexit.register | |
| def going_down(): | |
| import logging | |
| logging.getLogger('myapp').error("SERVER GOING DOWN") |
This file contains hidden or 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
| iso_4217_currencies = { | |
| "AED": "United Arab Emirates dirham United Arab Emirates", | |
| "AFN": "Afghan afghani", | |
| "ALL": "Albanian lek ", | |
| "AMD": "Armenian dram", | |
| "ANG": "Netherlands Antillean guilder", | |
| "AOA": "Angolan kwanza", | |
| "ARS": "Argentine peso", | |
| "AUD": "Australian dollar", | |
| "AWG": "Aruban florin", |