Skip to content

Instantly share code, notes, and snippets.

View VideoCarp's full-sized avatar
🅱️
no status.

VideoCarp VideoCarp

🅱️
no status.
View GitHub Profile
@VideoCarp
VideoCarp / lexer_function.ex
Last active May 24, 2022 00:55
Bits of code embedded onto my site.
defmodule Lexer do
def lex(current \\ 0, tokenstream \\ [], len, input_str) do
char = String.at(input_str, current)
unless current >= len do
cond do
...
end
else
tokenstream
end
@VideoCarp
VideoCarp / Function piping and composition.md
Created May 16, 2022 12:24
Function piping and composition

If you've been trying to get into functional programming, there's a good chance you've heard of composition and piping. These concepts apply to point-free programming. This is an attempt at a simple, clear explanation of function composition and piping. I will write these examples in F#, but the concepts apply to other languages like Haskell. They just use different operators sometimes.

Prerequisites: basic programming knowledge. This explanation is going to be simple.

Piping
Let's begin with the simpler of the two (at least according to my experience): piping. There are two ways which you could pipe a value to a function. Forwards, and backwards. When you pipe forward, you are applying the left side of the forward

@VideoCarp
VideoCarp / terminal_easy.md
Last active May 16, 2022 11:15
My python terminal module.

Progress bar. Code to run:

from terminal_easy import *
from asyncio import sleep as async_sleep
async def main():
    for _ in range(100):
        update_progress(1)
        await async_sleep(0.01)

progress(

GUI in Rust

The Rust programming language seems like a good fit for GUI programming. C++ developers have access to Qt, wxWidgets and many more. It's considered that GUI is just not there yet in Rust. I tried using Iced, it seemed like a good option. But Iced's examples were not working. I didn't bother with other libraries, they were mostly GTK and webview. I gave it another try. And at least two options did work! egui and Tauri. You've probably heard of both of them.

Tauri

You might criticize Tauri for its performance. But you'd be wrong.

@VideoCarp
VideoCarp / ConciseLexer.fsx
Last active May 8, 2022 03:33
A lexer for the English language written in F#.
open System
open System.Text
// Helper functions (SEE End of file for details)
let numeric c = (c >= '0' && c <= '9')
let ofword c =
(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c = '\'')
let str c = (c = '"') // fix highlighting syntax "
let notstr c = (c <> '"') // "
@VideoCarp
VideoCarp / MCFunction editor images.md
Last active April 23, 2022 14:24
Images for MCFunction Editor's latest version (or maybe not the latest version)

Default theme
image

Light theme
image

Message box
image

@VideoCarp
VideoCarp / Review of FP.md
Created April 19, 2022 10:04
Reviewing functional programming

Reviewing functional programming

Here, I'll cover review functional programming according to my experience when I tried it. I'll cover what advantages there are and what disadvantages there are. My struggles, and what I found easier, and finally a conclusion. This is not a scientific paper, and is based solely on developer experience, it's more useful if you're trying to understand developer experience. Hopefully, this will help you decide whether or not to try functional programming.
So, I originally started programming in general procedurally, with Python. It's important to note that functional programming and object oriented programming are not the only two paradigms -- contrary to popular belief. Procedural programming is largely very different to functional programming, so do keep that in mind.

When I started functional programming, I started with F#. I was careful to avoid imperative structures like control flow. And when I began, it was

@VideoCarp
VideoCarp / lexing.md
Last active May 3, 2024 13:43
Basics of lexing

Lexing for beginners

This is a guide that should teach you how to perform basic lexing in a functional programing language.
Everything was written in Elixir, but you should be able to follow it if you are using any functional programming language.
Or even an imperative programming language like Python, C or Java.\

What is lexing?

The first question you should ask yourself is, what is lexing? It's the same as tokenising, scanning or lexical analysis.
That might not help you if you haven't heard of these either. Put simply, lexing is the process of breaking down a string
into meaningful units, indepdendent of context.
What a lexer will do is make the following happen:

@VideoCarp
VideoCarp / lexer.ex
Last active April 11, 2022 00:43
A tiny lexer in Elixir.
# A small, unoptimized lexer in the Elixir programming language.
# No mutable values are used.
# This lexer was much, much easier for me to write and debug than when I had done it
# using imperative programming concepts such as loops and mutable values.
# This can be optimized by consuming the input string, instead of indexing.
defmodule Lexer do
# char info
def numeric(char) do
char >= "0" and char <= "9"
@VideoCarp
VideoCarp / tutorial.md
Last active September 11, 2020 07:10
How to move a world from a device to another tutorial.

Exporting your Map

Follow the process below.

Finding your Directory

Click the > like thing to expand.

Windows 10 Open up the "Run" app, (shortcut Win+R) and insert this.
%LocalAppData%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\minecraftWorlds
This will find the Minecraft Windows 10 Edition directory and you will see some folders here.