Skip to content

Instantly share code, notes, and snippets.

View maxbeatty's full-sized avatar

Max Beatty maxbeatty

View GitHub Profile
@maxbeatty
maxbeatty / select_country_by_continent.html
Created September 30, 2011 23:21
HTML Select Country by Continent
<label for="addressCountry">Country</label>
<select name="addressCountry">
<option></option>
<optgroup label="North America">
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="CA">Canada</option>
<option value="MX">Mexico</option>
<option value="AI">Anguilla</option>
<option value="AG">Antigua and Barbuda</option>
@maxbeatty
maxbeatty / lambda.js
Created August 22, 2017 20:01
using node-postgres (`pg`) in AWS Lambda
import λ from "apex.js";
import { Pool } from "pg";
// connection details inherited from environment
const pool = new Pool({
max: 1,
min: 0,
idleTimeoutMillis: 120000,
connectionTimeoutMillis: 10000
});
// original
@import "mgmt/sprites/icons/*.png";
$icons: sprite-map("mgmt/sprites/icons/*.png");
.test {
background: transparent $icons no-repeat 0 0;
}
// my test
@maxbeatty
maxbeatty / node-encrypt-decrypt.js
Created November 5, 2014 03:22
Encrypt and decrypt a string with Node.js
crypto = require('crypto');
exampleClientId = 'my_client_id'
mySharedKey = 'shared_key'
cipher = crypto.createCipher('aes256', mySharedKey)
cipherText = cipher.update(exampleClientId, 'utf8', 'base64')
cipherText += cipher.final('base64')
decipher = crypto.createDecipher('aes256', mySharedKey)
@maxbeatty
maxbeatty / hoc.js
Last active September 25, 2017 18:33
Trying to pass a React component in `getInitialProps` to a higher order component in next.js
import React from "react";
export default function MainLayout(Child) {
return class MainLayoutComponent extends React.Component {
static getInitialProps(context) {
return Child.getInitialProps(context);
}
render() {
@maxbeatty
maxbeatty / index.js
Created July 18, 2017 21:01
zeit/micro w/ sequelize
const Sequelize = require("sequelize");
const sequelize = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASS,
{
host: process.env.DB_HOST,
dialect: "mysql"
}
@maxbeatty
maxbeatty / b.js
Created March 5, 2017 18:47
AWS Lambda module caching anti-pattern
var first = true;
module.exports = function () {
console.log(`first: ${first}`);
if (first) {
first = false;
}
};
@maxbeatty
maxbeatty / example.md
Created February 1, 2017 18:55
example diff block in markdown

use diff to get fun red and green lines

- old
+ new

Keybase proof

I hereby claim:

  • I am maxbeatty on github.
  • I am maxbeatty (https://keybase.io/maxbeatty) on keybase.
  • I have a public key ASAj0U1E22K3wIaNOVtmMEMpV-5pX4F7hcPUOjCl58mg7Qo

To claim this, I am signing this object:

assert = require 'assert'
driver = require '../../src/driver'
describe 'driver', ->
it 'should have drive as skill', ->
assert.equal driver.data.skill, "Drive", "skill not set"