This script extracts DENO_DIR
location from deno info
command.
To run this, --allow-run
permission is required.
ref: https://deno.land/manual/getting_started/setup_your_environment#environment-variables
// Save the file to ~/.vim/coc-extensions | |
// Usage: xmap <silent> <TAB> <Plug>(coc-repl-sendtext) | |
const {commands, workspace} = require('coc.nvim') | |
exports.activate = context => { | |
let {nvim} = workspace | |
let terminal | |
context.subscriptions.push(commands.registerCommand('repl.openTerminal', async () => { | |
let filetype = await nvim.eval('&filetype') | |
let prog = '' |
This script extracts DENO_DIR
location from deno info
command.
To run this, --allow-run
permission is required.
ref: https://deno.land/manual/getting_started/setup_your_environment#environment-variables
#!/bin/bash | |
# Create and deploy a Python/Flask "hello world" app on Heroku. | |
# by James Thornton, http://jamesthornton.com | |
# To run it, do: | |
# $ heroku login | |
# $ bash setup.sh helloworld | |
# $ cd helloworld |
type Constructor<T> = new (...args: any[]) => T; | |
type Then<T, R> = (value: T) => R; | |
export function ifInstance<T, R>(instance: Constructor<T>, then: Then<T, R>) { | |
return (value: unknown) => { | |
if (value instanceof instance) { | |
return then(value); | |
} | |
throw value; |
These are my solutions to the RoboScript series of katas on CodeWars.
This Kata Series is based on a fictional story about a computer scientist and engineer who owns a firm that sells a toy robot called MyRobot which can interpret its own (esoteric) programming language called RoboScript. Naturally, this Kata Series deals with the software side of things (I'm afraid Codewars cannot test your ability to build a physical robot!).
.replace
calls as it can lead to unexpected results/* | |
* A simple, non-optimizing brainfuck to C translator. | |
* 2010-08-31 - Version 1.0 (Cory Burgett) | |
* | |
* This code is hereby placed into the public domain. | |
* | |
* Originally located at: http://www4.ncsu.edu/~cmburget/brainfucc.c | |
*/ | |
#include <stdio.h> |
import cache_dir from "https://deno.land/x/dir@1.5.1/cache_dir/mod.ts"; | |
import { ensureDirSync } from "https://deno.land/std@0.152.0/fs/ensure_dir.ts"; | |
export interface Options { | |
prelude?: string; | |
permissions?: string[]; | |
} | |
// deno-lint-ignore no-explicit-any | |
export default function installFn(fn: any, options?: Options) { |
Learning without thought is labor lost; thought without learning is perilous.
— Confucius
Programmer ninjas of the past used these tricks to sharpen the mind of code maintainers.
Code review gurus look for them in test tasks.
Novice developers sometimes use them even better than programmer ninjas.
Read them carefully and find out who you are – a ninja, a novice, or maybe a code reviewer?
function asyncThread(fn, ...args) { | |
if (!window.Worker) throw Promise.reject( | |
new ReferenceError(`WebWorkers aren't available.`) | |
); | |
const fnWorker = ` | |
self.onmessage = function(message) { | |
(${fn.toString()}) | |
.apply(null, message.data) | |
.then(result => self.postMessage(result)); |
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<alt>1']" | |
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<alt>2']" | |
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<alt>3']" | |
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<alt>4']" | |
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-1 "['<alt><shift>1']" | |
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-2 "['<alt><shift>2']" | |
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-3 "['<alt><shift>3']" | |
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<alt><shift>4']" |