Skip to content

Instantly share code, notes, and snippets.

Ryan Mitchell ryanand26

Block or report user

Report or block ryanand26

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View styling-children-based-on-their-number.css
/**
* http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/
*/
/* one item */
li:first-child:nth-last-child(1) {
width: 100%;
}
/* two items */
@ryanand26
ryanand26 / describeArc.js
Created May 31, 2016
Calculate the SVG Path for an arc (of a circle)
View describeArc.js
//calculate the SVG Path for an arc
//src: http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle/18473154#18473154
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
View links
@ryanand26
ryanand26 / gist:dce0033fa720428a504f
Created Nov 25, 2015
Reddit MobilePerf audit: Loading performance #247
View gist:dce0033fa720428a504f
Paul Irish : Performance audit of the new Reddit mobile site
Issue link : https://github.com/reddit/reddit-mobile/issues/247
View checkFileForModifiedImports
# grunt-newer:
# Check for newer @import .less files example
# See: https://github.com/tschaub/grunt-newer/issues/29
newer: {
options: {
/**
* when changing a less file, we run an addional check on all the *.less files to see if they are @importing a modified *.less file, and if so we include it in the files which less task should execute.
*/
override: function(details, shouldIncludeCallback) {
@ryanand26
ryanand26 / noTache.js
Created Jul 30, 2015
Very basic template renderer
View noTache.js
/**
* Take a basic template and return a populated result
* Required until our use of mustache is greenlit
*/
var Renderer = function () {
var startPattern = '{{',
endPattern = '}}',
tagPattern = /\{\{([#,\/])([\w,.]*\}\})/, //matches all opening or closing list tags
instance = this;
@ryanand26
ryanand26 / d3.axis.ticks.js
Created May 19, 2015
D3.js: Generate the ticks for an axis without having to render them to the svg. Allows us to adapt the tickSize and tickPadding to these values before drawing rather than afterwards.
View d3.axis.ticks.js
/**
* Generate the tick values for a given axis
* Reference: https://github.com/mbostock/d3/blob/master/src/svg/axis.js
*/
function getAxisTicks(axis) {
var scale1 = axis.scale(),
tickArguments_ = axis.ticks(),
tickValues = axis.tickValues(),
ticks;
@ryanand26
ryanand26 / gist:a6306ae7327b9c926d6d
Last active Aug 29, 2015
Grunt - Express server definition
View gist:a6306ae7327b9c926d6d
module.exports = function(grunt) {
var path = require('path');
grunt.initConfig({
//...
express : {
options : {
port : 80,
hostname : '*',
server : path.resolve(__dirname, 'server.js')
@ryanand26
ryanand26 / looseLoremIpsum
Created Apr 8, 2015
Replace text with lorem ipsum
View looseLoremIpsum
/*!
* Loose Lorem Ipsum replacer
*/
(function(window, document, $, undefined) {
'use strict';
var loremIpsum = ["lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "sed", "do", "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua", "ut", "enim", "ad", "minim", "veniam", "quis", "nostrud", "exercitation", "ullamco", "laboris", "nisi", "aliquip", "ex", "ea", "commodo", "consequat", "duis", "aute", "irure", "in", "reprehenderit", "voluptate", "velit", "esse", "cillum", "eu", "fugiat", "nulla", "pariatur", "excepteur", "sint", "occaecat", "cupidatat", "non", "proident", "sunt", "culpa", "qui", "officia", "deserunt", "mollit", "anim", "id", "est", "laborum", "at", "vero", "eos", "et", "accusamus", "iusto", "odio", "dignissimos", "ducimus", "qui", "blanditiis", "praesentium", "voluptatum", "deleniti", "atque", "corrupti", "quos", "dolores", "quas", "molestias", "excepturi", "sint", "occaecati", "cupiditate", "non", "provident", "similique", "sunt", "in"
@ryanand26
ryanand26 / server.js
Last active Aug 29, 2015
Basic SSI Express server
View server.js
var express = require("express"),
serveIndex = require('serve-index'),
connectSSI = require('connect-ssi'),
app = module.exports = express();
// serve directory listings
app.use(serveIndex(__dirname, {'icons': true}));
//catch shtml files and parse them
app.use(connectSSI({
You can’t perform that action at this time.