Skip to content

Instantly share code, notes, and snippets.

View localip
#! /usr/bin/env node
const os = require('os');
const getNetworkAddress = (interfaces) => {
for (const name of Object.keys(interfaces)) {
for (const interface of interfaces[name]) {
const {address, family, internal} = interface;
if (family === 'IPv4' && !internal) {
return address;
@VonHeikemen
VonHeikemen / esm.json
Last active Feb 10, 2021
Create a productive environment for small personal scripts. Only try this at home.
View esm.json
{
"cache": false,
"await": true
}
@VonHeikemen
VonHeikemen / complete-rc.vim
Last active Jan 24, 2021
make vim into a nice editor with this completely pluginless rc
View complete-rc.vim
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Don't include vi compatibility
set nocompatible
" Sensible backspace
set backspace=indent,eol,start
@VonHeikemen
VonHeikemen / better-netrw.vim
Last active Jan 8, 2021
Making a more intuitive netrw
View better-netrw.vim
" Open Netrw on the directory of the current file
nnoremap <leader>dd :Lexplore %:p:h<CR>
" Toggle the Netrw window
nnoremap <Leader>da :Lexplore<CR>
if &columns < 90
" If the screen is small, occupy half
let g:netrw_winsize = 50
else
View rc.vim
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Don't include vi compatibility
set nocompatible
" Sensible backspace
set backspace=indent,eol,start
@VonHeikemen
VonHeikemen / example-transducers-v3.js
Last active Dec 28, 2020
Transducers (in javascript) in action.
View example-transducers-v3.js
// Getting some stats from https://dev.to/dashboard
// Inspired by this: https://dev.to/tylerlwsmith/get-your-dev-2020-year-in-review-scraping-data-using-the-console-3gen
function compose(...fns) {
const apply = (arg, fn) => fn(arg);
return (initial) => fns.reduceRight(apply, initial);
}
function to_transducer(reducer) {
if(typeof reducer['@@transducer/step'] == 'function') {
@VonHeikemen
VonHeikemen / example-transducers-v2.js
Created Dec 26, 2020
Contrived example of transducer in action
View example-transducers-v2.js
// Common Utilities
function compose(...fns) {
const apply = (arg, fn) => fn(arg);
return (initial) => fns.reduceRight(apply, initial);
}
function curry(arity, fn, ...rest) {
if(arity <= rest.length) {
return fn(...rest);
@VonHeikemen
VonHeikemen / example-transducers-v1.js
Created Dec 26, 2020
Contrived example of transducers in action
View example-transducers-v1.js
// Common Utilities
function compose(...fns) {
const apply = (arg, fn) => fn(arg);
return (initial) => fns.reduceRight(apply, initial);
}
function curry(arity, fn, ...rest) {
if(arity <= rest.length) {
return fn(...rest);
@VonHeikemen
VonHeikemen / Taskfile.js
Created May 19, 2020
minimal, no dependencies task runner for deno.
View Taskfile.js
// Command line usage examples:
// 1: deno run --allow-run ./Taskfile.js start
// 2: deno run --allow-run ./Taskfile.js echo "what?"
// 3: deno run --allow-run ./Taskfile.js do-stuff one two three
run(Deno.args, {
start() {
exec.cmd('deno run ./src/index.js');
},
@VonHeikemen
VonHeikemen / .env
Created Mar 29, 2020
functional programming stuff... in js.
View .env
ENV=development
HOST=http://localhost:5000