Skip to content

Instantly share code, notes, and snippets.

@ijt
ijt / gofast_issue_28.go
Created July 20, 2018 16:32
Repro case for gofast issue 28
// This program spins up php-fpm in the background and a Go web server sending
// all requests to a PHP router script.
package main
import (
"context"
"flag"
"fmt"
"io/ioutil"
"log"
@ijt
ijt / stringsim.rs
Created October 3, 2019 00:36
Rust program to compute the trigram Jaccard similarity between two strings
//! The stringsim program prints out the trigram similarity of two strings
//! using what appears to be the same algorithm used by Postgres.
//! https://www.postgresql.org/docs/9.1/pgtrgm.html
use std::collections::HashSet;
use std::hash::Hash;
fn main() {
let args: Vec<String> = ::std::env::args().collect();
if args.len() != 1+2 {
@ijt
ijt / hijax.html
Created March 16, 2020 19:02
Intercept Ajax calls and make them do something else
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div id="d">nothing here yet</div>
<script>
var send = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
<script type="module">
import {html, render} from 'https://unpkg.com/lit-html?module';
const myTemplate = (name) => html`<p>Hello ${name}</p>`;
render(myTemplate('World'), document.body);
</script>
@ijt
ijt / lit-element.html
Created May 22, 2020 18:10
Minimal HTML page using LitElement
<!doctype html>
<html>
<head></head>
<body>
<my-element></my-element>
<script type="module">
import {LitElement, html} from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
class MyElement extends LitElement {
render() {