Skip to content

Instantly share code, notes, and snippets.

View a7ul's full-sized avatar
🚀

Atul R a7ul

🚀
View GitHub Profile
@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 / complex.diff
Created June 15, 2018 10:56
blog-on-node-addon-complex-obj
diff --git a/cppsrc/Samples/classexample.cpp b/cppsrc/Samples/classexample.cpp
index 8dfa3cc..834f7ea 100644
--- a/cppsrc/Samples/classexample.cpp
+++ b/cppsrc/Samples/classexample.cpp
@@ -22,8 +22,17 @@ ClassExample::ClassExample(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Cl
Napi::HandleScope scope(env);
int length = info.Length();
- if (length != 1 || !info[0].IsNumber()) {
- Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@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
@a7ul
a7ul / my-input.js
Last active January 27, 2019 22:02
react-webcomponentify-examples-my-input.js
import React from "react";
import { registerAsWebComponent } from "react-webcomponentify";
export class Input extends React.Component {
constructor(props) {
super(props);
this.state = { buttonText: "" };
this.onInputEnter = this.onInputEnter.bind(this);
}
onInputEnter(evt) {
@a7ul
a7ul / my-button.js
Last active January 27, 2019 22:15
react-webcomponentify-examples-my-button.js
import React from "react";
import { registerAsWebComponent } from "react-webcomponentify";
export const Button = props => {
return (
<button
style="height:40px;font-weight:bold;"
id={props.id}
onClick={props.onClick}
>
@a7ul
a7ul / my-complex-component.js
Last active January 27, 2019 23:18
react-webcomponentify-examples-my-button.js
import React from "react";
import { registerAsWebComponent } from "react-webcomponentify";
const MyComplexComponent = props => (
<div>
Kinda complex component 😂
<p>{props.text}</p>
<div>{props.children}</div>
</div>
);
@a7ul
a7ul / v0.13.0-features.md
Last active January 24, 2020 20:10
List of features in v0.13.0 of NodeGui

Qt Widgets

  • QCalendarWidget
  • QCheckBox
  • QDateEdit
  • QDateTimeEdit
  • QLabel
  • QDial
  • QFileDialog
  • QLineEdit
@a7ul
a7ul / inject_custom_codepush_bundle.ts
Last active January 4, 2023 04:40
How to load custom codepush bundle for a react native app without using offical codepush servers? This can allow us to load code push bundles from anywhere like a gcs bucket or even local http server.
// How to use it ?
// ===============
// Step 1: Create a custom codepush bundle
// ----------------------------------------
// react-native bundle --assets-dest out --bundle-output out/main.jsbundle --dev false --platform ios --entry-file index.ts
// Then just compress the contents of out dir into a single zip file. for example: out.zip
// Step 2: Create a remotePackage json object
// ------------------------------------------