Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
Found the internet!

AskProgramming

r/AskProgramming

Vote
Posted by2 hours ago

I have a DSL written in Antlr4 (https://www.antlr.org/) but need to port it to langium (https://langium.org/) as I want to take advantage of several langium features.

Does anyone know of either a automatic converter, or a comparison that will make this easier ?

Vote
1 comment
7
29
Vote
Posted by41 minutes ago

I would like to get up and running with this WikiSource export tool: https://github.com/wikimedia/ws-export

The documentation isn't detailed enough for a beginner like me:

Create a mysql database and database user and add these details to .env.local
.

Create the database with ./bin/console doctrine:database:create

Run the migrations with ./bin/console doctrine:migrations:migrate

This tool uses the Toolforge Bundle, and it connects to multiple databases.

Set replicas credentials in the .env.local
file.

Establish an SSH tunnel to the replicas (only necessary on local environments)

$ ./bin/console toolforge:ssh

Vote
0 comments
Vote
Posted by2 hours ago

Let it be known: I'm not an algorithms expert.

Dissolve

I'm trying to create a dissolve effect from one image to another on an LCD display.

While it's a 2d image, I'll just use i to refer to the pixel index and n the max number of pixels. (The 2d index can just be computed: y = i / WIDTH; x = i % WIDTH;) For the sake of completeness, assume every pixel changes: checking if the pixel is filled will always yield false if not filled and true if filled... no extra memory required.

Stupid method. Smallest code memory, perhaps?

The most naive/simple way I can imagine is also the one that takes the longest... while (1) { i = WIDTH*HEIGHT*rand(); fillpixel(i); } but has zero overhead. It's perhaps the dissolve equivalent of bogosort.

Zero memory (or close to zero)

If you want to finish at some point using the previous method, you'd need to eventually scan for whichever pixels haven't been filled and fill only those at random. I'd say we do the entire dissolve this way and call it, "good." To recap: The "good" zero memory technique is to pick a random number from 0 to n-1 and fillpixel, then pick from 0 to n-2, and fillpixel but jump the existing pixel if you reach it, then 0 to n-3 (jumping filled pixels) and so on. This takes longer than ideal but is guaranteed to terminate within one's lifetime.

Zero search time + zero overall added time with pre-stored (not randomized at runtime) table, otherwise linear shuffle time

The quickest method would be to have a lookup table already prepared with the numbers from 0 to n-1 randomly sorted. Then, you loop through the lookup table and fillpixel. This, however, would require the same amount of space as the image, so it's not memory-efficient. Shuffling would be quick... Fisher-Yates or similar.

Vote
1 comment
2
Posted by7 hours ago
2
3 comments

About Community

A subreddit for all your programming questions.
Created Mar 31, 2011
r/AskProgramming topics

86.4k

Members

91

Online

Top 5%

Ranked by Size

r/AskProgramming Rules

1.
No Self-Promotion
2.
No Trolling, Baiting, etc.
3.
Must be Programming related
4.
No Illegal/unethical activities
5.
No commercial offers
6.
No academic dishonesty
7.
Title and post quality
8.
Code must be text and properly formatted

Moderators

Moderator list hidden. Learn More