Skip to content

Instantly share code, notes, and snippets.

View nikkaroraa's full-sized avatar
👨‍💻
building!

nikhil nikkaroraa

👨‍💻
building!
View GitHub Profile
@nikkaroraa
nikkaroraa / hackCSI.txt
Created February 2, 2017 01:19
HackCSI'17 Rules
1. Each team has to come here to the stage, and the team members have to pick up 5 chits (in total).
This will be done for each and every team.
These 5 words are crucial for you.
Each team has to make some sense out of any 3 word combinations of the 5 words and build something by keeping in mind those 3 words.
For example, if someone got
Health, News, Alcohol, Fake, Meme
Then they have to choose any of the 3 word combinations and make sense out of them, like Health-News-Alcohol, Fake-Health-Meme......
1. Process exists in node shell but not in browser
Process gives access to the process of node shell
process.exit(0)
2. this in shell equals global object
this == global
window is an alias of global in browser
app.use(express.static(path.join(__dirname, 'b')));
Right, app.use() loads a function to be used as middleware. In this context, it loads the result of express.static(path.join(__dirname, 'public')).
The result of express.static(path.join(__dirname, 'public')) is a function (in JavaScript, functions may return functions), a function that express understands as a middleware (i.e. it has the following signature: function(request, response, next) {
express.static() is a function that takes a path, and returns a middleware that serves all files in that path to /. (If you wanted to prefix it with /public or whatever, you'd write app.use('/public', express.static(path.join(__dirname, 'public'))), where the first /public is the web path and the second is the filesystem path of the files being served).
For better clarity, the following:
Code @https://cb.lk/nodeintro
res.send("<html><b>hello</b></html>"); //html can be used with res.send() but not with res.write()
var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/public/'));
Understanding callback functions in Javascript
Callback functions are extremely important in Javascript. They’re pretty much everywhere.
If you’re coming from a background in functional programming, or you have experience in writing concurrent programs in other languages, you might not have any difficulty understanding why callback functions are used the way they are in Javascript programs, but I’ve talked to more than one programmer who found the concept very unintuitive.
Functions are objects
To understand callback functions you first have to understand regular functions. This might seen like a “duh” thing to say, but functions in Javascript are a bit different than (for example) methods in Java. Functions in Javascript are first-class, and are actually objects.
@nikkaroraa
nikkaroraa / classesES6.md
Last active July 10, 2017 20:02
es6ClassesnThis

ES6 Classes

Refer:

What's the difference between

var A = function () {

this.x = function () {

@nikkaroraa
nikkaroraa / childrenprops.md
Last active July 10, 2017 20:00
The significance of this.props.children

Some components don't know their children ahead of time. This is especially common for components like Sidebar or Dialog that represent generic "boxes".

We recommend that such components use the special children prop to pass children elements directly into their output:

function FancyBorder(props) {
  return (
    <div className={'FancyBorder FancyBorder-' + props.color}>
      {props.children}
    </div>

);

ctrl+shift+t -> Open sublime terminal.
ctrl+alt+t -> JS_Format
@nikkaroraa
nikkaroraa / dom-process.html
Created November 12, 2017 14:10
The DOM Process
<html>
<head>
<title>My title</title>
</head>
<body>
<a href="href">My link</a>
<h1>My header</h1>
</body>
</html>
@nikkaroraa
nikkaroraa / querySelector.html
Created November 13, 2017 18:26
querySelector
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<p id="paraId">First Paragraph</p>
</body>
<script>
//accessing the node with id="paraId"