Skip to content

Instantly share code, notes, and snippets.

Mike McNeil mikermcneil

Block or report user

Report or block mikermcneil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mikermcneil
mikermcneil / How to name a noun.md
Last active Sep 26, 2019
Naming conventions for things like variables, parameters, and attributes.
View How to name a noun.md

How to name a noun

Some of the naming conventions we use at Sails for nouns like variables, parameters, property names, config settings, database attributes/columns/fields, and so on.

Why bother?

Naming is hard. And naming conventions usually end up being wrong, or incomplete at best.

This may be an unpopular opinion, but in my experience, coming up with new methodologies for variables and such doesn't usually create a lot of value for an individual developer. So why bother?

@mikermcneil
mikermcneil / allow-emojis-mysql-with-nodejs-using-sailsjs-and-waterline.md
Created Mar 12, 2019
To allow emojis for one of your attributes when using Node.js / Sails / Waterline (MySQL)
View allow-emojis-mysql-with-nodejs-using-sailsjs-and-waterline.md

To allow emojis for one of your attributes when using Node.js / Sails / Waterline

Use the following auto-migration directive for MySQL:

columnType: 'LONGTEXT CHARACTER SET utf8mb4',// « allow emojis
@mikermcneil
mikermcneil / stripe-card-element.component.js
Created Feb 9, 2019
An example of a component for using Stripe Elements with parasails / Vue.js (`<stripe-card-element>`)
View stripe-card-element.component.js
/**
* <stripe-card-element>
* -----------------------------------------------------------------------------
* A wrapper for the Stripe Elements "card" component (https://stripe.com/elements)
*
* Example usage:
* ```
* <stripe-card-element stripePublishableKey="…" v-model="formData.cardInfo"></stripe-card-element>
* ```
*
@mikermcneil
mikermcneil / you-dont-have-to-worry-about-uncaught-rejections.js
Created Jan 29, 2019
...as long as you properly handle things at the top level. (or otherwise just let https://npmjs.com/package/parley do it for you)
View you-dont-have-to-worry-about-uncaught-rejections.js
async function hoHum() {
return 'ho hum';
}
async function hiHo() {
return 'hi ho!';
}
async function hoNo() {
throw new Error('ho... no!');
@mikermcneil
mikermcneil / js-timestamp.component.js
Created Oct 27, 2018
<js-timestamp>: A Parasails/Vue.js component for live-updating timestamps built on moment.js (relies on `moment` already being available to your frontend code-- eg. by putting it in assets/dependencies/moment.js).
View js-timestamp.component.js
/**
* <js-timestamp>
* (assets/js/components/js-timestamp.component.js)
* -----------------------------------------------------------------------------
* A human-readable, self-updating "timeago" timestamp, with some special rules:
*
* • Within 24 hours, displays in "timeago" format.
* • Within a month, displays month, day, and time of day.
* • Within a year, displays just the month and day.
* • Older/newer than that, displays the month and day with the full year.
@mikermcneil
mikermcneil / fa-ban.md
Last active Oct 24, 2018
In Fontawesome (at least Fontawesome 4.7.0), the icon for the red circle with a slash through it is called "fa-ban".
View fa-ban.md

In Fontawesome, the icon for the red circle with a slash through it is called "fa-ban"

Like a "no smoking" sign, but just the circle part

fontawesome 4.7.0: https://fontawesome.com/v4.7.0/cheatsheet/

Making this gist because I forget how to find it literally every time I want to use it

@mikermcneil
mikermcneil / datepicker.component.js
Created Aug 20, 2018
A datepicker component for Vue/parasails, assuming you're using the "Web App" template (aka parasails). _Note: this code was pasted here as of Mon Aug 20, 2018 -- note that this may have been updated or changed in the mean time._
View datepicker.component.js
// This goes in `assets/js/components/datepicker.component.js`
// ^^Remove this comment
/**
* <datepicker>
* -----------------------------------------------------------------------------
* A wrapper for the jQuery UI datepicker, which falls back to a date input on mobile.
*
* @type {Component}
*
* @event input [emitted when the value is changed privately]
@mikermcneil
mikermcneil / dom-fundamentals.md
Last active May 6, 2018
Dom Fundamentals Part 1: Display
View dom-fundamentals.md

Dom Fundamentals Part 1: Display

Repo:

https://github.com/mikermcneil/dom-fundamentals

Normal flow and display:inline

  • display:inline things work like text
  • <img> elements are technically display:inline by default. But that's dumb
  • To center a display:inline element, put text-align:center on the parent
@mikermcneil
mikermcneil / send-socket-request-from-ionic.js
Last active Apr 3, 2018
wrapper around sails.io.js (Sails.js socket.io client) for Ionic framework (circa 2017-2018 anyway). See https://gitter.im/balderdashy/sails?at=5ac146392b9dfdbc3a4620e1 for context
View send-socket-request-from-ionic.js
/**
* Module dependencies
*/
var _ = window['_'];
var io = window['io'];
import flaverr from './flaverr';
@mikermcneil
mikermcneil / parasails.sublime-syntax
Last active Mar 18, 2019
Syntax highlight template literals as HTML in Sublime Text 3 for Vue.js components, Vue app instances, or other client-side JavaScript. Particularly useful for the .page.js and .component.js files in your Sails app or other Parasails project. No grunt-ing, gulp-ing, webpack-ing, brunch-ing, or supper required.
View parasails.sublime-syntax
%YAML 1.2
---
# parasails.sublime-syntax
#
# Syntax highlight template literals as HTML in Vue components (standalone and inline).
# Automatically enabled for .component.js and .page.js files.
# (Designed for use with client-side JavaScript for your Vue.js, Sails.js,
# or Parasails app-- but could be used anywhere-- even on the server via Node.js.)
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
You can’t perform that action at this time.