Skip to content

Instantly share code, notes, and snippets.

@janpaul123
janpaul123 / permutations.js
Created February 12, 2018 15:56
Number of unique corners for given color / dot schemes
const uniq = require('lodash/uniq');
function permutations(n, colors, arr) {
if (!n) return [arr];
if (!arr) arr = [];
let ret = [];
for (let i = 0; i < colors; i++) ret = ret.concat(permutations(n - 1, colors, arr.concat([i])));
return ret;
}
@janpaul123
janpaul123 / FastScrollComponent-test.js
Created May 18, 2018 20:47
Copyright: Remix Software; License: MIT
/* eslint-disable react/prop-types */
import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import FastScrollComponent from './FastScrollComponent';
describe('<FastScrollComponent>', function() {
const setupComponent = ({ cacheWhenNotVisible = false, height = 100 }) => {
// eslint-disable-line react/prop-types
const rowHeight = 25;
@janpaul123
janpaul123 / reorder-rosbag.py
Created January 7, 2020 23:17
Read an "input.bag" ROS bag with messages stored in arbitrary order, and write to "output.bag" ordered by receive time (required by Webviz to read)
import rosbag
with rosbag.Bag('output.bag', 'w') as outbag:
for topic, msg, t in rosbag.Bag('input.bag').read_messages():
outbag.write(topic, msg, t)
@janpaul123
janpaul123 / find-removed-videos.sh
Created December 20, 2020 21:34
Find all Youtube videos in my archive which have since been removed
#!/bin/bash
set -Eeuxo pipefail
# Install youtube-dl
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /tmp/youtube-dl
chmod a+rx /tmp/youtube-dl
# Create /tmp/print-missing-youtube.sh script.
echo '#!/bin/bash' > /tmp/print-missing-youtube.sh