Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Pawan Chaurasia rjsnh1522

🎯
Focusing
View GitHub Profile
@rjsnh1522
rjsnh1522 / extension.py
Last active May 8, 2020
Adding custom filter to all variables in jinja2
View extension.py
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
View python-code-snippet.py
# To use redis in django
# in settings.py
REDIS = {
'host': 'localhost',
'port': 6379,
'db': 2
}
# make a singleton class and make one redis instance
import redis
@rjsnh1522
rjsnh1522 / recursive_file_deletion.py
Created Mar 15, 2019
To recursively delete files with a specific extensio
View recursive_file_deletion.py
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
rjsnh1522 / System Design.md
Created Mar 8, 2019 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

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
rjsnh1522 / notes.md
Created Jan 17, 2019 — forked from inecmc/notes.md
How to run multiple Redis instances on Ubuntu 16.04
View notes.md

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
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://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
@rjsnh1522
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
# https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/maximum-of-k-size-subarrays-deque/
# 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.