Skip to content

Instantly share code, notes, and snippets.

/* Simple JavaScript Inheritance for ES 5.1 ( includes polyfill for IE < 9 )
* based on http://ejohn.org/blog/simple-javascript-inheritance/
* (inspired by base2 and Prototype)
* MIT Licensed.
*/
(function (global) {
"use strict";
if (!Object.create) {
Object.create = (function () {
@rmkane
rmkane / MooToolsTimer.md
Last active August 29, 2015 14:08
Timer and TimerTask written using the MooTools framework.

#MooTools Timer Example

Below is a code snippet that uses the Timer and TimerTask classes.

##Script

function print(id, value) {
    document.getElementById(id).innerHTML = value;
}
@rmkane
rmkane / README.md
Last active August 29, 2015 14:13
A URL parser written in JavaScript

URL Parser

The following module handles parsing a URL in JavaScript. If this script is run outside of a browser, where the DOM is inaccessible, a regular expression will be executed to parse the provided URL.

Demo

[@JSFiddle][1]

Examples

@rmkane
rmkane / Angular.md
Last active August 29, 2015 14:22
JSON-P

Angular

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="countryApp">
  <div ng-controller="CountryCtrl">
    <table>
@rmkane
rmkane / CollectionUtils.java
Created July 10, 2015 20:26
Java: Bresenham's algorithm
package com.stackoverflow.utils;
import java.util.List;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Collections2;
public class CollectionUtils {
public static <T> String mapJoin(List<T> list) {
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by Isaac Holmlund (isaacch@gmail.com) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="type" nillable="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="action"/>
<xs:enumeration value="action-attack"/>
<xs:enumeration value="action-duration"/>
<xs:enumeration value="action-reaction"/>
@rmkane
rmkane / README.md
Last active October 8, 2015 22:21
HandlebarsJS Template w/ Sort

HandlebarsJS Example using a table template with sorting.

@rmkane
rmkane / GradientGeneratorLib.js
Last active October 8, 2015 22:39
Gradient Generator
function decToHex(dec) {
return (function (hex) {
return hex.length == 1 ? "0" + hex : hex;
})(dec.toString(16));
}
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
if (result) {
return {
@rmkane
rmkane / README.md
Last active October 8, 2015 23:29
Dynamic Multi-Sort

A sorting helper to sort an array of objects using multiple sorting properties. Property scoping is supported.

Your sorters can be simple property strings, or sorter objects.

This gist can be viewed at bl.ocks.org. Alternatively, you can view this example over at JSFiddle.

@rmkane
rmkane / clock-face.svg
Last active October 9, 2015 15:17 — forked from mbostock/.block
Digital Clock
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.