Skip to content

Instantly share code, notes, and snippets.

View marcioAlmada's full-sized avatar
🚀

Márcio Almada marcioAlmada

🚀
View GitHub Profile
@toomasv
toomasv / rays.red
Last active August 2, 2019 19:22
Ray-casting exercise
Red [
Description: {Ray casting exercise}
Needs: View
Date: 25-July-2019
Inspiration: https://github.com/krisajenkins/elm-rays
Tutorial: https://ncase.me/sight-and-light/
Redporter: "Toomas Vooglaid"
Licence: "Public domain"
]
; To change into plain light instead of radial
WITH RECURSIVE traversed (id, name, path, `left`, `right`) AS (
SELECT id,
name,
CAST(JSON_ARRAY(id) AS JSON),
`left`,
`right`
FROM binary_tree
WHERE id = 1
UNION
SELECT b.id,
anonymous
anonymous / default.txt
Created December 3, 2017 12:33
Users and their passwords attempts
[0]
4
1
1 -
2 !
2 !@
1 &
1 0
3 0000
package auth
import (
"context"
"net/http"
"strings"
"google.golang.org/grpc/metadata"
"github.com/andela/micro-api-gateway/pb/authorization"
// ==UserScript==
// @name DeezerCLI
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Control Deezer web player from the console
// @author pyarnau@gmail.com
// @match http://www.deezer.com/*
// @grant none
// ==/UserScript==
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

<?php
class C1 {
public $x = 0;
public $y = 0;
}
class C2 {
public $x = 0;
public int $y = 0;
}
@bradfitz
bradfitz / xmas.go
Created December 25, 2015 02:39
Brad's xmas lights
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@haskellcamargo
haskellcamargo / PipingOperator.php
Created June 3, 2015 14:32
Possible RFC - Piping operator
/**
* The piping operator (|>) is based on F# and LiveScript programming languages
* or (|) on Shell and allows you to compose functions in a stack and has
* left-associativity with lower precedence.
*/
function map(callable $fn, array $xs) {
$acc = [];
foreach ($xs as $x) {
$acc[] = $fn($xs);
}
@grifx
grifx / YCombinator.php
Last active December 17, 2015 13:00
The Little Schemer - Y combinator in PHP
<?php
/**
* “The Little Schemer” - Y combinator in PHP
* @author: Joris Garonian
*/
function Y($g) {
return call_user_func(function ($f) {
return $f($f);
}, function ($f) use ($g) {