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 / 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 / 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 / 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 / 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 / customElement.js
Created July 29, 2016 10:28
Exploring Custom Elements using the RMP.
var MyElement = new function MyElement() {
var obj = Object.create(HTMLElement.prototype);
var self = {
createdCallback: function createdCallback() {
console.log('createdCallback', this);
},
attachedCallback: function attachedCallback() {
console.log('attachedCallback', this);
},
@evolutionxbox
evolutionxbox / document.cookies.js
Last active June 7, 2016 16:29
document.cookies returns an object containing key value pairs of all the document's cookies.
// document.cookies
// getter property accessor
// returns Object
//
// Examples:
// var cookies = document.cookies;
// var mycookie = document.cookies.mycookie;
if (typeof Document.prototype.cookies == 'undefined') {
Object.defineProperty(Document.prototype, "cookies", {
@evolutionxbox
evolutionxbox / fontLoaded.js
Created May 20, 2016 16:45
Font Loaded fires an event when "FontAwesome" has been loaded.
// Font Loaded
(function fontLoaded() {
var retries = 300;
function checkReady() {
var canvas,
context;
retries -= 1;
canvas = document.createElement('canvas');
canvas.width = 20;
@evolutionxbox
evolutionxbox / object-composition.html
Created May 10, 2016 11:21
Object Compositional using Closures
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Object Composition</title>
</head>
<body>
<h1>
<a class="first" href="#">First</a>
<a class="second" href="#">Second</a>
@evolutionxbox
evolutionxbox / rgba-calc.js
Created May 3, 2016 10:04
Calculate the average alpha needed to get a foreground colour to be as close to a target colour, when used with transparency above a background colour.
var rgb = (function(red, blue, green) {
return {
red: red,
blue: blue,
green: green
};
});
var rgb1 = rgb(0, 0, 0); // colour to use
var rgb2 = rgb(255, 255, 255); // background colour
@evolutionxbox
evolutionxbox / counter-module.js
Created May 3, 2016 09:54
A simple counter object, which uses closures instead of "this".
var Counter = (function counter(i) {
increment = function increment() {
++i;
};
decrement = function decrement() {
--i;
};