By popular* request, I've created a table of contents page!

Here you go: Table of contents

Hello again

Somebody got into my Wordpress site and messed with it a fair bit. Of course it was my fault for not updating Wordpress for so long, but still. I've decided to remove just about everything on the server; I never liked Wordpress much anyways.

If you'd like to find me, there's a couple places you could look:

- Liam Long, long ago

I wonder

I wonder how reliable this site is? Let's see how long it's going to stay on the internet. Need to make web archive backups.

- Liam

I've got good news and bad news

Bad news first: BasicEdit is gone.

Good news: BasicEdit was terrible, I don't like it, and I don't think I learned that much in the process of making it!

(Hi Wettining!)

Oh yeah, there's also this which apparently I still have on the server. It's not great, but at least it's something I made a long time ago that was better than BasicEdit.

- Liam

This is a graveyard

Well, it isn't yet, but by the time you read this, it probably will be.

But it's fun to have an old place like this, right? Where you or anybody in a million years can see what I'm doing?

Too bad web browsers will probably be irrelevant.

- Liam

Boolean casting

Sometimes booleans (Booleans?) cast to numbers, and when they do, you can do some pretty interesting things. Here are generally the boolean casting rules:

  1. If a boolean's value is false, it will cast as a number to 0.
  2. If a boolean's value is true, it will cast as a number to 1.

Recently there's been an online project a bunch of people have participated in where you need to pass a color given an X and a Y position, using only one line of code. Boolean to number casting is allowed and it makes for a pretty useful tool.

For example, here's a piece of code that returns 100 assuming x is in range 20, 60 and y is in range 40, 90, and 50 otherwise:

50 + 50 * (x >= 20 & x <= 60 & y >= 40 & y <= 90)

The important part is the "50 * (condition)" part. If the condition is true, it'll be interpreted as "50 * 1", so 50. If the condition is false, it'll be interpreted as "50 * 0", or 0. Add 50 to that and you get 100 for positions in the range and 50 for numbers not in the range.

So to translate some pseudocode into inline-math-boolean-code:

condition ? x : 0

..is this:

x * condition

Changing that 0 is more difficult. This:

condition ? x : y

..gets turned into this:

x * condition + y * !condition

If condition is true, use x; if NOT condition is true, use y. (I'm not testing any of the code here. Yay logic!)

Let's say we want a pattern more or less like this:

00000000000
01010101000
00101010000
01010101000
00101010000
01010101000
00000000000

It's a checkerboard from 1,1 (excuse the starting-at-index-zero) to 7,5. Here's the checkerboard code - again, it should work, but I haven't tested it:

(1 + x + y) % 2

Here's the range condition:

x >= 1 & x <= 7 & y >= 1 & y <= 5

Put together:

((1 + x + y) % 2) * (x >= 1 & x <= 7 & y >= 1 & y <= 5)

(Parenthesis are to remove ambiguity.)

And that's with a binary black/white screen, people have made much more amazing programs using colors - there's actually a 3D sphere render entry! But if I'm understanding the programs correctly, drawing colors (probably generated by the program) based on range conditions (also probably generated by the program) is generally how the programs work.

I could be absolutely wrong though!

- Liam

My programming skills are fine

..but my pixel art skills aren't great. I made an isometric bridge maker thing today, and then I tried to make a duck with it.

Isometric duck

Amazing?

- Liam

Untrusted notes

By "Untrusted" I mean this cool game. In essence you're put into a room and you need to control objects, the environment, and yourself using code. Here are some of the more clever (in my own humble opinion) code entries I used.. (In GitHub Gist, because I'm too sensible to rewrite my code all escaped!)

Link!

(Update: pastes didn't quite work as well as I'd like them to. Blame the code editor in that project! It messes with indentation!)

- Liam

DS Hack

(The original title of this was going to be "DS Hack using microSD to connect to other devices idea", but that was too long.)

You know how there are fancy homebrew/emulation tools for the DS like the Supercard DSTwo 4-in-1? I got one of those recently and I've been using it a lot, and just now I got an idea - what if you hacked the microSD to take information from a network (and store that in a file)? It could be used for basic messaging from the DS to another device, such as your computer, as well as the other way around. Might be an interesting project.

Of course first you need to figure out how to hack the microSD. I have no idea how. Thankfully it looks like somebody else has already done that! ..But that's with an SD card, not a microSD. Hmm.

Here's something else.

I highly doubt that an ordinary microSD is going to come with some method of connecting to a network (or maybe whatever bluetooth is - I know nothing about it!) though, so.. good luck with this idea.

And it'd need to be an actual hack of the microSD hardware - you aren't going to be able to use an adapter of any kind blah blah, because then it won't fit in whatever homebrew DS card you're using.

