Skip to content

Instantly share code, notes, and snippets.

View zaach's full-sized avatar
🎯
Focusing

Zach Carter zaach

🎯
Focusing
View GitHub Profile
@zaach
zaach / turing-types.ts
Created November 26, 2020 05:29
turing machine simulator using TS types
// Natural Numbers
interface Zero {
isZero: true;
}
interface Successor<N extends Nat> {
prev: N;
isZero: false;
}
type Nat = Zero | Successor<Nat>;
@zaach
zaach / po2json.js
Created February 4, 2012 19:59
PO parser from http://jsgettext.berlios.de/lib/Gettext.js adapted for Node.js and modified to be more like po2json.pl
#!/usr/bin/env node
/*
PO parser from http://jsgettext.berlios.de/lib/Gettext.js
adapted for Node.js and modified to be more like po2json.pl
- Zach Carter <zcarter@cse.usf.edu>
*/
/*
Pure Javascript implementation of Uniforum message translation.
@zaach
zaach / gist:5061155
Last active December 22, 2022 19:06
Taming Configurations with node-convict

Taming Configurations with node-convict

In this installment of "A Node.JS Holiday Season" series we'll take a look at node-convict, a tool to help manage the configuration of node.js applications.

There are two main concerns regarding application configuration:

  • Most applications will have at least a few different deployment environments, each with their own configuration needs.
  • Including credentials and sensitive information in source can be problematic.
@zaach
zaach / 0_new.md
Created January 22, 2012 23:15
New Jison 0.3 features

Some improvements have been made for parser and lexer grammars in Jison 0.3 (demonstrated in the FlooP/BlooP example below.)

For lexers:

  • Patterns may use unquoted characters instead of strings
  • Two new options, %options flex case-insensitive
  • flex: the rule with the longest match is used, and no word boundary patterns are added
  • case-insensitive: all patterns are case insensitive
  • User code section is included in the generated module
@zaach
zaach / workflow.md
Created January 26, 2010 21:10 — forked from gstark/workflow.md

Semantic Versioning

Details:

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

@zaach
zaach / ackermann.ts
Last active November 26, 2020 22:10
Compute the Ackermann function using TS types
// Natural Numbers
interface Zero {
isZero: true;
}
interface Successor<N extends Nat> {
prev: N;
isZero: false;
}
type Nat = Zero | Successor<Nat>;

Semantic Versioning

Details: http://semver.org/, http://apr.apache.org/versioning.html

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

Patch level changes could also be for correcting incorrect APIs. In this case, the previous patch release may be incompatible, but because of bugs.

Minor versions may introduce new features, but do not alter any of the previous API.

@zaach
zaach / regex.js
Created July 12, 2012 16:49
origin regex
//var org = /^https?:\/\/(?=.{1,254}(?::|$))(?:(?!\d|-)(?![a-zA-Z0-9\-]{1,62}-\.)[a-zA-Z0-9\-]{1,63}\.)*(?:(?!\d|-)(?![a-zA-Z0-9\-]{1,62}-$)[a-zA-Z0-9\-]{1,63})(:\d+)?$/;
var org = /^https?:\/\/(?=.{1,254}(?::|$))(?:(?!\d|-)(?![a-z0-9\-]{1,62}-(?:\.|:|$))[a-z0-9\-]{1,63}\b(?!\.$)\.?)+(:\d+)?$/i;
/* Origin regex explained
/^ // beginning
https?:\/\/ // starts with http:// or https://
(?=.{1,254}(?::|$)) // the hostname chars must be within 1-254 bytes
yarn test
yarn run v1.7.0
$ react-scripts test --env=jsdom --runInBand
2018-07-10 11:10 node[865] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-10 11:10 node[865] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-10 11:10 node[865] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:167
throw er; // Unhandled 'error' event
^
0x2b65995251180A285caDE992Bfc56B3c7F11CE98