This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create a Directory | |
| mkdir git-repo | |
| cd git-repo | |
| # Initialize Git repository | |
| git init | |
| # Create a file | |
| touch my_code.sh | |
| git add my_code.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def singleton(Class): | |
| instances = {} | |
| def getInstances(*args, **kwargs): | |
| if Class not in instances: | |
| instances[Class] = Class(*args, **kwargs) | |
| return instances[Class] | |
| return getInstances | |
| @singleton | |
| class Test: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SingleTon: | |
| # Creating a static private variable | |
| _instance = None | |
| # __new__ is called inside __init__ for object instantiation. | |
| def __new__(self): | |
| if( not self._instance ): | |
| self._instance = super(SingleTon, self).__new__(self) | |
| self.y = 10 | |
| return self._instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import uuid | |
| import random | |
| from faker import Faker | |
| fake = Faker() | |
| def get_data(): | |
| data = list() | |
| for _ in range(10): | |
| data.append({'userId': uuid.uuid4(), 'id': random.randrange(1, 100), 'name': fake.name(), 'address': fake.address()}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask,jsonify | |
| from flask_sse import sse | |
| import logging | |
| from apscheduler.schedulers.background import BackgroundScheduler | |
| from flask_cors import CORS | |
| import datetime | |
| from helper import get_data,get_schd_time | |
| app = Flask(__name__) | |
| CORS(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script> | |
| var source = new EventSource("http://localhost:5000/events"); | |
| source.addEventListener('dataUpdate', function(event) { | |
| console.log(event); | |
| }, false); | |
| source.addEventListener('error', function(event) { | |
| console.log("Error"+ event) | |
| alert("Failed to connect to event stream. Is Redis running?"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Customer: | |
| def __init__(self, address, title, first_name, last_name): | |
| self.__address = address | |
| self.__title = title | |
| self.__first_name = first_name | |
| self.__last_name = last_name | |
| def get_title(self): | |
| return self.__title |
NewerOlder