Skip to content

Instantly share code, notes, and snippets.

View kcsanjeeb's full-sized avatar
🎯
Focusing

sanjeeb kc kcsanjeeb

🎯
Focusing
  • offix services pvt. ltd.
  • kapan, kathmandu
  • X @sanjeebkc9
View GitHub Profile
# SQLite database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase',
}
}
#MYSql Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': config('DB_NAME'),
'USER': config('DB_USER'),
'PASSWORD': config('DB_PASSWORD'),
'HOST': '127.0.0.1',
'PORT': '3306',
@kcsanjeeb
kcsanjeeb / pin requirements
Created January 17, 2023 03:36
pin requirements
python -m pip freeze > requirements.txt
@kcsanjeeb
kcsanjeeb / install requirements
Last active January 17, 2023 03:36
install requirements
python -m pip install -r requirements.txt
@kcsanjeeb
kcsanjeeb / gist:d63d2c08e478d2a1aa05302140c74fa0
Created January 17, 2023 03:19
virtualenvironment setup macOS
python3 -m venv env
source env/bin/activate
import React, { useState, useEffect ,useRef } from 'react';
import {
SafeAreaView,
ScrollView,
StyleSheet,
View,
ImageBackground,
Image,
Animated,
Dimensions,
if __name__ =='__main__':
blog_publisher = BlogPublisher()
for Subscribers in [SMSSubscriber,EmailSubscriber,AnyOtherSubscriber]:
Subscribers(blog_publisher)
print("\n Subscribers : ",blog_publisher.subscribers())
blog_publisher.addBlog('My First Blog!')
blog_publisher.notifySubscribers()
class SMSSubscriber:
def __init__(self,publisher):
self.publisher=publisher
self.publisher.attach(self)
def update(self):
print(type(self).__name__,self.publisher.getBlog())
class EmailSubscriber:
def __init__(self,publisher):
from abc import ABCMeta, abstractmethod
class Subscriber(metaclass=ABCMeta):
@abstractmethod
def update(self):
pass
class BlogPublisher:
def __init__(self):
self.__subscribers=[]
self.__latestBlog = None
def attach(self,subscriber):
self.__subscribers.append(subscriber)
def detach(self):
return self.__subscribers.pop()
def subscribers(self):
return [type(x).__name__ for x in self.__subscribers]