Skip to content

Instantly share code, notes, and snippets.

@pstjvn
pstjvn / app.min.js
Created December 7, 2016 20:05
Web worker, raf and nexTick
function aa(a, b) {
function c() {
}
c.prototype = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
for (var d in b) {
if (Object.defineProperties) {
var e = Object.getOwnPropertyDescriptor(b, d);
e && Object.defineProperty(a, d, e);
@pstjvn
pstjvn / debug log
Last active November 3, 2016 11:49
[1:35:22 PM]: ==> {"id":"1","method":"server.setSubscriptions","params":{"subscriptions":["STATUS"]}}
[1:35:22 PM]: ==> {"id":"2","method":"analysis.setAnalysisRoots","params":{"included":["/home/pstj/Documents/Projects/dart/svg-animation"],"excluded":[]}}
[1:35:22 PM]: ==> {"id":"3","method":"analysis.updateContent","params":{"files":{"/home/pstj/Documents/Projects/dart/svg-animation/lib/svg_animation.dart":{"type":"add","content":"library svg_animation;\n\nimport 'dart:html' as html;\nimport 'dart:svg' show PathElement, SvgElement;\nimport 'dart:async';\n\n/// Helper class to store information about a path element in the SVG element.\n///\n/// The class handles nuances of the SVG displaying, for example some paths\n/// do not report correctly the length and cannot be ainmated or report length\n/// of 0 but resetting the dash offset is not hiding them, so we abstract that\n/// and hide it in this implementation.\nclass PathInfo {\n final PathElement element;\n final int length;\n bool _isVisible = true;\n
@pstjvn
pstjvn / env-brebuilt.sh
Last active November 28, 2016 14:04
Provides closure compatible environment but instead of compiling from source uses pre-built binaries
#!/bin/bash
# Allows the usage of prebuilt binaries to be used.
APPSDIR=apps/
SRCDIR=src/
LIBDIR=library/
GCCDIR=compiler/
SOYDIR=templates/
GSSDIR=stylesheets/
@pstjvn
pstjvn / l4.html
Last active March 17, 2016 18:14
Question for l4
<!DOCTYPE html>
<html>
<head>
<title>Test scenario.</title>
</head>
<body>
<script>
var jobs = [], jobn = 0, result = '', i = 1;
var body = "<script>top.result += '3'</scr" +
"ipt><body></body>";
@pstjvn
pstjvn / env.sh
Last active November 28, 2016 12:57
Sample script to bootstrap closure based development environment
#!/bin/bash
APPSDIR=apps/
SRCDIR=src/
LIBDIR=library/
GCCDIR=compiler/
SOYDIR=templates/
GSSDIR=stylesheets/
PSTJLIBDIR=pstj/
SMJSLIBDIR=smjs/
'use strict';
goog.provide('pstj.ds.autogen.IconParser');
goog.require('goog.array');
goog.require('pstj.ds.autogen.IconRenderer');
goog.require('pstj.ds.template');
goog.scope(function() {
var auto = pstj.ds.autogen;
@pstjvn
pstjvn / 32bit.txt
Created November 12, 2015 11:09
Compiler generated filelist
../../library/closure/goog/base.js
../../library/closure/goog/promise/resolver.js
../../library/closure/goog/promise/thenable.js
../../library/closure/goog/math/size.js
../../library/closure/goog/string/typedstring.js
../../library/closure/goog/string/stringbuffer.js
../../library/closure/goog/string/string.js
../../library/closure/goog/i18n/bidi.js
../../library/closure/goog/i18n/datetimesymbols.js
../../library/closure/goog/async/freelist.js
@pstjvn
pstjvn / element.js
Created October 30, 2015 15:49
Custom elements / es6
(function() {
'use strict';
/**
* Class in es6
* @constructor
* @extends {HTMLElement}
*/
wc.element.Test = class extends HTMLElement {
constructor() {
@pstjvn
pstjvn / mode.js
Created October 19, 2015 16:41
example of @template
goog.scope(function() {
var ngmodel = pstj.ds.ngmodel;
/**
* @define {number} Defins the maximum number of NG cache instances to be
* used in the application. Attempts touse more cache instances (i.e. more
* bound elements/roots) will result in error. When defining the limit take into
* account the fact that using large number might result in slower response
* times and overwhole application lags.
@pstjvn
pstjvn / README.md
Last active September 28, 2015 14:05
Control delegation pattern

Main idea: separate the business logic from the underlying dom structure and bind execution to structure separately.

Benefits:

  • changes to DOM structure can be logically separated and execute from business logic changes
  • business logic changes do not rely on DOM strcuture (stability of business logic)
  • binding can be executed in any technology or mix of technologies
  • tests can be implemented for important business logic more easily as it is not bound to DOM.