Skip to content

Instantly share code, notes, and snippets.

@mucaho
mucaho / README.md
Created July 14, 2022 10:10
Google Sitemap Test

Minimum working example for issue described in https://support.google.com/webmasters/thread/171071268?hl=en

  • Requires installation of Node.js

  • Put these files into a directory, run npm install to install dependencies

  • Use ssh -R 80:localhost:8080 localhost.run to setup a temporary tunnel to your local machine, leave that shell open

  • Copy & paste the publicly accessible tunnel url that will be established, e.g. https://XXX.lhrtunnel.link

  • Open Google Search Console and create a new URL prefix property with that tunnel link

  • Use the meta tag verification method and paste it into the project's index.html file's header

@mucaho
mucaho / yt_restore_video_time.user.js
Created December 7, 2021 06:35
YouTube restore video time - ViolentMonkey user script
// ==UserScript==
// @name YouTube restore video time
// @namespace Violentmonkey Scripts
// @match https://*.youtube.com/*
// @grant none
// @version 1.0
// @author mucaho
// @description -
// ==/UserScript==
@mucaho
mucaho / async_await_trap.js
Last active February 22, 2021 07:33
Example code demonstrating the not immediately apparent issue of a promise rejecting while another one is being awaited.
async function main() {
const rej = Promise.reject('err')
// the following line is needed,
// otherwise UnhandledPromiseRejectionWarning is thrown
// which can't be caught anywhere else (not even by async caller)!
// can be NOOP though, if error handling may be delayed to below catch block
rej.catch(e => console.log(e)) // logs 'err'
const del = new Promise((resolve) => {
setTimeout(() => resolve('del'), 100)
@mucaho
mucaho / Dockerfile
Last active April 13, 2020 12:20
Example Dockerfile and docker-compose.yml for a node js application with mongo db
FROM node:12-alpine
RUN apk add --no-cache tini
RUN apk add --no-cache curl
ADD https://raw.githubusercontent.com/eficode/wait-for/master/wait-for /bin/wait-for.sh
RUN chmod +rx /bin/wait-for.sh
USER node
RUN mkdir -p /home/node/app
WORKDIR /home/node/app
@mucaho
mucaho / sc2-fast_max_supply_replays.ipynb
Last active October 10, 2017 21:49
Extract fastest Starcraft II replays that reach max supply, according to [MSC](https://github.com/wuhuikai/MSC)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mucaho
mucaho / scopelist.txt
Created April 7, 2016 22:05 — forked from jasonm23/scopelist.txt
A list of Sublime Scopes scraped from all themes listed by Aziz' tmTheme Editor
active_guide
argument-name
block_cursor
brackethighlighter.curly
brackethighlighter.tag
class
class-inheritance
class-name
comment
comment.block
@mucaho
mucaho / distance_both_axes.js
Created March 13, 2016 00:48
approximate distance ray <-> aabb
// See [this tutorial](http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_4_Spatial_Subdivisions.shtml) and linked materials
//
// return distance to nearest corner of rectangle,
// or return Infinity if no intersection with ray
//
// origin = {_x, _y}
// direction = {x, y}
function approximateDistanceFromRay(origin, direction) {
var epsilon = 0.00000001; //maximum error allowed
@mucaho
mucaho / example.html
Created November 20, 2015 23:25
CraftyJS using browserify CDN
<html>
<head>
</head>
<body>
<script src="https://wzrd.in/bundle/craftyjs@latest"></script>
<script>
var Crafty = require("craftyjs");
Crafty.init();
Crafty.background('rgb(127,127,127)');
</script>
@mucaho
mucaho / Makefile
Last active August 29, 2015 14:27 — forked from bellbind/Makefile
[iojs][emscripten] Call sudoku solver function implemented in C on iojs
all: libsudoku.js sudoku.js sudoku
clean:
rm -f libsudoku.js sudoku.js sudoku
rm -f libsudoku.js.map sudoku.js.map
rm -f libsudoku.js.mem sudoku.js.mem
# library for using functions in hand written JavaScript code
libsudoku.js: libsudoku.c
emcc -g4 -Wall -Wextra -std=c11 $^ -o $@ \
-s EXPORTED_FUNCTIONS="['_output', '_sudoku']" \
@mucaho
mucaho / generic-js-benchmark.html
Last active February 8, 2022 00:18
Generic template for benchmarking / performance testing JavaScript code using the [Benchmark node module](https://www.npmjs.com/package/benchmark)
<html>
<head>
<script src="https://wzrd.in/bundle/lodash@4.11"></script>
<script src="https://wzrd.in/bundle/platform@1.3"></script>
<script src="https://wzrd.in/bundle/benchmark@2.1"></script>
</head>
<body>
<script>
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;