Skip to content

Instantly share code, notes, and snippets.

View jordangray's full-sized avatar
💭
I may be slow to respond.

Jordan Gray jordangray

💭
I may be slow to respond.
View GitHub Profile
@jordangray
jordangray / TypeUtil.js
Created February 25, 2015 00:32
A couple of useful utility functions for working with JS types.
;(function() {
var global = this;
// Get the default value for a named type (primitive name, 'function' or name of constructor).
function defaultValue(type) {
if (typeof type !== 'string') throw new TypeError('Type must be a string.');
@jordangray
jordangray / StringPluralisation.cs
Last active August 29, 2015 14:15
A handy utility for pluralising strings based on a numeric value, using standard English pluralisation rules by default.
public static class StringPluralisation
{
private static Regex ConsonantY = new Regex("([bcdfghj-np-tv-z]|qu)y$");
private static Regex Sibilant = new Regex("(s|z|sh|ch)$");
private enum PluralRule { Regular, Sibilant, ConsonantY }
private static PluralRule GetPluralRule(string noun)
{
if (Sibilant.IsMatch(noun)) return PluralRule.Sibilant;
<ul class="products">
<li>
<a href="https://www.flickr.com/photos/35754040@N04/6786442153" title="DIY Two-Tone Cardigan by Stacie, on Flickr"><img src="https://farm8.staticflickr.com/7155/6786442153_217066b93b_s.jpg" width="75" height="75" alt="DIY Two-Tone Cardigan"></a>
<div class="text_holder">
<h3>Product name</h3>
<p class="description">Short description below product name</p>
<p class="price">$29.99<em>Was: $59.99</em></p>
</div>
</li>
@jordangray
jordangray / dabblet.css
Created October 3, 2014 14:30
Warning folding
/* Warning folding */
.error {
background: #fcc;
border: 3px solid #c00;
border-radius: 5px;
margin: 1em 0;
padding: 10px;
position: relative;
width: 300px;
@jordangray
jordangray / dabblet.css
Last active August 29, 2015 14:07
Collapsing warnings
/* Collapsing warnings */
.error {
background: #fcc;
border: 3px solid #c00;
border-radius: 5px;
margin: 1em 0;
padding: 10px;
position: relative;
width: 300px;
@jordangray
jordangray / dabblet.css
Created October 2, 2014 12:44
Warning sign
/* Warning sign */
.icon-warning-sign {
position: relative;
}
.icon-warning-sign:before {
left:0;
content: "";
width: 0;
@jordangray
jordangray / dabblet.css
Created August 29, 2014 14:42
Untitled
.icon-warning-sign {
position: relative;
}
.icon-warning-sign:before {
left:0;
content: "";
width: 0;
height: 0;
border-style: solid;
@jordangray
jordangray / Parse URL
Created May 28, 2014 10:48
Very basic URL parsing with regular expressions and named capture groups.
Regex ParseUrl = new Regex(@"(?:^\w*:?//)? # Protocol
(?<domain> [\.\w]+) # Domain
(?::\d)? # Port
(?:/.*)? # Path",
RegexOptions.IgnoreCase |
RegexOptions.IgnorePatternWhitespace);
// Example usage
var domain = ParseUrl.Replace(url, @"${domain}");
@jordangray
jordangray / dabblet.css
Created March 21, 2014 09:02
SO #22531861: simple progress spinner (SVG version)
/**
* SO #22531861: simple progress spinner (SVG version)
* http://stackoverflow.com/questions/22531861/create-circular-round-process-bar-with-gradient
*/
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
@jordangray
jordangray / dabblet.css
Created March 21, 2014 01:06
SO #22531861: simple progress spinner (SVG version)
/**
* SO #22531861: simple progress spinner (SVG version)
* http://stackoverflow.com/questions/22531861/create-circular-round-process-bar-with-gradient
*/
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}