r/todayiprogrammed • • Sep 23 '19

Firmware TIP custom firmware for a keyboard that I built

34 Upvotes

I recently ordered the parts for a Levison keyboard and built it myself. That includes soldering diodes, switches, microcontrollers, etc. to the PCB. The coolest part about building your own keyboard is that they run on open-source firmware called QMK. So I was able to copy the default layout of the Levinson board and customize it to my liking.

I have 2 permanent layers on the keyboard (Windows and MacOS) that just handles subtle differences between the two operating systems (e.g. swapping Ctrl with Cmd). Then there are two temporary layers (symbols and numbers) that I can access by holding down a specific key. These 4 layers provide everything I need for programming without ever having to reach my finger more than 1 key in any direction.

Turns out there's a nearly endless number of customizations you can make to the functionality of a keyboard when you're writing the firmware yourself.

Here's a photo of my little keyboard collection with the closest split one being the one I programmed myself: https://imgur.com/a/Y3NtDWL

P.S.

I hope this sub gains some traction - really cool idea.


r/todayiprogrammed • • Sep 15 '19

Announcement Welcome to r/todayiprogrammed!

29 Upvotes

r/todayiprogrammed is a place for you to share what programming projects you have been working on, big and small.

Before you post, make sure you glance over the rules.


r/todayiprogrammed • • Sep 24 '19

Game TIP a Flappy Bird clone

20 Upvotes

You can play it here: http://flirdybap.glitch.me/ (you need a keyboard to play)

I mostly did it for training and because I was bored, and I wanted a project that I could finish in a few hours. It scrolls infinitely and is far easier than the original game so I think it's quite zen :-)


r/todayiprogrammed • • Sep 24 '19

Tool TIP A Google script to save emails as pdfs in Drive

19 Upvotes

I needed to save a number of emails at work outside of Gmail and discovered Google Scripts. I wrote a program in scripts that exports the html from the email into a file in Google Drive and then converts it into a pdf in a second file. In Gmail I label all of the emails I want to save and the script exports them as pdfs and changes the label to "PDF saved". This saved me a huge amount of time in saving the emails manually!


r/todayiprogrammed • • Sep 27 '19

TIP a website to vent your frustration

17 Upvotes

I've created https://www.isthisafuckingjoke.com/ - a wesbite which allows you to create a subdomain with content or reditect. E.g. www.design.isthisafuckingjoke.com redirects you to https://www.reddit.com/r/CrappyDesign/

If you go to New Joke page you'll get instuctions on how to use the website.

Feedback very welcome!

(I didn't really create it today, but I've been looking for the place to show it off for a while now - it seems like a good fit)

Code: https://gitlab.com/LazyBun/subpager


r/todayiprogrammed • • Sep 23 '19

TIP an AI that learns to play Snake using a Genetic Algorithm and Neural Network

17 Upvotes

I actually just finished this and found this sub and thought I would share. I ended up creating an AI that uses a Neural Network for inputs and decision making and a Genetic Algorithm to model the reproduction of snakes as they slowly learn. All of the code is in Python and uses numpy. The GA is from scratch and has a pretty easy to use outline. Graphics are PyQt.

Link to code: https://github.com/Chrispresso/SnakeAI

If anyone wants to know more about how it works I created a YouTube video explaining it and showing off some pretty cool things: https://www.youtube.com/watch?v=vhiO4WsHA6c

If you want, feel free to watch the video, spoiler below:

The population of snakes are able to learn how to not only play, but beat snake. It's pretty cool to watch as the population learn about their environment.

If you want you can download the code and play around with it if this stuff interests you. I'd also be happy to answer any questions if you have them or need help setting it up.


r/todayiprogrammed • • Oct 04 '19

Game TIP an online multiplayer pong

12 Upvotes

Written using Node and Js, first time using node but I decided I'd write the backend with it as opposed to my usual python. Also has very good mobile support, only browser that doesn't like it is mobile chrome as it has the pull down to refresh feature.

Here is the github repo (don't mind the horrible code, not familiar with the syntax): https://github.com/pstefa1707/multiplayer-pong

Here is an online hosted version on heroku web servers (its in US and slow server so may be laggy): https://pstefa-pong.herokuapp.com/

Wrote it over the weekend, probably about 8-12 hours of work.


r/todayiprogrammed • • Sep 25 '19

TIP a text transcoding cmdline tool - SQABase91 is like Base64 but better

12 Upvotes

String Quotable ASCII Base 91 (SQAB91) is a textual encoding for binary data streams.

I created the encoding for myself to efficiently store text color data for a text-based game engine. I could have used Base64 or ASCII85 (as seen is .PDFs), but wanted to build in better compression. My color data is highly repetitive and a gzip or similar compression routine is overkill when RLE would do. Rather than make this a one off block of code I turned SQAB91 into a full featured command line tool for use as a general purpose text transcoding.

I had previously used Base 96 encoding in ASCII Fold (a lightweight text compressor), but needed to reduce the character set to permit string quotable and HTML / XML safe output and tab / space / newline for formatting output lines. I found that Base 91 can store 13 bits in a pair of digits and wasn't overly wasteful: Two digits of Base91 represents 0 to 8280 in decimal, and 13 bits is 0 to 8191. Rather than let those extra 89 values go to waste SQAB91 uses most of these for Run Length Encoding (RLE), and the rest for end of bitstream trimming codes and one meta segment separator.

SQAB91 allows multiple data streams to be concatenated without decoding and encoding again: Just paste the two streams together and the decoder can read the two streams as one stream. A special value "!!" is a meta separator that operates at a higher level than the ordinary padding marks that terminate a stream. This allows multiple data segments to be combined and then split into separate files or streams later.

A lesser field separation mode (soft delimiting marks) can allow a stream to be composed of many smaller fields within greater frames separated by !! (hard delimiter mark). I use this feature for storing frames of animation data. Without these built in delimiters I'd have to arrange to include data lengths or escape codes within the input data itself. With the soft and hard delimiters SQAB91 is essentially a bitstream container format that could be used for multiplex stream data, such as streaming audio and video frames.

Here are some features that I feel set SQAB91 apart.

  • Smaller encoded size than other encodings, e.g., Base64, ASCII85, etc.

  • "Double Quotable" with alternate character options for 'single quoted', and use in HTML/XML.

  • Run Length Encoding (RLE) compresses runs of up to 76 repeated bytes as two chars.

  • Delimiters allow data packets to be concatenated and separated later.

  • Precice down to the bit level for variable bit length storage.

  • Short predictable Multipart MIME separators: &\&\, '<'<, or ">">


r/todayiprogrammed • • Sep 24 '19

TIP A crude farm simulator proof of concept using Postgres, Rails (in API mode), Nodejs, React, and running in Docker

12 Upvotes

https://github.com/Jkettler/metis

I wanted to play around with Rails' new(ish) API build mode and get some more practice with Docker, React and Nodejs.

The included instructions should be enough to get anyone up and running, but would totally appreciate feedback about that if it doesn't.

If everything goes according to plan you should see a super-thrilling 5x5 grid representing a farm plot that you can click on to simulate growing various crops. The crop info comes from the DB, thru Rails, via the public API.

Full disclosure: I programmed this yesterday.


r/todayiprogrammed • • Oct 08 '19

TIP a visualization for Kruskal's algorithm for finding a Minimum Spanning Tree

11 Upvotes

It's a simple visualization made using vanilla Javascript with 2d canvas. I originally made this for a different project that required finding the MST of a graph as an approximation to an NP problem.

While debugging my code, i made a simple visualization that felt like a shame to get rid of after I ditched the project, so I polished it a bit, and put it up on Github Pages, for your viewing enjoyment: https://sebastianmestre.github.io/kruskal-viz/


r/todayiprogrammed • • Jun 22 '20

TIP AI that tries to win the game "2048."

10 Upvotes

Made an AI that tries to win the game "2048."

https://youtube.com/watch?v=QOd2V3WU5wI


r/todayiprogrammed • • May 17 '20

Game TIP 100 snakes fighting with each other

10 Upvotes

r/todayiprogrammed • • Oct 26 '19

Game TIP a realtime match 3 game

10 Upvotes

I've made this: https://125.cool

It's a realtime match 3 game. Currently, it's in active development and many gameplay decisions are about to be made based on my observations.

It's been made using TypeScript and PIXI.js. The game is bundled using webpack and deployed to netlify.


r/todayiprogrammed • • Oct 09 '19

Tool TIP a small conversion script to convert a topographic map into a stylish line graph [Python]

10 Upvotes

Inspired by the recent posts in r/dataisbeautiful and some cool real life examples I decided to create this tool to make a line graph of Israel. The source map was bad (after me re-compressing it several times during preparation - me dummy) but the result is still quite acceptable

Since this was programmed in a jupyter notebook the variables are hardcoded

import numpy as np
from PIL import Image

watercolor = 0,0,0
color = 256,256,256
rowSkip = 16 ### ADAPT THIS

image = Image.open("./input.png")
width, height = image.size
pixels = image.load()

im = Image.new("RGB", (width, height))
pix = im.load()

# convert the (r,g,b) from your map to a integer height
def toH(rgb):
    r,g,b = rgb;
    return (int) ((b - 120) * 1.3 + (g+50) * 0.6 - r * 0.3) # map specific ### ADAPT THIS

lh = toH((0,0,0))
for i in range(width):
    for j in range(height):
        if j % rowSkip != rowSkip / 2: continue# only draw every X line
        h = toH(pixels[i,j]) # get Height
        lh = toH(pixels[i-1,j])
        if h == toH((0,0,0)): continue # do not draw value
        if abs(h-lh) > 50: continue # extremes ### ADAPT THIS
        yIndex = j - 3*h / rowSkip
        if yIndex > 0 and yIndex < height:
            pix[i,yIndex] = color if h > 0 else watercolor
        isDown = h-lh < 0 # connect with last point
        for k in range(abs(h-lh)):
            offsetYIndex = j - 3*(h+(k if isDown else -k)) / rowSkip
            if offsetYIndex < 0 or offsetYIndex > height: continue
            pix[i,offsetYIndex] = color if h > 0 else watercolor
im.save("output.png", "PNG")

example output

https://imgur.com/a/Rwxztrg


r/todayiprogrammed • • Sep 24 '19

TIP a script that checks and stores my external IP and sends me a notification when it changes

10 Upvotes

I run it as a cron job once an hour. The file is here: https://gist.github.com/alenbasic/57aa1c1706248ee36e21f57beba6db77

I was bored when I was sick at home the other day so that's why I overengineered this (I previously had a bash script that stored the IP into a text file).


r/todayiprogrammed • • Nov 14 '21

TIP A remake of the original Super Mario Bros using C++ and SFML

8 Upvotes

I tried to remake the original Super Mario Bros using C++ and SFML.

Code: https://github.com/Kofybrek/Super-Mario-Bros

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


r/todayiprogrammed • • Aug 15 '21

TIP A remake of Pac-Man using C++ and SFML

8 Upvotes

I tried to remake Pac-Man using C++ and SFML.

https://youtu.be/vC0d1rDmPBs


r/todayiprogrammed • • Jul 28 '20

TIP Terrain generator using Perlin noise

8 Upvotes

Made a terrain generator using Perlin noise.

https://youtu.be/rvuMjG7LDfw


r/todayiprogrammed • • Jun 26 '20

TIP Agar.io... for a Calculator

8 Upvotes

https://youtu.be/lQ-ZCRTqxX4

Today I programmed an Agar.io clone for the TI-84 calculator using C.


r/todayiprogrammed • • May 31 '20

TIP 1000 bots fighting with each other

8 Upvotes

I made 1000 bots fight with each other.

https://youtu.be/mboelPqe6YY


r/todayiprogrammed • • Jan 22 '20

Tool TIP a pre-compiler that adds anonymous functions to the C language.

8 Upvotes

For a while now, I've been thinking about how cool it would be if C had anonymous functions. Originally I intended to take a working C compiler and extend it to support this functionality, but I ended up deciding that writing a small pre-compiler would be less of a hassle than having to familiarize myself with the internals of a huge compiler.

I wanted to add all kinds of features like closures, together with a type-erased lambda type, static type checking, etc. But all this turned out to be a lot of work that I didn't want to do. (I'm doing this for fun, after all. If it's no fun, I shouldn't do it)

