Skip to content

Instantly share code, notes, and snippets.

View feynon's full-sized avatar
🧑‍🍳
cook and let cook

Ankesh Bharti feynon

🧑‍🍳
cook and let cook
View GitHub Profile
For teh first
function wisePerson(wiseType, whatToSay) {
return `A wise ${wiseType} once said: "${whatToSay}".`;
}
FOr the second
function shouter(whatToShout) {
return `${whatToShout.toUpperCase()}!!!`;
https://repl.it/@AnkeshBharti/CanineEnormousBinarytree
function createMyObject() {
return {
foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function() {
return 'hello';
},
};
@feynon
feynon / arrowNotationUse.js
Created December 29, 2018 16:55
Just a basic conversion of a normal function to arrow under a special circumstance.
//This code snippet
function createMyObject() {
return {
foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function() {
return 'hello';
},
@feynon
feynon / recognizingText.js
Created January 11, 2019 11:39
Recognizing Text
function countBy(items, groupName) {
let counts = [];
for (let item of items) {
let name = groupName(item);
let known = counts.findIndex(c => c.name == name);
if (known == -1) {
counts.push({name, count: 1});
} else {
counts[known].count++;
}
@feynon
feynon / iterator.js
Last active January 23, 2019 19:15
THE ITERATOR INTERFACE FROM EJS
class Matrix {
constructor(width, height, element = (x, y) => undefined) {
this.width = width;
this.height = height;
this.content = [];
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
this.content[y * width + x] = element(x, y);
const roads = [
"Alice's House-Bob's House", "Alice's House-Cabin",
"Alice's House-Post Office", "Bob's House-Town Hall",
"Daria's House-Ernie's House", "Daria's House-Town Hall",
"Ernie's House-Grete's House", "Grete's House-Farm",
"Grete's House-Shop", "Marketplace-Farm",
"Marketplace-Post Office", "Marketplace-Shop",
"Marketplace-Town Hall", "Shop-Town Hall"
];
const roads = [
"Alice's House-Bob's House", "Alice's House-Cabin",
"Alice's House-Post Office", "Bob's House-Town Hall",
"Daria's House-Ernie's House", "Daria's House-Town Hall",
"Ernie's House-Grete's House", "Grete's House-Farm",
"Grete's House-Shop", "Marketplace-Farm",
"Marketplace-Post Office", "Marketplace-Shop",
"Marketplace-Town Hall", "Shop-Town Hall"
];
function parseINI(string) {
// Start with an object to hold the top-level fields
let result = {};
let section = result;
string.split(/\r?\n/).forEach(line => {
let match;
if (match = line.match(/^(\w+)=(.*)$/)) {
section[match[1]] = match[2];
} else if (match = line.match(/^\[(.*)\]$/)) {
section = result[match[1]] = {};
body footer nav::after {
content: " by Ankesh Bharti";
color: var(--accent-color);
font-size: 1em;
}
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&display=swap&subset=latin-ext');
:root {
--accent-color: #0000ff;