Skip to content

Instantly share code, notes, and snippets.

Stephen Stewart earnubs

Block or report user

Report or block earnubs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 {
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'));
}
@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?');
}
@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 keybase.md

Keybase proof

I hereby claim:

  • I am earnubs on github.
  • I am earnubs (https://keybase.io/earnubs) on keybase.
  • I have a public key ASDf4O3J1rj_nt3Ct5n09bM6nNSpyguG6ikOmcymDAJ06wo

To claim this, I am signing this object:

@earnubs
earnubs / rg-to-trello.js
Created May 14, 2018
Send rg results to Trello lane
View rg-to-trello.js
#!/usr/bin/env node
const readline = require('readline');
const request = require('request');
const RateLimiter = require('limiter').RateLimiter;
const limiter = new RateLimiter(5, 'second');
const TRELLO_KEY = process.env.TRELLO_KEY;
const TRELLO_TOKEN = process.env.TRELLO_TOKEN;
You can’t perform that action at this time.