TumbleConnect

Scroll less, discover more

Coding - Blog Posts

1 week ago

Warning: Contains rapidly changing colors


Tags
11 years ago

I made a parser

I made a parser for ~ATH in addition to the interpreter. I might make the interpreter use the parser at some point in the future, or I might not. If I made the interpreter use the parser, the code for the interpreter would probably be a little cleaner, and possibly a little faster.

The parser is available from my github.

To use it, call tokenize on the text, and then read_all_from on the result of tokenize.

The output will be a list of lists

https://github.com/drocta/TILDE-ATH-Parser

(haven't updated lately because of other unrelated projects, and also other reasons that aren't necessary to describe)


Tags
12 years ago

reading the contents of user input, and calculator improvement

This post will cover how to actually determine WHAT the user has typed, instead of just how long it is. It will also include how to interpret what the user enters as a binary number, so that its easier to type.

An Essential part of making it interpret binary numbers is making it double numbers repeatedly.

This actually has a few ways that can be done, so this is one of the first situations where coding style for this problem might differ from person to person. Because of this, I will say more than one way to do it.

The first way to do this it to copy the number twice, and then start from zero and add both of the copies. This is relatively inefficient, and would take

a copy thing, consisting of two bifurcates (which would take a little time)

where the size of the initial number is N, 2N normal bifurcates, 2N reverse bifurcates, and 4N lines relating to the actual loop

assuming each command takes the same amount of time (which is an oversimplification) this would take 9N+C line times. (C is a constant) This might be acceptable, but there is a more efficient and nicer looking way.

The second way is nicer looking, but still not the most effecient. However, when multiplying by a larger number(such as 3, or 4, or even large numbers), this method is part of what would be used.

The second method is essentially copying the number (using a reverse bifurcate and a normal bifurcate), and then adding the number to zero, except instead of each loop increasing the new number by one, it increases it by two. This is shorter, and it looks nicer. It also only takes half as many normal bifurcates. As a result, the number of steps it would take (again assuming each step is the same length) is 8N+C, instead of 9N+C 

this one I will write out, but it is still not the best way:

//N is the number initially BIFURCATE [NULL,NULL]2NULL; BIFURCATE [N,N]G; BIFURCATE G[NCOPY,JUNK]; BIFURCATE 2NULL[RESULT,JUNK]; ~ATH(NCOPY){ BIFURCATE NCOPY[JUNK,NCOPY]; BIFURCATE [BLAH,RESULT]RESULT; BIFURCATE [BLAH,RESULT]RESULT; } 

ok, so yeah. that takes N, and puts twice N into RESULT, but it is still inefficient.

A more efficient version is to copy the initial number, and add the number to itself. This way you only have to do half the number of reverse BIFURCATE statements. This is much more efficient, taking instead the steps:

a copy thing, consisting of two bifurcates (which would take a little time)

where the size of the initial number is N, N normal bifurcates, N reverse bifurcates, and 2N lines relating to the actual loop

This has 7N+C steps, which is a significant improvement. I think it is the fastest way to double a number in drocta ~ATH.

It is as follows (N is the number)

BIFURCATE [N,N]G; BIFURCATE G[NCOPY,RESULT]; ~ATH(NCOPY){ BIFURCATE NCOPY[JUNK,NCOPY]; BIFURCATE [BLAH,RESULT]RESULT; } 

This is shortest and fastest solution I have found. If you find a shorter or faster method, please tell me.

Ok. Now we can double numbers. That is good. That is an important step. But we still haven't gotten user input to be read in any reasonable way.

Hang on, I'm GETTING TO THAT. GEEZ. (I'm kidding, no one has been complaining about my taking so long, other than myself)

Ok, so here goes:

To interpret the binary number input and convert it to a "number", we can follow the following algorithm:

start with zero.(this is before the loop)

If there are any characters left, double the number that is being created.

remove the first character from the remaining characters. If it is "1" or whatever symbol (or alternatively if it is not "0"), add one to the number that is being created. Otherwise, continue onto step 4 without doing anything first.

go back to the start of the loop (step 2)

Ok. thats the algorithm we are going to use. But I STILL haven't explained how to recognize what the next character is. Seriously what is up with that?

What you do is you bifurcate the rest of the input into [the next character,the rest of the input].

Now you have the next character. Then what you do is you reverse bifurcate it with some other object, and then you check whether that object is already dead or not.

But how do you make it so the combination is already dead? How do you get the object for the character before the user has even inputed it?

Answer: You don't. Not in the current version of drocta ~ATH anyway. You will have to tell the user to enter all the characters they will be using ahead of time. Yes this is horrible and stupid. No its not exactly like that in the comic. Its ~ATH what do you expect? :P

