Skip to content

Instantly share code, notes, and snippets.

View maxmckenzie's full-sized avatar

Max McKenzie maxmckenzie

View GitHub Profile
@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 / 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 / .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 / 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 / React table
Last active July 30, 2019 15:05
No thrills React table component
import React from 'react';
import classes from './Table.module.css';
const Row = props => {
return props.keys.map((key) => {
return <td key={props.data[key]}>{props.data[key]}</td>
})
}
const Table = ({
@maxmckenzie
maxmckenzie / Sass type scale mixin
Created August 2, 2019 11:19
Sass type scale & vertical rhythm mixin use `@include typeScale(1, 1)` or `@include typeScale(-1, 1)` for font sizes below 1rem. Just change the values of line height and scaling factor. Make sure that the line height is always larger than the font size and you will keep the vertical rhythm consistent across the document ``` $base-font-size: 1re…
:root {
font-size: 16px;
}
@function pow($number, $exponent) {
$value: 1;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $number;
@maxmckenzie
maxmckenzie / storybook webpack
Created August 17, 2019 08:15
storybook webpack
const path = require('path');
// your app's webpack.config.js
const custom = require('../build/webpack.base.js');
module.exports = async ({ config, mode }) => {
return { ...config,
module: {
...config.module,
rules: custom.module.rules,
},
@maxmckenzie
maxmckenzie / Storybook react stories.js file
Created September 19, 2019 13:05
Storybook react stories
import { storiesOf } from '@storybook/react';
import React from 'react';
storiesOf('example', module)
.add(
'example',
() => (
<div>
<div></div>
</div>
# Theme
ZSH_THEME="robbyrussell"
# PATH exports
PATH=$PATH:/usr/local/bin/; export PATH
export PATH=/usr/local/share/npm/bin:$PATH
export ZSH="/Users/xamkcm/.oh-my-zsh"
# Alias's for git
alias gs='git status'
@maxmckenzie
maxmckenzie / pc.laptop
Last active September 5, 2021 17:02 — forked from jonschoning/pc.laptop
/usr/share/X11/xkb/symbols/pc (swap CTRL+ALT+CAPS; ALT->CTRL) https://github.com/jonschoning/xkb_symbols
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };