Skip to content

Instantly share code, notes, and snippets.

@femto113
femto113 / five-five.py
Created August 5, 2022 03:37
five five-letter words with twenty-five unique letters
# this expects to be run in a directory with a file named "words" with one valid word per line
# for testing I used one found here:
# https://github.com/tabatkins/wordle-list
# On a 2022 MacBook Air this takes about 15 minutes to process
def pick(rack, words):
used_letters = set("".join(rack))
if len(used_letters) > 20:
print(" ".join(rack))
return
@femto113
femto113 / covid-bluffs.html
Last active April 13, 2020 17:48
Plot of COVID-19 cases by state in the style evocative of Joy Division's Unknown Pleasures album cover
<!DOCTYPE html>
<html>
<head>
<style>
/* so body text will match the chart */
ul li { font-family: sans-serif; }
svg {
display: block;
var fs = require("fs");
var Github = require("github");
var package = JSON.parse(fs.readFileSync('./package.json'));
var username_password_user_repo = package.repository.url.match(/(?:https?:\/\/|git)(?:([^:@\/]+)(?::([^@]+))?)?@?github.com[:\/]([^:\/.]+)\/([^\/.]+).git$/).slice(1);
var github = new Github({
// required
version: "3.0.0",
// optional
year Class of 2029 Class of 2028 Class of 2027 Class of 2026 Class of 2025 Class of 2024 Class of 2023 Class of 2022 Class of 2021 Class of 2020 Class of 2019 Class of 2018 Class of 2017 Class of 2016 Class of 2015 Class of 2014 Class of 2013 Class of 2012 Class of 2011 Class of 2010 Class of 2009 Class of 2008 Class of 2007 Class of 2006
2006 45 86 81 136 128 139 146 134 109 105 102 83
2007 51 80 99 86 129 136 146 154 109 107 96 101
2008 69 104 122 112 90 147 147 146 127 103 93 96
2009 55 88 117 134 118 124 155 143 129 120 93 91
2010 53 117 125 136 148 168 135 177 125 125 117 88
2011 74 124 173 156 164 241 190 156 142 122 116 114
2012 84 133 203 221 172 275 271 197 139 138 117 113
2013 105 153 191 231 241 300 292 275 192 132 130 112
2014 99 240 242 260 274 409 316 311 244 182 125 117
@femto113
femto113 / generate.c
Last active March 3, 2019 01:29 — forked from munificent/generate.c
A random dungeon generator that (no longer) fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
// 2008-2019
const int H = 40;
const int W = 80;
int m[H][W];
int g(int x)
@femto113
femto113 / gist:f6ef14d208e21a119b78
Last active August 29, 2015 14:15
javascript injected by Superfish from www.best-deals-products.com onto Lenovo laptops
// retrieved from https://www.best-deals-products.com/ws/sf_main.jsp?dlsource=hdrykzc on 2015-02-19
if (window == top && !window.similarproducts && navigator.appVersion.toLowerCase().indexOf('msie 7') == -1) {
(function() {
var windowLocation = location.href.toLowerCase();
var nofish = false;
var metaTags = document.getElementsByTagName('meta');
var metaTag;
for (var i = 0, l = metaTags.length; i < l; i++) {
@femto113
femto113 / service-port.js
Created January 23, 2014 08:05
canonical web service port numbering scheme. See blog post for details: http://www.codesuck.com/2014/01/a-simple-canonical-port-numbering.html
// given a service name return a canonical TCP port number in the range of 1024 - 33791
function port(serviceName)
{
// replace any invalid digits with valid ones
serviceName = serviceName.replace(/[^A-Va-v0-9]/g, mapSpecialChar);
// take the first 3 characters (= first 15 bits), right padding with 0 as necessary
serviceName = (serviceName + '00').substring(0, 3);
// interpret as 15-bit, base32 encoded int,
// then add 1024 to clear the restricted ports
return parseInt(serviceName, 32) + 1024;
var cluster = require('cluster');
var numCPUs = parseInt(process.argv[2]) || 1;
var MESSAGE_BURST = 10; // how many messages are sent by master in each round
var WORK_COST = 128; // factor to slow down average message handling cost in each worker
var REPORTABLE_WORK = 100; // how often worker reports its accomplishments
var ready_workers = [];
if (cluster.isMaster) {
@femto113
femto113 / bootstrap_chef.bash
Created November 30, 2012 00:18 — forked from chrismdp/bootstrap_chef.bash
Bootstrap Chef Solo on Ubuntu
#!/usr/bin/env bash
# call like this on the target server:
# NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='git@example.com:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 )
# You will need to ensure that the ssh key is already set up on the server.
set -e
export CHEF_DIR="${HOME}/chef"
sudo rm -rf $CHEF_DIR
mkdir -p "$CHEF_DIR"
@femto113
femto113 / LICENSE.txt
Created February 20, 2012 08:50 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
Copyright waived, this code is in the public domain.