Skip to content

Instantly share code, notes, and snippets.

View HalCanary's full-sized avatar

Hal Canary HalCanary

View GitHub Profile
@HalCanary
HalCanary / git-update-module
Last active April 22, 2021 17:26
git-update-module
#! /bin/sh
# git-update-module
if [ -z "$1" ]; then
echo "Usage: $0 SUBMODULE_DIRECTORY" >&2
exit 1
fi
MOD="$1"
set -e -x
git submodule update --init "$MOD"
if [ "$(git -C "$MOD" status --porcelain)" ];then
#! /usr/bin/env node
// Copyright 2020 Hal W Canary III. All Rights Reserved.
const Point = (x0, y0, z0, c) => ({x:x0, y:y0, z:z0, color:c});
const Color = (r0, g0, b0) => ({r:r0, g:g0, b:b0});
const Shape = (pts, fcs) => ({points:pts, faces:fcs});
// prints a complete PLY file to stdout
#! /usr/bin/env python
# Copyright 2020 Hal W Canary, III. all rights reserved.
import lxml.html
import subprocess
import sys
import urllib2
class WikipediaTextParser:
// returns 0 for Sunday, 6 for Saturday, -1 for unsupported day,
// (proleptic) Gregorian calendar weekday calculator
int day_of_week(int day, int month, int year) {
if (year < 1 || day < 1 || day > 31 || month < 1 || month > 12) {
return -1;
}
if (month < 3) { month += 12; --year; } // put leap day at end of year.
return ((26 * (month - 2) - 2) / 10 + // first day of month for year 0.
year + // day of week shifts every year.
year / 4 - year / 100 + year / 400 + // number of leap days since 0
// Copyright 2020 Google LLC. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>crbug.com/1003114</title>
<style>
.pagina {
height: 1056px !important;
width: 816px !important;
page-break-inside: avoid;
#! /usr/bin/env python
# Copyright 2019 Google LLC.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#ifndef clipboard_DEFINED
#define clipboard_DEFINED
#include <vector>
namespace editor {
// This is a placeholder for a clipboard that will tie into the System Clipboard.
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// How does std::variant work?
// compile with --std=c++14
#if __cplusplus >= 201402L
#include <new>
#include <type_traits>
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#ifndef typedunion_DEFINED
#define typedunion_DEFINED
#include <new>
#include <type_traits>
// A typed union of two C++ classes. The classes A and B do not need to be POD,
// but they should be memory-movable, i.e. if