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 isAm = (s = '', regex = /am/) => regex.test(s.toLowerCase()) | |
const getHead = (s = '') => s.split(':')[0] | |
const getTail = (s = '') => s.slice(2, 8) | |
const convertToNum = (s = '') => parseInt(s) | |
const convertedNum = (s = '') => convertToNum(getHead(s)) | |
const calcAm = (s = '') => | |
convertedNum(s) === 12 | |
? (convertedNum(s) - 12).toString() + 0 | |
: convertedNum(s) < 10 | |
? '0' + convertedNum(s) |
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 { all, either, is, isEmpty, isNil, pipe, values,when } from 'ramda' | |
const isNilOrEmpty = either(isNil, isEmpty) | |
const areAllNilOrEmpty = pipe( | |
when(is(Object), values), | |
all(isNilOrEmpty), | |
) | |
describe('nilOrEmptyCheck util contains two utils, returns boolean (true or 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
import React, { Component } from "react"; | |
import { sleep } from "../helpers/sleep"; | |
export class Location extends Component { | |
// Always set initial states, here we have 2 booleans we are expecting and checking / updating against. | |
// This allows for easy checks in the render() method and for us to know what we are expecting to get as values. | |
state = { | |
show: false, | |
loading: true | |
}; |
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, { Component } from "react"; | |
// import our child component Location | |
import Location from "./Location"; | |
// import our mock data that we will be using as an example | |
import { MockData } from "../mock-data/MockData"; | |
// our ulitiy function to help simulate some network latency | |
import { sleep } from "../helpers/sleep"; | |
class LocationList extends Component { | |
// Always set initial state, either empty [] for array, {} for objects, and so on. |
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
// This is my es6 re-write of the fiddle below. | |
// http://jsfiddle.net/cferdinandi/nb40j6rf/6/?mc_cid=1d481e891a&mc_eid=a3f6fd745a | |
// still a working progress but here is a live example: | |
// https://repl.it/@iamwill123/Creating-components-with-es6-vanilla-javascript-Reactive-UI | |
/** | |
* A vanilla JS helper for creating state-based components | |
* @param {String|Node} elem The element to make into a component | |
* @param {Object} options The component options | |
*/ |
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
// create a stop watch | |
function makeStopWatch() { | |
var seconds = 0; | |
var intervalID; | |
function tickTock() { | |
console.log(seconds); | |
return seconds++; | |
} |
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
if (5 + 5 == 10) | |
puts "this is true" | |
else | |
puts "this is false" | |
end |