Skip to content

Instantly share code, notes, and snippets.

View kriscooke's full-sized avatar

kriscooke

  • British Columbia, Canada
View GitHub Profile
const path = require('path');
const gulp = require('gulp');
const del = require('del');
const gulpif = require('gulp-if');
const uglify = require('gulp-uglify');
const htmlMinifier = require('gulp-html-minifier');
const mergeStream = require('merge-stream');
const polymer = require('polymer-build');
'use strict';
@kriscooke
kriscooke / github-pages-101.md
Last active February 21, 2021 17:53
GitHub Pages 101 aka. free hosting for all your public demos

GitHub Pages, aka. free hosting for all your public demos:

Without your writing any webserver code, GitHub can recognize specifically-named repos/branches and will serve a static page (including HTML/CSS/JS and other static files) at a certain GitHub-based URL. This means free hosting for your public demos, and makes it really easy to host a doc/demo site associated with each of your repositories. You can even set it up with a custom domain.

User Page (or Organization)

  • Accessible at: yourusername.github.io
  • GitHub automatically reserves this URL for every user and organization to use as their User page, although nothing is published there until you publish.
  • To deploy a static site to this URL:
    1. Create a Github repo with the exact name: yourusername.github.io
  1. Commit an index.html in the root folder to the master branch and push. (From the index page you can link to other folders/files as usual)
@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
@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 / 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 / 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.

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 / .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 = [email protected]
signingkey = yyyyyyyyyyyyyyyy
@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 / 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)