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
fetch(new Request('https://api.github.com/users/timothyjellison')).then(response => { | |
return response.json(); | |
}).then(data => { | |
console.log(data); | |
}); |
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 templateTag = transformer => (strings, ...args) => { | |
if (args.length === 0) { | |
return strings.toString(); | |
} | |
const transformed = []; | |
strings.forEach((val, i) => { | |
transformed.push(val); | |
if (args[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
import React from 'react'; | |
import _ from 'lodash'; | |
class DebounceExample extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
on: 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
// An answer for this stackoverlow question: https://stackoverflow.com/questions/48831701/jest-how-to-mock-default-export-component-when-same-module-also-has-named-expor | |
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import App, { myUtilityFunction } from './App'; | |
jest.mock('./App'); | |
App.mockImplementation(() => { | |
return { |
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 csv = require('csvtojson'); | |
const YAML = require('json2yaml'); | |
const fs = require('fs'); | |
const _ = require('lodash'); | |
const camelcase = require('camelcase'); | |
const inp = process.argv[2]; | |
const otp = process.argv[3]; | |
const rawData = []; |
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
// all credit to stackoverflow user "Useless Code" | |
// see https://stackoverflow.com/questions/42998327/preloading-background-images | |
var myImages = ['https://www.nationalparks.org/sites/default/files/yosemite-merced.jpg']; | |
var banner = document.getElementById('banner'); | |
var spinner = document.getElementById('spinner'); | |
function loadImages (images) { | |
let loader = function (src) { | |
return new Promise(function (resolve, reject) { |
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 express = require('express'); | |
const bodyParser = require('body-parser'); | |
const {check, validationResult} = require('express-validator/check') | |
const {sanitize} = require('express-validator/filter'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({extended: false})); | |
app.post('*', [ | |
check('inputValue').isLength({max: 5}), |
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 rot13(encodedStr) { | |
var codeArr = encodedStr.split(""); // String to Array | |
var decodedArr = []; // Your Result goes here | |
// Only change code below this line | |
codeArr.forEach(function(letter){ | |
oldCode = letter.charCodeAt(0); | |
if (oldCode >= 65 && oldCode <= 90) { | |
newCode = oldCode + 13; | |
if (newCode > 90) { | |
newCode -= 26; |