Skip to content

Instantly share code, notes, and snippets.

View alexilyaev's full-sized avatar

Alex Ilyaev alexilyaev

View GitHub Profile
@alexilyaev
alexilyaev / prettier-config.md
Created November 26, 2020 18:57
Prettier Config

trailingComma: es5 (default)

https://prettier.io/docs/en/options.html#trailing-commas

When set to none...

  • Often forgetting to add a comma when adding entries to an Object.
  • Commenting a property in an object currently removes the comma from the property above it.
  • Moving the last property of an object up requires an extra step to add a comma at the end.
  • Messes up Git diff and sometimes creates conflicts.
@alexilyaev
alexilyaev / deploy-ci.sh
Last active May 19, 2020 16:55
Git CI authentication with SSH keys
#!/usr/bin/env bash
# References:
# https://docs.travis-ci.com/user/environment-variables
#
# Inspired by:
# https://gist.github.com/willprice/e07efd73fb7f13f917ea
# But using SSH keys instead of Personal Access Token:
# https://gist.github.com/alexilyaev/2672fe6d99756377fbffaabad6db1f45
@alexilyaev
alexilyaev / Next.js-9.3.md
Last active May 11, 2020 21:25
Summary of the new stuff in Next.js 9.3

The blog post on Next.js 9.3

export async getStaticProps

  • Runs at build time only, meaning if there’s no getInitialProps, the page will be served as a static file (no SSR).
  • Can pass data to the page component as props.
  • In development runs on every request

export async getStaticPaths

@alexilyaev
alexilyaev / time-to-decimal.js
Created December 6, 2018 11:09
Alfred Worflow - Time To Decimal
/**
* Convert a time string to a decimal value
*
* @param {string} argv e.g. 142h13m, 142 h 13 min
*/
function run(argv) {
const query = argv[0];
const [, hours, minutes] = query.match(/\s*(?:(\d+)\s*h)?\s*(?:(\d+)\s*m)?/)
let decimal = 0;
@alexilyaev
alexilyaev / license-checker.js
Created November 19, 2017 13:03
A small script to check packages installed through npm against a whitelist of licenses and packages
'use strict';
const _ = require('lodash');
const winston = require('winston');
const checker = require('license-checker');
const chalk = require('chalk');
const licensesWeAreOKWith = `
MIT,
MIT*,
@alexilyaev
alexilyaev / canvas-ping-pong.markdown
Created November 16, 2017 15:13
Canvas - Ping Pong
@alexilyaev
alexilyaev / index.html
Created November 16, 2017 15:12
SVG Tape
<svg width="500" height="300" viewBox="0 0 500 300">
<!-- Define components -->
<defs>
<g id="tape">
<rect width="450" height="200" fill="#222"
stroke="#aaa" stroke-width="5"/>
</g>
<g id="wheel">
<circle cx="50" cy="50" r="50"
@alexilyaev
alexilyaev / .hyper.js
Last active July 31, 2017 09:14
Hyper.js configuration
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 16,
// font family with optional fallbacks
fontFamily: '"Fira Code", Monaco, Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248, 28, 229, 0.8)',
@alexilyaev
alexilyaev / Gruntfile.js
Last active July 30, 2017 13:06
Gruntfile.js - JSHint, Uglify, SASS, Clean, Watch, Connect with LiveReload
module.exports = function (grunt) {
'use strict';
var port = grunt.option('port') || 9001,
lrPort = grunt.option('lr-port') || 35731,
hostname = 'localhost',
baseFolder = '.';
// Display the elapsed execution time of grunt tasks
require('time-grunt')(grunt);
@alexilyaev
alexilyaev / gh-pages-deploy.md
Created April 30, 2017 12:19 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).