Skip to content

Instantly share code, notes, and snippets.

View arpitbbhayani's full-sized avatar
🎲
building @DiceDB

Arpit Bhayani arpitbbhayani

🎲
building @DiceDB
View GitHub Profile
def __call__(self, *args, **kwargs):
"""Overriding the __call__ function which makes the
instance callable.
"""
# fetching the function to be invoked from the virtual namespace
# through the arguments.
fn = Namespace.get_instance().get(self.fn, *args)
if not fn:
@overload
def area(l, b):
return l * b
@overload
def area(r):
import math
return math.pi * r ** 2
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> def foo(a, b):
... return a + b
...
>>>
>>> import sys
>>> sys.ps1 = '::: '
:::
import sys
sys.ps1 = "\033[1;33m>>>\033[0m "
sys.ps2 = "\033[1;34m...\033[0m "
# -*- coding: utf-8 -*-
import sys
class IPythonPromptPS1(object):
def __init__(self):
self.line = 0
def __str__(self):
self.line += 1
return "\033[92mIn [%d]:\033[0m " % (self.line)
sys.ps1 = IPythonPromptPS1()
sys.ps2 = " \033[91m...\033[0m "
export PYTHONSTARTUP="$HOME/ipython.py"
def get_ratelimit_config(key):
value = cache.get(key)
if not value:
value = config_store.get(key)
cache.put(key, value)
return value
def get_current_window(key, start_time):
ts_data = requests_store.get(key)
if not key:
return 0
total_requests = 0
for ts, count in ts_data.items():
if ts > start_time:
total_requests += count
else: