Skip to content

Instantly share code, notes, and snippets.

@ryanand26
ryanand26 / styling-children-based-on-their-number.css
Created April 6, 2017 19:58
CSS styling based on number of items
/**
* 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 15:09
Calculate the SVG Path for an arc (of a circle)
//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))
};
@ryanand26
ryanand26 / gist:dce0033fa720428a504f
Created November 25, 2015 16:54
Reddit MobilePerf audit: Loading performance #247
Paul Irish : Performance audit of the new Reddit mobile site
Issue link : https://github.com/reddit/reddit-mobile/issues/247
# 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 July 30, 2015 08:08
Very basic template renderer
/**
* 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 09:46
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.
/**
* 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 August 29, 2015 14:19
Grunt - Express server definition
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 April 8, 2015 14:37
Replace text with lorem ipsum
/*!
* 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 August 29, 2015 14:18
Basic SSI Express server
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({