Skip to content

Instantly share code, notes, and snippets.

View jakub-g's full-sized avatar

jakub-g jakub-g

  • Antibes, France
  • 12:40 (UTC +02:00)
View GitHub Profile
@jakub-g
jakub-g / gist:dddd8f3cdd11efdfd65e
Created September 23, 2014 08:56
Run nodist-installed grunt in node debug mode
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
{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 /}
{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
{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
{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
{macro main()}
<button {on click "updateModel" /}>Update</button>
<br>
{section {
macro: "printText",
bindRefreshTo : [{
inside: this.data,
to: 'myContainer'
}]
@jakub-g
jakub-g / windows-must-have-tools.md
Last active September 8, 2015 14:51
Windows tools
@jakub-g
jakub-g / execSync.js
Created October 19, 2015 13:55
NodeJS synchronous exec: printing output to console vs returning output from function
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.
/**
* 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.