Skip to content

Instantly share code, notes, and snippets.

@Angularjschile
Angularjschile / pivotDirective.js
Created February 26, 2015 13:17
pivotDirective
angular.module('pivotDirective')
.directive('pivot', ['localStorageService', function (localStorageService) {
return {
restrict: 'AE',
scope: {
data: '='
},
link: function (scope, elem, attr) {
var renderers = $.extend($.pivotUtilities.renderers );
@Hypercubed
Hypercubed / directive.js
Last active June 3, 2016 16:01
Use systemjs/plugin-text to import html directly to $routeProvider or $templateCache, works great with jspm bundle.
import somethingHTML from './something.html!text';
angular.module('myApp',[])
.directive('myDirective', function() {
return {
template: somethingHTML
}
});
@bterlson
bterlson / mod.js
Last active January 26, 2017 15:25
Module export forms have subtle differences
// exporter1.js
let foo = 1;
export { foo as default }; // exports the foo binding
foo = 2;
// exporter2.js
let foo = 1;
export default foo; // creates a new binding named *default* and initializes it to 1.
foo = 2; // assigns to the foo binding which is not exported
@shancarter
shancarter / .block
Last active November 28, 2019 02:01
Mister Nester
license: mit
height: 700
@thebinarypenguin
thebinarypenguin / DiceRoller.js
Created June 19, 2013 01:27
A dice roller library for javascript
/*
* A virtual dice roller that accepts standard dice notation
*
*
* Dice Notation
*
* [Num Dice] d <Num Sides> [Modifier]
*
*
* Num Dice - Number of dice to roll (optional)
@syntagmatic
syntagmatic / README.md
Last active August 9, 2020 18:50
Hypersolids
@shannonmoeller
shannonmoeller / multiline-regexp.js
Last active April 12, 2021 22:16
Multiline Regular Expressions using ES6 Template Strings
/**
* Inspired by XRegExp via 2ality
* http://www.2ality.com/2012/12/template-strings-xregexp.html
* http://xregexp.com/
*/
import test from 'ava';
export function rx(flags) {
const trailingComments = /\s+#.*$/gm;

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate

@shangaslammi
shangaslammi / concatenative.hs
Created February 17, 2012 06:01
Concatenative Programming in Haskell
{-# LANGUAGE TypeOperators, NoImplicitPrelude #-}
import qualified Data.List as L
import Control.Arrow
import Control.Monad
import Prelude (Bool, Int, Float, fst, snd, flip, ($), uncurry, Show(..), String, (.), otherwise, IO)
import qualified Prelude as P
data s :. a = !s :. !a
infixl 1 :.
@WebReflection
WebReflection / String.prototype.template.js
Last active August 17, 2022 04:04
ES6 Template like strings in ES3 compatible syntax.
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});