Skip to content

Instantly share code, notes, and snippets.

View syedjafer's full-sized avatar
🎯
Focusing

syedjafer_k syedjafer

🎯
Focusing
View GitHub Profile
@syedjafer
syedjafer / create_merge_conflict.sh
Created February 17, 2023 15:48
File to create a merge conflict
# 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
const contextmenu = document.querySelector(".contextmenu");
let ctxPosition = {
pageX: 0,
pageY: 0
};
document.addEventListener("contextmenu", (e) => {
e.preventDefault();
const ctxHeight = contextmenu.offsetHeight;
const ctxWidth = contextmenu.offsetWidth + 5;
body {
font-family: sans-serif;
position: relative;
height: 100vh;
margin: 0;
}
ul {
list-style: none;
margin-block-start: 0;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Custom Context Menu</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<link rel="stylesheet" href="index.css">
</head>
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:
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
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()})
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)
<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?");
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