Skip to content

Instantly share code, notes, and snippets.

View progrium's full-sized avatar

Jeff Lindsay progrium

View GitHub Profile
@progrium
progrium / README.md
Last active April 7, 2024 21:42
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

@progrium
progrium / cli.go
Created September 2, 2021 01:13
350 line reimplementation of cobra, simplified and with no dependencies
package cli
import (
"bytes"
"context"
"flag"
"fmt"
"os"
"reflect"
"strings"
@progrium
progrium / badger.html
Created October 23, 2011 14:54
Proof of concept for entirely self-contained HTML badge printing system
<html>
<head>
<style type="text/css">
svg { margin-left: -2000px; }
</style>
<script type="text/javascript" src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"> </script>
@progrium
progrium / gist:956006
Created May 4, 2011 20:50
Greenlet exception handling in gevent
import gevent
import gevent.pool
class GroupWithExceptionCatching(gevent.pool.Group):
def __init__(self, *args):
super(GroupWithExceptionCatching, self).__init__(*args)
self._error_handlers = {}
def _wrap_errors(self, func):
"""Wrap a callable for triggering error handlers
#!/bin/sh
apptron app indicator - ./icon.png <<MENU |
Timers
5 seconds
10 seconds
30 seconds
Say Hello
---
Quit
MENU
@progrium
progrium / datetimeformat.js
Last active November 20, 2021 04:02
Intl.DateTimeFormat is kinda nutty with custom format strings, this makes it sane
function dateTimeFormat(timestamp, locale, str, ...opts) {
const d = new Date(timestamp);
return str.replace(/{(\d+)}/g, function(match, number) {
return typeof opts[number] != 'undefined'
? new Intl.DateTimeFormat(locale, opts[number]).format(d)
: match;
});
}
console.log(dateTimeFormat("2021-11-19T19:19:36.598071-06:00", "en", "{0} at {1}!", {dateStyle:"short"}, {timeStyle:"long"}))
// styling module provides a helper for building style
// and class attributes for elements.
type Styling = string | Object | Style | (() => boolean);
type ConditionedStyle = [string, () => boolean];
export function from(...styling: Styling[]): Style {
return Style.from(...styling);
}
@progrium
progrium / README.md
Last active October 17, 2021 18:33
Large Type CLI utility for Mac in less than 80 lines of Go

largetype

largetype screenshot

Building

Note: For now, Apple Silicon users need to be set up for x86 mode

First, download Go or brew install go. Then, put largetype.go in a directory called largetype and from there run:

$ go mod init largetype
@progrium
progrium / server.go
Created August 25, 2021 15:59
simple qtalk rpc server example
// server.go
package main
import (
"fmt"
"log"
"net"
"strings"
"github.com/progrium/qtalk-go/codec"
@progrium
progrium / client.go
Last active August 25, 2021 15:58
simple qtalk rpc example client
// client.go
package main
import (
"context"
"log"
"github.com/progrium/qtalk-go/codec"
"github.com/progrium/qtalk-go/fn"
"github.com/progrium/qtalk-go/talk"