Skip to content

Instantly share code, notes, and snippets.

View saravanan10393's full-sized avatar
🎯
Focusing

Saravanan Ramupillai saravanan10393

🎯
Focusing
View GitHub Profile
var spawn = require('child_process').spawn;
wifiNetworksRSSI(function(err, data, raw) {
if (!err) {
console.log(data); // formatted data with SSID, BSSID, RSSI
// console.log(raw); // raw output from netsh
} else {
console.log(err);
}
});
@saravanan10393
saravanan10393 / Firebase_Chat_Schema.json
Last active July 3, 2017 10:14
Firebase Schema structure for 1 to 1 and group chat.
{
"users": {
"uid_0": {
"name": "user1",
"profileUrl": "sdfs",
"contacts": {
"uid_1": {
"conversation":"con_0",
"status":"active"
},
@saravanan10393
saravanan10393 / Event Callback
Created December 17, 2017 09:45
Event callback / Ref in react.
import React, { Component } from 'react';
class Greeting extends Component {
constructor(props) {
super(props);
// you can see the onGreet function we passed from App component to this component
// in props
console.log('Greeting props are ', props);
}
componentDidMount() {
@saravanan10393
saravanan10393 / Event Emitter example
Last active September 28, 2023 10:21
EventEmitter Example for React.md
import EventEmitter from 'wolfy87-eventemitter'
//Create a instance for event emitter
const Event = new EventEmitter()
class Parent_1-Component extends Component{
componentDidMount(){
// Emit welcome message to grant child component without passing it through
// via child component.
Event.emit('Greet', "Hello Raja");
class Calculator {
constructor(a, b) {
this.a = a;
this.b = b;
}
add() {
return this.a + this.b
}
subtract() {
var path = require('path')
module.exports = {
entry: "./src/calculator.js",
output: {
path: path.resolve(__dirname, 'dist'),
filename: "calculator.bundle.js"
},
module: {
rules: [
{
@saravanan10393
saravanan10393 / service_worker.js
Last active February 2, 2018 08:36
Sample service worker for caching image files
cacheName = "IMAGE_CHACHE";
self.addEventListener('install', (event) => {
console.log('service worker installed successfully ');
});
self.addEventListener('fetch', (event) => {
let requestURl = new URL(event.request.url);
if(!requestURl.pathname.endsWith('.gif')) {
//return if the request is not a gif file.
@saravanan10393
saravanan10393 / Blocking Thread operation
Created June 12, 2018 17:29
Example to show case what is blocking operation is
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align: center;
}
.counterSetter{
box-shadow: 0px 2px 25px 0 rgba(17, 17, 24, 0.12);
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align: center;
}
.counterSetter{
box-shadow: 0px 2px 25px 0 rgba(17, 17, 24, 0.12);
@saravanan10393
saravanan10393 / InfinitescrollNotifier.js
Created September 24, 2018 06:25
Infinite scroll notifier based on IntersectionObserver API
import React from "react";
import PropTypes from "prop-types";
export class RefreshAtEnd extends React.Component {
static propTypes = {
root: PropTypes.string.isRequired, // list container
onVisible: PropTypes.func // callback to call when loading is visible
};
static defaultProps = {