Skip to content

Instantly share code, notes, and snippets.

👀
Trying my hardest

Jonathan Cousins evolutionxbox

View GitHub Profile
@evolutionxbox
evolutionxbox / Quick-FED-Interview-Questions.md
Last active Jan 29, 2018
Quick Front-end Interview Questions
View Quick-FED-Interview-Questions.md

General

  1. Describe three ways to test accessibility?
  2. How would you approach fixing browser-specific styling issues?
  3. In what ways can a websites loading performance be improved?

HTML

  1. Have you used different HTML templating languages before?
  2. Describe at least one way you check the accessibility of written HTML?

CSS

@evolutionxbox
evolutionxbox / classNameToSelector.js
Created Oct 26, 2017
Takes className(s) and converts it to a CSS string (although a little buggy)
View classNameToSelector.js
/**
* "foo bar baz", "bar foo moo" -> ".foo.bar.baz .bar.foo.moo"
* @param {String...} classString
* @return {String}
*/
module.exports = function classNameToSelector(classString) {
var selector = [];
for (var i = 0, len = arguments.length; i < len; i++) {
selector.push(_classNameToSelector(arguments[i]));
}
View simpleSerializeFormData.js
// Serialize form data
function serialize (form) {
return [...form.elements]
.filter(element => element.type !== 'radio' || element.checked)
.map(element => element.name + '=' + encodeURIComponent(element.value))
.join('&');
}
@evolutionxbox
evolutionxbox / generateUniqueID.js
Created Jun 13, 2017
Simple Unique ID Generator (well, not entirely unique...)
View generateUniqueID.js
function generateUniqueID() {
function chr4(){
return Math.random().toString(16).slice(-4);
}
return chr4() + chr4() +
'-' + chr4() +
'-' + chr4() +
'-' + chr4() +
'-' + chr4() + chr4() + chr4();
}
@evolutionxbox
evolutionxbox / Array.prototype.reject.js
Last active Apr 12, 2017
Like filter, but negated
View Array.prototype.reject.js
/*
# `Array.prototype.reject`
## Summary
Like `filter`, except negated.
**Example:**
```js
@evolutionxbox
evolutionxbox / loadstyles.js
Created Mar 23, 2017
Load those styles all async like!
View loadstyles.js
// TODO: convert into promise =)
// Load Style
function loadStyle(url, callback) {
if (!url || url === '') return;
var linkElement = document.createElement('link');
linkElement.href = url;
linkElement.setAttribute('rel', 'stylesheet');
@evolutionxbox
evolutionxbox / loadscripts.js
Last active Mar 23, 2017
Load those scripts all async like!
View loadscripts.js
// TODO: convert into promise =)
// Load Script
function loadScript(url, callback) {
if (!url || url === '') return;
var scriptElement = document.createElement('script');
scriptElement.src = url;
if(typeof callback === 'function') {
@evolutionxbox
evolutionxbox / roguetext-wrapper.js
Created Mar 23, 2017
Wrap those rogue text nodes (inside table-cells)!
View roguetext-wrapper.js
// Wrap all "rogue" textNodes in a paragraph
(function wrapAllRogueTextNodes () {
var allowedElements = [ 'A', 'B', 'BIG', 'I', 'SMALL', 'TT', 'ABBR', 'ACRONYM', 'CITE', 'DFN', 'EM', 'KBD', 'STRONG', 'TIME', 'BR', 'SUB', 'SUP' ];
function arrayFrom (arrayLike) {
return Array.prototype.slice.call(arrayLike);
}
function wrapInParagraph (nodes) {
if (nodes.length > 0) {
View outofhours-redirect.js
//---------------------------------------------------------------------
function dateObj(d) {
var parts = d.split(/:|\s/),
date = new Date();
if (parts.pop().toLowerCase() == 'pm') parts[0] = (+parts[0]) + 12;
date.setHours(+parts.shift());
date.setMinutes(+parts.shift());
return date;
}
@evolutionxbox
evolutionxbox / params.js
Created Mar 2, 2017
Get URL params (querystring), returns object
View params.js
// Get URL params (querystring)
if (!location.params) {
Object.defineProperty(location, 'params', {
enumerable: false,
get: function () {
var search = location.search;
var all = /(?:[?&;])(?:[^&;#]+)/g;
var pair = /[?&;]([^&;=#]+)=?([^&;#]*)/;
var results = {};
You can’t perform that action at this time.