Skip to content

Instantly share code, notes, and snippets.

View devarajchidambaram's full-sized avatar

devaraj devarajchidambaram

View GitHub Profile
@devarajchidambaram
devarajchidambaram / captureStackTrace.js
Created February 28, 2019 06:15
captureStackTrace
Error.captureStackTrace(targetObject[, constructorOpt])#
targetObject <Object>
constructorOpt <Function>
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // similar to `new Error().stack`
@devarajchidambaram
devarajchidambaram / server.js
Created February 27, 2019 05:12
web socket server
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('messsage received: %s', message);
});
@devarajchidambaram
devarajchidambaram / client.js
Created February 27, 2019 05:11
Websocket in nodejs
var url = 'ws://localhost:8080/'
var connection = new WebSocket(url)
connection.onerror = error => {
console.log(`WebSocket error: ${error}`)
}
connection.onopen = () => {
connection.send('hey')
}
@devarajchidambaram
devarajchidambaram / memcached_install.txt
Last active February 25, 2019 07:06
Install memcached in windows
Download and install
https://commaster.net/content/installing-memcached-windows
Default port : 11211
To set value
memcached.set('foo', 'bar', 10, function (err) {
})
Note :- 10 is the expiry time is 10 seconds
@devarajchidambaram
devarajchidambaram / index.js
Created November 28, 2018 11:40
Memory and cpu stopping
/**
* Created by prmadi on 8/20/2015.
*/
var http = require('http');
var port = process.env.PORT || '3000';
// Memory Leak
function LeakingClass() {
}
Hapi (short for (Http)API, pronounced “happy”)
@devarajchidambaram
devarajchidambaram / node_gyp.md
Created October 26, 2018 11:16
Node-gyp install in windows
@devarajchidambaram
devarajchidambaram / index.md
Created October 25, 2018 05:52
Grant all permissions to mysql data base to access every IP

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; Query OK, 0 rows affected (0.13 sec)

@devarajchidambaram
devarajchidambaram / index.txt
Created October 16, 2018 07:41
Sample nodejs apps
https://github.com/bmorelli25/simple-nodejs-weather-app
@devarajchidambaram
devarajchidambaram / Counter.js
Created October 11, 2018 11:55
React js + redux
import React ,{Component} from "react";
import { connect } from 'react-redux';
alert(connect)
class Counter extends Component{
constructor(props){
super(props);