This file contains hidden or 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 getObjectProperty = (obj, path, defaultValue="", returnUndefined=true) => { | |
const checkForDefaultValue = value => | |
value !== undefined ? value : undefined; | |
if (path === undefined) { | |
return obj; | |
} | |
try { | |
const value = path.split('.').reduce((o, i) => o[i], obj); | |
if (value === undefined && returnUndefined) return value; |
This file contains hidden or 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
// Returns an array of dates between the two dates | |
var getDates = function(startDate, endDate) { | |
var dates = [], | |
currentDate = startDate, | |
addDays = function(days) { | |
var date = new Date(this.valueOf()); | |
date.setDate(date.getDate() + days); | |
return date; | |
}; | |
while (currentDate <= endDate) { |
This file contains hidden or 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
[{ | |
"stateName": "Federal Capital Territory", | |
"lgas": ["Gwagwalada", "Kuje", "Abaji", "Abuja Municipal", "Bwari", "Kwali"] | |
}, { | |
"stateName": "Abia", | |
"lgas": ["Aba North", "Aba South", "Arochukwu", "Bende", "Ikwuano", "Isiala-Ngwa North", "Isiala-Ngwa South", "Isuikwato", "Obi Nwa", "Ohafia", "Osisioma", "Ngwa", "Ugwunagbo", "Ukwa East", "Ukwa West", "Umuahia North", "Umuahia South", "Umu-Neochi"] | |
}, { | |
"stateName": "Adamawa", | |
"lgas": ["Demsa", "Fufore", "Ganaye", "Gireri", "Gombi", "Guyuk", "Hong", "Jada", "Lamurde", "Madagali", "Maiha ", "Mayo-Belwa", "Michika", "Mubi North", "Mubi South", "Numan", "Shelleng", "Song", "Toungo", "Yola North", "Yola South"] | |
}, { |
This file contains hidden or 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
// Bonfire: Repeat a string repeat a string | |
// Author: @kenshinman | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20if(num%20%3E%200)%7B%0A%20%20%20%20str%20%3D%20str.repeat(num)%3B%0A%20%20%20%20return%20str%3B%0A%20%20%7Delse%20if(num%20%3C%200)%7B%0A%20%20%20%20str%20%3D%20%22%22%3B%0A%20%20%20%20return%20str%3B%0A%20%20%7D%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function repeat(str, num) { | |
// repeat after me | |
if(num > 0){ | |
str = str.repeat(num); | |
return str; |
This file contains hidden or 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
# Change YOUR_TOKEN to your prerender token | |
# Change example.com (server_name) to your website url | |
# Change /path/to/your/root to the correct value | |
server { | |
listen 80; | |
server_name example.com; | |
root /path/to/your/root; | |
index index.html; |
This file contains hidden or 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
// Returns an array of dates between the two dates | |
function getDates (startDate, endDate) { | |
const dates = [] | |
let currentDate = startDate | |
const addDays = function (days) { | |
const date = new Date(this.valueOf()) | |
date.setDate(date.getDate() + days) | |
return date | |
} | |
while (currentDate <= endDate) { |