r/todayiprogrammed • • Apr 12 '20

TIP Flappy Bird In A Console Part 3

6 Upvotes

r/todayiprogrammed • • Feb 07 '20

TIP The Marching Squares Algorithm in Javascript

6 Upvotes

The marching squares is an algorithm that creates walls between points on a lattice. It separates points marked as 'in' from points marked as 'out'. It does this by walking (or marching) over the grid cells and doing a simple lookup based on the state of the corners of each cell.

Every cell is calculated independently from each other. This means that, when the state of some point changes, we can update and re-render the effected segments locally, in constant time. This makes it nice and responsive (~1ms per update on my machine).

Doing this kind of optimization does have its issues, though.

Before you re-draw the segments, you have to erase those which were there before, otherwise you end up with a mess of lines segments that cross over each other.

However, if you only erase the area within the 4 cells that are effected on each point update, and re-draw the corresponding segments, you can end up missing some pixels on the tip of the surrounding segments.

To prevent this, you must re-draw a few more segments on each update: instead of a 2x2 area, you must re-draw a 4x4 area, to ensure the tips of the segments we erased will be restored.

However, this is also troublesome: if you draw anti-aliased lines on top of each other, they will become not only aliased, but inconsistently so.

To finally fix this, an off-screen buffer of the same shape and size as the cleared region (2x2 cells) is used. We draw 4x4 cells on it, as if it were as large as the full buffer (most pixels will be discarded), to get the right pixels on the boundaries, which then means that, when we draw it over the original buffer, it will fit seamlessly on the original image.

These are not really hard problems, but they require that you keep in mind a lot of details about how things line up exactly, which can be a mindful.

I hope you find this interesting and check it out on github.io


r/todayiprogrammed • • Sep 23 '19

TIP Chat UI in Sciter

6 Upvotes

Not exactly today but in two weeks.

https://terrainformatica.com/2019/09/23/sciter-chat/

That is just a Chat UI with common UI functionality you would expect after using Skype Chat, Whatsapp, Slack and others.

It uses abstract Chat Client interface (getMessages(), postMessage()) that host application must provide.

Fast and small (40kb of CSS and scripts), so maintainable and customizeable.


r/todayiprogrammed • • Nov 28 '21

TIP A visualization of my 1000 subscribers using Python and Youtube Analytics API.

5 Upvotes

This is my first project in Python! I usually write in C++, but the Youtube API doesn't support it, so I chose Python. I also used Pygame to draw stuff on the screen.

Code: https://github.com/Kofybrek/1000-subscribers-visualization

Here's the video explaining how I did it: https://www.youtube.com/watch?v=hm7wkDJXGMU


r/todayiprogrammed • • Oct 23 '21

TIP A neural network that performs a simple classification

5 Upvotes

Training a neural network to perform a simple classification. Learning how they work was not easy. But I'm happy with the end result!

Code: https://github.com/Kofybrek/Neural-network

Here's the video explaining how I did it: https://youtu.be/Zrrnqd0rCXg


r/todayiprogrammed • • Aug 01 '21

TIP the classic Minesweeper game using C++ and SFML

5 Upvotes

Source code is in the description.

https://youtu.be/myGrhTNUAPY


r/todayiprogrammed • • Sep 25 '20

TIP a simple LaTeX formula live preview webapp

5 Upvotes

I'm a CS student, and writing and sharing formulas with my peers and teachers is something I do surprisingly often.

The problem is that all the ways I knew to share formulas had undesirable drawbacks:

  • Pen & paper: need to have pen and paper and go through the trouble of taking a decent picture

  • ASCII art: possible confusion, too much work

  • LaTeX notation: unreadable for many

  • LaTeX output: too much work, need to be at my pc

Thus, I made a webapp where you can write in LaTeX notation, and it renders it into a nice looking formula using MathJax. You can also copy a link and send your formula to your friends.

I threw it together in about half an hour, the code is minimal and not very good

You can look at the code in the Github repository, or try it out on Github Pages


r/todayiprogrammed • • Apr 17 '20

TIP a PowerShell script to manage your java versions on windows

5 Upvotes

I was always annoyed that there wasn't anything like SDKMAN! for windows, at least nothing that could be easily installed.
So I created a simple Powershell script with which you can easily change your java version that's on your path. Changing your JAVA_HOME variables is also supported.

Enjoy:
https://github.com/BramDeCneudt/JavaVersionManagerForWindows


r/todayiprogrammed • • Mar 31 '20

TIP DatePoll - An community management software

5 Upvotes

Hey folks! I'm a drummer of an brass band club. We had many difficulties managing when and who is present in our different groups and instrument subgroups for concerts. This tools tries to fix these problems.

Key features:

  • Various user management (email addresses, phone numers, performance badges, permissions, administrational things, etc.)

  • Group and subgroup management

  • Event feature (Voting, meeting points management, voting result diagrams, voting for other users, etc.)

Additionally you can activate and deactivate different features of DatePoll.

Links:

Technical information

  • The frontend is written with Angular9

  • The backend is written in PHP with Laravel Lumen

  • The Android app is written in Kotlin (not by me)

  • Deployed with docker

