the ~karx journals

various musings of ~karx

from cup import coffee (sandwich devlog #4)

February 16, 2021 — ~karx

In today’s sandwich-making adventure, I improved the comment parser. Not you can use comments inline. For example:

# this is a comment
pHello #this is an inline comment
pWorld # <- Will print World!

the # symbol turns the rest of the line into a comment, so be careful! Everything before the comment symbol will be evaluated.

I also added the ability to import things from other files with the i opcode, like so:

#one.txt
pHello world!

itwo.txt# now everything from two.txt will be imported into one.txt
p$v #v is defined in two.txt

And the external file would look like this:

#two.txt (external)

lvsome variable

So the output would be “some variable”. Note that the file is evaluated before importing, like in Python. This means that any print statements or math operations in the file that are not enclosed in a variable or a function will be executed like a normal program.

As always, the code is up on tildegit, so clone a copy and get started with sandwich! PRs can be made on Gitea or sent to my tilde.team email (karx AT tilde DOT team) as patches.

tags: sandwich, rust, programming, devlog

Sandwich Devlog 3: Function Junction

February 10, 2021 — ~karx

Today, I added functions! functions are a neat little tool that let you “pipe” math operation outputs into other instructions. For example, you could assign the output to a variable, like below:

#Declare a function
fxa3-3
#Call the function and assign it to variable
lv*x
#will print out 6
p$v

Or you could print it out directly:

#Declare a function
fxs30-3
#Call it and print it out
#Will print out 27
p*x

You can also use variables inside a function, like so:

#Declare a variable
lv3
#Declare a function that will use the variable
fxs30-$v
#Prints out 27
p*x

Note that functions will only get evaluated when they’re called. This means that if you reassign the variable v in between the function declaration and the function call, the function will use the new value of the variable. Also, functions are re-evaluated for each call. So if they depend on an outside variable and the variable changes frequently, the result of the function will also change frequently.

Nested function calls also work:

#Declare a function
fxa2-2
#Declare a function that calls the other one
fya*x-4
#Will print out 8
p*y

Also note that the only operations you can perform inside a function are the math functions, which are a, s, m, and d.

The code is up on tildegit, so clone a copy and get started with sandwich!

tags: sandwich, rust, programming, devlog

Sandwich devlog #2

February 08, 2021 — ~karx

Today (well, actually, yesterday. I just forgot to write this until just now), i did three things in the sandwich development process.

newline separator

the first thing i did was make the separator a \n instead of a space. because of this change, you can now print strings with spaces in them. for example, to print “Hello, world!” in the previous version, you had to do this:

pHello pWorld!

but they would actually print on separate lines. this is not what i wanted, so i changed it to look like this:

pHello world!

subsequent instructions would go on their own lines, rather than being next to other instructions.

explicit variable calls and comments

before, variables would get automatically get converted. however, this can be very annoying. this is what it looked like:

lhHello ph

but what if you wanted to print h? you’d have to set the variable h to be h, then print it out, then set it back to what it was before. to combat this, i’ve changed this to look like the following:

lhHello
p$h

variables are now denoted by a $ before its name.

i also added comments, which can be used like so:

pHello, world!
# the interpreter will skip the next line (and this line)
#pThis will not print

readme, license, code comments

i added a readme and a (un)license, so newcomers will know how to use the language. i also added comments to the code, so people readding the source code can tell what each peice of code does.

as always, please try to contribute to sandwich by sending a patch to my email or making a pull request on tildegit. instructions are in the README.

happy coding!

tags: sandwich, rust, programming, devlog

Make bashblog look the way you want it!

February 06, 2021 — ~karx

bashblog, in its default configuration, looks okay. but usually, it doesn’t fit with the style of the rest of your site. so how did i get it to do that? that’s what i’m going to show you today.

the first thing to do is to take a look at your .config file in the blog directory. it should look something like this:

global_title="my tildelog"
global_description="a blog about tildes"

this config is the file that configures bashblog. all the options are pretty clear as to what they do. now, we will make a head template. make a new file called .header.template. it should look like this:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <meta name="theme-color" content="#00cc00">


        <!-- Replace with whatever CSS you want to add -->
        <link rel="stylesheet" href="https://tilde.team/css/hacker.css">
        <link rel="stylesheet" href="card.css"> 

        <link rel="alternate" type="application/rss+xml" title="subscribe to this page..." href="feed.rss" />

notice that we didn’t close the <head> tag. now, add this line to your config:

header_file=".header.template"

now we will make a before and after body template. this is used for wrapping the content in some sort of container or card, like i did in this blog. make a file called .beforebody and add something like this:

<div class="container">
    <div class="card">
        <div class="card-body">

be sure not to close these divs unless you’re sure what you’re doing. next, make a file called .afterbody and use it to close out all the divs.

        </div>
    </div>
</div>

once you have added these files, add these lines to your config:

body_begin_file=".beforebody"
body_end_file=".afterbody"

your completed config file should now look like this:

global_title="my tildelog"
global_description="a blog about tildes"
header_file=".header.template"
body_begin_file=".beforebody"
body_end_file=".afterbody"

now all that’s left to do is to run bb rebuild and feast your eyes on your new, beautiful blog!

tags: bashblog, html, css

Reddi minus TOR

February 05, 2021 — ~karx

on this day, february 5th, 2021 (it’s the 5th already? dang), i figured out how to switch channels in irc (thanks to the people on #team!)

in other news, reddit no longer works on tor browser, giving a 503 error. you can still access old reddit on tor though, which makes me think that it’s a temporary configuration error of some sort. after all, 503 stands for service temporarily unavailable, so this might be fixed in a bit.

i’m also working on a funny little “programming language” called sandwich, written in rust. it doesn’t do much, currently it only prints strings and does the basic 4 mathematical operations. (add, subtract, multipy, divide) also you can’t print strings with spaces in them, because the separator for instructions is a space; therefore, if you try to print a string with a space, it’ll only print the first word and treat the next word(s) as instructions. it still needs a readme, preferably with installation instructions and language specifications. pull requests/patches sent to my email are welcome!

also, know how to add rust autocompletion to micro? trying to make a programming language without auto-completion is hard.

tags: reddit, tor, sandwich

Hello, World!

February 04, 2021 — ~karx

hey this blog thingy is pretty cool

i’ve been on tilde.team for about 43 minutes now, and i’ve pretty much set up a working shell environment

so this is my intro page, i guess?

you can reach me via my tilde.team email.

if you do happen to read this blog, please tell me how to switch channels in irc lol

here are some other places you can find me:

i’m proficient in python, html/css/js, and i’m dabbling in reactjs and rust.