Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Maiaroto tmaiaroto

View GitHub Profile
@tmaiaroto
tmaiaroto / usc.go
Created Nov 7, 2014
Golang map of US state codes : full name
View usc.go
// A handy map of US state codes to full names
var usc = map[string]string{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
@tmaiaroto
tmaiaroto / virtual.conf
Created Aug 9, 2012
Nginx Virtual Host Setup for OS X using Homebrew
View virtual.conf
#
# A virtual host using mix of IP-, name-, and port-based configuration.
# This is based on using Homebrew for OS X. You can use this in other
# cases though, but you'll likely need to adjust some of the paths below.
#
server {
# Replace this port with the right one for your requirements
# listen 80 [default|default_server]; #could also be 1.2.3.4:80
@tmaiaroto
tmaiaroto / Dockerfile
Last active Jun 30, 2022
WordPress on Amazon ECS
View Dockerfile
FROM alpine:3.3
MAINTAINER Tom Maiaroto <tom@outdoorsy.co>
# Install packages
RUN apk --update --repository http://dl-3.alpinelinux.org/alpine/edge/main add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \
@tmaiaroto
tmaiaroto / collection+json.md
Last active May 23, 2022
JSON Based Hypermedia Structures - Notes & Comparisons
View collection+json.md

Collection+JSON format

http://amundsen.com/media-types/collection/examples/

This format takes into consideration collections (much like Siren). It also takes into consideration versioning. However, I'm not certain version matters in the data set if it pertains to an API version. That is best left being in the API URL. It could pertain to collection version, but I'm not sure the point. Documentation says each collection should have a version - but says nothing more about meaning or why.

Items are clearly distinct in this format and are organizationally positioned separate from links.
This is by far the most collision free structure.

However, the data format itself is a bit strange...Every field being an array. Data is always an array of objects. I understand the flexibility this presents and am not 100% against it. I just believe it's perhaps not needed as things could change based on the client application.

@tmaiaroto
tmaiaroto / image-proxy.conf
Last active Dec 16, 2021
Nginx Image Filter Resize Proxy Service
View image-proxy.conf
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@tmaiaroto
tmaiaroto / Gruntfile.js
Created Jul 2, 2015
Gruntfile for working with Hugo
View Gruntfile.js
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
shell: {
options: {
stdout: true
},
server: {
View google_twunter_lol
4r5e
5h1t
5hit
a55
anal
anus
ar5e
arrse
arse
ass
@tmaiaroto
tmaiaroto / get_raw_sql.ts
Created Jun 24, 2020 — forked from slavivanov/get_raw_sql.ts
Get generated SQL query from Sequelize
View get_raw_sql.ts
import * as Sequelize from "sequelize";
import uuidv1 = require("uuid/v4");
import { SequelizeModelStatic } from "./sequelize";
import * as pLimit from "p-limit";
import _ = require("lodash");
/**
* Get generated SQL query from sequelize. Returns a promise that:
* 1. Adds a hook that receives the prepared options from Sequelize
* - Since hooks work on the whole model,
View getIEVersion.js
// Looks at User Agent to determine if IE and which version
function GetIEVersion() {
var sAgent = window.navigator.userAgent;
var idx = sAgent.indexOf("MSIE");
var versionNumber = 0;
// If IE, return version number.
if (idx) {
try {
versionNumber = parseInt(sAgent.substring(idx+ 5, sAgent.indexOf(".", idx)));
@tmaiaroto
tmaiaroto / material-ui-flexible-fixed-header-table.js
Created Mar 16, 2020 — forked from antonfisher/material-ui-flexible-fixed-header-table.js
React.js Material-UI Table component with flexible height and fixed header
View material-ui-flexible-fixed-header-table.js
/*
* React.js Material-UI Table and TableRow components with flexible height and fixed header
* - fixes "jumping" scrolling bar in WebKit browsers
* - shows permanent scrolling bar for other browsers
*
* Usage: import this Table and TableRow component instead of
* 'material-ui/Table' and 'material-ui/TableRow' component
*/
import React, {PropTypes} from 'react';