Skip to content

Instantly share code, notes, and snippets.

@joewalker
joewalker / ssh.js
Created February 23, 2022 14:36
Prototype SSH version of ZX
// @ts-check
import { readFile } from 'fs/promises';
import { Client } from 'ssh2';
import { ProcessPromise, ProcessOutput, $ } from 'zx';
import chalk from 'chalk';
/**
* @typedef {import('ssh2/lib/Channel.js').Channel} Channel)}
* @typedef {import('./ssh-types').HostConfig} HostConfig
* @typedef {import('./ssh-types').SshZx} SshZx
@joewalker
joewalker / flatmap.js
Created May 11, 2017 16:43
Annoying flow problem
// @flow
type FlatMapMapper<In, Out> = (elem: In, index: number, arr: In[]) => Out | Out[];
function flatMap<In, Out>(arr: In[], mapFunc: FlatMapMapper<In, Out>): Out[] {
const result = [];
for (const [ index, elem ] of arr.entries()) {
const x = mapFunc(elem, index, arr);
// We allow mapFunc() to return non-Arrays
if (Array.isArray(x)) {
@joewalker
joewalker / repl_against_tofino.clj
Created December 12, 2016 17:48
Get a repl that allows you to use your tofino profile to practice your datascript
; $ cd .../datomish
; lein repl
(require '[datomish.api :as d])
(require '[datomish.sqlite])
(require '[datomish.jdbc-sqlite])
(require '[clojure.core.async :as async])
; You'll need to replace $HOME with whatever $HOME is, and if not on a mac, do something AppData like
import webpack from 'webpack';
import config from './webpack.config';
import { mapObject } from './web/util/util';
export const original = config;
/**
* Development config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.dev.js
@joewalker
joewalker / webpack.mutate.js
Created January 27, 2016 21:32
Keep your core webpack config simple and mutate it with ES.whatever Object Rest/Spread
import webpack from 'webpack';
import config from './webpack.config';
import { mapObject } from './web/util/util';
export const original = config;
/**
* Development config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.dev.js
function decorate(func) {
return func();
}
function Foo(name) {
this.name = name;
}
Foo.prototype = {
function trim(value) {
return value.replace(/\[\]/g, '').replace(/\{\}/g, '').replace(/\(\)/g, '');
}
function braces(value) {
while (true) {
var newValue = trim(value);
if (value === newValue) {
return (value === '' ? 'YES' : 'NO');
@joewalker
joewalker / nesting_tojson.js
Created July 27, 2015 11:48
What happens if you nest toJSON functions?
var obj = {
foo: 'foo',
toJSON: function() {
return {
bar: 'bar',
toJSON: function() {
return {
baz: 'baz'
};
@joewalker
joewalker / designer.html
Created December 17, 2014 16:59
designer
<link href="../paper-input/paper-input.html" rel="import">
<link href="../paper-button/paper-button.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;

Keybase proof

I hereby claim:

  • I am joewalker on github.
  • I am joewalker (https://keybase.io/joewalker) on keybase.
  • I have a public key whose fingerprint is 4095 0774 8EC8 CFB7 6F38 86AB 1074 915B 5725 BBE4

To claim this, I am signing this object: