Skip to content

Instantly share code, notes, and snippets.

View kriscooke's full-sized avatar

kriscooke

  • British Columbia, Canada
View GitHub Profile
@kriscooke
kriscooke / atob.js
Created June 18, 2020 04:46 — forked from jmshal/atob.js
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
@kriscooke
kriscooke / atob.js
Created June 18, 2020 04:46 — forked from jmshal/atob.js
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
@kriscooke
kriscooke / prevent-node-gyp-fetch.sh
Created April 27, 2020 22:40
Prevent node-gyp from having to fetch node headers for rebuild during installation
#!/bin/bash
# https://github.com/nodejs/node-gyp/issues/812
npm install --nodedir $(which node)
# OR, in ~/.bash_profile:
npm_config_nodedir=$(which node)
@kriscooke
kriscooke / post-checkout
Created April 23, 2020 18:21
Keep Git submodules in the right state when switching branches
# https://ttboj.wordpress.com/2014/05/06/keeping-git-submodules-in-sync-with-your-branches/
# Create a file in your project's hooks: touch .git/hooks/post-checkout
# And add the following:
#!/bin/bash
exec git submodule update
# Then chmod u+x .git/hooks/post-checkout
@kriscooke
kriscooke / .company-a.gitconfig
Last active March 31, 2020 05:00
Multiple scoped Git identities and configurations (eg: personal and professional emails, multiple keys, etc.). Ideal for developers who use the same computer for multiple work and personal projects. Credit: https://stackoverflow.com/a/49154229
# Example configuration for Company A
# This will only be applied for Git operations within ~/code/company-a-work/
# Within this scope, values below will overwrite the corresponding ones in the global .gitconfig
# Only mention configs that overwrite or elaborate on the global .gitconfig
[user]
name = Dr. Betty White
email = professional@company-a.com
signingkey = yyyyyyyyyyyyyyyy

START BY NOT CODING - PLAN!

  1. User Stories (what & why)
    • As a ... I want to / should be able to ... because ... (benefit)
      • eg: As an admin, I should be able to edit my event because the timing and details might change.
      • As a public user, I should be able to see all events and their details.
  2. User Scenarios (sequence of HOW user can accomplish each user story)
    • Given ... when ... then ... and ...
      • eg: Given that I'm logged in, when I select my event from the calendar then I can use the datepicker to edit the date and click "Save" to keep the change.
  3. MVP: What is the MVP design (total of all user stories)?
@kriscooke
kriscooke / vscode_as_git_editor.md
Last active October 18, 2019 00:19
How to use VSCode as your default Git message editor

How to use VSCode as your default Git message editor

1. Make it possible to open VSCode from the terminal:

Use Cmd + Shift + P to open the command menu Type and select: Shell Command: Install 'code' command in PATH

This allows you to open VS Code from your terminal. ex: In your terminal, type code . from your terminal to open the current directory in VSCode.

@kriscooke
kriscooke / discover-bower-pkg-versions.js
Created April 11, 2017 15:42
Parse bower_components and output repository source URL + version of installed modules as JSON
const bower_components = './src/bower_components';
const dependencies = require('./src/bower.json').dependencies;
const outputJson = require('./bower-pkg-versions.json');
const fs = require('fs');
const path = require('path');
const modules = fs.readdirSync(bower_components);
function getAlternativeSourceOrVersion(dir, json) {
@kriscooke
kriscooke / encodegif.sh
Last active February 7, 2017 01:23
Color-optimized Video to GIF with ffmpeg
#!/bin/sh
# Generates an infinitely looping GIF (-loop 0) from an input video with ffmpeg.
# Arguments, in order: input video file, output gif file, end time (seconds)
# Modify args in `filters` to change fps or size (height) in pixels.
# Credit for optimizing color palette quality goes to:
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
palette="/tmp/palette.png"
@kriscooke
kriscooke / bash
Created January 26, 2017 06:54
Zip a directory but excluding git repo and other annoying files
zip -9 -r --exclude=*.git* --exclude=*.DS_Store* result.zip originalfolder