Skip to content

Instantly share code, notes, and snippets.

View paularmstrong's full-sized avatar
🐈‍⬛
Codes with cats

Paul Armstrong paularmstrong

🐈‍⬛
Codes with cats
View GitHub Profile
@paularmstrong
paularmstrong / foo.test.js
Last active March 29, 2018 03:00
Mocha test runner with Require.js
define(['modules/foo'], function (foo) {
describe('test foo', function () {
// ...
});
});
diff --git a/tests/variables.test.js b/tests/variables.test.js
index fc7cc70..162dc11 100644
--- a/tests/variables.test.js
+++ b/tests/variables.test.js
@@ -61,6 +61,9 @@ var cases = {
{ c: '{{ food.a }}', e: 'tacos' },
{ c: '{{ food["a"] }}', e: 'tacos' },
{ c: '{{ g[0][h.g.i]["c"].b[i] }}', e: 'hi!' },
+ ],
+ 'getters work just fine': [
{% block content %}{% endblock %}
<!doctype html>
<html>
<head>
<script src="swig.pack.min.js"></script>
</head>
<body>
<script>
var ctx = {
abcdefghijklmnopqrstuvwxyz: [
{ foo: 'bar' }
Benchmarking
Bigger is better
========================================
basic.html compile
----------------------------------------
swig@0.14.0 5714
Swig:Next 10240
----------------------------------------
Swig:Next is 1.79 times faster
@paularmstrong
paularmstrong / swignext.js
Last active December 20, 2015 10:19
Swig:Next benchmarking
function anonymous(_swig,_ctx,_filters,_,_fn) {
var _output = "";
_output += _filters["e"]((((typeof obj !== "undefined" && obj.hasOwnProperty("a")) ? ((typeof obj !== "undefined" && obj.hasOwnProperty("a")) ? obj.a : "") : ((typeof _ctx.obj !== "undefined" && _ctx.obj.hasOwnProperty("a")) ? _ctx.obj.a : ""))));
_output += "\n";
_output += _filters["e"]((((typeof obj !== "undefined") ? ((typeof obj !== "undefined") ? obj : "") : ((typeof _ctx.obj !== "undefined") ? _ctx.obj : ""))['b']));
_output += "\n";
return _output;
}
diff --git a/lib/lexer.js b/lib/lexer.js
index 155a137..21e7159 100644
--- a/lib/lexer.js
+++ b/lib/lexer.js
@@ -1,36 +1,12 @@
var _ = require('lodash');
-var TYPES = exports.types = {
- WHITESPACE: 0,
- STRING: 1,
@paularmstrong
paularmstrong / Midnight.dvtcolortheme
Created April 1, 2013 02:40
Xcode 4 Color theme modified
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Regular - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@paularmstrong
paularmstrong / git-line-count.js
Last active December 11, 2015 17:58
get the lines existing per user in a git repo
#!/usr/bin/env node
var child_process = require('child_process'),
users = {},
c = 0,
modes = ['100644', '100664', '100755'];
function blameFile(file, i) {
setTimeout(function () {
child_process.exec('git blame ' + file, function (error, stdout, stderr) {
if (document.hasOwnProperty('createTouch')) {
try {
var ignore = /:hover/;
Array.prototype.slice.call(document.styleSheets).forEach(function (sheet) {
Array.prototype.slice.call(sheet.cssRules).forEach(function (rule) {
if (rule.type === CSSRule.STYLE_RULE && ignore.test(rule.selectorText)) {
sheet.deleteRule(j);
}
});
});