Skip to content

Instantly share code, notes, and snippets.

@perey
perey / gamepad-api-implementation-notes.md
Created Apr 10, 2022
Browser Gamepad API test and example
View gamepad-api-implementation-notes.md

Firefox 98:

  • navigator.getGamepads() only contains Gamepad objects, and only for gamepads that are actually connected.
  • When handling a gamepadconnected event, the event's gamepad property is a live reference to the gamepad in question. It can be saved and used to check for future changes to the gamepad state.
  • While handling a gamepaddisconnected event, the array obtained from navigator.getGamepads() will still include the gamepad being disconnected, but will report it as having 0 buttons and 0 axes.
  • I have only ever seen index 0 be assigned to the first-connected gamepad.

Chrome 100:

  • navigator.getGamepads() contains four items, which are null until a gamepad is actually connected. (I expect this is a minimum and the array will expand if you connect five or more gamepads, but I haven't tested it.)
@perey
perey / korean_testcases.csv
Created Feb 10, 2018
Test cases for romanising Korean
View korean_testcases.csv
Hangul Latin Comments
gak Initial and final ㄱ, vowel ㅏ
kkaek Initial and final ㄲ, vowel ㅐ
nyan Initial and final ㄴ, vowel ㅑ
dyaet Initial and final ㄷ, vowel ㅒ
tteo Initial ㄸ, vowel ㅓ
rel Initial and final ㄹ, vowel ㅔ
myeom Initial and final ㅁ, vowel ㅕ
byep Initial and final ㅂ, vowel ㅖ
ppo Initial ㅃ, vowel ㅗ
@perey
perey / resource.svg
Created Oct 21, 2017
Test case for styling of SVG <use> element referencing an external file
View resource.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View nearest_stars.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A star map</title>
<style>
html {
background-color: black;
@perey
perey / challenge_mondrian_results.txt
Last active Dec 20, 2016
Mondrian Puzzle in Piet
View challenge_mondrian_results.txt
? 200
____________________________________________________________________________________________________
| |
| |
| |
| |
| |
| |
| |
| |
View paint_by_prog.py
#!/usr/bin/env python3
"""Line-art painter."""
# Copyright © 2016 Timothy Pederick.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
View esolang0815_examples.md

Hello World

The Esolang wiki version

<:48:x<:65:=<:6C:$=$=$$~<:03:+$~<:ffffffffffffffbd:+$<:ffffffffffffffb1:
+$<:57:~$~<:18:x+$~<:03:+$~<:06:x-$x<:0e:x-$=x<:43:x-$

Explanation

@perey
perey / hexagonmake.py
Created Sep 18, 2015
Hexagon maker for "Beatles Songs and Hexagons" challenge
View hexagonmake.py
#!/usr/bin/env python3
"""Triangular code checker and hexagon builder.
http://codegolf.stackexchange.com/questions/58186/beatles-songs-and-hexagons
When run from the command line, this program accepts two filenames as
arguments. It will:
a) Check that they conform to the format specified in the challenge
b) Merge them into a hexagon and print the result to STDOUT
@perey
perey / fraction.chef
Last active Aug 29, 2015
Chef code for converting improper fractions to mixed numbers.
View fraction.chef
Fraction Dosa.
This recipe takes a numerator and denominator from STDIN and outputs the
mixed-number representation to STDOUT.
Ingredients.
2 cups numerator rice
2 cups denominator ukda chawal
1 cup whole part urad dal
10 teaspoons new line poha
@perey
perey / challenge224hard.py
Last active Aug 29, 2015
Langford sequence coding challenge
View challenge224hard.py
#!/usr/bin/env python3
"""Daily Programmer Challenge #224 [Hard] Langford Strings
https://www.reddit.com/r/dailyprogrammer/
"""
from string import ascii_uppercase
from copy import copy