Skip to content

Instantly share code, notes, and snippets.

View jakub-g's full-sized avatar

jakub-g jakub-g

  • Antibes, France
  • 18:39 (UTC +01:00)
View GitHub Profile
@jakub-g
jakub-g / gist:dddd8f3cdd11efdfd65e
Created September 23, 2014 08:56
Run nodist-installed grunt in node debug mode
View gist:dddd8f3cdd11efdfd65e
node --debug-brk /d/bin/nodist/bin/node_modules/grunt-cli/bin/grunt
@jakub-g
jakub-g / InstantTemplate.tpl
Last active August 29, 2015 14:07
Aria Templates common mistakes: not using $json.setValue
View InstantTemplate.tpl
{macro main()}
<button {on click "updateModelBad" /}>Update counter</button>
<button {on click "updateModelBetter" /}>Update counter (better)</button>
<br>
Counter has value of: {@aria:Text {
text : this.data.counter,
bind : {
text : {
inside: this.data,
@jakub-g
jakub-g / InstantTemplate.tpl
Last active August 29, 2015 14:07
AT: deprecated widgets used as containers Usage of most of the widgets as "containers" (i.e. {widget}{/widget}) was deprecated. You should switch to the self-closing syntax, i.e. {widget /}
View InstantTemplate.tpl
{var counter = 0 /}
{macro main()}
{call tooltipDefinitions() /}
{call writeLinks() /}
{set counter = counter + 1 /} <br>
The main macro was executed ${counter} times.
{/macro}
@jakub-g
jakub-g / InstantTemplate.tpl
Last active August 29, 2015 14:07
AT: misusing setValue
View InstantTemplate.tpl
{macro main()}
<button {on click "updateModelBad" /}>Update (bad)</button>
<button {on click "updateModelStillBad" /}>Update (even worse)</button>
<button {on click "updateModelBetter" /}>Update (best)</button>
<br>
Magic value is: {@aria:Text {
bind : {
text : {
inside: this.data.myContainer,
@jakub-g
jakub-g / InstantTemplate.tpl
Last active August 29, 2015 14:07
AT: confusing strings and identifiers 1
View InstantTemplate.tpl
{macro main()}
magicValue: {@aria:Text {
bind : {
text : {
inside: this.data,
to: magicValue
}
}
}/}
{/macro}
@jakub-g
jakub-g / InstantTemplate.tpl
Last active August 29, 2015 14:07
AT: Replacing object in data model
View InstantTemplate.tpl
{macro main()}
<button {on click "updateModel" /}>Update</button>
<br>
{section {
macro: "printText",
bindRefreshTo : [{
inside: this.data,
to: 'myContainer'
}]
@jakub-g
jakub-g / execSync.js
Created October 19, 2015 13:55
NodeJS synchronous exec: printing output to console vs returning output from function
View execSync.js
function execSyncPrintOutput(command, env) {
env = env || process.env;
try {
return require('child_process').execSync((command), {
stdio: 'inherit',
env: env
});
} catch (e) {
__handleExecFailure(command);
@jakub-g
jakub-g / localStorageWrapper.js
Last active November 25, 2015 16:57
localStorageWrapper that silently fails (reports error to console) on write fail. This is one of the options to tackle Safari's zero quota of localStorage when in private mode.
View localStorageWrapper.js
/**
* A constructor for a wrapper class implementing the localStorage public interface
* (getItem, setItem, removeItem, key, clear) and some of our extensions
* (getObject, setObject, removeObject, getObjectEvenIfNull).
*
* The idea is to create global `localStorageWrapper` and `sessionStorageWrapper` variables,
* to be used instead of `localStorage` and `sessionStorage` (see below).
* This is because in Safari on iOS in private mode, localStorage has a quota of 0
* and always throws an exception when trying to save anything.