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
/* Ultra lightweight Github REST Client */ | |
const token = 'github-token-here' | |
const githubClient = generateAPI('https://api.github.com', { | |
headers: { | |
'User-Agent': 'xyz', | |
'Authorization': `bearer ${token}` | |
} | |
}) | |
async function getRepo() { |
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
string pangram = "The quick brown fox jumps over the lazy dog"; | |
string[] words = pangram.Split(' '); | |
foreach (string word in words) | |
{ | |
char[] chars = word.ToCharArray(); | |
Array.Reverse(chars); | |
string wordReversed = new string(chars); | |
Console.Write($"{wordReversed} "); | |
} |
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
const curry = | |
(fn) => | |
// Rest into an array | |
(...args) => | |
// If we have enough arguments, call the function | |
args.length >= fn.length | |
? // Spread array into arguments | |
fn(...args) | |
: curry( | |
/** |
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
const results = JSON.parse(data) | |
.map( | |
({ | |
"Transaction date": date, | |
Description: description, | |
Amount: amount, | |
}) => ({ | |
date, | |
description, | |
amount, |
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
const buildPipeline = | |
(...fns) => | |
(x) => | |
fns.reduce((accV, fxn) => fxn(accV), x); |
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
const { gql } = require('apollo-server'); | |
module.exports = gql` | |
type Post { | |
_id: ID! | |
body: String! | |
createdAt: String! | |
username: String! | |
comments: [Comment] | |
commentCount: Int! |
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
const converters = { | |
toCelsius(tempF) { | |
return ((tempF - 32) * 5) / 9; | |
}, | |
toFahrenheit(tempC) { | |
return ((tempC - 32) * 5) / 9; | |
}, | |
}; | |
function tryConvert(temperature, conversion) { |
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
// Loads a reusable Mongo client for the application. | |
import { MongoClient } from "mongodb"; | |
// TODO: Check that your path is correct if using a config file (which you should) | |
import config from "../../config.js"; | |
// TODO: Check that your config file is exporting out an object with properties used in the next line. | |
const client = new MongoClient(config.db.clientURL); | |
client |
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
const person = { | |
name: "Mark", | |
age: 35 | |
} | |
if (person.age >= 21) { | |
console.log(`${person.name} can have a drink of alcohol.`); | |
} else { | |
console.log(`${person.name} shsoud have a soda`); | |
} |
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
// Destructuring | |
const data = { | |
first_name: "John", | |
age: 30, | |
employer: { | |
company: "Google", | |
}, | |
}; | |
// Object destructuring with renaming |