Skip to content

Instantly share code, notes, and snippets.

@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});
@ryanburgess
ryanburgess / README.md
Last active October 19, 2015 09:58
Determines whether or not the given browser supports SVG

If SVG

Is a simple JavaScript module that determines whether or not the given browser supports SVG.

Install

npm install if-svg --save-dev
@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 );
@nbar1
nbar1 / socks.js
Created March 2, 2015 02:49
socks.js
function wash(socks) {
var socksYouHave = [];
var sockSizes = ['small', 'medium', 'large'];
socks.forEach(function(sock) {
// Weird socks never survive
if(sockSizes.indexOf(sock) === -1) return;
// One in ten socks never make it out alive
if(Math.floor(Math.random() * 10) === 0) return;
@pilwon
pilwon / code.js
Last active October 13, 2015 04:13
react-native DependencyResolver perf test (script & full result) https://github.com/facebook/react-native/issues/361#issuecomment-87829808
var path = require('path');
var async = require('async');
var mathjs = require('mathjs');
var ReactPackager = require('react-native/packager/react-packager');
var blacklist = require('react-native/packager/blacklist');
var reactNativePackage = require('react-native/package');
var NUM_TESTS = 100;
function test() {

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

@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
}
});
@zachlysobey
zachlysobey / ng-directive-inline-multi-line-template-string.es6.js
Last active March 3, 2016 11:17
Angular 1 Directive with ES6 Multi-line string template inline.
(function() {
'use strict';
angular
.module('myModule')
.directive('myDirective', myDirective);
const template = `
<div class="my-directive-template">
<h1>Using multi-line Strings for templates</h1>
@syntagmatic
syntagmatic / README.md
Last active August 9, 2020 18:50
Hypersolids
@Hypercubed
Hypercubed / .gitignore
Last active December 11, 2015 08:45
plotly-jspm
jspm_packages