Skip to content

Instantly share code, notes, and snippets.

View MikeDigitize's full-sized avatar
👋
Howdy

Mike Chadwick MikeDigitize

👋
Howdy
View GitHub Profile
@MikeDigitize
MikeDigitize / Unique string permutations mathematical
Created January 22, 2019 17:40
Get all unique string permutations using non-mathematical recursion vs mathematical recursion
function getNumberOfPermutations(input) {
if (!input.length) {
return 0;
}
let { length } = input;
let dividend = getFactorial(length);
let divisor = 0
<span class="ball"></span>
<span class="ball"></span>
<span class="ball"></span>
<span class="ball"></span>
<span class="ball"></span>
.ball {
width: 20px;
height: 20px;
border-radius: 50%;
@MikeDigitize
MikeDigitize / CSS challenge
Created June 26, 2018 20:04
CSS challenge
<style>
.box {
display: flex;
align-items: center;
justify-content: center;
margin: auto;
}
.red {
width: 300px;
@MikeDigitize
MikeDigitize / Web Animation API challenge
Last active April 22, 2018 20:30
Web Animation challenge
// Write a wrapper around the Web Animations API
// takes a HTML element upon creation
// constructor exposes the HTML element, a `keyframe` array of keyframe objects and a `config` object
// the `keyframe` array has a minimum length of 2 (animation start and end), can't start an animation unless satisfied
// each object in the `keyframe` array has a CSS property and value with an optional `offset` property (between 0 - 1, for keyframe %)
// the config object specifies duration, easing and iterations
function makeIndex() {
return Math.random().toString(12).substring(2, 12);
}
function Awesome() {
Object.defineProperty(this, 'index', {
writable: false,
configurable: false,
value: makeIndex()
});
// choose an attribute style
const AwesomeComponent = ({ onAwesomeHappening }) => (
<div className={`${styles.awesomeHolder}`}>
<span
data-mode="awesome-mode"
data-tagging="awesome-btn-click"
className={`${styles.awesomeBtn}`}
onClick={ () => onAwesomeHappening('Awesome!') }>
Save
</span>
/* without making `counter` a global variable refactor callMe
so the recursion it's attempting works correctly
and it logs 'Finished' when complete
var callMe = function() {
const counter = 0;
if(counter == '10') {
console.log('Finished');
}
counter++;
/* Array.prototype.fill
Can only modify an array that has a length of at least 1
It changes ALL the values of an array to a single value.
Make a betterFill method that fills an empty array
And takes a first argument which is the length of the array
And a second which is the values to insert
The second should be either a single value or an array of values
/* Modify the below to create a new builder constructor pattern
Give Video a static property called `make` - an object - that creates the following API:
Video.make
.setSrc('/videos/video.mpeg')
.setTitle('AO Video')
.setLoop(true);
which returns a new instance of Video
/* Create a Stack constructor that
- creates an object that stores strings within a single string
- that has a way of delimiting strings
- has a push, pop, concat method that works exactly like their array counterparts
- has an indexesOf method that behaves just like Array.prototype.indexOf but will also find all indexes if more than one exist
- does your constructor initialise with a single string or an array of strings?
- does it have to be called as a constructor / class - could it just be an object / function?
*/