Skip to content

Instantly share code, notes, and snippets.

View boblauer's full-sized avatar

Bob Lauer boblauer

  • ClassDojo
  • Chicago
View GitHub Profile
@asleepace
asleepace / try.ts
Last active September 3, 2024 20:37
A simple extension for TypeScript which enables the `.try(args)` method on functions. This works for both normal & async functions, and reduces a lot of boilerplate.
// Try.ts
// By Colin Teahan
// August 14th, 2024
//
// This TypeScript file enables usage of the .try() method which will return a result tuple of [T?, Error?]
// from any function or async function. This works by defining a new property on the global Object.prototype
// and then do some type-fu.
//
// Example usage:
// https://www.typescriptlang.org/play/?target=99#code/MYewdgziA2CmB0w4EMBOAKAlAKGwejwAJCAVVAT3gBcJ8jCAhcwgYRgEsxTZkALZMHWIBBAK4BzURCqEAjABYqvADSEATAAY18ukNK92EUuQAOsAMrBU7EzIBm7OIVhhkAIzhGpycbEIg7QiU-agosQgBbWCUQABNCAHcDYF5Ex2hCVGjRVC5kTNgIUWgZKlETJwDCAG0SAH5VAFFUVBBUOoBdPTtWiMIBZjtRMGAqdnB-VH6IchHCIZGx8Hh9Q0S2gGsjN2ZY2AcwTnF+wjBYBMITVrNUKmYJ4MJxaBA3ZAyAeTcAK1hR+CuICoQNMsD0AniwS4sRAhCgUSCoIAtEN4LoCMRGgAPZARCp+by+ABc6PoC1G4y4vioAFUILBUEwAJKxdDsWJE06iCJuBmYQgAbz0xGI7ECbPiAB4ALyEDT8pStC5nC7NVoYADknAAbu92YQpAzCOyNTgMSLiFkyrlBadcbBORqGK8Nap9QBfPSegh6UCQGTVQ2oVQM9UdQiy6l0hnM2KhcjoeWESVIpHOFptNLQDK8grWs6xX3gaQ1IMhjOocOR6LRxnkFnx9CyfkptNBwhOl3GoxWnIF0nEAByHxIjU5JAMRjW0nSJwSm2NXEB4iyECMEO7pyBcNE
@jesstelford
jesstelford / 01-shape-up-to-kindle.md
Last active November 17, 2024 13:20
Read SHAPE UP by basecamp on a Kindle / reMarkable / eReader

Read Shape Up by basecamp on a kindle / reMarkable / eReader

Basecamp's new book Shape Up is now available online (https://basecamp.com/shapeup) to read page-by-page.

There is a .pdf version, but that's not the best format for Kindle / other eReaders. Instead, we can convert the page-by-page into an eReader friendly format.

Part 1: Convert to a single page

NOTE: This has only been tested on Chrome

@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});