Skip to content

Instantly share code, notes, and snippets.

View iamwill123's full-sized avatar
💻
x.x

will.iam iamwill123

💻
x.x
View GitHub Profile
@iamwill123
iamwill123 / timeConversion12to24hrs.js
Last active July 3, 2021 15:52
converting 12 to 24 hours
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)
@iamwill123
iamwill123 / isReallyEmpty.test.js
Last active July 3, 2021 15:53
*WIP* isReallyEmpty - Ramda - enzyme / jest test
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)', () => {
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
};
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.
@iamwill123
iamwill123 / es6_reactive_ui.js
Last active October 5, 2022 22:23
Creating components w/ es6 vanilla javascript - Reactive UI
// 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
*/
@iamwill123
iamwill123 / StopWatch.js
Last active June 6, 2017 19:14
StopWatch created by iamwill123 - https://repl.it/I9AY/0
// create a stop watch
function makeStopWatch() {
var seconds = 0;
var intervalID;
function tickTock() {
console.log(seconds);
return seconds++;
}
@iamwill123
iamwill123 / program2.rb
Created April 11, 2016 19:59
3.2: Control Flow in Ruby
if (5 + 5 == 10)
puts "this is true"
else
puts "this is false"
end