Share your projects


Lay down carpet then. Or is your mom strictly against carpet?
no idea my mom lives on the other side of Brisbane... 50 Km away..lol
The missus falls asleep with the remote on her lap. when she gets up to go to bed the remote sometimes goes flying and misses the rug...
 
I've been pondering about using Unicode Character 'LOWER HALF BLOCK' to double the pixel resolution on a terminal, such that the background and foreground colors of that block are "two pixels" in one.
So I searched the web on how to get pixel information from ImageMagick, which I then feed to a perl script to join together (so two pixel lines make one ascii line).
I then tried to convert the truetype colors to RGB256, and the result was rather bland when using real pictures, but okayish with drawings. Then I added file compression by checking the previous pixel, and if it's the same color, it skips printing the ansi escape codes.
Improvements can be made by using quadrants to curve-fit better, but that would require to antialias with the image before compressing it down with ImageMagick. That would fix the jaggedness of the chin in the sample image. But within that block, we can still only use 2 colors. (a limitation familiar to C64 graphic artists)

$ ./image2ascii.pl ~/Picture/socialmedia/12399.jpg 12399.ascii 0 1

Screenshot_miku.jpeg

ASCII_DBPlogo.jpg

Edit: Added the code to GitHub:
 
Last edited:
wow that's pretty amazing. except your perl bites ;) you should submit it to TPJ.
True that (that was 2 hours into the project). I was too exited and posted too soon. I've uploaded a stable version to Github. And Of course, the == are now eq (thanks to use warnings pragma). It now has proper getopts and the compression algorithm (to skip ANSI escape codes when not needed) has been fixed.

 
I've changed my zoo game from using the Quest game engine to using the Bitsy one, because as of version eight Bitsy has sound/music support and I fancied messing around with the new features.

xnwkP2Ur.png
 
  • Like
Reactions: rSl
small IMG_2435.JPG


been using the 3d printer to make some LED lighting panels, 120 Led at 12V quite bright...

small IMG_2441.JPG


i had 3M of the strip left so i printed up a cylinder big enough to wind around and popped it into a 1Kg greek yogurt bucket... with the handel it will make a great camping light.
 
  • Love
Reactions: rSl
$ ./image2ascii.pl ~/Picture/socialmedia/12399.jpg 12399.ascii 0 1

And another proof that Perl is not obsolete yet!
I use it constantly, as it gives me lots of freedom in programming. It is a handy "algorithmic notepad" - all programming techniques accessible at any moment.

UNFORTUNATELY all techniques...
A small part of the project I was doing a few years ago:
monstrosity.png

And 10-12 of such lines, nicely formatted in the form of shorter and shorter lines, who knows why.

What is more surprising, this works well and was used in a few computational geometry projects, mostly to determine relations between moving objects.
 
Perl is not a license to write illegible (shite) code. On the contrary. Your example is convoluted, the author should have unpacked the array into variables. Agree with everything else.
 
Perl is not a license to write illegible (shite) code. On the contrary. Your example is convoluted, the author should have unpacked the array into variables. Agree with everything else.
True, but that freedom given to just do it, like, treat numbers as strings while retaining the "numberness", I find that powerful. `perl -E 'for(1..20){say $_ if /5$/}'`
It just gives me a little bit more than sed and awk (and those guys... wow, those are weird languages as well once you dive deeper into them). And there's the "Here be dragons" disclamer, which makes it alright (not for NASA production code, but alright for other things)

As for that function, by not declaring @_ into local variables and even by not using 'return', it makes the function faster. There is also prettify, which can make it a bit more readable. Then again, it's a function, it has to work and I should not care (unless it's not working, like when one point is 0,0,0. I remember Wozniak explaining how he did the rounded buttons on the mac, and that was also "magic code".

 
A friend wanted to extract the audio from some video files so that they could then get rid of the video files. I wrote the following simple script for them to use alongside ffmpeg. I wrote it in DOS/Windows batch script because I hate either them or myself, and now I'm sharing it here because I hate you too. :p

Code:
for %%f in (input\*.*) do ffmpeg -i "%%f" -vn -f flac "output\%%~nf.flac"

The -vn option means block the video stream from being included in the new file, and I've used %%~nf instead of %%f for the output file name variable substitution so that the new file doesn't end up with a double file extension.
 
hollow knight is one of my favorite games, and i'm going to attempt to build a fan game in 3D, using Godot. i already have a pretty decent movement controller, and i'll be starting to add in some enemies soon.

 
I've been rewriting my audio extractor script in Python and ran into a first world problem earlier today.

I had to decide whether to use
Python:
os.chdir(os.path.dirname(os.path.abspath(__file__)))
or
Python:
os.chdir(os.path.abspath(os.path.dirname(__file__)))
to change the working directory to the directory that the script is located in. I've decided to play it safe by picking the second method because I'd rather get the path info then fiddle with it than fiddle with it from the start.

Example code:
Python:
import os

a = os.path.dirname(__file__)
b = os.path.abspath(a)
c = os.path.abspath(__file__)
d = os.path.dirname(c)

print(a)
print(b)
print(c)
print(d)
Example output:
Code:
D:\audex
D:\audex
D:\audex\test.py
D:\audex
 
This is also not my own project, but I was looking into this when working on a proof-of-concept workaround for getting a 3G extender work abroad. The 3G extender would check neighboring 2G towers to check your home location, which can be spoofed by setting up your own 2G base-station. Which at the time was an expensive option compared to hacking the firmware, which someone already did before.

If you fancy having a 2G base-station, this is a somewhat entertaining video. There a other options to do this, but this is one of the cheaper ones. If you live in a town without cellphone reception this might also be a nice option.
 
  • Like
Reactions: rSl
I've been rewriting my audio extractor script in Python and ran into a first world problem earlier today.

I had to decide whether to use
Python:
os.chdir(os.path.dirname(os.path.abspath(__file__)))
or
Python:
os.chdir(os.path.abspath(os.path.dirname(__file__)))
to change the working directory to the directory that the script is located in. I've decided to play it safe by picking the second method because I'd rather get the path info then fiddle with it than fiddle with it from the start.

Example code:
Python:
import os

a = os.path.dirname(__file__)
b = os.path.abspath(a)
c = os.path.abspath(__file__)
d = os.path.dirname(c)

print(a)
print(b)
print(c)
print(d)
Example output:
Code:
D:\audex
D:\audex
D:\audex\test.py
D:\audex
Oh you're making your script self aware ....

Can you not read what you need via the package loader as a resource and avoid direct filesystem access?

 
Here's the rewritten version.

Python:
# Import required modules
import os, subprocess

# Change working directory
os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Loop through files in input folder
with os.scandir('input') as inpfold:
    for vidfile in inpfold:
        if not vidfile.name.startswith('.') and vidfile.is_file():
           
            # Construct output file path
            fnameparts = os.path.splitext(os.path.basename(vidfile))
            audfile = os.path.join('output', fnameparts[0] + '.flac')
           
            # Run ffmpeg with specified options
            subprocess.run(['ffmpeg', '-i', vidfile, '-vn', '-f', 'flac', audfile])

I've also uploaded a copy here which has the input and output folders already present so they don't have to be manually created.

Prerequisites:
  • Python (Tested with version 3.10.11)
  • FFmpeg (Tested with FFmpeg 6.0 fork located here)
Usage:
  • Put video files in the input folder
  • Execute script using preferred method
  • Audio files magically appear in the output folder
License: Unlicense
 
  • Like
Reactions: rSl
Back
Top