Skip to content

Instantly share code, notes, and snippets.

@sayrer
sayrer / Makefile
Created July 4, 2011 00:17
Start of a Makefile for PDF.js
REPO = git@github.com:andreasgal/pdf.js.git
BUILD_DIR := build
DEFAULT_BROWSERS := test/resources/browser_manifests/browser_manifest.json
DEFAULT_TESTS := test/test_manifest.json
# JS files needed for pdf.js.
# This list doesn't account for the 'worker' directory.
PDF_JS_FILES = \
pdf.js \
crypto.js \
@sayrer
sayrer / twitter-text-init.diff
Created July 16, 2011 19:15
don't create regexes during pageload
diff --git a/twitter-text.js b/twitter-text.js
index 0741aa2..adc2388 100644
--- a/twitter-text.js
+++ b/twitter-text.js
@@ -5,6 +5,7 @@ if (!window.twttr) {
(function() {
twttr.txt = {};
twttr.txt.regexen = {};
+ twttr.txt.initialized = false;
// Option 4
function mkAttrs() {
if (condition) {
return a;
}
return b;
}
function() {
@sayrer
sayrer / gist:1504888
Created December 21, 2011 06:21 — forked from anonymous/gist:1484531
Rendering
// require hogan
var hogan = require("hogan.js");
// compile template
var template = hogan.compile("@{{name}}");
var team = ['dhg', 'fat', 'jimio', 'nickgreen', 'sayrer'];
team.map(function (twitterer) {
@sayrer
sayrer / precompile.1.0.1.js
Created December 24, 2011 19:52
Hogan precompiled
var Hogan = require('./lib/hogan');
var templates = {
test: 'Hello {{name}}!',
test2: 'Lorem ipsum dolor sit amet, {{foo}}consectetur adipisicing elit, sed do eiusmod tempor {{bar}}.',
test3: '<html><body>incididunt ut labore et dolore magna aliqua.{{baz}} Ut enim ad minim veniam, quis nostrud.</body></html>'
};
var compiled = [];
/* where foo and bar are passed through structured-clone */
/* begin null_environment + spawn */
function example(const foo, const bar) {
const baz = foo + bar;
spawn(function () { return baz + 1 });
}
/* end null_environment + spawn */
Baz.js
--------------
goog.require('goog.array');
function Baz() {}
Baz.prototype = {
baz: function() {
return goog.array.last(['asdf','asd','baz']);
},
bar: function () {
return 4 + 4;
(function (window) {
'use strict';
//
// Detect full support
//
var isSupported = (
'CustomEvent' in window &&
// in Safari, typeof CustomEvent == 'object' but it works
(typeof window.CustomEvent === 'function' ||
/**
* Records information for later handling of events. This type is
* shared, and instances of it are passed, between the eventcontract
* and the dispatcher jsbinary. Therefore, the fields of this type are
* referenced by string literals rather than property literals
* throughout the code.
*
* 'targetElement' is the element the action occured on, 'actionElement'
* is the element that has the jsaction handler.
~ $ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo():
@property
def bar(self):
return "42"
>>> "The magic number is {foo.bar}".format(foo=Foo())
'The magic number is 42'