Apparently you can send code to run over wifi to a microSD? I haven't read into it much but if that's possible perhaps you could get it to run some file-write code, for the DS program you made to read.. Dunno if that's only on boot-up (is that a thing for these cards?) though.

- Liam

Should you use Minecraft 1.9 command blocks properly?

Let's find out! I've been working on a big project in Minecraft recently (you hackers on Xx_LeeterHax0rzOnG4mes_xX-YT probably know about it, maybe I'll write about it here at some point?) that involves lots of redstone and command blocks, so I think it's an appropriate test case.

Before learning how to use 1.9 command blocks:

before

After learning how to use 1.9 command blocks:

after

I'll let you decide which to use.

Did you know you can hold your mouse still over images to get a little tooltip text?

- Liam

Looking for old terminal commands

Looking for old terminal commands is fun! I like to do a simple history | grep:

$ history | grep suspend
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend
history | grep suspend

- Liam

RSS and stuff

Using the horrendous monster called PHP, I made an RSS feed everybody can use. Yay.

Also you should keep an eye on the table of contents. Occasionally I put things there.

The table of contents still isn't automatically updated, though. Yay!

- Liam

Just a counter

- Liam

The most helpful bash pipe

xargs -r "printf > (file)"

(If you're on a Mac, like me, the -r flag is implied, and will actually throw an error, so make sure you remove it.)

It sends errors to your terminal and success to a file.

It's really handy for a program I'm making right now that fetches data from a webpage and outputs the data, which I want to send to a file.

- Liam

Bad names

const f = n => { return {
  valueOf() {
    return n
  }
}}

let k = f(32)
k=f(++k)
k=f(++k)
k=f(++k)
k=f(++k)
console.log(+k)

It was an accident, I swear! (Not literally.. :))

(Context: responding to this StackOverflow question.)

- Liam

Still alive

I'm still alive!

This is going to be a little long just because I feel like rambling, so.. sections!

On blogs

Mildly shocking judging by the fact that it's been nearly a month since my last post here.

Did I mention that this is a graveyard?

Anywho, blogs are interesting. For instance Stalkertron 2000 has been going for over sixteen years, and somehow it's still awesome. That's motivating!

Then there are other blogs such as tuibooks.com where you wonder if the blog is abandoned. Judging by the fact that the last post was over two months ago that's reasonable to wonder, right?

So no, this blog hasn't been abandoned (yet).

On music

This is good music.

On programming

This afternoon my friend __init__ thought it would be funny if he played a Practical Joke(tm) on me and reminded me of one of my old projects. Like, "I was eleven" old. That's a long time ago.

Anyways he linked to an old project I made called BaseCode. Apparently that was supposed to be some kind of Ultimate Modding Experience(tm) (no, seriously). Silly, right? Well, I looked at it, figuratively cringed for a moment, and decided to try something with it.

But first, a summary of BaseCode..

BaseCode was all about modding. You'd basically add modules to make commands.. well, I assume. Judging by the very uncommented source code of the project. I think I originally used the word "modding" as in "modifying", but in retrospect I think thinking of it as in "adding modules" is better.

Supposedly it was supposed to be a programming language, but frankly it's better as a really small scripting language. If you mod it. On its own, do you know what it can do?

Print things!

Wow, that was surprising.

So think of it as a really bare command line interface (to a realistically unuseful world).

The biggest thing I found it was lacking, experimenting with it this morning, was files. Oops. A little inconvenient, not having files. I figured that since the whole point of the project was modding, I might as well make a file system mod. Sound kind of silly?

Implementing the file system wasn't that hard, actually. It was really mostly just implementing the different methods on files. Here's a quick summary of how it works:

There's a big Scratch list of strings called filedata. It's your entire storage area. The contents of the list is fairly self-descriptive, so here's some example contents:

MYFILE
HELLO
WORLD
**TERMINATE**
BRAGPROG
ECHO THIS IS AMAZING
ECHO I'M VERY GOOD AT MAKING PROGRAMS.
ECHO I SHOULD STOP BRAGGING
**TERMINATE**

Get the structure?

  1. File name.
  2. Any contents - this would be spread out over multiple lines/list items.
  3. A **TERMINATE** string to terminate the file.

Pro-tip: don't put **TERMINATE** in your files!

I created a few commands to basically make that list and then I was done. But a little note: I figured you'd need a way to edit and make your files. Kind of obvious. The general idea was that you'd use the text buffer to create a file like you would a program:

1 HELLO
2 WORLD

And after you had that in the text buffer (which you could RUN if you wanted to) you save it into a file with FS.WRITE:

FS.WRITE MYFILE

Later, you could get back to the file using FS.READ:

FS.READ MYFILE
READ

And that's all there is to it. It's not my greatest program, but I'm kind of proud of how I got it to work.

Finishing words

Haha, you wanted finishing words!

Well, I have none.. sorry.. and I don't really have anything to pay you back with.. please don't kill me?

- Liam