Skip to content

Instantly share code, notes, and snippets.

View asselin's full-sized avatar

Andre Asselin asselin

View GitHub Profile
@asselin
asselin / example.html
Created May 21, 2012 15:25
Handlebars block helper to extend if to support generic Javascript logical expressions
{{#jsif "astring=='abc'"}}
Is true
{{else}}
Is false
{{/jsif}}
@asselin
asselin / doc.html
Created May 21, 2012 15:32
Handlebars helper for generic Javascript expressions
This helper allows you to use generic javascript expressions in a handlebars template. It can be used to call Javascript functions on a value or do data structure access that Handlebars doesn't support (e.g. accessing an element of an array).
@asselin
asselin / dialog.html
Created August 1, 2012 02:01
"Popup Dialog" styling of a div
<div style="position: fixed; background-color: green; top: 5%; bottom: 5%; left: 5%; right: 5%;">
<div style="position: absolute; bottom: 0px; color: white;">
Hi
</div>
</div>
@asselin
asselin / callback.js
Created April 23, 2014 02:01
promises
function getData(callback) {
var result = {};
getJSONAsync('/users',
function(data) {
result.users = data;
getJSONAsync('/companies',
function(data) {
result.companies = data;
getJSONAsync('/contacts',
@asselin
asselin / compile.js
Last active March 3, 2016 15:16
Code for 'Client Side Swagger Support for AngularJS' http://www.pointsource.com/blog/client-side-swagger-support-for-angularjs
var SwaggerParser = require('swagger-parser');
var fs = require('fs');
var CodeGen = require('swagger-js-codegen').CodeGen;
SwaggerParser.validate('uber-v1.yaml').then(
function(api) {
var angularjsSourceCode = CodeGen.getAngularCode({
className: 'UberV1',
swagger: api
});
@asselin
asselin / OpenWithSublimeText3.bat
Last active November 30, 2016 21:24 — forked from roundand/OpenWithSublimeText3.bat
Open folders with Sublime Text 3 from windows explorer context menu (tested in Windows 10)
@echo off
FOR /F "tokens=* USEBACKQ" %%F IN (`where sublime_text`) DO (
SET st3Path=%%F
)
ECHO %st3Path%
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@asselin
asselin / component.js
Last active February 9, 2017 20:58
Dynamically extending a Vue Object
import Vue from 'Vue';
beforeCreate () {
this.$options = Vue.util.mergeOptions({
data: function() {
return {
selectedItem: 8
}
},
computed: {
@asselin
asselin / example1.html
Last active March 24, 2017 20:26
Code snippets for "Tech note: Using VueJS events together with v-model"
<template>
<label role="radio" tabindex="0">
<input type="radio" v-on:something="clicked" name="r1" value="One" v-model="picked">
<span>One</span>
</label>
<label role="radio" tabindex="0">
<input type="radio" v-on:something="clicked" name="r1" value="Two" v-model="picked">
<span>Two</span>
</label>
@asselin
asselin / solution.html
Last active March 24, 2017 20:26
Code snippets for "Tech note: Using VueJS events together with v-model"
<template>
<label role="radio" tabindex="0">
<input type="radio" v-on:change="clicked" name="r1" value="One" v-model="picked">
<span>One</span>
</label>
<label role="radio" tabindex="0">
<input type="radio" v-on:change="clicked" name="r1" value="Two" v-model="picked">
<span>Two</span>
</label>
@asselin
asselin / back.js
Created October 5, 2018 16:46
How to detect browser back button
window.addEventListener("popstate", function(args) {console.log("pop ", args);}, false);