Skip to content

Instantly share code, notes, and snippets.

View xjamundx's full-sized avatar

Jamund Ferguson xjamundx

View GitHub Profile
@xjamundx
xjamundx / v0.js
Created January 19, 2013 21:15
Versioned Route Example
// Version 0
var express = require('express');
var contacts = require('../control/contacts')
var customAuth = require('../lib/customAuth')
var app = module.exports = express();
// middleware that only applies to this version of the API
app.use(customAuth());
// normal routes, all will be pre-fixed by the version
@xjamundx
xjamundx / versionedAPIs.js
Last active December 11, 2015 08:48
Versioned APIs with Express
// define the versions
var VERSIONS = {'Pre-Production': '/v0', 'Version 1': '/v1'};
// route to display versions
app.get('/', function(req, res) {
res.json(VERSIONS);
})
// versioned routes go in the routes/ directory
// import the routes

OAuth 1.0A

Pros:

  1. Shared login without giving out your password. (Not our problem)
  2. "State-ful" security without cookies or HTTPS (sort-of)
  3. Ability to de-authorize

Cons:

@xjamundx
xjamundx / sticky-footer.scss
Created November 9, 2012 17:00
sticky-footer of the future
@xjamundx
xjamundx / validator.js
Created October 16, 2012 22:43 — forked from jquerygeek/validator
validator.nu client-side
// easy way to get current pages HTML
$.get('#', function(html) {
// emulate form post
var formData = new FormData();
formData.append('out', 'json');
formData.append('content', html);
// make ajax call
$.ajax({
init: function() {
var html = "<!doctype html><html lang='en'>" + $('html').html() + "</html>";
var validatorURL = "http://html5.validator.nu/?out=json";
$.post({url: validatorURL, headers: {"Content-type": "text/html"}, body: html},
function(err, res, body) {
alert('response: '+res);
if (err) alert(err);
var data = JSON.parse(body);
console.log(data);
});
@xjamundx
xjamundx / git-prompt.bash
Created October 12, 2012 20:14
git prompt
git_prompt ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="${c_git_clean}"
@xjamundx
xjamundx / jitsu-errors
Created September 17, 2012 16:56
nodejitsu erros with mhash via mongoskin i think
~/Sites/no.desk [master] $ jitsu deploy
info: Welcome to Nodejitsu xjamundx
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing your application dependencies in app.js
info: Creating snapshot 0.0.3
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: npm WARN package.json no.desk@0.0.3 No README.md file found!
npm http GET http://nj-npm.irisnpm.com/express/2.5.8
@xjamundx
xjamundx / svg.md
Created August 14, 2012 20:12
Everything I Know About SVG

Everything I Know About SVG

SVG is arguably going to be the main image format of the modern web. I recently wrote an article for Safari Books Online called SVG Icons for New Devices that covers some of the basics of dealing with SVG. This article covers more the pain points of using SVG in production and as it turns out there are many.

Plain Old <img> Tags

Here's how you link to your amazing vector image.

<img src="/images/logo.svg">
@xjamundx
xjamundx / html5-valid.js
Created July 24, 2012 02:24
html5 validator
// HTML5 Validator using http://about.validator.nu/#api
exports.validate = function(data, done) {
var url = data.url
var html = data.html
if (!url && !html) return done(new Error("You forget a URL for the validator"))
if (html) return complete(html)
utils.printTitle("HTML5 Validator")
request(url, function(err, res, body) {