Skip to content

Instantly share code, notes, and snippets.

View Zegnat's full-sized avatar

Martijn van der Ven Zegnat

View GitHub Profile
@Zegnat
Zegnat / README.md
Created February 24, 2012 12:03
Fixing your skip links. [JS]

Fixing your skip links.

Read Damon Muma on this. He proposes the following jQuery solution (inspired by Thompson, fixed by me):

// Apply focus properly when accessing internal links with keyboard in WebKit browsers.
$("a[href^='#']").not("a[href='#']").click(function() {
   $("#"+$(this).attr("href").slice(1)+"").focus();
});
GET http://localhost:7331/test
An unhandler error occured: TypeError: /Users/martijn/Source/thumbswise/src/routes/test.tsx: Duplicate declaration "createRouteData"
> 1 | import { createRouteData, useRouteData } from "solid-start";
| ^^^^^^^^^^^^^^^
2 | import { createServerData$ } from "solid-start/server";
3 |
4 | export function routeData() {
@Zegnat
Zegnat / index.php
Created September 4, 2022 12:14
IndieAuth Ticket Auth testing page, created July 2021
<?php declare(strict_types = 1);
define('MINTOKEN_CURL_TIMEOUT', 4);
define('MINTOKEN_SQLITE_PATH', 'tokens.db'); // Created with schema.sql
// Support functions. Mostly stripped from other projects.
if (!file_exists(MINTOKEN_SQLITE_PATH)) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: text/plain;charset=UTF-8');
exit('The token endpoint is not ready for use.');
@Zegnat
Zegnat / kendo-filter.json
Last active August 26, 2022 23:26
JSON Schema for validating JSON representations of Kendo filters.
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"definitions": {
"filter": {
"oneOf": [
{
"type": "object",
"properties": {
"field": {
"type": "string",
@Zegnat
Zegnat / README.md
Last active December 25, 2021 22:37
JSON Schema for Microformats

The schema has been moved to its own repository so unit tests could be added. This makes sure the schema actually works for known microformats2 parser outputs.

Find the repository at: Zegnat/microformats2-json-schema and the latest version of the schema JSON on at ./schema.json.

@Zegnat
Zegnat / GeminiStreamWrapper.php
Created August 15, 2021 19:20
Add gemini:// support for file_get_contents(). Will turn into proper repo with Composer support later.
<?php declare(strict_types=1);
namespace Zegnat\Gemini;
/**
* @see https://www.php.net/manual/en/class.streamwrapper.php
*/
final class GeminiStreamWrapper {
/** @var resource $context if a stream context was provided it will be set here, even before __construct */
public $context;
@Zegnat
Zegnat / background.js
Created January 6, 2021 16:57
Swapping between two browser context menus depending on the amount of selected tabs.
let single = true
const menus = {
single: browser.menus.create({
contexts: ['tab'],
title: '&Close Tab'
}),
selection: browser.menus.create({
contexts: ['tab'],
title: '&Close Tabs',
@Zegnat
Zegnat / yt.html
Last active November 8, 2020 19:55
I keep forgetting how I can do sleek YouTube embeds. Here is one from a project. Still tweaking.
<!--
Embedded Youtube player that combines:
* https://jameshfisher.com/2017/08/30/how-do-i-make-a-full-width-iframe/
* https://css-tricks.com/lazy-load-embedded-youtube-videos/
* https://stackoverflow.com/a/42555610/3225372
* https://web.dev/iframe-lazy-loading/
* https://github.com/paulirish/lite-youtube-embed/blob/a927d63781883088c185cb69a0baade52732ab3e/src/lite-yt-embed.js#L28
Other things I am still thinking of adding:
* https://www.maxlaumeister.com/articles/hide-related-videos-in-youtube-embeds/
-->
@Zegnat
Zegnat / cal.php
Created November 5, 2020 15:23
Quicky to plain text calendar generation
<?php
$tz = new DateTimeZone('UTC');
$now = (new DateTimeImmutable('now', $tz))->setTime(12, 0, 0, 0);
$start = filter_input(INPUT_GET, 'start', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '@\d{4,}-\d\d-\d\d@']]);
$end = filter_input(INPUT_GET, 'end', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '@\d{4,}-\d\d-\d\d@']]);
if (
is_string($start) &&
($startParts = array_map('intval', explode('-', $start))) &&
@Zegnat
Zegnat / README.md
Last active March 14, 2019 12:44
Simple script for accessing the contents of an encrypted andOTP backup.

andOTP Decrypt

Simple script for accessing the contents of an encrypted andOTP backup. As long as Sodium is available this does not require any dependencies outside of PHP.

This was written as a replacement for [asmw/andOTP-decrypt][], which I found a little annoying to get going and depends on several external packages. (Hold! Was PHP easier than Python here? Oh my!)

Usage

To decrypt and write to a JSON file: