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 / 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
@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
background: linear-gradient(176deg, #3c7b6b, #00ffbe);
background-size: 400% 400%;
-webkit-animation: tealy 48s ease infinite;
-moz-animation: tealy 48s ease infinite;
-o-animation: tealy 48s ease infinite;
animation: tealy 48s ease infinite;
@-webkit-keyframes tealy {
0%{background-position:29% 0%}
50%{background-position:72% 100%}
100%{background-position:29% 0%}
@roc
roc / debugmocha.sh
Created August 14, 2015 11:46
Interactive mocha debugging
# add debugger; statement to your specific mocha test/file you are testing first
# install node-inspector
npm install -g node-inspector
# open node-inspector in separate terminal/tmux/whatever
node-inspector
# open node-inspector in a browser
open http://127.0.0.1:8080/debug?port=5858
# run mocha
mocha [whatever options you normally include] --debug-brk
# wait for ages for the inspector to load in the browser, but it will load!
@roc
roc / npm.freeze.sh
Created May 15, 2015 13:28
npm freeze
npm ls | grep -E "^(├|└)─" | cut -d" " -f2 | awk -v quote='"' 'BEGIN { FS = "@" } ; { print quote $1 quote,":",quote $2 quote"," }' | sed -e 's/ :/:/g'