that might change in future versions, but I will try to stay backwards compatible with that.

but anyway, back to comparing it:

so you say something along the lines of:

import comparingobject CMP1; othercodehere makeNEQ1besomethingalive BIFURCATE [CMP1,CHAR]EQ1; BIFURCATE [NULL,NULL]2NULL; ~ATH(EQ1){ print yep, they are equal; BIFURCATE 2NULL[EQ1,NEQ1]; } ~ATH(NEQ1){ print nope, they are not equal; BIFURCATE 2NULL[NEQ1,JUNK]; }  

in the othercodehere you get the character a head of time, and say BIFURCATE[CMP1,THECHARTHATMATCHESWITHCMP1]D; D.DIE();

That makes it so that it will go through the one section of code if the character is the right one, but something else if it is something else.

Which is what we want.

So to put it all together, and make the thing that interprets the input as a binary number(hold on tight(ok, what, why did I say that), this will be a long one(why am I talking like this?)):

import blah BLAH; print please enter whatever character you will be using for binary zero.; INPUT ZEROCHAR; BIFURCATE ZEROCHAR[ZEROCHAR,JUNK]; import chrcmp CMP0; BIFURCATE [CMP0,ZEROCHAR]D; D.DIE(); print please enter whatever character you will be using for binary one.; INPUT ONECHAR; BIFURCATE ONECHAR[ONECHAR,JUNK]; import chrcmp CMP1; BIFURCATE [CMP1,ONECHAR]D; D.DIE(); BIFURCATE [NULL,NULL]2NULL; BIFURCATE 2NULL[OUTNUM,JUNK]; print please input the binary number you want.(it will be converted to unary); INPUT BINNUM; ~ATH(BINNUM){ BIFURCATE [OUTNUM,OUTNUM]G; BIFURCATE G[NCOPY,OUTNUM]; ~ATH(NCOPY){ BIFURCATE NCOPY[JUNK,NCOPY]; BIFURCATE [BLAH,OUTNUM]OUTNUM; }  BIFURCATE BINNUM[CHAR,BINNUM]; BIFURCATE [CMP0,CHAR]NEQ0; ~ATH(NEQ0){ BIFURCATE [BLAH,OUTNUM]OUTNUM; BIFURCATE 2NULL[NEQ0,JUNK]; } } print ok, going to print it out in unary, with each digit on one line. If the number you entered was large you might want to close the program instead of hitting enter.; INPUT JUNK; BIFURCATE [OUTNUM,OUTNUM]GOUTNUM; BIFURCATE GOUTNUM[OUTNUMCOPY,JUNK]; ~ATH(OUTNUMCOPY){ BIFURCATE OUTNUMCOPY[JUNK,OUTNUMCOPY]; print 1; } print Am I a terrible person for writing this?; 

Oh gosh. I wish I could indent in tumblr. that is terrible to read. tumblr is a terrible source code editor.

One time someone called me a masochaist for writing this type of stuff.

And then we just have to put that together with the adding thing, and then maybe add a better way of outputting the number. maybe in binary.

HAHAHAHAH

ok, yeah, I'm going to put it together in the next post, not this one, because I have to homework now.(using the noun homework as a verb was intentional)

yeah. putting it together in the next post.

As always, if something was confusing, please ask for clarification.


Tags
12 years ago

User input, and a basic calculator.

Most programs people use have some form of user input. A calculator isn't much use if it always uses the same numbers after all!

~ATH of course accepts user input and output as shown in the file Roxy sent Jane.

Also I just found out you can put more than one read more line in one post.

The input command has the syntax:

INPUT VARNAME;

What this does is when program execution meets this line, the program pauses execution, allowing the user to input text. When the user hits enter, program execution will continue and the variable VARNAME will be made to point to an object corresponding to the text the user entered.

This object is such that the left half is the object that corresponds to the first character. If there is no character after that, the right half will be the NULL object. Otherwise the right half will be the object corresponding to the input without the first character. If they hit enter without inputting any characters the object will just be the NULL object.

Now that we have that all explained, we can start to make programs that actually take user input!

As you might have guessed from the title, the thing we will be making is a very basic calculator. All it does is add two numbers, like in the last example.

But in this, it will get the numbers from the user!

One simple way to do this is to use the length of the input text as the number: The way we define what we call numbers just so happens (heh) to be such that if we interpret the object for the input string as a number, the number will be the same as the length of the input!

This isn't the greatest solution, but it is easier than other methods. We will use this method first and then move on to other methods that are harder to write, but will be nicer when using the end program.

