Skip to content

Instantly share code, notes, and snippets.

@kgrz
kgrz / vimgrep.md
Created October 5, 2020 10:54 — forked from seanh/vimgrep.md
vimgrep cheatsheet

vimgrep

  • Vimcasts on vimgrep

  • Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.

You can do a normal within-file search first, then re-use the same pattern to

@kgrz
kgrz / feature-flags.md
Created August 10, 2020 01:33 — forked from threepointone/feature-flags.md
Feature flags: why, how, all that

(I'm enjoying doing these raw, barely edited writeups; I hope they're useful to you too)

Feature flags

This is my own writeup on feature flags; for a deep dive I'd recommend something like Martin Fowler's article (https://martinfowler.com/articles/feature-toggles.html).

So. Feature flags. The basic idea that you'll store configuration/values on a database/service somewhere, and by changing those values, you can change the user experience/features for a user on the fly.

Let's say that you're building a new feature, called 'new-button' which changes the color of buttons, which is currently red, to blue. Then you'd change code that looks like this -

@kgrz
kgrz / ToggleHDRCatalina.applescript
Created July 15, 2020 04:39 — forked from lexrus/ToggleHDRCatalina.applescript
Workaround the HDR bug of macOS Catalina 10.15.4
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
activate
delay 1
click menu item "Displays" of menu "View" of menu bar 1
delay 1

Mistakes to Avoid: Docker Antipatterns

Whichever route you take to implementing containers, you’ll want to steer clear of common pitfalls that can undermine the efficiency of your Docker stack.

Don’t run too many processes inside a single container

The beauty of containers—and an advantage of containers over virtual machines—is that it is easy to make multiple containers interact with one another in order to compose a complete application. There is no need to run a full application inside a single container. Instead, break your application down as much as possible into discrete services, and distribute services across multiple containers. This maximizes flexibility and reliability.

Don’t install operating systems inside Docker containers

It is possible to install a complete Linux operating system inside a container. In most cases, however, this is not necessary. If your goal is to host just a single application or part of an application in the container, you need to install only the essential

@kgrz
kgrz / remove_mcafee.md
Created October 15, 2019 03:46 — forked from pjobson/remove_mcafee.md
OSX McAfee Removal

Removal of McAfee from OSX

Note: This was written in 2015, it may be out of date now.

There are a lot of commands here which I use sudo if you don't know what you're doing with sudo, especially where I rm you can severely screw up your system.

There are many reasons which you would want to remove a piece of software such as McAfee, such as not wanting it to hammer your CPU during work hours which seems like primetime for a virus scan.

I intend this to be a living document, I have included suggestions from peoples' replies.

// wip
import * as ts from 'typescript';
import { readFileSync, stat } from 'fs';
import { promisify } from 'util';
const statp = promisify(stat);
const filelist = process.argv;
if (!filelist || !filelist.slice(2).length) {
console.error('need atleast one file.');
@kgrz
kgrz / jessfraz.md
Created June 3, 2019 05:55 — forked from acolyer/jessfraz.md
Containers, operating systems and other fun things from The Morning Paper
@kgrz
kgrz / safari-nomodule.js
Created May 29, 2019 07:32 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
* <script nomodule>alert('no modules');</script>.
*
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
* This allows us to trap the module and nomodule load.
@kgrz
kgrz / 0.md
Created November 6, 2018 07:21 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

@kgrz
kgrz / browser-and-engine.js
Created March 7, 2018 07:03 — forked from derek-knox/browser-and-engine.js
Simple method definition and execution with detailed comments on browser and engine behavior. Anything missing or incorrect in the comment breakdown?
function makeBackgroundBlack() {
document.body.style.backgroundColor = '#000000';
}
makeBackgroundBlack();
/*
- browser parses html
- browser sees <script> - blocks (and downloads if src attr)