Skip to content

Instantly share code, notes, and snippets.

@roc
roc / .deno_prompt_for_zshrc
Created January 31, 2021 17:11
Echo out the current deno version in a powerlevel9k segment
# print the current version of deno in prompt
function prompt_my_deno_version() {
local vers=`deno -V`
p10k segment -b '#0F467A' -f 'white' -i '🦕' -t ${vers//"deno "/""}
}
# ...
# Customise the Powerlevel9k prompts
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@roc
roc / .slate
Created May 5, 2020 09:25
Slate config 5-may-2020
# GLOBAL CONFIGURATIONS
# -------------------------------------------------------------------
# See https://github.com/jigish/slate/wiki/Global-Configs
config defaultToCurrentScreen true
config secondsBeforeRepeat 0.4
config secondsBetweenRepeat 0.1
config keyboardLayout "qwerty"
config nudgePercentOf screenSize
config resizePercentOf screenSize
// async fs directory listing
// https://nodejs.org/api/fs.html#fs_fs_promises_api
const fs = require('fs').promises;
const bytes = require('bytes');
const relativeDate = require('tiny-relative-date');
const getHumanReadable = stats => {
// filesize
// date modified
@roc
roc / promise-wrapper.js
Last active August 6, 2017 13:53
wrap a callback bound function in a promise
// mercilessly culled from npm-promisify
const alreadyAPromise = o => o && typeof o.then === "function" && typeof o.catch === "function";
// As simple as I can get it:
// wrap a function, apply a callback
// return the callback response in Promise.resolve
//
// NB. This doesn't handle node style err first
// callbacks with a rejection, but you could...

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@roc
roc / today.md
Last active May 2, 2016 14:09
Show a calendar with today's date highlighted
cal | GREP_COLOR='1;32' grep -w -A4 -B6 --color "$(date +%e)"

Alias with

alias today="cal | GREP_COLOR='1;32' grep -w -A4 -B6 --color "$(date +%e)"
# or add to .aliases file
(echo ""; echo alias cal | GREP_COLOR='1;32' grep -w -A4 -B6 --color "$(date +%e)"') >> ~/.aliases
RIP Onload - Finding a better measurement yardstick
---------------------------------------------------
(Soasta)
- Buddy Brewer
- Philip Tellis
@roc
roc / techtest.md
Last active January 18, 2016 10:24 — forked from chrisns/techtest.md

JS technical test

Starter

  • Do you know anything about HOD? GDS/etc — can give quick introduction
  • What have you been working on recently? Good things/bad things?
  • Familiar with agile? How have you been working with your team?

What don't you like about:

  • JS/angular/backbone/ember
# GLOBAL CONFIGURATIONS
# -------------------------------------------------------------------
# See https://github.com/jigish/slate/wiki/Global-Configs
config defaultToCurrentScreen true
config secondsBeforeRepeat 0.4
config secondsBetweenRepeat 0.1
config keyboardLayout "qwerty"
config nudgePercentOf screenSize
config resizePercentOf screenSize
@roc
roc / write_as_root
Created December 19, 2013 08:10
You started editing a file in vim and you did a great job and now you're going to save it and OH IT'S OWNED BY ROOT but you know what...
:w !sudo tee %