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' | |
// app/readlineCalc.js | |
const readline = require('readline') | |
// const calc = require('./calc') | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}) |
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
Vue.component('desktop-notificator', { | |
props: ['message', 'title'], | |
template: '<button v-on:click="notify()">??</button>', | |
methods: { | |
notify: function() { | |
if (Notification.permission !== "granted") { | |
Notification.requestPermission(); | |
} else { | |
new Notification(this.title, { | |
body: this.message, |
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 fs = require('fs') | |
var path = require('path') | |
fs.readdir(process.argv[2], function (err, list) { | |
list.forEach(function (file) { | |
if (path.extname(file) === '.' + process.argv[3]) | |
console.log(file) | |
}) | |
}) |
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
# Process I/O files synchronously in node.js | |
var fs = require('fs') | |
var contents = fs.readFileSync(process.argv[2]) | |
var lines = contents.toString().split('\n').length - 1 | |
console.log(lines) | |
// note you can avoid the .toString() by passing 'utf8' as the | |
// second argument to readFileSync, then you'll get a String! |
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
<html> | |
<head> | |
<title>Information Gathered</title> | |
</head> | |
<body> | |
<!-- | |
You embed PHP code between tags |
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 factorialize(num) { | |
factorialArr = []; | |
if (num === 0) { | |
factorialArr = [1]; | |
} else { | |
for (i = 1; i < num + 1; i++) { | |
factorialArr.push(i); | |
} | |
} |
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 isIsogram(str){ | |
//..... | |
if (str === null) { | |
return false; | |
} else { | |
var strInput = str.toLowerCase(); | |
var repeatedChr = (/([a-zA-Z]).*?\1/).test(strInput); | |
return !repeatedChr; | |
} | |
} |
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 alphabetPosition(text) { | |
var textWithoutSymbols = text.replace(/[^\w]|_|\d/g, "").toLowerCase(); | |
var objAlphabet = {"a" : 1, "b" : 2, "c" : 3, "d" : 4, "e" : 5, "f" : 6, "g" : 7, "h" : 8, "i" : 9, "j" : 10, "k" : 11, "l" : 12, "m" : 13, "n" : 14, "o" : 15, "p" : 16, "q" : 17, "r" : 18, "s" : 19, "t" : 20, "u" : 21, "v" : 22, "w" : 23, "x" : 24, "y" : 25, "z" : 26} | |
var alphaNumericCypher = textWithoutSymbols.split("").map(function (a) { | |
for(var key in objAlphabet) { | |
if(objAlphabet.hasOwnProperty(key)) { | |
if (key === a) return objAlphabet[key]; | |
} |
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 isPrime(num) { | |
var absNum = Math.abs(num); | |
if (absNum <= 1) { | |
return false; | |
} else if (absNum <= 3) { | |
return true; | |
} else if (absNum % 2 === 0 || absNum % 3 === 0) { | |
return false; | |
} |
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
/* Excellent piece of code to determine the index of a particular | |
element being searched.*/ | |
var indices = []; | |
var element = 0; | |
var idx = arrNum.indexOf(element); | |
// console.log(idx); | |
while (idx != -1) { | |
indices.push(idx); | |
idx = arrNum.indexOf(element, idx + 1); |
NewerOlder