Skip to content

Instantly share code, notes, and snippets.

View joyrexus's full-sized avatar

J. Voigt joyrexus

View GitHub Profile
@joyrexus
joyrexus / install.py
Last active September 26, 2020 05:55
Shopify App Installation URL via AWS Lambda (Python)
# https://help.shopify.com/api/guides/authentication/oauth#scopes
scopes = []
scopes.append('read_content')
scopes.append('write_content')
scopes.append('read_themes')
scopes.append('write_themes')
scopes.append('read_products')
scopes.append('write_products')
scopes.append('read_customers')
@joyrexus
joyrexus / index.js
Last active December 2, 2016 18:25
hapi redirect demo
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({
host: 'localhost',
port: 8000
});
@joyrexus
joyrexus / style.md
Last active August 16, 2016 01:23
Simple node.js code style tips to improve code quality

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

@joyrexus
joyrexus / custom-error.js
Created June 7, 2016 15:23 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@joyrexus
joyrexus / http-errors.js
Created June 6, 2016 23:30 — forked from moleike/http-errors.js
HTTP Error classes in Node.js
'use strict';
const statusCodes = require('http').STATUS_CODES;
function createError(code, name) {
return function(message) {
Error.captureStackTrace(this, this.constructor);
this.name = name;
this.message = message;
this.statusCode = code;
}
@joyrexus
joyrexus / README.md
Last active November 28, 2016 22:34
go api dev, part 2
@joyrexus
joyrexus / premailerfixup.py
Created January 26, 2016 02:14 — forked from texuf/premailerfixup.py
fix for "WARNING Property: Unknown Property name." error from cssutils
from cssutils import profile
from cssutils.profiles import Profiles, properties, macros
#patch um up
properties[Profiles.CSS_LEVEL_2]['-ms-interpolation-mode'] = r'none|bicubic|nearest-neighbor'
properties[Profiles.CSS_LEVEL_2]['-ms-text-size-adjust'] = r'none|auto|{percentage}'
properties[Profiles.CSS_LEVEL_2]['mso-table-lspace'] = r'0|{num}(pt)'
properties[Profiles.CSS_LEVEL_2]['mso-table-rspace'] = r'0|{num}(pt)'
properties[Profiles.CSS_LEVEL_2]['-webkit-text-size-adjust'] = r'none|auto|{percentage}'
#re-add
profile.addProfiles([(Profiles.CSS_LEVEL_2,
@joyrexus
joyrexus / README.md
Last active January 20, 2017 12:08
Abbo’s Alley I

Abbo's Alley I

Quick demo showing how to add Sewanee trail data to a map using Mapbox GL JS.

The key building blocks here are sources and layers. Sources contain the underlying geo data. Layers let you specify how to style this data.

In our demo we're adding two data sources: the trail route for one section of Abbo's Alley and markers indicating exit points. The trail data was taken from a geojson file containing information about all trails on the Domain.

About Abbo's Alley

@joyrexus
joyrexus / index.html
Created October 6, 2015 19:00
Sewanee Flyover III
<html>
<head>
<meta charset='utf-8' />
<title>Domain Flyover</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@joyrexus
joyrexus / index.html
Created October 6, 2015 18:50
Sewanee Flyover II
<html>
<head>
<meta charset='utf-8' />
<title>Domain Flyover</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }