Skip to content

Instantly share code, notes, and snippets.

@earnubs
earnubs / vmware-ubuntu-workspace.md
Last active Mar 17, 2020
Ubuntu on VMware with LXD containers
View vmware-ubuntu-workspace.md
View gist:87e6e54cf29d346dbb2305183fca7dd8
diff --git a/packages/shared/compile-template.js b/packages/shared/compile-template.js
index f505702..8ace3db 100644
--- a/packages/shared/compile-template.js
+++ b/packages/shared/compile-template.js
@@ -17,6 +17,18 @@ export function compileFromString(str: string) {
export function compileTemplate(component: Component): void {
if (component.template) {
+ if (component.template.charAt('#') === '#') {
+ var el = document.querySelector(component.template);
View cheatsheet.md

Find minimum in array of things:

$ cat gitlab.json | jq '.locationFactors | min_by(.locationFactor)'

Sort by value, reverse:

$ cat gitlab.json | jq '.locationFactors | sort_by(.locationFactor) | reverse

View bitwise-state-thing.js
//(0b001 << 0b010).toString(2)
const isBuilding = 0b001;
const hasFinished = 0b010;
const hasFailed = 0b100;
let combinedBuildState = 0b000;
combinedBuildState = combinedBuildState | isBuilding;
View trycatch.js
const callApi = () => {
const response = fetch(...);
// do stuff with response
return response;
}
try {
@earnubs
earnubs / Brewfile
Last active May 20, 2019
Bitnami setup
View Brewfile
tap "bazelbuild/tap"
tap "codekitchen/dinghy"
tap "datawire/blackbird"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
cask "osxfuse"
brew "automake"
View gist:e59993102aaf52838a1c6347b12aa5cc
yarn list --json | jq '.data.trees[] | select(.name | contains("caniuse-lite"))'
cat charts.json | jq -r '.data[].attributes | [.name, .home, .description] | @csv' | sed 's/"//g' | awk -F, '{ printf "\n%s (%s)\n%s\n",$1,$2,$3}'
@earnubs
earnubs / index.js
Created Mar 29, 2019
date-fns, days of month
View index.js
const df = require('date-fns');
const today = Date.now();
const tomorrow = df.addDays(today, 1);
function getWorkDaysInMonth(day) {
return df.eachDay(df.startOfMonth(day), df.endOfMonth(day))
.filter(date => !df.isWeekend(date))
.map(date => df.format(date, 'ddd Do'));
}
View .vimrc
set expandtab
set shiftwidth=2
set softtabstop=2
set nu
set path+=**
set clipboard=unnamed
set wildignore+=.git,.DS_Store
set statusline+=%F
set backspace=indent,eol,start
@earnubs
earnubs / docker-ip.js
Created Feb 5, 2019
use dockerode to get container ip address
View docker-ip.js
const Docker = require('dockerode');
const fs = require('fs');
const socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock';
const stats = fs.statSync(socket);
if (!stats.isSocket()) {
throw new Error('Are you sure the docker is running?');
}