Skip to content

Instantly share code, notes, and snippets.

@mucaho
mucaho / thoughts_on_yaes.md
Last active May 1, 2025 08:28
YAES: Thoughts on context-based capability passing style for state threading and integration into tagless-final application

First creation date: 2025-04-20
Latest update date: 2025-04-24

Changelog

  • 2025-04-24: Updated solution for state-threading

Table of Contents

@mucaho
mucaho / arel_helpers.rb
Created April 19, 2025 11:23 — forked from hadees/arel_helpers.rb
Arel Helpers
module ArelHelpers
extend self
def self.included(base)
base.extend self
end
def asterisk(arel_table_or_model)
arel_table, columns = case arel_table_or_model
when Arel::Table
@mucaho
mucaho / arel_cheatsheet_on_steroids.md
Created April 19, 2025 11:22 — forked from ProGM/arel_cheatsheet_on_steroids.md
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@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)
Loading
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