Skip to content

Instantly share code, notes, and snippets.

View themaxhero's full-sized avatar
😀

Marcelo Amancio de Lima Santos themaxhero

😀
View GitHub Profile
defmodule CeasarCipher do
@lower Enum.to_list(?a..?z)
@upper Enum.to_list(?A..?Z)
defp map_within_range(c, range, shift) do
if c in range do
range
|> Stream.cycle()
|> Stream.drop(shift + (c - hd(range)))
|> Stream.take(1)
@themaxhero
themaxhero / HeroLisp Testing.livemd
Last active July 3, 2024 12:07
HeroLISP.livemd

NimbleParsec Playground

Mix.install([
  {:nimble_parsec, "~> 1.0"}
])

My first ever try to make a LISP with

1..100_000
|> Task.async_stream(&do_something/1)
|> Stream.map(fn {:ok, v} -> v end)
@themaxhero
themaxhero / rmagick_palette_swap.rb
Last active May 11, 2024 00:06
This Script downloads it's dependencies after made executable if you have nix package manager installed.
#!/usr/bin/env nix-shell
#!nix-shell -i ruby -p ruby rubyPackages.rmagick
require "rmagick"
include Magick
colors = {
{r: 32, g: 48, b: 120} => [0, {r: 0, g: 0, b: 0}],
{r: 32, g: 64, b: 168} => [1, {r: 17, g: 17, b: 17}],
{r: 48, g: 104, b: 200} => [2, {r: 34, g: 34, b: 34}],
{r: 56, g: 128, b: 216} => [3, {r: 51, g: 51, b: 51}],
@themaxhero
themaxhero / install-erlang-through-asdf.sh
Created February 8, 2022 09:00
Script for Installing the latest version of erlang in Archlinux
#!/bin/bash
sudo pacman -S openssl-1.0
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang
mkdir ~/.openssl-1.0
cd ~/.openssl-1.0
ln -s /usr/include/openssl-1.0 include
ln -s /usr/lib/openssl-1.0 lib
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
@themaxhero
themaxhero / projects.sh
Created January 21, 2022 00:56
Wofi Project Selector
#!/bin/bash
__choice=$(printf '%s\n' Work Personal | wofi -dmenu -p "Select project scope" -L 2)
__work_projects=~/projects/work
__personal_projects=~/projects/personal
show_options() {
case $1 in
'Open with Emacs') emacs $2;;
@themaxhero
themaxhero / double_cola.ex
Last active November 3, 2021 10:42
Resolution for Double Cola Problem in Elixir
defmodule DoubleCola do
defp mapper({current_names, size}),
do: Enum.map(current_names, &(%{name: &1, size: size}))
defp traverse([%{name: name, size: size} | rest], n) when n <= size,
do: name
defp traverse([%{name: name, size: size} | rest], n),
do: traverse(rest, n - size)
def find_nth(names, n) do
type Result<T> = {type: "ok", data: T} | {type: "error", reason: string};
export const ok = <T = unknown>(data: T): Result<T> => {
return {type: "ok", data };
};
export const error = <T = unknown>(reason: string): Result<T> => {
return {type: "error", reason};
};
@themaxhero
themaxhero / rockman_x_legacy_collection_{1,2}.sh
Last active December 21, 2022 04:10
How to make Rockman X Legacy Collection {1,2} work just like in Windows.
#!/bin/sh
# Instructions
# Before running this:
# - Delete your ~/.local/share/Steam/steamapps/compatdata/$GAME_ID folder.
# - Then set your proton version to 5.0-10 for the game.
# - Run the game and close after it starts.
# - After that, you're good to go.
# If the game is Rockman X Legacy Collection 1, the ID should be 743890
# If the game is Rockman X Legacy Collection 2, the ID should be 743900
# Thanks to https://github.com/PedroHLC for Debbuging this thing and finding out how to solve.
@themaxhero
themaxhero / revert_subtraction.rb
Created December 9, 2020 05:39
Revert Subtraction using Percentage by adding percentage
require 'bigdecimal'
@percentages = [
BigDecimal("0.99"),
BigDecimal("0.98"),
BigDecimal("0.97"),
BigDecimal("0.96"),
BigDecimal("0.95"),
BigDecimal("0.94"),
BigDecimal("0.93"),