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
{% 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);
}
});
});
@paularmstrong
paularmstrong / index.html
Last active December 10, 2015 04:48
Table vs Line-Height
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>table + line-height</title>
<style type="text/css">
* {
box-sizing: border-box;
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}