Skip to content

Instantly share code, notes, and snippets.

https://ao.com/lg
@Dobby89
Dobby89 / gulpfile.js
Created February 20, 2018 08:43
Temp backup of gulpfile changes when making lazyload
/* eslint-disable max-len, no-process-env */
/*
Project setup...
*/
const AO_FEA_GLOBALS_PATH = 'node_modules/ao-globals/'; // Change path to point at root globals
const PROJECT_NAME = 'pc-gaming-cat-pages'; // Change project name to your project name
const PROJECT_SERVER_PATH = '//media.ao.com/uk/qa/pc-gaming-cat-page/'; // Change project server path to your project path
/*
@Dobby89
Dobby89 / htmlToFragment.js
Created January 4, 2018 13:25
Create a DOM element from a string without having to append to a containing <div>
/**
* Create a DOM element from a string without
* having to append to a containing <div>
*
* @param {String} e.g. `<div><span>Hello World</span></div> Foo bar`
* @return {Element}
*/
export function htmlToFragment(htmlString) {
const fragment = document.createDocumentFragment();
const wrapper = document.createElement('div');
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
indent_style = tab
indent_size = tab
tab_width = 4
end_of_line = lf
charset = utf-8
@Dobby89
Dobby89 / htmlToElement.js
Last active January 16, 2018 08:41
Create a DOM element from a string
/**
* Create a DOM element from a string
*
* @param {String} e.g. `<div><span>Hello World</span></div>`
* @return {Element}
*/
export function htmlToElement(htmlString) {
const wrapper = document.createElement('div');
wrapper.innerHTML = htmlString;
document.body.appendChild(wrapper);
@Dobby89
Dobby89 / WithPrivates.js
Created August 16, 2017 16:06
Get and set private property in a javascript class
const PRIVATE_PROPERTY_1 = new Symbol();
class WithPrivates {
get prop1(){
return this[PRIVATE_PROPERTY_1];
}
set prop1(value){
if(typeof value == 'number'){
@Dobby89
Dobby89 / flattenArray.js
Created July 26, 2017 15:06
Flatten a multi-dimensional array in JavaScript
var arr = [1,2,3,4,[5,5,[1,1,1],6,7],[1,2,[2,3,[100,[23,45,11,[600,599]],101,99],4],3]];
function flattenArray(array) {
return array.reduce(function(accumulator, current) {
if (Array.isArray(current)) {
return accumulator.concat(flattenReduce(current));
} else {
return accumulator.concat(current);
}
}, []);
.ao-seo-tool {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
min-height: 100%;
font-family: Arial, sans-serif;
}
@Dobby89
Dobby89 / group_concat.sql
Created December 9, 2016 16:05
SQL Query with Concat and Group Concat
SELECT
p.product_id,
pd.name,
pd.description,
pd.title_tag AS meta_title,
pd.meta_keywords,
pd.meta_description,
CONCAT('http://www.domain.co.uk/', u.keyword) AS URL,
GROUP_CONCAT(pt.tag) AS tags,
p.status
@Dobby89
Dobby89 / Create a test file
Created December 1, 2016 16:18
Creates a 1Mb file called 1Mbfile.png in Windows Cmd
fsutil file createnew 1Mbfile.png 1000000