This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://gist.github.com/jkoop/afc386f5742c2b61bf9657577b974449 --> | |
<?php if (isset($_GET['access_token']) && isset($_GET['project_id']) && isset($_GET['milestone_name'])) : ?> | |
<meta http-equiv="refresh" content="3600"> <!-- refresh every 1 hour --> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script src="https://cdn.jsdelivr.net/npm/chart.js@^3"></script> | |
<script src="https://cdn.jsdelivr.net/npm/moment@^2"></script> | |
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@^1"></script> | |
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation@^1/dist/chartjs-plugin-annotation.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
git ls-files -z | \ | |
xargs -0n1 git blame -w | \ | |
grep -o --binary-files=text '^[^(]*([^)]*)' | \ | |
grep -o '([^0-9]*' | \ | |
grep -o '[^(]*' | \ | |
sed 's/\s*$//g' | \ | |
sort -f | \ | |
uniq -c | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a number to A,B,C,...,X,Y,Z,AA,AB,AC,...,ZZ,AAA,AAB, etc. | |
* | |
* @param int $int must be at least 1 | |
* @return string | |
*/ | |
function spreadsheetLetters(int $int): string { | |
if ($int < 0) throw new TypeError('$int must be at least 0'); | |
$numeric = $int % 26; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(10 - ( | |
substr(isbn, 1, 1) * 1 + | |
substr(isbn, 2, 1) * 3 + | |
substr(isbn, 3, 1) * 1 + | |
substr(isbn, 4, 1) * 3 + | |
substr(isbn, 5, 1) * 1 + | |
substr(isbn, 6, 1) * 3 + | |
substr(isbn, 7, 1) * 1 + | |
substr(isbn, 8, 1) * 3 + | |
substr(isbn, 9, 1) * 1 + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/** | |
* This script SSHes into all of my AeroHive Wifi APs, gets a list of current | |
* connected clients from each if them, assembles the list into one, and writes | |
* that list to a JSON file. | |
* | |
* This is intended to be run as a minutely `cron` job. As such, the path of the | |
* output file is the date, formatted to not put a million files in one folder: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run this as root | |
GOOGLE_API_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | |
TRACCAR_URL='https://traccar.example.com' | |
INTERFACE=wlan0 | |
DEVICE_ID=123456 | |
json=$(sudo iwlist $INTERFACE scan | egrep -o 'Address: .*|Channel:.*|Signal level=.*|Last beacon:.*' | sed -E 's/Address: (.*)/\{"macAddress":"\1",/g' | sed -E 's/Channel:(.*)/"channel":\1,/g' | sed -E 's/Signal level=(.*) dBm/"signalStrength":\1,/g' | sed -E 's/Last beacon: (.*)ms ago/"age":\1}/g') | |
json=$(echo "$json" | head -n 1; echo "$json" | sed -E 's/\{/,{/g' | tail -n +2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** This plugin replaces UNIX timestamps with human-readable dates in your local timezone. | |
* Mouse click on the date field reveals timestamp back. | |
* | |
* @link https://www.adminer.org/plugins/#use | |
* @author Anonymous | |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 | |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* numbers.h - Terse shorthands for numeric types | |
* Copyright (c) 2023 Joe Koop | |
* License: The MIT License (MIT) | |
*/ | |
#include <stdint.h> | |
// E for "exact" | |
typedef int8_t i8e; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* For Laravel 10. | |
* Automatically set app locale based on browser's preferred language and server's `lang/` directory. | |
* @copyright 2024 Joe Koop | |
* @license MIT | |
*/ | |
namespace App\Http\Middleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* For Laravel 10. | |
* Automatically set App and User's locale based on browser's preferred | |
* language and server's `lang/` directory. | |
* @copyright 2024 Joe Koop | |
* @license MIT | |
*/ |