Skip to content

Instantly share code, notes, and snippets.

View Chemaclass's full-sized avatar
👓
🏗️ building

Jose M. Valera Reales Chemaclass

👓
🏗️ building
View GitHub Profile
@Chemaclass
Chemaclass / fibonacci.phel
Created April 18, 2024 20:21
A fibonacci implementation written in phel
(ns phel-testing\local)
(defn fib [n]
(loop [fib-nums [0 1]]
(if (>= (count fib-nums) n)
(slice fib-nums 0 n)
(let [[n1 n2] (reverse fib-nums)]
(recur (push fib-nums (+ n1 n2)))))))
(println (fib 50))
@Chemaclass
Chemaclass / racing_horses.go
Last active April 1, 2024 04:54
Racing horses using goroutines
package main
import (
"fmt"
"math/rand"
"os"
"os/exec"
"os/signal"
"sync"
"time"
@Chemaclass
Chemaclass / php_macos_installation.md
Last active March 17, 2024 12:26
Managing diff local PHP versions in MacOS

Managing diff local PHP versions in MacOS

Identify which php versions do you have installed locally

  • brew search php

Install the versions that you need

@Chemaclass
Chemaclass / highlight_line.sh
Created October 22, 2023 15:06
A highlight line function
# highlight_line
#
# arg $1 file path; it can contain the line directly at the end after :
# arg $2 line or range; the line if it was not specified in the file path ($1)
# arg $3 range; the range +- to display from the line
#
# Usage example:
# hl file/path/foo.txt 47
# hl file/path/foo.txt 47 3
# hl file/path/foo.txt:47
@Chemaclass
Chemaclass / simple-cli-snake-game.phel
Last active March 20, 2023 12:17
simple-version/game
#########################################################################################
# This is a working (and simplified) example of the snake-cli-game, with the following elements:
# - A board
# - A snake with constant speed inside the board
# - The game ends when the snake touches the board
#########################################################################################
# Try it out: vendor/bin/phel run src/simple-cli-snake-game.phel
#########################################################################################
# composer dependencies:
# > "phel-lang/phel-lang": "dev-master" - the phel language: https://phel-lang.org/
@Chemaclass
Chemaclass / gist:474ff7768737889629027eba658f30be
Created March 16, 2023 13:15
Verifying my account on nostr
My Public Key: "npub1ch2gzhpxux8zc9upxvqy5mwm4x5k5hm6772682mqd5g65yz4z34qg4sxwx"
@Chemaclass
Chemaclass / using-diff-php-versions-mac.bash
Created July 24, 2022 10:45
Using different PHP versions in your local mac
# Install the different PHP versions from `shivammathur`
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
# Create a function in your `.zshrc` like:
sphp() {
brew unlink php && brew link --overwrite --force php@$1
}
@Chemaclass
Chemaclass / gacela-in-a-file.php
Last active August 17, 2024 21:41
A Gacela module example using anonymous classes
<?php
declare(strict_types=1);
# Using https://github.com/gacela-project/gacela
require __DIR__ . '/../vendor/autoload.php';
use Gacela\Framework\AbstractConfig;
use Gacela\Framework\AbstractFacade;
(ns phel-exercises\exercise\count-words)
(defn- fill-keys
"Exchanges all keys with their associated values in an array."
[xs v]
(-> (to-php-array xs)
(php/array_fill_keys v)
(php-array-to-table)))
######################
@Chemaclass
Chemaclass / is_descent_branch.sh
Created April 15, 2021 20:06
Is descent git branch
pushedrev=$1
basename=${2:-develop}
if ! baserev="$(git rev-parse --verify refs/heads/"$basename" 2>/dev/null)"; then
echo "'$basename' is missing, call for help!"
exit 1
fi
parents_of_commits_beyond_base="$(
git rev-list --pretty=tformat:%P "$pushedrev" --not "$baserev" |