Skip to content

Instantly share code, notes, and snippets.

@AVGP
AVGP / json-ldfy.php
Last active December 20, 2023 13:20
A barebones WP plugin to add JSON-LD based on post data automatically. It won't really work, but it's a starting point for exploration.
<?php
/*
Plugin Name: JSON-LDfy
Plugin URI: https://www.google.com
Description: Add JSON-LD based on some post data
Version: 1.0
Author: Martin Splitt
Author URI: https://www.google.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@AVGP
AVGP / robots-rule-matching.js
Created September 8, 2021 14:57
Experimental code to match robots.txt rules against a given path.
const patterns = [
/*
'/path/yolo.png',
'/path',
'/something',
'/path/hello.png$',
'/path/hello$',
'/a*bc'
*/
'/a*a'
<?php
if( !empty( $_POST ) ) {
die( "data: " . $_POST["msg"] );
}
?>
<form method="post">
<button type="button">Go</button>
</form>
@AVGP
AVGP / dms.xml
Last active October 2, 2020 14:02
UPnP test server (incomplete)
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<dlna:X_DLNADOC>DMR-1.50</dlna:X_DLNADOC>
<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
<friendlyName>YoloCast</friendlyName>
@AVGP
AVGP / index.html
Created December 3, 2018 20:37
Stupidest, simplest JS web app ever
<!doctype html>
<html lang="en">
<head>
<title>Kitten Corner</title>
<meta charset="utf-8">
<meta name="description" content="Kitten Corner has a bunch of lovely cat pictures ready for you!">
<meta name="viewport" content="width=device-width">
<style>
body {
@AVGP
AVGP / test.html
Created September 25, 2018 12:06
Tests for prerendering of structured data
<!doctype html>
<html>
<body>
<h1>Rendered using JavaScript:</h1>
<p></p>
<!-- JavaScript - should be removed by the prerendering -->
<script>
const paragraph = document.querySelector('p');
paragraph.textContent = "Hello, World!";
</script>
@AVGP
AVGP / polymer-playground-app.html
Created May 28, 2018 09:23
A polymer 2 component using iron-ajax to load some data
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<dom-module id="polymer-playground-app">
<template>
<iron-ajax auto url="https://jsonplaceholder.typicode.com/posts/1" handle-as="json" last-response="{{post}}"></iron-ajax>
<p>[[post.title]]</p>
</template>
<script>

A primer on x86 assembly with GNU assembler

When it comes to assembly language, it isn't as hard as many people think. Fundamentally, you write short, human-readable commands for the processor to execute (your assembly code) and then use a tool (the actual assembler) to translate your code into machine-readable binary instructions. Unlike high-level languages, assembly language is very simple and doesn't have that many features. The difficulty is to deal with memory and build more complex flows (e.g. loops or I/O) from the simple primitives that the assembly language gives you.

Registers and instructions

CPUs usually have small, very fast storage available for the data that is used in its instructions. This kind of storage is much smaller but also much faster than the RAM and is called registers. An x86 processor has a bunch of them to store generic data, manage the stack, keep track of the current instruction and other administrative inform

@AVGP
AVGP / materials.txt
Created February 19, 2018 16:22
List of predefined Archilogic materials
basic-floor
basic-balcony
basic-wall
basic-ceiling
wood_parquet_oak
wood_parquet_4
wood_parquet_oak_stained
wood_parquet_oak_dark
wood_parquet_oak_black
floor_oak_parquet
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/unistd.h>
#include <linux/utsname.h>
#define MEM_READONLY 0x10000 // bit 16 in cr0 specifies if "readonly" memory is protected
// we define a type for the original uname syscall handler function
typedef asmlinkage long (*orig_uname_t)(struct new_utsname *);