Skip to content

Instantly share code, notes, and snippets.


Pawan Chaurasia rjsnh1522

View GitHub Profile
rjsnh1522 /
Last active May 8, 2020
Adding custom filter to all variables in jinja2
from jinja2.lexer import Token
from jinja2.ext import Extension
class ListDictTable(Extension):
tags = set(['listdicttable'])
def filter_stream(self, stream):
variable_done = False
in_trans = False
# To use redis in django
# in
'host': 'localhost',
'port': 6379,
'db': 2
# make a singleton class and make one redis instance
import redis
rjsnh1522 /
Created Mar 15, 2019
To recursively delete files with a specific extensio
import os
def caller():
for (root,dirs,files) in os.walk(os.getcwd(), topdown=True):
for file in files:
if file.endswith('.url') or file.endswith('.txt'):
print(os.remove(os.path.join(root, file)))
rjsnh1522 / System
Created Mar 8, 2019 — forked from vasanthk/System
System Design Cheatsheet
View System

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
rjsnh1522 /
Created Jan 17, 2019 — forked from inecmc/
How to run multiple Redis instances on Ubuntu 16.04

Create the directory for the new instance

$ sudo install -o redis -g redis -d /var/lib/redis2

Create a new configuration file

$ sudo cp -p /etc/redis/redis.conf /etc/redis/redis2.conf
rjsnh1522 / new_environment_installation
Last active Jun 8, 2018
New Environment installations for rails development in ubuntu and mac
View new_environment_installation
===================================INSTALL CHROMIUM==============================
# install chromium
$ sudo apt-get install chromium-browser
===================================INSTALL rvm==============================
$ gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL | bash -s stable --ruby
rjsnh1522 / max_of_k_size_sub_array.rb
Created Mar 6, 2018
Maximum Of K- size subarrays (Deque)
View max_of_k_size_sub_array.rb
# question
# quertion url
# Given an array A of size 'N' and an integer k, find the maximum for each and every contiguous subarray of size k.
# Input :
# First line contains 2 space separated integers 'N' and 'k' .
# Second line contains 'N' space separated integers denoting array elements.
You can’t perform that action at this time.