Skip to content

Instantly share code, notes, and snippets.

@jbmoelker
jbmoelker / angular-attribute-if-directive.js
Last active August 29, 2015 13:57
attributeIf is an AngularJS directive which adds an HTML attribute if a given condition is satisfied. Should be used for boolean attributes which are not already supported by Angular's native BOOLEAN_ATTR directive: https://github.com/angular/angular.js/blob/8b395ff3/src/ng/directive/booleanAttrs.js#L331
angular
.module('directives.attributeIf', [])
.directive('attributeIf', [
/**
* @ngdoc directive
* @name directives.attributeIf:attributeIf
* @description
* Adds an HTML attribute if a given condition is satisfied. Should be used for boolean
* attributes which are not already supported by Angular's native BOOLEAN_ATTR directive:
* https://github.com/angular/angular.js/blob/8b395ff3/src/ng/directive/booleanAttrs.js#L331
@jbmoelker
jbmoelker / markdown-with-yaml-metadata.md
Created March 28, 2014 19:10
Example of wiki article at De Voorhoede in Markdown format enhanced with metadata in YAML format.
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 1 column 1
---
	title: Writing Wiki Articles
	description: How to properly author (structure & format) a wiki article.
	tags: [wiki, article, markdown, yaml, syntax, format]
	authors: 
		- Jasper Moelker
		- Someone Else
---

Writing Wiki Articles

@jbmoelker
jbmoelker / gulpfile.js
Created October 12, 2015 17:10
Watch and compile Sass with notifications on error; Serve generated files independently using BrowserSync;
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var gulp = require('gulp');
var gulpIf = require('gulp-if');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('build:css', buildCss);
@jbmoelker
jbmoelker / idLabsStaticSocialShare.class.php
Last active December 17, 2015 14:18
Instead of using javascript heavy widgets to provide an option to share a webpage via social media, consider using static links (urls) instead. These will work regardless of whether the user has javascript is enabled. They improve the load speed of your page and are less of a hit on the battery of your users' devices.This gist contains static ur…
<?php
/**
* @example
*
* $url = 'http://www.example.com/a-specific-page';
* $options = array(
* 'title' => 'A specific page',
* 'text' => 'short descriptive summary of the page',
* 'source' => 'Example.com',
* );
@jbmoelker
jbmoelker / grunt-prompt-builder.js
Last active January 3, 2016 00:39
The Grunt Task Wizard prompts user all available grunt tasks, and asks the user for optional arguments to run the task with. When prompt closes `task-wizard:run-task` is executed, which runs the selected task with the given arguments.This way users don't need to know tasks by heart, just type: `grunt task-wizard` to get started. To make it even …
var grunt = require('grunt');
/**
* Prompt, utility to configure and run grunt-prompt.
* @see https://github.com/dylang/grunt-prompt
*
* @example
* var prompt = require('prompt');
* prompt('create-component')
* .addQuestion({
@jbmoelker
jbmoelker / async-submit-form.ts
Created January 9, 2016 18:02
Submit an HTMLFormElement asynchronously and receive a Promise which resolves with the response data.
export default function asyncSubmitForm (form:HTMLFormElement): Promise<Response> {
return window.fetch(formRequest(form))
.then(checkStatus)
.then(response => response.json());
}
export function formRequest(form:HTMLFormElement): Request {
return new Request(form.action, {
method: form.method,
headers: {
@jbmoelker
jbmoelker / bootstrap.js
Last active January 15, 2016 19:22
requirejs-bootstrap-plugin
// Create shim for requested bootstrap component and require
// and return jQuery so you do not have to inject it separately
// every time you use a bootstrap component.
define({
load: function (name, req, onload, config) {
// Set this path to wherever the bootstrap components live.
// Contents should match https://github.com/twbs/bootstrap/tree/master/js
var component = 'path/to/bootstrap/js/'+name;
var shim = {};
@jbmoelker
jbmoelker / riotjs-style-guide.md
Last active March 9, 2016 15:56
[WIP] Opinionated RiotJS Style Guide

Note: These are just my personal notes. Rules which are formalised are moved to voorhoede/riotjs-style-guide

RiotJS Style Guide

Opinionated RiotJS Style Guide for teams by De Voorhoede.

Purpose

This guide provides a uniform way to structure your RiotJS code. Making it

@jbmoelker
jbmoelker / lightweight-front-end-servers.md
Created March 18, 2016 13:35
[Notes] Lightweight front-end servers
@jbmoelker
jbmoelker / riotjs-style-guide-badge.svg
Last active March 24, 2016 13:38
[WIP] RiotJS Style Guide badge
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.