Monday, November 7, 2016
There's an app for that
Sharing little code snippets on this blog is fine in its own right, but there's a platform out there specifically for that - GitHub Gist (https://gist.github.com/). I think from now on, rather than paste it here, I'd upload it to Gist and link.
Tuesday, September 13, 2016
JavaScript says "beep"
UPDATE: it's now a Gist.
UPDATE: better with a blob: URL.
Today's snippet: generating a simple musical tone purely from JavaScript. I saw some online samples for doing it on a server (e. g. in PHP) and sending to the client, but that's a waste of bandwidth.
The ingredients are twofold:
Today's snippet: generating a simple musical tone purely from JavaScript. I saw some online samples for doing it on a server (e. g. in PHP) and sending to the client, but that's a waste of bandwidth.
The ingredients are twofold:
- An <audio> element with a source that's populated from a data: URI
- An ArrayBuffer object with WAV data inside
Sunday, May 8, 2016
You can try or you can __try
Some time ago, I've outlined a technique for wrapping a C++ fragment in a Structured Exception Handling (SEH) crash catcher. It involved a rather convoluted sequence of C++ to C back to C++ calls.
Thursday, April 21, 2016
UTF-8 in Transact-SQL: no CLR necessary
UPDATE: it's now a Gist.
While we're on the subject of Transact-SQL utilities, here's one for converting a Unicode string (as NVARCHAR) to a UTF-8 binary data block. It works correctly with non-UCS2 strings encoded as UTF-16. To make sure, try it on a string with an Emoji character, for example, N'😂'. That's codepoint U+1F602, the widely smiling face.
While we're on the subject of Transact-SQL utilities, here's one for converting a Unicode string (as NVARCHAR) to a UTF-8 binary data block. It works correctly with non-UCS2 strings encoded as UTF-16. To make sure, try it on a string with an Emoji character, for example, N'😂'. That's codepoint U+1F602, the widely smiling face.
Saturday, April 16, 2016
Your software WILL crash.
When reporting on unhandled .NET exceptions, don't use the builtin Exception.StackTrace. Instead, construct an instance of System.Diagnostics.StackTrace with the exception object as the parameter, and generate your own trace. The difference is, with the latter, you can get offset to the crash point within the method.
Friday, April 15, 2016
Object Linking and Embedding Database
Recently, I've been messing with a database API I've never used directly before, even though I've been using it all the time. I'm talking about OLE DB, the interface behind ActiveX Data Objects (ADO).
MurmurHash in Transact-SQL
UPDATE: it's now a Gist.
UPDATE: now in Pascal too.
UPDATE: now for MySQL too.
Sometimes, one needs an intermediate strength hash. Something less collision prone than CRC32 or Adler-32, but smaller and less costly than MDx or SHAxxx. My favorite for a while has been MurmurHash64 - it produces a 64-bit value, just the right size to fit into a scalar variable in a C program, or a bigint database field.
UPDATE: now in Pascal too.
UPDATE: now for MySQL too.
Sometimes, one needs an intermediate strength hash. Something less collision prone than CRC32 or Adler-32, but smaller and less costly than MDx or SHAxxx. My favorite for a while has been MurmurHash64 - it produces a 64-bit value, just the right size to fit into a scalar variable in a C program, or a bigint database field.
Subscribe to:
Posts (Atom)