Skip to content

Instantly share code, notes, and snippets.

View SourabhSNath's full-sized avatar
🎯
Focusing

Sourabh S Nath SourabhSNath

🎯
Focusing
View GitHub Profile
@SourabhSNath
SourabhSNath / qt_tcp_udp_communication.py
Created March 14, 2022 09:58
TCP and UDP communication in PyQt6
from PyQt6 import QtWidgets, QtNetwork, QtCore
from PyQt6.QtCore import pyqtSignal, QObject
class ChatWindow(QtWidgets.QWidget):
submitted = pyqtSignal(str)
def __init__(self):
super().__init__()
self.setLayout(QtWidgets.QGridLayout())
@SourabhSNath
SourabhSNath / json_append.py
Last active March 2, 2022 10:21
To append new data to json file in python.
import json
if file_exists(file_name):
self.data = import_data_from_json(file_name)
self.data.append(dict_data)
export_data_to_json(file_name, self.data)
else:
# Create new json file if it doesn't exist. Put the data in an array.
export_data_to_json(file_name, [dict_data])
@SourabhSNath
SourabhSNath / gist:f775a5dd54ddda4565cfbaf3e1f15982
Created October 30, 2020 05:57
To run Kotlin and then delete the jar and class files after running using Code Runner on VS Code
// Add this within code-runner.executorMap
"kotlin": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar && rm -r $fileNameWithoutExt.jar $fileNameWithoutExtKt.class"