Skip to content

Instantly share code, notes, and snippets.

View elazar's full-sized avatar

Matthew Turland elazar

View GitHub Profile
@elazar
elazar / html-in-php.php
Last active November 13, 2022 01:11
HTML-in-PHP
<?php
if (!function_exists('array_is_list')) {
function array_is_list(array $array): bool
{
return array_keys($array) === range(0, count($array) - 1);
}
}
$data = [
@elazar
elazar / TwitterCrawler.php
Created May 27, 2022 13:15
Twitter Follower Crawler
<?php
// https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api
define('TWITTER_BEARER_TOKEN', '...');
date_default_timezone_set('America/Chicago');
function sendRequest($path)
{
$context = stream_context_create([
@elazar
elazar / readme.md
Last active December 10, 2022 02:53
Personal Finance Project RFC

Problem

Existing software-based personal finance systems (hereafter abbreviated as PFS) tend to lack data portability, customizability, support for self-hosting, mobile-friendliness, or some combination thereof, and are often used as an indirect form of advertising or to otherwise promote paid third-party services.

@elazar
elazar / refind-to-postmarks.php
Created October 17, 2023 01:33
Convert Refind export to Postmarks SQL
<?php
$date = fn(int $timestamp): string => date('Y-m-d H:i:s', $timestamp);
$doc = XMLReader::open('refind collection links.html', null, LIBXML_NOERROR | LIBXML_NOWARNING);
$links = [];
$currentTag = null;
while ($doc->read()) {
if ($doc->nodeType == XMLReader::ELEMENT) {
if ($doc->localName === 'h3') {
$currentTag = $doc->readString();
if ($currentTag === 'Dungeons and Dragons') {
@elazar
elazar / MultiplicativeTriangle.java
Last active January 20, 2025 01:14
Power of Two Triangle
/**
* To run this:
*
* 1. Compile it.
*
* javac MultiplicativeTriangle.java
*
* 2. Run it.
*
* java MultiplicativeTriangle