Skip to content

Instantly share code, notes, and snippets.

View adityapatnaik's full-sized avatar
👍
Humility is the greatest asset!

Aditya Patnaik adityapatnaik

👍
Humility is the greatest asset!
View GitHub Profile
@adityapatnaik
adityapatnaik / custom-exception-handling-annotation.md
Last active May 15, 2024 03:56
Custom Exception Handling Annotation that does try catch with input as a custom message and list of exception classes
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>
spring.aop.auto=true
@adityapatnaik
adityapatnaik / sb-select-delete-insert-api.md
Last active May 15, 2024 03:52
Spring Boot Select and Insert API using jdbc template with configurable columns, source and destination tables.

Data Transfer Service

This is a Spring Boot application that provides a REST API endpoint to transfer data from a source table to a destination table in a database. The source table, destination table, and columns to be transferred can be configured through a properties file.

Prerequisites

  • Java 11 or higher
  • Maven

Configuration

@adityapatnaik
adityapatnaik / App.js
Created October 9, 2020 11:56
How to implement Routing in Electron with React: Hashed Router to the rescue.
import React from 'react';
import {HashRouter,Link,Route,Switch} from "react-router-dom";
const Stand = ()=>{
return(
<Stand/>
)
}
const Sit = ()=>{
@adityapatnaik
adityapatnaik / App.js
Last active October 9, 2020 11:54
How to implement Routing in Electron with React: Why not BrowserRouter in Electron?
import React from 'react';
import {BrowserRouter,Link,Route,Switch} from "react-router-dom";
const Stand = ()=>{
return(
<Stand/>
)
}
const Sit = ()=>{
@adityapatnaik
adityapatnaik / App.js
Created October 8, 2020 16:01
Synchronous Reply:App.js
<button onClick={()=>{
console.log('sync',ipcRenderer.sendSync('anything-synchronous', 'ping'))
// prints "sync pong"
}}>
Sync
</button>
@adityapatnaik
adityapatnaik / main.js
Created October 8, 2020 15:59
Synchronous Reply: main.js
ipcMain.on('anything-synchronous', (event, arg) => {
console.log("sync",arg) // prints "sync ping"
//reply
event.returnValue = 'pong'
})
@adityapatnaik
adityapatnaik / App.js
Last active October 8, 2020 15:57
Asynchronous Reply: App.js
<button onClick={()=>{
ipcRenderer.send('anything-asynchronous', 'ping')
// reply
ipcRenderer.on('asynchronous-reply', (event, arg) => {
console.log("Hiii",arg) // prints "Hiii pong"
})
}}>
Async
@adityapatnaik
adityapatnaik / main.js
Created October 8, 2020 15:56
Asynchronous Reply:main.js
ipcMain.on('anything-asynchronous', (event, arg) => {
console.log("async",arg) // prints "async ping"
event.reply('asynchronous-reply', 'pong')
})
@adityapatnaik
adityapatnaik / main.js
Created October 8, 2020 15:52
Let's see the IPC in action with a React component:main.js
//write this below the app.whenReady() function in the main.js file
ipcMain.on('anything-asynchronous', (event, arg) => {
// gets triggered by the async button defined in the App component
console.log("async",arg) // prints "async ping"
})
// gets triggered by the sync button defined in the App component
ipcMain.on('anything-synchronous', (event, arg) => {
console.log("sync",arg) // prints "sync ping"
@adityapatnaik
adityapatnaik / App.js
Created October 8, 2020 15:50
Let's see the IPC in action with a React component:App.js
import React from 'react';
import './App.css';
const { ipcRenderer } = window.require('electron');
function App() {
return (
<div className="App">
<button onClick={()=>{