Skip to content

Instantly share code, notes, and snippets.

View nsisodiya's full-sized avatar

Narendra Sisodiya nsisodiya

View GitHub Profile
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"env": {
@nsisodiya
nsisodiya / s.sh
Created April 7, 2016 07:10
HaProxy Restart
ps -ef | grep /var/run/haproxy | grep -v grep | tr -s ' ' | cut -d" " -f2 | while read i; do kill -9 $i; done
@nsisodiya
nsisodiya / JS_DB_Spec.js
Created February 10, 2016 13:10
JavaScript DataBase Brainstorming
/**
* Created by narendrasisodiya on 10/02/16.
* Twitter/Github @nsisodiya
*/
//======================== DataBase Description ======================
var eventName = {
@nsisodiya
nsisodiya / Button Submit With Progress Bar 01.markdown
Created December 28, 2015 06:14
Button Submit With Progress Bar 01
@nsisodiya
nsisodiya / example.js
Created November 14, 2015 07:25
convert a callback-style node method to promise
var User = {
getData: function(userId, cb){
AsyncDB.query("GET DATA FOR userId", function(err, data){
cb(err, data);
});
}
};
promisify(User, 'getData');// This will append method called `getDataAsync`
@nsisodiya
nsisodiya / todo-reducer.js
Last active October 24, 2015 09:55
TODO Reducer - Alternate Syntax
var methods = {
ADD_TODO(state, action){
return [...state, {
text: action.text,
completed: false
}];
},
COMPLETE_TODO(state, action){
return [
@nsisodiya
nsisodiya / generatePromise.js
Created September 14, 2015 12:25
convert callback API into Promise
var generatePromise = function () {
var gen = {};
return {
callback: function (err, data) {
if(err){
gen.reject(err);
}
gen.resolve(data);
},
promise: new Promise(function (resolve, reject) {
import React, {Component} from 'react';
import request from 'superagent-bluebird-promise';
class AjaxGet extends Component {
constructor(props, context) {
super(props, context);
this.state = {
data: {}
};
@nsisodiya
nsisodiya / util.js
Created September 6, 2015 13:26
loadReactComponent
define(['util'], function () {
'use strict';
return {
loadReactComponents: function (id, moduleName) {
var node = document.getElementById(id);
React.render(React.createElement(window.reactComponents[moduleName], null), node);
}
};
});
@nsisodiya
nsisodiya / load.js
Created September 6, 2015 13:15
argument based React Component Loader
var moduleName = window.location.search.split("?m=")[1];
if (window.reactComponents[moduleName] === undefined) {
alert("Error, There is no such component I found ," + moduleName);
} else {
var node = document.getElementById('content');
React.render(React.createElement(window.reactComponents[moduleName], null), node);
}