Skip to content

Instantly share code, notes, and snippets.

View a7ul's full-sized avatar
🚀

Atul R a7ul

🚀
View GitHub Profile
@a7ul
a7ul / webpack.config.js
Created January 21, 2018 11:19
Webpack config for electron + react apps
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, '../index.js'),
output: {
path: path.resolve(__dirname, '../build'),
filename: 'bundle.js'
},
devtool: 'eval',
devServer: {
@a7ul
a7ul / .gitignore
Last active June 13, 2018 07:09
blog-addons-first
node_modules
*.log
build
@a7ul
a7ul / index.js
Last active June 13, 2018 07:18
blog-on-node-addons-second
//index.js
const testAddon = require('./build/Release/testaddon.node');
module.exports = testAddon;
@a7ul
a7ul / function.diff
Last active June 13, 2018 08:59
blog-on-node-addon-third
diff --git a/binding.gyp b/binding.gyp
index 23b9976..2d188af 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -4,7 +4,8 @@
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [
- "cppsrc/main.cpp"
+ "cppsrc/main.cpp",
@a7ul
a7ul / add_function.diff
Created June 13, 2018 10:38
blog-on-node-addon-function-with-params
diff --git a/cppsrc/Samples/functionexample.cpp b/cppsrc/Samples/functionexample.cpp
index 0bd9bc2..37b7eb9 100644
--- a/cppsrc/Samples/functionexample.cpp
+++ b/cppsrc/Samples/functionexample.cpp
@@ -4,13 +4,33 @@ std::string functionexample::hello(){
return "Hello World";
}
+int functionexample::add(int a, int b){
+ return a + b;
@a7ul
a7ul / actualclass.cpp
Created June 15, 2018 09:18
blog-on-node-addon-class
/* cppsrc/Samples/actualclass.cpp */
#include "actualclass.h"
ActualClass::ActualClass(double value){
this->value_ = value;
}
double ActualClass::getValue()
{
@a7ul
a7ul / class.diff
Last active June 15, 2018 09:56
blog-on-node-addon-add-class-diff
diff --git a/binding.gyp b/binding.gyp
index 2d188af..031bf18 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -5,7 +5,9 @@
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [
"cppsrc/main.cpp",
- "cppsrc/Samples/functionexample.cpp"
+ "cppsrc/Samples/functionexample.cpp",
@a7ul
a7ul / app.js
Last active July 15, 2018 07:07
blog-console-web-ui-color-output
const style = require('ansi-styles');
const express = require('express');
const hello = () =>`
${style.green.open}Hello Green!${style.green.close}
${style.red.open}Hello Red!${style.red.close}
`;
const app = express();
app.get('/hello', (req, res) => {
@a7ul
a7ul / app.js
Last active July 15, 2018 08:07
blog-console-web-ui-animated-example
const express = require('express');
const { Readable } = require('stream');
// This is the special ANSI code to tell terminals to clear the screen
const PAGE_BREAK = '\033[2J\033[H';
// This function gets the current date in string format along
// with a page break on top.
// Note that you would need to add a new line for the terminal to
// interpret it. That is `hello` will not work while `hello\n` will.
@a7ul
a7ul / app.js
Last active July 15, 2018 11:25
blog-console-web-ui-htmlandconsole
const express = require('express');
const hello = require('./src/ansi/animations/hello');
const PORT = process.env.PORT || 3000;
const app = express();
// simple hello route
app.get('/hello', async (req, res, next) => {
const userAgent = req.headers['user-agent']; // checking the useragent