Skip to content

Instantly share code, notes, and snippets.

@joeytwiddle
joeytwiddle / 1_small_repos_first_please.md
Last active July 23, 2020 21:08
Me complaining about GitHub notification UI v2

This is what I sent to GitHub's feedback form (plus a few edits)

The new notifications page is blocking me from working on small open source projects!

The first thing I want to do is see the projects with the least new notifications. But you have truncated them off the bottom of the list! (The list down the left-hand side.)

With the old UI, I used to immediately scroll to the bottom, and interact with the small projects first, before reading the notifications of larger projects.

Why? Because these small activity projects are more likely to be projects with only a few contributors, where I can make the most impact. Sometimes they are even my own projects. These are usually the projects of most interest to me.

@joeytwiddle
joeytwiddle / nn-images.html
Last active November 17, 2019 06:51
A neural network to generate images
<html>
<body>
<canvas id="canvas" width="512" height="512"></canvas>
<!-- <script src="./nn-image.js"></script> -->
<script>
class Network {
layers = []
weightsLayers = []
@joeytwiddle
joeytwiddle / github_get_all_forks.sh
Last active October 13, 2023 20:50
Add all forks of the current repo as remotes
#!/usr/bin/env bash
set -e
# See also: https://github.com/frost-nzcr4/find_forks (same thing but in python)
origin_url="$(git remote show origin | grep 'Fetch URL:' | sed 's+.*: ++')"
full_repo_name="$(echo "$origin_url" | sed 's+.*github.com/++ ; s+\.git$++')"
forks_url="https://api.github.com/repos/${full_repo_name}/forks"
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const fn = (ms) => delay(ms).then(() => console.log('done after ' + ms));
// Sequential
async function test1() {
const [one, two] = [await fn(2000), await fn(1000)];
console.log('mikael1 finished');
}

Asking Good Questions

Suggestions to help you ask good questions on StackOverflow, GitHub issues and IRC, as well as when asking colleagues face-to-face.

General rule: Put at least as much effort into the question as you would like others to put into the answer.

Preparation

  1. Check that you have the latest version of the software. (The bug might have already been fixed.)

Preamble

I have used WebStorm at work for the past three years. But last month I used VSCode exclusively for four weeks, because I wanted to learn it. I noted my observations here.

Eventually, as a deadline approached, I switched back to WebStorm. Why? VSCode is very good, and I was impressed. But I still find WebStorm is slightly better at a few things which I use very frequently. These small improvements really add up when I'm trying to get stuff done.

In keeping with the Pareto principle, small advantages with only a few commonly used features are enough to make one editor stand out for me. Specifically, "Go to Definition/References", "Searching" and "Carrying imports" are so important, that just making these more convenient means that all other concerns are irrelevant.

So, for the reader's convenience, these are the first few features I will address below.

#!/usr/bin/env bash
set -e
cache_dir="$HOME/Library/Group Containers/K36BKF7T3D.group.com.apple.configurator/Library/Caches/Assets/TemporaryItems/MobileApps"
if command -v find >/dev/null && command -v mktemp >/dev/null && command -v unzip >/dev/null && command -v grep >/dev/null
then :
else
echo "This script requires the follow executables to run: find mktemp unzip grep"
@joeytwiddle
joeytwiddle / asyncWrappersForRestify.js
Last active October 7, 2019 02:57
Helper to use promises in restify (might also work for express)
/**
* Use restify with promises
*
* Restify middleware and route handlers are passed a callback function `next`
* which must be called on success, or on an error.
*
* But you may prefer to define your middleware and routes using promises or
* async functions instead of using callbacks.
*
* To achieve that, simply wrap your middleware functions in `middleware()` and
@joeytwiddle
joeytwiddle / cooldown-monitor.js
Created April 30, 2019 04:40
Cooldown Monitor
"use strict";
/*
Simulates an object which can heat up and overheat, but with a constant rate of cooling over time.
Useful for throttling when you want to provide an initial allowance.
For example, it could be used to manage the overheating of a weapon in a game, or to avoid errors from generating huge logfiles, but without throttling the first few errors.
@joeytwiddle
joeytwiddle / move_dropbox_to_ext4_fs.sh
Created November 6, 2018 05:07
Creates a file with an ext4 filesystem inside it, and moves Dropbox into that filesystem
#!/bin/bash
set -e
set -x
# You could put the fs file and the mountpoint inside your home folder
#new_fs_file="$HOME/dropbox_partition.ext4fs"
#mountpoint="$HOME/Dropbox.mnt"
# But that may not work if you are using a fuse-mounted homefolder (e.g. encrypted with encfs)
new_fs_file="/home/dropbox_for_$USER.ext4fs"
mountpoint="/mnt/dropbox.$USER"