Skip to content

Instantly share code, notes, and snippets.

View mikermcneil's full-sized avatar
🧑‍🚀

Mike McNeil mikermcneil

🧑‍🚀
View GitHub Profile
@mikermcneil
mikermcneil / 2-kinds-of-procedural-parameters.md
Last active December 20, 2017 03:31
Seems to me there are two varieties of procedural parameters out there: "leases" and "consequences".

2 kinds of procedural parameters

Seems to me there are two varieties of procedural parameters out there: "leases" and "consequences".

Examples

Procedures (generic)

@mikermcneil
mikermcneil / sublime-3-settings.js
Created December 11, 2017 08:43
My settings for Sublime 3 (press CMD+, to get here)
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@mikermcneil
mikermcneil / whats-the-big-deal.md
Last active November 5, 2022 11:03
What's the big deal with Node.js and `await`?

What's the big deal with Node.js and await?

So I really don't like most new things. The only reason I even got involved with Node.js early on was because of its sweeping promise: "One language, spoken by developers across the world." By consolidating parallel efforts, it would accelerate the pace of innovation, and quickly lead to more transformative and disruptive developer tools. It would create tremendous value for software businesses by unlocking efficiencies in the hiring and implementation process. And best of all everyone would waste less time on boring stuff.

Still, there was a problem. While it's true most developers have touched some JavaScript callbacks up there in browserland, in the bowels of the application server, there tends to be a lot more asynchronous things going on. And that causes all sorts of issues. All those callbacks also make for a way steeper

@mikermcneil
mikermcneil / pause.js
Last active December 21, 2017 01:46
that thing everyone needs now, if you're using `await` on the front-end. Obvious caveat: Don't actually use this without babel et al
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// UPDATE:
//
// If you're using a Sails app, and you need to do this on the backend, then instead of the code below,
// consider just using `sails.helpers.flow.pause()` from sails-hook-organics.
// (Now available by default in the "Web App" template.)
//
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@mikermcneil
mikermcneil / smry
Created November 4, 2017 16:16
Gist for iterating over files in a particular folder and checking their git status
#!/bin/bash
# smry
#
# Copyright Nov 4, 2017, Mike McNeil
# MIT License
#
# Adapted from https://gist.github.com/lmj0011/1a8dd1e376234ac7bf0fba2748ecdd0f
# and https://gist.github.com/mzabriskie/6631607#gistcomment-1738920
# which was originally adapted from https://gist.github.com/mzabriskie/6631607
@mikermcneil
mikermcneil / latest-open-source-misc-package-README-boilerplate.md
Last active November 3, 2017 20:09
latest template for the bottom of READMEs

Help

If you have a question, need commercial support from the engineers who build Sails, or you just want to talk Sails/Node.js with other folks in the community, click here.

Bugs   NPM version

To report a bug, click here.

@mikermcneil
mikermcneil / setting-up-cloudflare-and-heroku-with-ssl
Last active June 5, 2019 19:43
For future reference: When attempting to set up cloudflare and heroku properly with SSL, here's how you do it.
For future reference: When attempting to set up cloudflare and heroku properly, here's how you do it:
1. Just buy the dingdang SSL cert through Cloudflare.
2. Enable Cloudflare's built-in https:// redirect functionality.
3. Use the "Full" SSL setting in Cloudflare
4. In Cloudflare, have your DNS set up to point at the normal/default DNS setting (not the special SSL one!)
5. Don't do anything related to SSL in heroku (or in your app logic)
> If you choose "Partial" SSL in Cloudflare or start monkeying around with SSL in Heroku, things get kind of weird.
echoSinceTagInfo()
{
if git describe --abbrev=0 --tags 1>/dev/null 2>/dev/null;
then
local LAST_TAG=`git describe --abbrev=0 --tags`;
local CHANGED_SINCE_LAST_TAG=`git diff ${LAST_TAG} --shortstat`;
if [ -z "${CHANGED_SINCE_LAST_TAG}" ]
then
// This gist is just to keep track of this somewhere for posterity.
// In the future, we might look into adding support for something like the following...
// ––
// Parse and validate the provided data to ensure it's valid for this
// cloud action. (This also provides a basic level of client-side validation.)
argins = Cloud.login.parse(argins)
.tolerate('E_INVALID_ARGINS', (err)=>{
// Upon noticing any validation error, set error states in the form
// accordingly and send back argins as `undefined`.
@mikermcneil
mikermcneil / about-unless-and-early-returns.js
Last active October 17, 2017 21:57
Some demonstrative examples of early returns with promises/`async`+`await` in synchronous vs. asynchronous usage. (This is mostly about weighing the pros and cons of `.unless()`.)
await User.create({
emailAddress: 'asdf@asdf.com'
})
.unless('E_UNIQUE', ()=>{
return exits.conflict()
});
return exits.success();