HERE WE GO:

ok, so like I said, much of it is pretty much the same as that previous program, so we might as well just include said here:

SOME CODE TO GET A AND B HERE import bluh BLAH; BIFURCATE [BLAH,A]ATEMP; BIFURCATE [BLAH,B]BTEMP; BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,NULL]C; BIFURCATE C[JUNK,C]; ~ATH(ATEMP){ BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE [BLAH,C]C; } ~ATH(BTEMP){ BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,C]C; } BIFURCATE [BLAH,C]CTEMP; BIFURCATE CTEMP[JUNK,CTEMP]; ~ATH(CTEMP){ BIFURCATE CTEMP[JUNK,CTEMP]; print some text; } print DONE!; 

so pretty much what we need to do it put the code to get A and B where that goes(at the beginning), as well as stuff to tell the user how to print stuff.

Like I said, the objects from the input commands can be interpreted as numbers.

so this becomes:

print INPUT SOMETHING WITH THE NUMBER OF CHARACTERS AS THE FIRST NUMBER YOU WANT TO ADD; INPUT A; print INPUT SOMETHING WITH THE NUMBER OF CHARACTERS AS THE SECOND NUMBER YOU WANT TO ADD; IMPORT B; import bluh BLAH; BIFURCATE [BLAH,A]ATEMP; BIFURCATE [BLAH,B]BTEMP; BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,NULL]C; BIFURCATE C[JUNK,C]; ~ATH(ATEMP){ BIFURCATE ATEMP[JUNK,ATEMP]; BIFURCATE [BLAH,C]C; } ~ATH(BTEMP){ BIFURCATE BTEMP[JUNK,BTEMP]; BIFURCATE [BLAH,C]C; } BIFURCATE [BLAH,C]CTEMP; BIFURCATE CTEMP[JUNK,CTEMP]; ~ATH(CTEMP){ BIFURCATE CTEMP[JUNK,CTEMP]; print some text; } print DONE!; 

So yeah. That should work. I still need to test this, but I am pretty dang sure that this works.(have to go do homework now) In the next post I will explain how to make it so that the user can type in the number as an actual number!


Tags
1 year ago

I was gonna post a video of a prototype of a thing I programmed but it took too long and I'm hungry so ill post it later

My online school offered me a really cool programming class where you build the entire decorative light box thingy. I made much more complex one but my family member put it in a bag when I told them not to and the ground wire snapped. But thats fine. 🙂 👌


Tags
2 years ago
Hello From The Academic Side :)

Hello from the academic side :)

Unlike everyone else, as someone who has not yet taken a vacation, I am at least entering my last week before the finals. But the endings are often harder…

After a coding war.. 🥲

For music: Çok Yorgunum

{Ladin}


Tags
2 years ago
HOW DO I FIX THIS?!?? I Just Want To Customize My Blog But I Don't Know What I Did To Receive This??

HOW DO I FIX THIS?!?? I just want to customize my blog but I don't know what I did to receive this?? HELP-

aaaaaaaaaaaaaaaaaaaaa


Tags
1 year ago

Can you get a job with just html, css and Java? Basically just as a front end developer ? With square space, Shopify, and WordPress does this take away a lot of need for front end developers?

Also with ai becoming more prominent is it "useless" to just have front end experience and are more companies wanting more people with back end experience?


Tags
4 months ago

I don't use social media that much anymore, but I saw this and I remembered ,,Hey I modified that one's code to work better on mobile" so I thought I would share how I did it!

(Disclaimer; I don't know how to code in CSS, I've only coded in C++ and thus mostly just... Deleted code and shortened the words, so if you can make this work better/in a not half baked way, then please do share!) This is basically how it looks;

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