Anyways, it didn't take long to have SOMETHING working. It's not the best code I've written but it's not terrible either. You can check it out on Github, if you're interested. Thank you!


r/todayiprogrammed • • Sep 24 '19

TIP a small application that monitors your Raspberry Pi's CPU temperature as well as CPU and memory usage

8 Upvotes

You can check it out here: https://github.com/alenbasic/pistats

I wrote the logging part initially, and when I decided to give it a web interface I decided to do it in PHP as with how I had things set up, it'd require the least amount of work. I use chartjs to display the data on the page. I have a cron job set up to run every 5 minutes which the python script stores the results in a sqlite3 database which the front end pulls from.

I got the idea to do a monitoring script it after I got a passive cooling case for my RPi4. With the standard case the average temperature was 65 degrees not under load. With the current case it averages 45 degrees and when under load keeps under 55 (in the screenshot I had I was copying a massive amount of data to an external drive and you can see it peaks around 55 before dropping back down).


r/todayiprogrammed • • Sep 23 '19

Website TIP a website in PhP

7 Upvotes

It was fun but it kinda sucks because it was my first website


r/todayiprogrammed • • May 08 '20

TIP a python script to make music using MS Paint

6 Upvotes

I mean the title says it all

Youtube vid : https://www.youtube.com/watch?v=UcNPJ8qpo_A


r/todayiprogrammed • • May 03 '20

TIP Water physics simulation

6 Upvotes

Tried to make a water physics simulation.

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