Skip to content

Instantly share code, notes, and snippets.

@jtacoma
jtacoma / index.md
Last active August 29, 2015 14:08
UTF is not a character encoding

[Unicode transformation formats (UTF)][utf] is not a character encoding. It is a family of mutually incompatible character encodings that are each capable of expressing the full range of possible Unicode characters.

Microsoft desktop applications that deal with plain text files, e.g. Notepad and Excel, use [UTF-16LE][utf16] under the name Unicode. Newer versions also offer UTF-16BE under the name Unicode big endian. An idiosyncrasy of Microsoft applications is that the character encoding of a plain text file is declared in a [byte order mark (BOM)][bom] at the beginning of the file. This works like magic in many cases, but results in a few garbled characters at the beginning of the file when the BOM is not respected as such.

While the preferred encoding for web applications these days is [UTF-8][utf8], not all platforms allow custom content to declare its character encoding. Even Microsoft's own IIS doesn't respect the [BOM][bom]. Plain text file formats like CSS and JavaScript that, unlike XML an

@jtacoma
jtacoma / index.html
Last active August 29, 2015 14:01
libswe demo
<html>
<head>
<script src="https://github.com/jtacoma/libswe/releases/download/v2.00.00-1alpha0/libswe.js"></script>
</head>
<body>
<p>
The current time, as a Julian Day Number in Universal Time, as
calculated by the Swiss Ephemeris is:
</p>
<p>
@jtacoma
jtacoma / net35.diff
Created February 7, 2014 15:40
Apply this diff to bfc0349506fc8d2ea80e80eb36cbd838092313a6 of zeromq/netmq to make it compatible with .Net 3.5, thanks to https://gist.github.com/tobi-tobsen/6389448 for an earlier version of this patch.
diff --git a/src/NetMQ.Tests/NetMQ.Tests.csproj b/src/NetMQ.Tests/NetMQ.Tests.csproj
index bb7590e..5d4f9f8 100644
--- a/src/NetMQ.Tests/NetMQ.Tests.csproj
+++ b/src/NetMQ.Tests/NetMQ.Tests.csproj
@@ -12,6 +12,8 @@
<AssemblyName>NetMQ.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
@jtacoma
jtacoma / Dockerfile
Created January 25, 2014 21:14
Dockerfile for ZeroMQ 4.x development
FROM ubuntu
MAINTAINER Joshua Tacoma <[email protected]>
RUN apt-get install -y build-essential git libtool
RUN git clone https://github.com/jedisct1/libsodium && cd libsodium && ./autogen.sh && ./configure && make check install && ldconfig && cd ..
RUN git clone https://github.com/zeromq/zeromq4-x && cd zeromq4-x && ./autogen.sh && ./configure && make check install && ldconfig && cd ..
RUN git clone https://github.com/zeromq/czmq && cd czmq && ./autogen.sh && ./configure && make check install && ldconfig && cd ..
@jtacoma
jtacoma / conventions.md
Last active December 27, 2015 23:19
Conventions

Lately, I've been trying to get started on porting Hula Hoop (an Android app based on the GDX game programming library and the Box2D physics library) to C/C++. Of course, it's of utmost importance to shave a few yaks before getting started.

First Steps

GNU/Linux is a software development environment in much the same way that git is a source code management tool: they're both of the "choose your own convention" variety so common in the Unix culture (linfo.org, joelonsoftware.com). Some things I've figured out so far:

  • If the app is going to be built for a variety of platforms, I'm going to need to build the dependecies for those platforms too. That means I don't want to depend on system-wide library installations, and
@jtacoma
jtacoma / bar.go
Last active December 19, 2015 19:19
foo to bar
// Package bar provides thneeds (things everyone needs).
//
// Those switching from "example.com/pkg/foo" to bar will have to run the
// following commands (which are intended to be idempotent).
//
// go fmt -r 'a.ChopTruffulaTree(b) -> a.ChopTruffulaTrees(b, b, b, b, b)'
//
// Of course, if you're using sufficiently smart tools, your code may already
// be updated.
//
package main
import (
"log"
"time"
zmq "github.com/alecthomas/gozmq"
)
func main() {

Changing the Public API

When I started looking for ways to help on the "github.com/alecthomas/gozmq" package a few months ago, a recurring topic in discussions was that an earlier decision to provide a hidden struct type through a public interface type had become restrictive. We couldn't just drop the interface and make the struct public because that would be backwards-incompatible. Or could we?

No

This had to be the first considered option, and was the standing decision at the time. If we could continue providing what the package aims to provide without breaking backwards compatibility, then by all means, we should not break it.

Unfortunately this meant we couldn't provide all that we aimed to provide. Or could we?

@jtacoma
jtacoma / .gitignore
Last active December 13, 2015 20:18
gozmqgen: some scripts for generating ZMQ-related Go code.
.cache
getsockopt-*.go
setsockopt-*.go
socket*.go
@jtacoma
jtacoma / echo.go
Last active December 12, 2015 04:09
A sample gozdcf-based application.
// Though it's not necessary, you might want to run this with environment
// variable GOMAXPROCS set to the number of CPUs on your machine.
//
// For example, at a bash prompt:
//
// $ GOMAXPROCS=4 go run echo.go
//
package main
import (