This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node server instead of xampp ; | |
var http = require('http'); | |
var fs = require('fs'); | |
http.createServer(function (request, response) { | |
var filePath = '.' + request.url; | |
console.log(request.url); | |
fs.readFile(filePath, function(error, content) { | |
response.writeHead(200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var fs = require('fs'); | |
var bodyParser = require('body-parser'); | |
var app = express(); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(bodyParser.json()); | |
var events = JSON.parse(fs.readFileSync("data.json",'utf8')); | |
var counter = Object.keys(events).length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function outerFunction(){ | |
var someCount = 0; | |
return function innerFunction(){ | |
someCount++; | |
console.log("Called ",someCount," times"); | |
} | |
} | |
var counter = outerFunction(); | |
counter(); // "Called 1 times" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function myFunction (name, iceCreamFlavor) { | |
console.log(`${name} really likes ${iceCreamFlavor} ice cream.`) | |
} | |
const flavours = [ 'Banana', 'Lemon'] | |
const lovedFlavours = [ "Straciatella", ...flavours] // this is the same as .concat() | |
const args = ['Iulia', lovedFlavours ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class Student { | |
constructor({ firstName, lastName, age, interestLevel = 5 } = {}) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.age = age; | |
this.interestLevel = interestLevel; | |
} | |
get name(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateEmail(email) { | |
return /.+@.+/.test(email); | |
} | |
$("form").on("submit", function(event){ | |
var inputArray = $(this).find("input"); | |
var valid = true; | |
inputArray.each(function(index,input){ | |
if(input.attr("required") !== undefined && !input.val()){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcWhiteSpaces(limit) { | |
var whitespace = " "; | |
for ( var i= 0 ; i < limit ; i++){ | |
whitespace += " " | |
} | |
return whitespace; | |
} | |
function calcBranchWidth(limit) { | |
var draw = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.full-height | |
height: 100% | |
.inline-block | |
display: inline-block | |
.block | |
display: block | |
=uppercase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a demo task. | |
A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices, i.e. | |
A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1]. | |
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1. | |
For example, consider the following array A consisting of N = 8 elements: | |
A[0] = -1 | |
A[1] = 3 |
OlderNewer