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 / Initial CSS resources list.md
Last active August 29, 2015 13:57
A list of handy CSS resources.

JLo's CSS Resource List

Or "Everything you know about CSS is wrong."

First thing to learn: classitis is bollocks! Giving elements multiple class names makes coding a lot easier!

Websites

Although a better description is on Smashing Magazine and Vanseo Design.

@james-jlo-long
james-jlo-long / javascript resource list.md
Last active August 29, 2015 13:57
A brief list of JavaScript resources

JLo's JavaScript Resource List

Or "Everything you know about JavaScript is wrong."

Managing jQuery Validate

jQuery Validate massively simplifies form validation. It's very extensible and will handle almost every situtation in which you can find yourself. But, if you're not careful, it can become an horrific plugin on a large site.

Without thinking, the errorPlacement function can end up looking like this:

@james-jlo-long
james-jlo-long / grid.less
Created March 12, 2014 12:48
Liquid grid in LESS
* {
&,
&:after,
&:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
@james-jlo-long
james-jlo-long / outline.md
Last active November 14, 2016 21:17
Your CSS Sucks

Your CSS sucks

Contents

  • Styles aren't modular
  • Confused content and container
  • Not re-using styles
  • Changing too much
  • No naming convention
<?php
class Foo {
public function __construct($name) {
$this->name = $name;
}
@james-jlo-long
james-jlo-long / grid.less
Created August 24, 2015 10:45
It can be handy to have a grid layout for very small devided (< 480). This snippit adds "xxs" columns to Bootstrap 3 which solve that purpose
// Generate the extra-extra small columns
// These go from a screen width of 0 to (@screen-xs-min - 1), existing below XS.
.make-xxs-column(@columns; @gutter: @grid-gutter-width) {
min-height: 1px;
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
position: relative;
@james-jlo-long
james-jlo-long / dom.js
Created October 1, 2015 15:16
Just enough of a framework to get DOM nodes common ancestors - based on https://gist.github.com/benpickles/4059636
var dom = (function () {
'use strict';
var dom = {};
function isElement(element) {
return element instanceof HTMLElement;
}
@james-jlo-long
james-jlo-long / array-first-last.js
Last active October 8, 2015 09:31
Douglas Crockford mentioned that when JavaScript has proper tail calls, he'll stop using while. This gist is me going through some of my old functions to see how to remove while. This is mainly me thinking aloud, but feel free to comment any changes or suggestions.
// Array first and last
//
// var array = [1, 'two', 3, 'four', 5];
// function isString(o) {
// return typeof o === 'string';
// }
// util.Array.first(array); // -> 1
// util.Array.first(array, isString); // -> 'two'
// util.Array.last(array); // -> 5
// util.Array.last(array, isString); // -> 'four'
@james-jlo-long
james-jlo-long / Query.js
Last active January 10, 2017 17:37
A manager for URL query strings
/*
TODO: Allow Query#parseString to correctly parse square brackets.
TODO: Handle nested objects correctly.
*/
var Query = (function () {
"use strict";
var hasOwn = Object.prototype.hasOwnProperty;
@james-jlo-long
james-jlo-long / PW.js
Last active March 22, 2017 10:27
A couple of functions to generate simple passwords. Beware that this is based on Math.random() - it is not cryptographically secure
var PW = (function () {
"use strict";
var sym = "!£$%^&*()-_=+[{]};:@#~,<.>/?\\|";
var getRand = (n) => Math.floor(Math.random() * n);
var basic = () => (
btoa(getRand(Date.now()))
.replace(/=+$/, "")