Skip to content

Instantly share code, notes, and snippets.

<script>
class MyThing extends HTMLElement {
constructor() { super() }
connectedCallback() {
this.textContent += 'World'
}
}
</script>
<my-thing>Hello</my-thing>
@AVGP
AVGP / index.html
Last active August 1, 2017 11:33
Three.js demo during workshop
<!doctype html>
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.min.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/r86/examples/js/loaders/GLTF2Loader.js"></script>
<script>
var renderer = new THREE.WebGLRenderer()
renderer.setSize(500, 500)
renderer.setClearColor(0)
@AVGP
AVGP / wat.js
Created September 6, 2017 22:17
ffmpeg.js converting webm from a media recorder into mp4
var ffmpeg = require('ffmpeg.js/ffmpeg-mp4.js')
document.querySelector('button').addEventListener('click', (evt) => {
document.querySelector('[camera]').setAttribute('animation', {
property: 'rotation',
to: '0 360 0',
dur: 10000,
easing: 'linear'
})
@AVGP
AVGP / index.html
Created November 6, 2017 12:50
Hosting Data3D in Aframe
<!doctype html>
<html>
<head>
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="https://dist.3d.io/3dio-js/1.x.x/3dio.min.js"></script>
</head>
<body>
<a-scene>
<a-entity position="0 0 -2" io3d-data3d="url:untitled.gz.data3d.buffer"></a-entity>
</a-scene>
#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 *);
@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

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 / 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>
@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>