Skip to content

Instantly share code, notes, and snippets.

View deepakshrma's full-sized avatar
🎯
Focusing

Deepak Vishwakarma deepakshrma

🎯
Focusing
View GitHub Profile
@deepakshrma
deepakshrma / 01-read.py
Last active April 4, 2025 17:33
Reading Data with Python | Easy Learning
# Read entire file one time
page = ""
with open("app.log", 'r') as file:
page = file.read()
print(page)
"""
# Output
03/22 08:51:06 TRACE :...read_physical_netif: Home list entries returned = 7
03/22 08:51:06 INFO :...read_physical_netif: index #0, interface VLINK1 has address 129.1.1.1, ifidx 0
...
@deepakshrma
deepakshrma / 01-react.tsx
Last active May 4, 2022 15:59
Using Context and TypeScript to build an Alert Messenger in React.js
// index.tsx
import { StrictMode } from "react";
import ReactDOMClient from "react-dom/client";
import { createGlobalStyle, ThemeProvider } from "styled-components";
import App from "./App";
import { AlertContextProvider } from "./components/Alert/AlertContextProvider";
const Global = createGlobalStyle`
p,
h1,
h2,
@deepakshrma
deepakshrma / DOMParserDemo.kt
Created June 11, 2022 11:05
XSD Parser Kotlin
import org.w3c.dom.Document
import org.xml.sax.SAXException
import org.xml.sax.SAXParseException
import org.xml.sax.helpers.DefaultHandler
import java.io.StringReader
import javax.xml.XMLConstants
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.stream.StreamSource
import javax.xml.validation.SchemaFactory
@deepakshrma
deepakshrma / Java01.java
Last active June 19, 2022 16:38
Working with XML Serialization and Response in Java and Kotlin
// imports
@SpringBootApplication
@RestController
public class XmlDemoApplication {
public static void main(String args[]) {
SpringApplication.run(XmlDemoApplication.class, args);
}
@RequestMapping(
value = "/xml",
method = RequestMethod.GET,
@deepakshrma
deepakshrma / js-observable.js
Created June 26, 2022 09:42
JavaScript Observable
const debounce = (fn, ms = 0) => {
let id;
return (...args) => {
if (id) clearTimeout(id);
id = setTimeout(() => fn(...args), ms);
};
};
const observable = (render) => {
const that = {};
const _render = debounce(render);
@deepakshrma
deepakshrma / react-flow-simple-traverse.js
Created August 1, 2022 14:26
react-flow Simple Tree Traverse
const data = {
nodes: [
{
width: 150,
height: 36,
id: "id_1",
data: { label: "Node 1" },
position: { x: 100, y: 100 },
positionAbsolute: { x: 100, y: 100 },
},