This file contains 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
const data = { | |
nodes: [ | |
{ | |
width: 150, | |
height: 36, | |
id: "id_1", | |
data: { label: "Node 1" }, | |
position: { x: 100, y: 100 }, | |
positionAbsolute: { x: 100, y: 100 }, | |
}, |
This file contains 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
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); |
This file contains 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
// imports | |
@SpringBootApplication | |
@RestController | |
public class XmlDemoApplication { | |
public static void main(String args[]) { | |
SpringApplication.run(XmlDemoApplication.class, args); | |
} | |
@RequestMapping( | |
value = "/xml", | |
method = RequestMethod.GET, |
This file contains 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 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 |
This file contains 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
// 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, |
This file contains 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
# 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 | |
... |
This file contains 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 Car { | |
String type; | |
String model; | |
String color; | |
int speed; | |
Car(String type, String model, String color) { | |
this.type = type; | |
this.model = model; |
This file contains 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
console.log("Welcome to How To Write Services Using JavaScript") | |
const http = { | |
cb: [], | |
intercept(cb) { | |
this.cb.push(cb); | |
}, | |
async get(url, options = {}) { | |
return this.request(url, null, options) | |
}, |
This file contains 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
function calculateInterest(p: number, t: number, r: number) { | |
return (p * t * r) / 100; | |
} | |
console.log(calculateInterest(1000, 5, 5)); | |
//250 |
This file contains 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
// Draft Service class | |
const services = { | |
fetchTodos: () => | |
fetch("https://jsonplaceholder.typicode.com/todos/") | |
.then((d) => d.json()) | |
.then((list) => list.slice(0, 5)), // Show last 5 | |
createTodo: (todo) => | |
fetch("https://jsonplaceholder.typicode.com/todos/", { | |
method: "POST", | |
headers: { |
NewerOlder