For starters, install the extension the same way you would on a PC, it was the exact same procedure if I remember correctly (at least on Firefox, can't speak for Chrome)

Then you should be able to: go to extensions -> [whatever you used to run the code, in my case TamperMonkey] -> settings -> Installed Userscripts, and be able to see the and edit the code of the comment box script

Once there I went to shorten the text (as I have no idea how to properly set the sizes of everything) which is this line right here!

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

Just shorten what's in between the " ", without deleting them, I personally went with "Insert" only, but you can replace it with any text (shorter or more specific if you need!)

(Tiny side note here, when i comment quoting the Fanfic, I personally use the <blockquote> command and not the <i>, so if you want to change that instead of reviewing it manually, down there on line number 357 you can change the <i> </i> for the command you may use!)

For the "Add to Comment Box", I just shortened it to "Add" here on line 339

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

I had no idea how to edit the size of the "Font Size" bar, and just... Scrapped the code that displays it. Which is not the best thing to do, but I don't know this coding language and it was my best attempt; here from line 205 to line 222, delete it all

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

For the other commands, I just shortened them from "Delete" to "Del", "Full Chapter" to "Full", and "By Chapter" to "Chp" in the lines 273, 305, and 306 respectively;

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's
I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

And lastly! Once I had done all this, I noticed it was noticeably better, but now the box is too big for my screen! If this is a problem for you as it was me, you can change the outside box's size here;

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

(personally lowered it to "95%" and it worked perfectly fine, you can experiment with the other commands of this however to make it as long, short, tall or whatever else you may need!)

Note I did this all in my phone backtracking to my laptop's code, so this could definitely be better, and be done better first in a computer and then passed to phone. But essentially, that is all!!

Last couple of notes here, I changed both the "0" and "X" for opening/closing the box to ":3" and "xP" in the code because I just like it that way okay. (Change both "0"s that are there, as one is the first-time-appearing "0" and the second being the one that stays once you've already closed the box)

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

As well as also changing the blue colour of the select boxes to green, because I like green. These are the (easy) changeable hex codes for colour edition! The bed code next to primary is the blue colour, which I changed to green; success is the colour of a successfully inserted section, or added comment (to the ao3 box), which is green in the original code; and danger is the red tone of both the Delete button as well as the one for closing the box

I Don't Use Social Media That Much Anymore, But I Saw This And I Remembered ,,Hey I Modified That One's

In the spirit of encouraging people to comment on fanfics while also making it easier to do so, I feel obliged to share a browser extension for ao3 that has quite literally revolutionized the comment game for me.

I present to you: the floating ao3 comment box!

From what I've seen, a big problem for many people is that once you reach the comments at the bottom of a fic, your memory of it miraculously disappears. Anything you wanted to say is stuck ten paragraphs ago, and you barely remember what you thought while reading. This fixes that!

I'll give a little explanation on the features and how it works, but if you want to skip all that, here's the link.

The extension is visible as a small blue box in the upper left corner.

(Side note: The green colouring is not from the extension, that's me.)

In The Spirit Of Encouraging People To Comment On Fanfics While Also Making It Easier To Do So, I Feel

If you click on it, you open a comment box window at the bottom of your screen but not at the bottom of the fic. I opened my own fic for demonstrative purposes.

In The Spirit Of Encouraging People To Comment On Fanfics While Also Making It Easier To Do So, I Feel

The website also gives explanations on how exactly it functions, but I'll summarize regardless.

insert selection -> if you highlight a sentence in the fic it will be added in italics to the comment box

add to comment box -> once you're done writing your comment, you click this button and the entire thing will automatically copied to the ao3 comment box

delete -> self explanatory

on mulitchapter fics, you will be given the option to either add the comment to just the current chapter or the entire fic

The best part? You can simply close the window the same way you opened it and your progress will automatically be saved. So you can open it, comment on a paragraph, and then close it and keep reading without having the box in your face.

Comments are what keep writers going, and as both a writer and a reader, I think it's such an easy way of showing support and enthusiasm.


Tags
2 months ago
pqln-kelvin - Sem título

Tags
1 month ago

my lungs r on fire & i am full of ire

today there is much to do, such as arrange ten functions into a menu using jframes on netbeans,,, i feel like eclipse or intellij would be better but i have very little time to explore because of how much i have to do. also being ill these past few days has been less than ideal.

i have very limited spoons and breathing is very hard. fuck my yaoi life. i'll be working on C problems because i need to understand data structures better, but my minors are also creeping up on meeeee

will reblog w a progress update by EOD.


Tags
1 month ago

i am so sick rn but the leaf site got hacked and its shit got leaked. i fear i must get up just to see the uncommented 10k lines of code. what the fuck were you all doing. is this normal in php

how did the janitors live like this

were they operating this by sacrificing virgin lines of code to the maw of source files


Tags
2 months ago

The Pixar lamp on the left is the final touch that leads to perfection

i post from here. if you even care.

I Post From Here. If You Even Care.

Tags
1 month ago

Update :3

trying to make my first visual novel! just practing how to code so far as i never done it. I still have 2 months of highschool left so i'm just making something simple as my first attempted. My coding skills are literally non existent. Will try to post updates on how it's going. The finished visual novel will be free to play but very short :c Just a simple dating sim bc i really like dating sims. not used to writing, i got Expressive language disorder.


Tags
Loading...
End of content
No more pages to load
Explore Tumblr Blog
Search Through Tumblr Tags