Skip to content

Instantly share code, notes, and snippets.

@oplanre
oplanre / Sorter.php
Last active June 27, 2024 00:54
Light abstraction layer for sorting arrays in php
<?php
class Sorter {
public function __construct(private array $array) {}
/**
* Sort the array by a specific key in ascending or descending order.
*
* @param string $key The key to sort by.
* @param string $order The order direction, 'asc' for ascending or 'desc' for descending. Default is 'asc'.
* @return self
@srcrip
srcrip / error_html.ex
Created February 15, 2024 19:42
Custom Phoenix error pages
# goes in lib/your_app_web/controllers/error_html.ex
defmodule ExampleWeb.ErrorHTML do
use ExampleWeb, :html
def render("404.html" = template, assigns) do
assigns =
assigns
|> Map.merge(%{__changed__: %{}})
|> assign(:message, Phoenix.Controller.status_message_from_template(template))
// code updates are now there:
// https://github.com/Bleuje/processing-animations-code/blob/main/code/fractalsliding2d/fractalsliding2d.pde
// Processing code by Etienne JACOB
// for collab with Yann Le Gall (https://demozoo.org/graphics/322553/)
// motion blur template by beesandbombs
// See the license information at the end of this file.
// View the rendered result at: https://bleuje.com/gifanimationsite/single/2dfractalslidingsquares/
// using double instead of float makes the code a bit more complicated
@lgmoneda
lgmoneda / org-yank-link.el
Last active April 10, 2023 23:24
Copy Slack behavior of automatically creating link when pasting url with text selected
@joshnuss
joshnuss / streaming_http_requests.ex
Last active March 31, 2023 09:02
Streaming HTTP requests
defmodule MyApp.Integrations.Skubana do
@host "..."
@headers [ ... ]
# returns a stream of shipments
def get_shipments do
# start with page 1
start = fn -> 1 end
# create a stream, it will make HTTP requests until the page returned is empty
@GromNaN
GromNaN / RouterTest.php
Created December 15, 2021 20:43
Symfony Integration test for route configuration: controller does neither exist as service nor as class
<?php
namespace Tests\Integration;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\RouterInterface;
@lukaseder
lukaseder / postgis-mandelbrot.sql
Created November 14, 2021 10:03
PostGIS Mandelbrot
with recursive
dims (r1, r2, i1, i2, s, it, p) as (values (-2::float, 1::float, -1.5::float, 1.5::float, 0.01::float, 100, 256.0::float)),
sprites (s) as (values (st_makepolygon(st_geomfromtext('linestring (0 0, 0 1, 1 1, 1 0, 0 0)')))),
n1 (r, i) as (select r, i from dims, generate_series((r1 / s)::int, (r2 / s)::int) r, generate_series((i1 / s)::int, (i2 / s)::int) i),
n2 (r, i) as (select r::float * s::float, i::float * s::float from dims, n1),
l (cr, ci, zr, zi, g, it, p) as (
select r, i, 0::float, 0::float, 0, it, p from n2, dims
union all
select cr, ci, zr*zr - zi*zi + cr, 2 * zr * zi + ci, g + 1, it, p from l where g < it and zr*zr + zi*zi < p
),
@bjo3rnf
bjo3rnf / example_form.html.twig
Last active November 14, 2023 08:52
Stimulus.js controller for Symfony collection form type with configurable item limit
{% macro collection_item(form) %}
<div data-form-collection-target="field">
{{ form_widget(form) }}
<button type="button"
data-action="form-collection#removeItem">
remove
</button>
</div>
{% endmacro %}
@fabiolimace
fabiolimace / UUIDv6.sql
Last active September 16, 2024 08:02
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* 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 permit persons to whom the Software is
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active September 19, 2024 15:38
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) because d