Skip to content

Instantly share code, notes, and snippets.

View evolutionxbox's full-sized avatar
👀
Trying my hardest

Jonathan Cousins evolutionxbox

👀
Trying my hardest
View GitHub Profile
@evolutionxbox
evolutionxbox / twitter-logo.html
Created September 21, 2016 13:44
Semantic Twitter Logo using CSS
<div class="twitter-logo">
<span class="head">Welcome to Twitter.</span>
<span class="beak-top">Find out what’s happening,</span>
<span class="beak-bottom">right now,</span>
<span class="wing-top">with the people</span>
<span class="wing-middle">and organizations</span>
<span class="wing-bottom">you care about.</span>
<span class="body">Logo remade by <a href="//jonweb.co.uk">Jonathan Cousins (@evolutionxbox)</a></span>
</div>
@evolutionxbox
evolutionxbox / str_reverse.js
Created October 11, 2016 10:19
String Reverse
if (!String.prototype.reverse) {
String.prototype.reverse = function reverse() {
if (typeof this !== 'string') {
this.split('').reverse().join('');
} else {
throw new ReferenceError(this);
}
}
}
@evolutionxbox
evolutionxbox / findUnicodeChars.js
Created October 20, 2016 13:28
Find Unicode Chars in String
// Returns array of objects containing the character it found, and it's hexidecimal string value.
function findUnicodeChars(str) {
var arr = str.split('');
return arr.filter(char => {
return (char.charCodeAt(0) > 255) && char;
}).map(char => {
return {
char: char,
code: char.charCodeAt(0).toString(16)
};
@evolutionxbox
evolutionxbox / Gemfile.lock
Created October 26, 2016 13:53
TW Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
colorator (1.1.0)
ffi (1.9.14)
foreman (0.78.0)
thor (~> 0.19.1)
forwardable-extended (2.6.0)
jekyll (3.2.1)
colorator (~> 1.0)
@evolutionxbox
evolutionxbox / params.js
Created March 2, 2017 16:27
Get URL params (querystring), returns object
// 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 = {};
@evolutionxbox
evolutionxbox / outofhours-redirect.js
Created March 8, 2017 10:36
Link Out-of-Hours Redirect
//---------------------------------------------------------------------
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 / roguetext-wrapper.js
Created March 23, 2017 11:09
Wrap those rogue text nodes (inside table-cells)!
// 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) {
@evolutionxbox
evolutionxbox / loadscripts.js
Last active March 23, 2017 11:27
Load those scripts all async like!
// 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 / loadstyles.js
Created March 23, 2017 11:29
Load those styles all async like!
// 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 / Array.prototype.reject.js
Last active April 12, 2017 12:28
Like filter, but negated
/*
# `Array.prototype.reject`
## Summary
Like `filter`, except negated.
**Example:**
```js