Skip to content

Instantly share code, notes, and snippets.

View james-jlo-long's full-sized avatar

James Long james-jlo-long

View GitHub Profile
@james-jlo-long
james-jlo-long / OSCAR.md
Last active May 31, 2017 13:20
I'm working on a very basic CSS methodology. I'm saving it here to make it easier to find and modify.

OSCAR

OSCAR stands for "Only Style Classes, AlRight?". It's a CSS methodology that is designed to be very simple and lead into other mentalities such as OOCSS, SMACSS or ITCSS. The idea is to take the most basic parts of the other methodologies and create some simple rules that can be quickly taught to a new-comer without weighing them down with complexities. This is the starting point for better CSS.

Two Simple Rules

1. Only add styles to class selectors

No IDs, no elements. Only classes. You can have up to 1 class, 1 pseudo-element and 1 state or pseudo-class.

@james-jlo-long
james-jlo-long / low-poly-es-flag.svg
Last active May 12, 2017 15:15
A version of the flag of Spain with very low detail. Designed with just enough detail for a small icon
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@james-jlo-long
james-jlo-long / con.js
Last active June 7, 2017 10:52
A version of console that can be used on mobile devices such as iPads and iPhones
/**
* @file A version of console that can be used on mobile devices.
* @author James "JLo" Long <[email protected]>
* @version 1.0.0
* @license MIT
*/
var con = (function () {
"use strict";
@james-jlo-long
james-jlo-long / add.js
Last active March 13, 2018 09:42
JavaScript translation
// This demo shows how to simply add some translations.
__.add({
"Hello": "Bonjour"
});
@james-jlo-long
james-jlo-long / validate.js
Last active October 2, 2017 15:30
A form validator that relies on HTML5 Form Validation
/**
* Validates the form. The validation relies on HTML5 Form Validation.
*
* @see https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation
* @alias validate
* @param {Element} form
* Form to validate.
* @param {Object} settings
* Settings for the form.
* @param {String} settings.highlightClass
@james-jlo-long
james-jlo-long / createElement.js
Last active January 17, 2019 10:14
A simple library for creating DOM elements.
/**
* A helper function for looping over all elements that match the given
* selector. This function returns the results of the function being called on
* all elements.
*
* @param {String} selector
* CSS selector to identify elements.
* @param {Function} handler
* Function to execute on all elements.
* @param {?} [context]
@james-jlo-long
james-jlo-long / .bashrc
Last active December 15, 2020 10:25
The abbreviations that I use for git. Place this file in "~" and be sure to grab the ".git-completion.bash" file
# Git bash completion
# https://gist.github.com/JuggoPop/10706934
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
__git_complete gch _git_checkout
__git_complete gf _git_fetch
__git_complete gp _git_push
__git_complete gm _git_merge
__git_complete gr _git_rebase
fi
@james-jlo-long
james-jlo-long / ARIA.js
Last active February 27, 2018 14:28
Thinking-aloud a simple WAI-ARIA library that doesn't rely on other frameworks so can work with any of them
// Interface
ARIA.normalise = function (attribute) {}; // memoise
ARIA.getById = document.getElementById.bind(document);
ARIA.identify = function (element, prefix = "", getById = ARIA.getById) {};
ARIA.set(element, {
hidden: true,
controls: document.querySelector(".element"),
labelledby: document.querySelectorAll(".reference"), // can have multiple references
@james-jlo-long
james-jlo-long / SemVer.js
Created March 1, 2018 11:50
Extremely basic Semantic Version comparison function.
function SemVer(version) {
var parsed = String(version).match(/^(\d+)\.(\d+)\.(\d+)$/) || [];
this.string = version;
this.version = [
Number(parsed[1]) || 0,
Number(parsed[2]) || 0,
Number(parsed[3]) || 0
];
@james-jlo-long
james-jlo-long / Using define.js
Last active May 25, 2018 13:01
A poor-man's require. A simple JavaScript module manager
// Creating a module
//
// Here's a simple module that is created. The function isn't executed until
// another module tries to use it and it's only executed once.
myNamespace.define("one", function () {
return 1;
});
// Here's a module that requires another module. This doesn't execute the