Skip to content

Instantly share code, notes, and snippets.


Kevin Boutin kevboutin

View GitHub Profile
kevboutin / project.xml
Created Apr 5, 2013
This is a custom target to use with any ant build. The idea is that this file should be included into your build script and reference the dependency target where appropriate (ex. <import file="./project.xml" /> ). This step should be used after the publish directory is loaded up with all assets and ready to be deployed/packaged. Once this target…
View project.xml
<target name="-tarball">
<condition property="publish.exists">
<available file="${dir.publish}" type="dir"/>
<condition property="dist.exists">
<available file="${dir.dist}" type="dir"/>
<equals arg1="${publish.exists}" arg2="true"/>
kevboutin / security.conf
Created Apr 8, 2013
This is a default addition to httpd.conf via Include for security purposes.
View security.conf
# ----------------------------------------------------------------------
# A little more security
# ----------------------------------------------------------------------
# To avoid displaying the exact version number of Apache being used, add the
# following to httpd.conf (it will not work in .htaccess):
# ServerTokens Prod
# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
kevboutin / performance.conf
Last active Dec 15, 2015
This is a default addition to httpd.conf via Include for performance purposes.
View performance.conf
# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------
# Force the latest IE version, in various cases when it may fall back to IE7 mode
# Use ChromeFrame if it's installed for a better experience for the poor IE folk
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
kevboutin / gist:5768004
Created Jun 12, 2013
This Javascript will print out response headers to the console.
View gist:5768004
// Print out response headers for current URL
(function() {
var request=new XMLHttpRequest();'HEAD',window.location,false);
var headers = request.getAllResponseHeaders();
kevboutin / shop.html
Last active Dec 19, 2015
An example of how to handle the display of multiple products/items on a page in reponsive grid system. The media queries are not really required but they are there in case other things on the page will interact responsively.
View shop.html
<!DOCTYPE html>
<title>Product Shopping View Example</title>
Original idea:
kevboutin / calculateDistance.js
Last active Jan 30, 2016
Calculate shortest distance between two points
View calculateDistance.js
function calculateDistance(lat1, lon1, lat2, lon2) {
var R = 6371; // km
var dLat = (lat2 - lat1).toRad();
var dLon = (lon2 - lon1).toRad();
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d;
kevboutin / webWorker.js
Created Jan 30, 2016
Example webworker library
View webWorker.js
// simple implementation of a thread pool
function Pool(size) {
var _this = this;
// set some defaults
this.taskQueue = [];
this.workerQueue = [];
this.poolSize = size;
this.addWorkerTask = function(workerTask) {
kevboutin / hapi-cookies.js
Created Feb 26, 2016
Shows how to use hapi within node to manage state with cookies.
View hapi-cookies.js
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 8000 });
server.state('hello', {
//ttl = time to live
ttl: 60 * 60 * 1000,
isHttpOnly: true,
encoding: 'iron',
kevboutin / hapi-request-validation.js
Created Feb 26, 2016
Shows how to use joi for request validation when using hapi within Node.js.
View hapi-request-validation.js
'use strict';
const Hapi = require('hapi');
const Joi = require('joi');
const server = new Hapi.Server();
server.connection({ port: 8000 });
// test by calling:
// http POST localhost:8000/user/123?id=456
// or for validation failure testing, call:
// http POST localhost:8000/user/123?id=foo
kevboutin / hapi-friendly-error-pages.js
Last active Feb 26, 2016
Shows how to configure and use friendly error pages using extension events in hapi within node.
View hapi-friendly-error-pages.js
'use strict';
const Hapi = require('hapi');
const Boom = require('boom');
const server = new Hapi.Server();
server.connection({ port: 8000 });
// test by using this in browser:
// http://localhost:8000
server.register(require('vision'), () => {