Skip to content

Instantly share code, notes, and snippets.

View jtmcdole's full-sized avatar

John McDole jtmcdole

View GitHub Profile
@jtmcdole
jtmcdole / Chapter 70: Threaded Webcrawler
Created March 18, 2013 04:45
Falling in love with Go! Chapter 70 of tour.golang.org asks you to re-write their crawler to use goroutines and to skip already seen URLs. Here's my simple solution. Note; according the what documentation I read, the Go runtime will schedule threads accordingly. One could simply take the incoming URLs and queue them up for a smaller number of ca…
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
@jtmcdole
jtmcdole / .promptrc
Last active April 15, 2024 08:38
My byobu prompt
#!/bin/bash
# modified from byobu's bashrc -- colorize the prompt
# Copyright (C) 2014 Dustin Kirkland
#
# Authors: Dustin Kirkland <kirkland@byobu.co>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
From e7129ae561b328301ddbccddd08b98b8097cee3d Mon Sep 17 00:00:00 2001
From: John Thomas McDole <john@mcdole.org>
Date: Thu, 5 Nov 2015 18:37:32 -0800
Subject: [PATCH] Curses Wide Character & UTF8 Support
---
README.cursesw | 14 +++++++++++
include/config.h | 2 +-
include/wincurs.h | 2 --
src/drawing.c | 9 +++++--
@jtmcdole
jtmcdole / canvas_font_texture.dart
Created May 1, 2016 02:14
simple canvas font texture atlas
import 'dart:async';
import 'dart:html';
import 'dart:convert';
// add <link href='https://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'> to html
// Draw red top, green ascent, and blue height
bool drawBounds = true || window.location.href.contains('drawBounds');
bool drawBox = true || window.location.href.contains('drawBox');
@jtmcdole
jtmcdole / nbonacci.dart
Created May 12, 2018 23:46
p = p-2 + n*p-1
nBonacci(num n, {num a = 0, num b = 1, int max = 10}) {
var seq = <num>[a, b];
for (int i = 0; i < max; i++) {
seq.add(a + b*n);
a = b;
b = seq.last;
}
return seq;
}
@jtmcdole
jtmcdole / ntz.dart
Last active March 27, 2023 04:52
Number of Trailing Zeros - Dart Edition
/// Returns the number of trailing zeros in a 32bit unsigned integer.
///
/// Hacker's Delight, Reiser's algorithm.
/// "Three ops including a "remainder, plus an indexed load."
///
/// Works because each bit in the 32 bit integer hash uniquely to the
/// prime number 37. The lowest set bit is returned via (x & -x).
ntz32(int x) {
assert(x < 0x100000000, "only 32bit numbers supported");
return _ntzLut32[(x & -x) % 37];
@jtmcdole
jtmcdole / main.dart
Created August 5, 2020 17:02
flutter ClipRect + SlideTransition
// Flutter code sample for SlideTransition
// The following code implements the [SlideTransition] as seen in the video
// above:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
@jtmcdole
jtmcdole / capCarve.py
Last active March 26, 2024 20:03
Blender carving a keycap
# Carve legends into keycaps.
#
# This script uses Intersect (knife) to make accurate cuts. The downside is you need to convert
# a text object into a mesh and extrude by just the right amount. We can do this for caps since
# we know how tall the cap-well is.
#
# Unlike knife-project; this doesn't mess with context, view3d, projections, etc.
#
# TODO: save some custom data to layout the keyboard for renderin.
import bpy
@jtmcdole
jtmcdole / KINESIS-Gaming-Freestyle-Edge-RGB-Split.kbd.json
Last active February 15, 2021 05:39
KINESIS Gaming Freestyle Edge RGB Split
[
{
"backcolor": "#000000",
"name": "KINESIS Gaming Freestyle Edge RGB Split",
"author": "codefu",
"switchMount": "cherry",
"switchBrand": "cherry",
"switchType": "MX1A-G1xx"
},
[
@jtmcdole
jtmcdole / README.md
Last active March 15, 2021 00:10
Dartpad Bigπ

Dartpad for Bigπ

Fooling around with Dartpad sharing + Pi day fun.

How many digits of pi do you really need? Not that many it turns out. According to JPL1 you need ~40 to calculate the circumference of the universe to within the width of a hydrogen atom.