Skip to content

Instantly share code, notes, and snippets.

@sanjay1909
sanjay1909 / npm without sudo
Created August 1, 2015 10:54
How to get ownership of the .npm directory
// Don’t ever use npm with sudo (eg: sudo npm install) except if you want to install a package.
// Problem is permissions issue in your our Home directory.
// reclaim ownership of the .npm directory.
sudo chown -R $(whoami) ~/.npm
// the write permission in node_modules directory:
sudo chown -R $(whoami) /usr/local/lib/node_modules
var reactComponent = React.createClass({
// The object returned by this method sets the initial value of this.state
getInitialState: function () {
return {};
},
// The object returned by this method sets the initial value of this.props
// If a complex object is returned, it is shared among all component instances
getDefaultProps: function () {
@sanjay1909
sanjay1909 / float.html
Last active August 29, 2015 14:21
Code snippet to explain how css float property works
<style>
.container {
height: 30px;
width: 340px;
padding: 2px 2px;
font-size: 12px;
}
.float {
float: left;
}
@sanjay1909
sanjay1909 / baiscHttpServer.js
Created April 16, 2015 14:11
Basic Hrrtp server, to load file for the request and server response time to get for an ajax call
var port = 8001;
var serverUrl = "127.0.0.1";
var http = require("http");
var path = require("path");
var fs = require("fs");
var url = require('url');
var responseStartTime;
console.log("Web server starting at " + serverUrl + ":" + port);
var extensions = {
@sanjay1909
sanjay1909 / ObjectUtils.js
Last active August 29, 2015 14:14
Object Comparison in Javascript ported from Apache Flex Actionscript code
// namespace - Utils
this.utils = this.utils || {};
/**
* This provides a set of useful static functions for Object Comparison.
* All Static functions are Ported from Apache Flex mx.utils.ObjectUtil - ActionScript Code
* @author sanjay1909
*/
(function(){
"use strict";
//constructor
<html>
<head>
<title>Scope Test</title>
<script>
function print(value, desc) {
var p = document.createElement("p");
p.className = function(value){if(value == true)
return "pass";
else if(value == false)
return "fail";