Skip to content

Instantly share code, notes, and snippets.

View mikermcneil's full-sized avatar
🧑‍🚀

Mike McNeil mikermcneil

🧑‍🚀
View GitHub Profile
@mikermcneil
mikermcneil / How to name a noun.md
Last active October 7, 2023 16:51
Naming conventions for things like variables, parameters, and attributes. (Naming nouns)

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 March 12, 2019 19:36
To allow emojis for one of your attributes when using Node.js / Sails / Waterline (MySQL)

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 February 9, 2019 15:37
An example of a component for using Stripe Elements with parasails / Vue.js (`<stripe-card-element>`)
/**
* <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 January 29, 2019 05:58
...as long as you properly handle things at the top level. (or otherwise just let https://npmjs.com/package/parley do it for you)
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 October 27, 2018 08:33
<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).
/**
* <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 October 24, 2018 17:59
In Fontawesome (at least Fontawesome 4.7.0), the icon for the red circle with a slash through it is called "fa-ban".

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

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

@mikermcneil
mikermcneil / datepicker.component.js
Created August 20, 2018 21:23
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._
// 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 23:55
Dom Fundamentals Part 1: Display

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 April 3, 2018 16:37
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
/**
* Module dependencies
*/
var _ = window['_'];
var io = window['io'];
import flaverr from './flaverr';
@mikermcneil
mikermcneil / parasails.sublime-syntax
Last active March 24, 2023 17:47
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.
%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.)
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #