Skip to content

Instantly share code, notes, and snippets.

@greglockwood
greglockwood / index.html
Created December 11, 2012 05:32 — forked from bunkat/index.html
Swimlane Chart using d3.js
<html>
<head>
<title>Swimlane using d3.js</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script type="text/javascript" src="randomData.js"></script>
<style>
.chart {
shape-rendering: crispEdges;
}
@greglockwood
greglockwood / index.html
Last active December 17, 2015 22:29 — forked from orrery/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
// moment.js
// version : 1.6.0
// author : Tim Wood

The tick format provided by d3.time.scale is a multi-scale tick format, meaning that it formats times differently depending on the time. For example, the start of February is formatted as "February", while February second is formatted as "Feb 2". The format is implemented using an array of time formats, each with an associated filter. The first filter that returns true is used. (In the implementation below, the formats are processed in reverse order.) You can create your own custom multi-scale time format using the same technique with only a few lines of code.

@greglockwood
greglockwood / dabblet.css
Created July 12, 2013 04:49
Use the following CSS code if you want to use data attributes for inserting your icons
@font-face {
font-family: 'IcoMoon';
src: url('http://benfrain.com/downloads/IcoMoon.eot');
src: url('http://benfrain.com/downloads/IcoMoon.eot?#iefix') format('embedded-opentype'),
url('http://benfrain.com/downloads/IcoMoon.svg#IcoMoon') format('svg'),
url('http://benfrain.com/downloads/IcoMoon.woff') format('woff'),
url('http://benfrain.com/downloads/IcoMoon.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@greglockwood
greglockwood / dabblet.css
Created July 30, 2013 12:09
Quote demonstration
/**
* Quote demonstration
*/
html {
min-height: 100%;
}
body {
background-image: linear-gradient(yellow, orange);
@greglockwood
greglockwood / angular-grid.ts
Created June 15, 2015 08:41
Angular Grid Typescript Definitions
declare module ng.grid {
interface GridOptions<T> {
columnDefs?: ColumnDef<T>[]; // Array of Column Definitions..
groupHeaders?: boolean; // Whether to group the headers. Default is false.
headerHeight?: number; // Height, in pixels, of the header row. If not grouping headers, default is 25. If grouping headers, default is 50.
rowData?: T[]; // Data to be displayed as rows in the table
rowSelection?: string; // Type of row selection, set to either 'single' or 'multiple' to enable selection.
rowDeselection?: boolean; // Set to true or false (default is false). If true, then rows will be deselected if you hold down ctrl + click the row.
pinnedColumnCount?: number; // Number of columns to pin. Default is 0.
@greglockwood
greglockwood / debug-helpers.js
Created April 18, 2017 22:56
Debug Helper Functions Snippet
const print = (param, ...args) => {
console.log(param, ...args);
return param;
};
const traceFn = (fn, context) => function () {
console.trace(`${fn.name} called with arguments: `, arguments);
return fn.apply(context || this, arguments);
};
@greglockwood
greglockwood / .gitignore
Last active July 19, 2019 17:25
NoExtraProperties<T> generic type in TypeScript
node_modules
**/*.js
@greglockwood
greglockwood / no-extra-properties.ts
Last active August 6, 2023 21:18
NoExtraProperties<T> TypeScript type
/*********************************************************************************
Copyright (c) 2019, Greg Lockwood
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.