Skip to content

Instantly share code, notes, and snippets.

View RBFraphael's full-sized avatar
🙂

Raphael Batista Fontão RBFraphael

🙂
View GitHub Profile
@RBFraphael
RBFraphael / database.js
Last active December 30, 2023 17:56
Electron SQLite Example
const path = require("path");
const fs = require("fs");
const { app } = require("electron");
const sqlite3 = require("sqlite3").verbose();
// Build the database path and output to the console
const appDataPath = app.getPath("appData");
const databasePath = path.join(appDataPath, "database.sqlite");
console.log(`Database Path: ${databasePath}`);
@RBFraphael
RBFraphael / ApiService.ts
Created August 11, 2023 15:40
Service TypeScript
import axios, { AxiosError } from "axios";
const WebApi: any = axios.create({
headers: {
'Content-Type': "application/json",
'Accept': "application/json",
}
});
const PublicApi: any = axios.create({
@RBFraphael
RBFraphael / envvars.js
Created June 20, 2023 15:36
envvar NodeJS helper
const { exec } = require("child_process");
const appPath = process.env.PATH.split(";").filter((segment) => segment.trim().length > 0).filter((segment) => segment.indexOf("node_modules") > -1);
export function getVar(variable, callback){
exec(`echo %${variable}%`, (err, stdOut, stdErr) => {
if(err == null){
if(callback){
callback(stdOut);
}