Skip to content

Instantly share code, notes, and snippets.

@martenc
martenc / gist:9263274
Created February 28, 2014 01:16
neh - node express handlebars
/*
Simple recipe for using these together. Use npm to install:
npm install -g express
npm install -g hbs
*/
/*
Import and config like so:
*/

Showcase idea (hover the iPhone)

Wanted to get some interactivity in my portfolio-images, this is one of the ideas that I had and something that I will use for the site. (Only works in webkit at the moment)

A Pen by Patrik Hjelm on CodePen.

License.

@martenc
martenc / html5-zipcode-validator.markdown
Created December 16, 2014 19:47
html5 zipcode validator
@martenc
martenc / console-util.js
Created April 17, 2015 17:44
Avoid `console` errors
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
@martenc
martenc / api_helper.js
Created April 17, 2015 17:51
js api helper
/*
Generally helpful method for making https calls to your api
*/
var querystring = require('querystring');
var https = require('https');
exports.performRequest = function(host, endpoint, method, data, success) {
var dataString = JSON.stringify(data);
var headers = {};
@martenc
martenc / package.json
Created June 30, 2017 19:02
Generic - React Node
{
"name": "",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "",
@martenc
martenc / gulpfile.js
Created June 30, 2017 19:03
Generic - React Gulp
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); //Runs a local dev server
var open = require('gulp-open'); //Open a URL in a web browser
var browserify = require('browserify'); // Bundles JS
var reactify = require('reactify'); // Transforms React JSX to JS
var source = require('vinyl-source-stream'); // Use conventional text streams with Gulp
var concat = require('gulp-concat'); //Concatenates files
var lint = require('gulp-eslint'); //Lint JS files, including JSX
@martenc
martenc / s3-invalidation.js
Created July 13, 2017 02:30 — forked from supinf/s3-invalidation.js
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;
@martenc
martenc / fiddle.html
Created March 19, 2018 23:27 — forked from anonymous/fiddle.html
Solution - Token Authentication Using the Nuxeo JS Client (source: https://jsfiddle.net/martenc/3fq0acfw/)
<body>
<h1>
Solution - Token Authentication Using the Nuxeo JS Client
</h1>
<h2>
Your Goal
</h2>
@martenc
martenc / nuxeo-test.js
Created March 23, 2018 00:49
example code for accessing nuxeo with nodejs
#!/usr/bin/env node
'use strict'
const Nuxeo = require('nuxeo');
// let baseURL = 'http://localhost:8080/nuxeo/';
let baseURL = 'http://localhost:8080/nuxeo/';
// let username = 'Administrator';
// let password = 'Administrator';