Skip to content

Instantly share code, notes, and snippets.

View maxmckenzie's full-sized avatar

Max McKenzie maxmckenzie

View GitHub Profile
@maxmckenzie
maxmckenzie / instanceof vs typeof
Created July 29, 2019 11:43
instanceof (custom types or custom built in types) vs typeof (built in types)
Use instanceof for custom types:
```
var ClassFirst = function () {};
var ClassSecond = function () {};
var instance = new ClassFirst();
typeof instance; // object
typeof instance == 'ClassFirst'; // false
instance instanceof Object; // true
instance instanceof ClassFirst; // true
instance instanceof ClassSecond; // false
@maxmckenzie
maxmckenzie / .babelrc
Last active July 29, 2019 09:00
generic babel config #config
{
"presets": [
["env", {
"targets": {
"node": "current",
"browsers": ["last 2 versions", "safari >= 11.1","ie 8"]
}
}]
],
"plugins": [
@maxmckenzie
maxmckenzie / sockets-server.js
Last active July 29, 2019 09:02
basic bare minimum express server #express
import express from 'express';
import http from 'http'
/**
* Express Set Up
*/
const app = express()
app.set('view engine', 'pug')
app.use('/assets', express.static('assets'));
const server = http.createServer(app);
const io = require('socket.io').listen(server);
@maxmckenzie
maxmckenzie / auth-express-sha-1.js
Last active July 29, 2019 09:02
sha-1 authentication signature server using express.js #express
// https://url/?timestamp=&UID=&secretKey=
const express = require('express');
const crypto = require('crypto');
const app = express()
const signature = (timestamp, uid, secretKey) => {
const buf = Buffer.from(secretKey, 'base64');
const baseString = timestamp + "_" + uid
const binaryBaseString = baseString.toString('binary')
const sig = crypto.createHmac('sha1', buf).update(binaryBaseString).digest()
console.log(sig.toString('base64'))
@maxmckenzie
maxmckenzie / spread-operators.js
Last active July 29, 2019 09:05
spread operators snippet #esnext
// Spread operators baby
var Array = [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
var result = [].concat(...Array);
console.log(result);
@maxmckenzie
maxmckenzie / god-damn-it-apple.sh
Created July 13, 2019 09:36
god-damn-it-apple i'll install what i want use this to install apps from anywhere.
sudo spctl --master-disable
@maxmckenzie
maxmckenzie / logger.js
Created July 13, 2019 09:35
logger example with sentry
/* eslint-disable no-console */
import raven from 'raven';
/*
To Use
import logger from './logger';
logger.error('test error');
logger.debug('test debug');
logger.warning('test warning');
logger.fatal('test fatal');
> This example uses global environment configurations
@maxmckenzie
maxmckenzie / eslint.rc
Last active July 29, 2019 09:02
eslint config #config
module.exports = {
"extends": "standard",
"plugins": [
"standard",
"promise"
],
"rules": {
// i know... i'm happy to omit them
// but mi dios, its like walking down the street wearing real fur
"semi": ["error", "always"]
@maxmckenzie
maxmckenzie / editor.conf
Created July 13, 2019 09:34
default editor config
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@maxmckenzie
maxmckenzie / gitlab-ci.yml
Last active July 29, 2019 09:05
gitlab-ci deploy to heroku #ci
stages:
- deploy
deploy to development:
stage: deploy
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --strategy=api --app=example-dev --api-key=$HEROKU_API_KEY