Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Drummond addrummond

View GitHub Profile
View html_lint_native.exs
defmodule HtmlLintNative do
use Rustler, otp_app: :platform, crate: "platform_plugs_htmllintnative"
def add(_a, _b), do: error()
def lint(_html_string), do: error()
defp error(), do: :erlang.nif_error(:nif_not_loaded)
end
View html_lint_fragment.rs
#[rustler::nif]
fn lint(env: Env, input: String) -> Result<Term, Error> {
let parse_errors = lint_html::lint(input);
return convert_errors(env, parse_errors);
}
fn convert_errors(env: Env, parse_errors: Vec<(u64, String)>) -> Result<Term, Error> {
if parse_errors.len() == 0 {
return Ok(ok().to_term(env));
} else {
@addrummond
addrummond / html_lint.ex
Last active Mar 17, 2021
Example HTML lint plug code
View html_lint.ex
defmodule HtmlLintPlug do
require Logger
def init(opts), do: opts
def call(conn, _opts) do
Plug.Conn.register_before_send(conn, &lint/1)
end
defmodule Error do
View import.go
// Set up the following environment variables and then run with the path to the 'deploy' dir as the first and only argument.
//
// export IBEXFARM_DATABASE_URL=postgresql://postgres:password@localhost:6432/nmibex_dev
// export IBEXFARM_QUOTA_ID=1
// export IBEXFARM_S3_HOST=http://localhost:9000
// export IBEXFARM_S3_BUCKET=nmibex-dev
// export IBEXFARM_NO_S3_SSL=true
// export IBEXFARM_USE_MINIO=true
// export AWS_ACCESS_KEY_ID=key
// export AWS_SECRET_ACCESS_KEY=password
View The new Ibex Farm.md
View Kanban and dense orders.md

Appendix to the blog post.

The following assumes that the alphabet is {A, B}. The results easily generalize.

Lemma 1: Two strings S1 and S2 have no string lexicographically between them iff S1 = S2A or S2 = S1A. (Proof at end.)

Definitions:

  • Two strings S1 and S2 are adjacent iff S1 ≠ S2 and there is no S3 such that S1 < S3 < S2 or S2 < S3 < S1.
View keybase.md

Keybase proof

I hereby claim:

  • I am addrummond on github.
  • I am alexdrummond (https://keybase.io/alexdrummond) on keybase.
  • I have a public key ASAMFkJCiG1DjIEFh9ywx_lXhw8ViQsJtN7any7dRyN2Hwo

To claim this, I am signing this object:

View example_data.js
// ========== START OF CODE TO COPY INTO YOUR DATA FILE ==========
var IMAGES_TO_PRELOAD = [
// CHANGE THESE TO THE URLS OF THE IMAGES THAT YOU WANT TO PRELOAD
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG/1200px-Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG",
"http://elelur.com/data_images/mammals/alpine-ibex/alpine-ibex-01.jpg"
];
define_ibex_controller({
name: "Preloader",
jqueryWidget: {
View MyDashedSentence.js
/* This software is licensed under a BSD license; see the LICENSE file for details. */
function boolToInt(x) { if (x) return 1; else return 0; }
define_ibex_controller({
name: "MyDashedSentence",
jqueryWidget: {
_init: function() {
this.cssPrefix = 'DashedSentence-';
@addrummond
addrummond / kaldur.py
Last active Dec 16, 2015
This is a Python script for computing the strong paradigm for Icelandic 'kaldur' ('cold') given the toy analysis presented in Drummond & Hornstein (forthcoming).
View kaldur.py
# coding=utf-8
import sys
from itertools import *
from sets import *
vocab_items = [(x[0], Set(x[1])) for x in
(u'kalt', ()),
(u'kaldur', ('+A', '+B')),
(u'köld', ('-B',)),
(u'kaldan', ('-pl', '+acc', '+A', '+B')),