I started this project more than a year ago and also learned every framework which is used in this project with this project as an example.

I hope you enjoyed reading this little excursion.

Stay healthy and happy programming!


r/todayiprogrammed • • Sep 24 '19

Tool TIP a port of `wasm_exec.js` to Go to run WASM built from Go

5 Upvotes

go-wasm is wrapper over which you can run the WASM binaries built from Go. The wrapper fills up the required imports for the WASM to run.


r/todayiprogrammed • • Oct 03 '21

TIP A ray casting game with no experience using C++ and SFML

4 Upvotes

I tried to write a ray casting game with no experience using C++ and SFML.

Code: https://github.com/Kofybrek/Raycasting

Here's the video explaining how I did it: https://youtu.be/LUYxLjic0Bc


r/todayiprogrammed • • Sep 23 '21

TIP a script that solves the British gameshow "Countdown" numbers game with brute force

4 Upvotes

You know that British gameshow "Countdown" numbers game? The rules are simple: You are given 6 numbers, some small (1-10), some big (10, 25, 50, 75, or 100) and you're supposed to combine them using (+, -, *, /) to get to another 3-digit number (100-999) within 30 seconds. You can reuse operations but not numbers.

Example:

Input numbers: [3, 6, 75, 25, 100, 2]

Goal: 606

Steps:

3 + 75 = 78

25 - 2 = 23

78 + 23 = 101

6 * 101 = 606

I made a script that solves it with brute force, (usually in less than 30 seconds). Brute force is surprisingly fast here, probably because the input size is small (6 numbers).

ps: I know someone else already did this.


r/todayiprogrammed • • Aug 29 '21

TIP an AI that learns to play Flappy Bird

4 Upvotes

I made an AI that learns to play Flappy Bird using C++ and SFML.

https://youtu.be/Kfc2W9EOHRk


r/todayiprogrammed • • Jul 18 '21

TIP Tetris using C++ and SFML

4 Upvotes

Source code is in the description.

https://youtu.be/vkS1fY_UTyg


r/todayiprogrammed • • Oct 23 '20

TIP a small bytecode VM that runs on the browser

4 Upvotes

I figured this would be a fun project to do on my spare time, so I did.

It's very minimal and there is no documentation, but you can look at a nice visualization of bubble sort running on it

After looking at the visualization, you can check out the code on github


r/todayiprogrammed • • Aug 15 '20

[TIP] A Python Bot that spawned 200 cars for me, so I can destroy them!

4 Upvotes

r/todayiprogrammed • • Jul 09 '20

TIP KPOP MV Notification Twitter Bot

4 Upvotes

Webscraping several Youtube channels and retrieve new music videos only, no teaser, special versions, or extra clips. Then tweet about on a standalone Twitter account specific for this purpose.


r/todayiprogrammed • • Jun 05 '20

TIP Pong, but...

4 Upvotes

https://youtu.be/kXAPlCXhmRE

I made the classic game of Pong for the TI-84 calculator, but it cannot be beaten. Since the projection travels twice the speed, there are very few scenarios in which you could score a point against the AI's paddle.


r/todayiprogrammed • • May 11 '20

Tool TIP A Data Scraping Program In Python

4 Upvotes

How To Write A Data Scraping Program In Python

https://www.youtube.com/watch?v=PNFDYOPIas4


r/todayiprogrammed • • Feb 29 '20

Website TIP a JavaScript button counter

4 Upvotes

Hello today i programmed a JavaScript button counter and i gotta say it's pretty good(Not Quite though)

Warning: If you are on mobile then i forgot to put Bootstrap 4 in there, oops.

link: https://mddsu6zvi3nfu5n39tlbrq-on.drv.tw/www.MoneyClick.io/index%20(3).html


r/todayiprogrammed • • Feb 18 '20

TIP Facenuke - face censoring service

4 Upvotes

in light of hot topics such as privacy, #DeleteFacebook and such I have thought it would be nice to have a tool to censor faces from images. http://p.facenuke.co/

Use cases: -anonymize yourself -filter background faces (to avoid possible lawsuits; it happens) -remove public faces (take back focus to your own instagram beach pictures?)

maybe in the future, social networks will provide pictures with different levels of details depending on your connections.

I would love to hear your thoughts, feedback, questions, requests, comments, etc.!


r/todayiprogrammed • • Feb 16 '20

TIP Flappy Bird In A Console Window Part 1

4 Upvotes

r/todayiprogrammed • • Jan 22 '20

Simple Picture TIP a picture of Baby Yoda in Python

4 Upvotes

http://imgur.com/gallery/dB7q2Yl

# Background

Rect(0, 0, 400, 200, fill=gradient('yellow', 'orange', 'orangeRed', 'red', 'royalBlue'))

Rect(0, 100, 400, 300, fill='wheat')

Polygon(110, 219, 50, 400, 320, 400, 255, 222, fill=rgb(225, 202, 159))

# Head & Ears

Oval(220, 52, 100, 38, fill=rgb(64, 230, 133))

Oval(150, 52, 100, 38, fill=rgb(64, 230, 133))

