Skip to content

Instantly share code, notes, and snippets.

View anuragrana's full-sized avatar

Anurag Rana anuragrana

View GitHub Profile
#!/bin/env python
import sys
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
@anuragrana
anuragrana / logger_settings.py
Last active December 10, 2017 09:33
Simplest Logger settings for Django project
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'large': {
'format': '%(asctime)s %(levelname)s %(process)d %(pathname)s ' +
'%(funcName)s %(lineno)d %(message)s '
}
},
'handlers': {
@anuragrana
anuragrana / email.py
Created June 15, 2018 07:57
Sending email using python and gmail
# import dependencies
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import email
import email.mime.application
from django.utils.html import strip_tags
# create message
disposable_emails = [
"yopmail.com",
"0-mail.com",
"0815.ru",
"0clickemail.com",
"0wnd.net",
"0wnd.org",
"10minutemail.com",
"20minutemail.com",
"2prong.com",
#
# Printing square of all numbers less than number n.
# n is provided at runtime.
# Author: https://www.pythoncircle.com
#
if __name__ == '__main__':
n = int(input())
for x in range(n):
print(x*x)
#
# Program to confirm is a given year is leap year or not
# year is provided at runtime.
# Author: https://www.pythoncircle.com
#
def is_leap(year):
leap = False
if year % 4 == 0:
if year % 100 == 0:
@anuragrana
anuragrana / snake_ladder.py
Created December 25, 2018 17:11
text based snake and ladder game
#
# Text based snake and ladder game
# Author - https://www.pythoncircle.com
#
import time
import random
import sys
# just of effects. add a delay of 1 second before performing any action
@anuragrana
anuragrana / kafka-cheat-sheet.md
Created May 16, 2020 11:59 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...