Skip to content

Instantly share code, notes, and snippets.

View sffc's full-sized avatar

Shane F. Carr sffc

View GitHub Profile
@sffc
sffc / rcv_toposort.py
Created August 14, 2024 22:06
Process ranked-choice votes via the topological sort of head-to-heads
# Copyright 2024 Google LLC.
# SPDX-License-Identifier: Apache-2.0
from cyclic_toposort import cyclic_toposort, acyclic_toposort
from collections import defaultdict
import re
votes = """
Shane: 1 ~> 3a > (3b ~> 5) > (2 ~> 4)
Manish: (1 ~> 3b) > 3a > 5 > 2 >> 4
@sffc
sffc / bigbox.rs
Last active July 11, 2023 21:47
Repro for crbug 13958
// Build this file with:
// rustc --target wasm32-unknown-unknown bigbox.rs
#![crate_type = "cdylib"]
type INNER = Vec<u8>;
#[no_mangle]
pub extern "C" fn make_big_box(len: usize) -> *mut core::ffi::c_void {
let memory: Box<INNER> = Box::new(vec![0; len]);
Apache v2 Contributor License Agreement: Octave Online LLC
==========================================================
Thank you for your interest in Octave Online LLC (the "Company").
In order to clarify the intellectual property license granted with
Contributions from any person or entity, the Company must have a
Contributor License Agreement ("CLA") on file that has been signed by
each Contributor, indicating agreement to the license terms below.
This license is for your protection as a Contributor as well as the
protection of the Company and its users; it does not change your
@sffc
sffc / icu-data-filter-schema.json
Created December 6, 2018 09:37
Schema for the data filter file introduced in unicode-org/icu#301
{
"$id": "http://unicode.org/icu-filter-schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "JSON Schema for an ICU data filter file",
"type": "object",
"properties": {
"localeFilter": { "$ref": "#/definitions/filter" },
"featureFilters": {
"type": "object",
"properties": {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" href="http://www.unicode.org/reports/reports.css"
type="text/css">
<title>UTS #35: Unicode LDML: General</title>
@sffc
sffc / markdown.conf
Last active July 31, 2024 07:55
Apache config to render *.md files as HTML (client-side). Prefer server-side rendering? See https://github.com/sffc/apache-php-markdown/blob/master/README.md
# File: /etc/apache2/conf-available/markdown.conf
#
# Copyright (c) 2018 Shane F. Carr
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@sffc
sffc / Gemfile
Last active July 12, 2020 09:27
Drop-in extension for image optimization during a Jekyll build. Save jekyll_image_optim.rb in your _plugins directory and make the stated changes to your Gemfile and _config.yml. https://blog.sffc.xyz/post/182420136145/optimized-images-in-jekyll
gem "image_optim", "~> 0.25"
gem "image_optim_pack", "~> 0.5.1"
@sffc
sffc / icu_unicodestring_prettyprinter.py
Last active September 22, 2024 14:19
A GDB pretty-printer for ICU4C UnicodeStrings
# To autoload this file into GDB, put the following line in ~/.gdbinit:
#
# python execfile("/path/to/icu_unicodestring_prettyprinter.py")
#
# You can also run that line of code in the GDB console without adding it to ~/.gdbinit.
from __future__ import print_function
from array import array
import re
@sffc
sffc / braindead.c
Last active February 21, 2017 20:51
Comparison between "braindead" double-to-ascii and sprintf
#include "stdio.h"
#include "stdint.h"
#include <float.h>
#include <limits.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define LOG2_10 3.32192809488736
@sffc
sffc / analyze.rb
Last active July 1, 2017 07:43
Helper script for counting the recruitment stats in the IRON Recruitment Corps
#!/usr/bin/env ruby
require 'uri'
LAST_MONTH_DAN = "2017/april-dan.txt"
THIS_MONTH_DAN = "2017/may-dan.txt"
THIS_MONTH_RULERS = "2017/may-rulers.txt"
THIS_MONTH_THREADS = "2017/may-threads.txt"
rulers = File