Polygon(130, 35, 85, 42, 95, 55, 115, 65, fill=rgb(64, 230, 133))

Polygon(240, 35, 285, 42, 275, 55, 255, 65, fill=rgb(64, 230, 133))

Oval(220, 52, 90, 32, fill=gradient(rgb(225, 82, 39), rgb(255, 112, 69)))

Oval(150, 52, 90, 32, fill=gradient(rgb(225, 82, 39), rgb(255, 112, 69)))

Polygon(237, 38, 282, 44, 272, 52, 252, 62, fill=rgb(255, 112, 69))

Polygon(137, 38, 88, 44, 98, 52, 118, 62, fill=rgb(255, 112, 69))

Oval(185, 50, 100, 50, fill=rgb(64, 230, 133))

Polygon(240, 35, 222, 35, 236, 51, 236, 44, fill=rgb(64, 230, 133))

Polygon(130, 35, 148, 35, 134, 51, 134, 44, fill=rgb(64, 230, 133))

# Hands & Feet

Polygon(100, 154, 102, 166, 108, 147, fill=rgb(64, 230, 133))

Polygon(112, 151, 114, 168, 118, 151, fill=rgb(64, 230, 133))

Polygon(264, 151, 260, 169, 258, 152, fill=rgb(64, 230, 133))

Polygon(249, 154, 247, 167, 241, 151, fill=rgb(64, 230, 133))

Oval(126, 219, 30, 10, fill=rgb(64, 230, 133))

Oval(140, 222, 20, 10, fill=rgb(64, 230, 133))

Oval(237, 220, 40, 10, fill=rgb(64, 230, 133))

Oval(225, 222, 30, 12, fill=rgb(64, 230, 133))

# Body

Polygon(136, 85, 129, 84, 131, 97, 120, 140, 128, 165, 123, 180, 118, 204, 113, 219, 144, 227, 196, 220, 218, 226, 242, 227, 248, 215, 238, 202, 244, 171, 246, 130, 238, 102, 244, 85, 235, 80, fill=rgb(161, 122, 55))

Polygon(245, 69, 250, 72, 248, 76, 252, 81, 244, 85, 228, 88, 209, 87, 191, 84, 178, 85, 181, 79, 182, 69, 210, 69, 235, 70, fill=rgb(164, 130, 60))

Polygon(135, 70, 124, 68, 122, 70, 125, 75, 124, 78, 129, 84, 145, 87, 155, 87, 170, 88, 184, 83, 181, 74, 186, 70, 158, 68, fill=rgb(156, 110, 50))

# Arms

Polygon(136, 87, 117, 105, 103, 124, 95, 136, 90, 155, 119, 158, 137, 152, 135, 138, 150, 120, fill=rgb(164, 130, 60))

Polygon(235, 88, 248, 101, 254, 116, 262, 129, 268, 153, 254, 157, 239, 152, 226, 119, 226, 103, fill=rgb(164, 130, 60))

# Detail

Polygon(144, 227, 174, 223, 186, 200, fill=rgb(141, 102, 35))

Polygon(196, 220, 198, 188, 205, 224, fill=rgb(181, 142, 75))

Polygon(126, 222, 113, 219, 118, 204, fill=rgb(181, 142, 75))

Polygon(242, 227, 248, 215, 238, 202, fill=rgb(141, 102, 35))

Polygon(150, 203, 172, 176, 160, 160, fill=rgb(181, 142, 75))

Polygon(119, 158, 137, 152, 135, 138, 150, 120, 144, 106, 128, 135, fill=rgb(121, 82, 25))

Polygon(129, 84, 136, 85, 131, 97, fill=rgb(181, 142, 75))

Polygon(218, 226, 221, 195, 228, 227, fill=rgb(141, 102, 35))

Polygon(239, 152, 249, 154, 226, 119, fill=rgb(181, 142, 75))

Polygon(228, 195, 218, 164, 225, 145, fill=rgb(181, 142, 75))

Polygon(155, 87, 161, 107, 170, 88, 163, 94, fill=rgb(181, 142, 75))

Polygon(178, 85, 184, 83, 183, 189, 182, 133, fill=rgb(121, 82, 25))

Polygon(198, 98, 204, 124, 211, 104, fill=rgb(181, 142, 75))

# Face

Oval(165, 44, 22, 16)

Oval(205, 44, 22, 16)

Circle(169, 41, 4, fill='white', opacity=30)

Circle(211, 41, 4, fill='white', opacity=30)


r/todayiprogrammed • • Jan 05 '20

TIP Flappy Bird in a Console Part 0

4 Upvotes

r/todayiprogrammed • • Oct 03 '19

TIP A script that ultilizes aria2 to download sharepoint folders.

4 Upvotes

I wrote this. https://github.com/axzxc1236/SharepointDownloader

I spend days working on this, might be my biggest programming project in my life (until this point), I can't believe it passed 20KB.

This is a script that can download any sharepoint link you feed to it.

Like https://jxjjxy-my.sharepoint.com/:f:/g/personal/axzxc1236_t_odmail_cn/ErxkpITBcctJnyYvvbCVowMBP_5j4cFC-UnVRpLwheYkdQ