AboutI dabble with various languages for work and pleasure (C is my favourite). Getting into electronics/Arduino. I also enjoy making music in my spare time.
Joined devRant on 1/20/2018
Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
While messing around with the Windows WM_NCPAINT message, I forced the WindowProc to return without calling DefWindowProc.
This resulted in interesting effects when pressing mouse buttons down on the right hand side of the title bar. This is on Windows 10.
Bottom part of the image is when I clicked on things and is Windows 9x-XP style. Top part of the image is when the window was deactivated and is Vista/Windows 7 style. Once they appear, the buttons behave as they did (visually - e.g. highlighting) as they did on those versions of Windows.
Just found it funny to see older bits of the Windows UI still hanging around behind the scenes!3
While sorting through my downloads folder, I noticed the file size for the Atom setup program: 138MB. For a text editor, that's pretty ridiculous and makes its name quite ironic.
I have similar disdain for Piskel (pixel graphics editor) and Etcher (USB/SD card image writer). Though these are all useful programs, none of these ought to be anywhere near the sizes they are.
Meanwhile, Notepad++ weighs 3MB which is a lot more reasonable.
Every time I see #MOTD trending on Twitter I hope it's people talking about an interesting Message Of The Day that they have seen. Instead, it's just football ("Match Of The Day").2
I have too many geeky non-dev activities. I don't know which is the geekiest...
Built a server rack out of bits of spare wood (going to rebuild and improve it in future). Wired up the entire house with network cabling. Didn't need to, just prefer not to use WiFi for things where possible. Also ceiling mounted a PoE WiFi AP for things that have to use WiFi (e.g. smartphones).
DIY built a rack mountable Pi shelf with faceplate.
Configured a dedicated TV tuner/PVR PC used by Kodi running on Raspberry Pi for a couple of TVs (all diskless/network boot).
Got a colocated server running in a data centre for running various VMs on for different things. Run my own email, webserver, DNS, VPN, voice chat server, various other stuff.
Gradually getting into electronics, which overlaps with dev a bit.
Sometimes I play games. I built a dedicated VR PC which occupies the smallest room of the house.
Unsure which is the geekiest thing!3
NO. NO. A THOUSAND TIMES: NO.
I clicked on this out of genuine curiosity to see if someone was finally trying to discourage people from annoying the shit out of website visitors. A summary of the suggestions in their article as to what to use popups for:
1. Announce new products/services, features, policy updates, new blog posts
2. Promote your sales or coupons (including countdowns)
3. Encourage people to input their e-mail address / subscribe, perhaps also offering some vague thing they will get as a reward for doing so
4. Contact forms (e.g. support etc.)
5. Prompt visitors to confirm their age before showing content
6. Login/register forms
7. Display social media "share" buttons when a visitor has scrolled a certain way through the page content.
8. Display cookie consent prompt.
9. Help guide visitors to the part of the website they want to go to.
Of these: 1, 2, 3, and 7 need to die for sure. If a website does any of these things I'm inclined to immediately leave and never return. 8 is a little annoying but seems a necessity.
Someone even replied to the Tweet saying that popups are annoying, the company responded with "let's change that!"
Blank portions of the screenshot are to avoid promoting the company unintentionally as a result of the rant ;)4
Been working with NodeJS a lot lately. Finding it really convenient and flexible. As someone who spent a lot of time using C, it's like going from eating fruit to candy bars. Seems pretty amazing just npm installing whatever you need and working with those packages... Until you dare to look at the list of ingredients.5
I write code as part of my job but also tend to have a lot of pet projects I think about in my spare time. A lot of those projects are not specifically targeted at solving an actual real problem but are just a curiosity (like my Duktape/ECMAScript thing that could import and call DLL routines.) I often find it difficult to choose which one to continue working on and end up not working on any of them because I can't decide which one is more interesting at the time! Or I get stuck and struggle to find a way around whatever roadblock I've hit.1
I've spent a lot of time messing around with C, having struggled with object-oriented programming (due to not really knowing how best to structure things, not knowing when to apply certain design patterns).
When writing C code, I'd write OOP-esque code (pass around a struct to routines to do things with it) and enjoyed just making things happen without having to think too much about the overall design. But then I'd crave being able to use namespaces, and think about how the code would be tidier if I used exceptions instead of having every routine return an error code...
Working with Python and Node over the past couple of years has allowed me to easily get into OOP (no separate declaration/definition, loose typing etc.) and from that I've made some fairly good design decisions. I'd implemented a few design patterns without even realising which patterns they were - later reading up on them and thinking "hey, that's what I used earlier!"
I've also had a bit of an obsession with small executable files - using templates and other features of C++ add some bloat (on Windows at least) compared to C. There were other gripes I had with C++, mostly to do with making things modular (dynamic linking etc.) but really it's irrelevant/unreasonable.
And yes, for someone who doesn't like code bloat, working with Node is somewhat ironic... (hello, node_modules...)
So today I decided to revisit C++ and dust off my old copy of C++ in a Nutshell, and try to see if I could write some code to do things that I struggled with before. One nice thing is that this book was printed in 2003, yet all of its content is still relevant. Of course, there are newer C++ standards, but I can happily just hack away and avoid using anything that has been deprecated.
One thing I've always avoided is dynamic_cast because every time I read about it, I read that "it's slow". So I just tried to work around it when really if it's the right tool for the job, I might as well use it... It's really useful!
Anyway, now I've typed all this positivity about C++ I will probably find a little later on that I hit a wall with what I'm doing and give up again... :p9
ECMAScript is everywhere, so I thought: Let's do even more inappropriate and insane things with it ;)
...Like using Duktape (small ECMAScript engine) and exposing LoadLibrary/GetProcAddress along with some helper routines to describe the routine's argument types and return type, and finally providing a routine to invoke those routines.
It's a very rough prototype that can handle up to 4 arguments in a 64-bit Windows environment.
Next "todo" is structure handling which will initially be a case of stuffing data into a Buffer() object.
I'm not sure what exactly I'm trying to do with it or why...1
Today I was enjoying a coffee and browsing the Internet on my phone for information on making mulled wine (planning on brewing some and wasn't sure whether to add ingredients during the fermentation stage or after) and came across this incredible example of what is wrong with websites these days.
I actually didn't spot the "close" for the subscription popup before leaving the page and later reviewing the screenshot.1
How would you approach choosing a fairly short but meaningful domain name? Common words are obviously going to be taken.
I have a handful of domain names used for different things, but my main one is 17 characters long and made up of 2 words and not particularly interesting (my surname + another word). It's relatively easy to read out to people over the phone, but inputting it in a phone handset or on a device without a keyboard (e.g. setting the hostname + domain of a media centre with a remote control) is a bit tiresome.
Doesn't even have to be something I can say easily as I mainly want it just for "infrastructure" purposes rather than to host a website etc.
I'd probably use it for sign-up e-mails to reduce the amount of spam/newsletter mail (I do generate a separate address for signing up to most services) but other than that wouldn't be using it regularly for e-mail.
But I don't want something meaningless like abcxyz.2
Recently had to deal with support of Ring and Nest due to some issues with their cloud services (i.e. not with my device or apps). So fed up of being told to uninstall, reinstall, reset this etc. when I go look on Twitter and see others reporting the exact same problems at the same time. What bothered me most is that I start by explaining the exact issue, that other have same problem (including other users on my account in different cities etc.) and they just ignore it and start copy/pasting bits of their self-help articles.
I have a bookshelf full of tech books. What should I do with outdated ones? What approach should I take to buying new ones? A lot of them are probably irrelevant now. Things that don't change significantly are fine (I have old C++ and Make books whose content is still relevant even if some new stuff is missing) but web development has evolved significantly and I'm reluctant to get anything framework related due to needing to replace books frequently.
I could get ebooks, but having tried a few, I much prefer a physical book.
In the case of old books I no longer need, I can recycle them (as waste paper, or at a book recycling place) or donate them to a charity shop. It seems silly to recycle them as waste paper, but on the other hand I doubt the content will be that useful to others nor will it be that useful in a charity shop!
So instead they just sit on my shelf and remain unused...
What do you folks do with your books when you don't need them any more?4
Here's my current setup. Needs a bit of improvement still.
A few years back I thought getting two big touchscreens would be amazing to use for making music. I rarely touch them. They get dusty all the time. They are too reflective. The border around them is way too thick. They are too big to be useful in this configuration. I'll be replacing them with normal screens and probably go for a vertical arrangement instead.
As you can see, there's a fair bit of stuff on my desk. There's a USB sound interface that could be rack mounted but I've been too lazy to buy or make anything to house it. I have a pair of headphones, a wireless headset and a Rift hanging off of the microphone stand. I rarely use the microphone and guitar at the moment (considered trying some voice acting, not particularly good at guitar!)
The desk was originally 2 desks from an Internet cafe that was being refurbished. I cut the ends off them and joined them together to make a desk to fit the space I had and stuck some metal legs onto it (used to have a big ugly brown metal frame). Oh and made some holes to add cable grommets and it has an IKEA cable tray underneath.
There's also a slide out music keyboard underneath (made from some bits of wood and a drawer runner, it's quite clunky and I'm tempted to use some rack rails instead).
The drawers were to store stuff from my desk in but I just replaced that stuff with other stuff...5
Just thought I'd share my current project: Taking an old ISA sound card I got off eBay and wiring it up to an Arduino to control its OPL3 synth from a MIDI keyboard. I have it mostly working now.
No intention to play audio samples, so I've not bothered with any of the DMA stuff - just MIDI (MPU-401 UART) and OPL3.
It has involved learning the pinout of the ISA bus connectors, figuring out which ones are actually used for this card, ignoring the standards a little (hello, amplifier chip that is wired up to the +12V line but which still happily works at +5V...)
Most of the wires going to it are for each bit of the 16-bit address and 8-bit data. Using a couple of shift registers for the address, and a universal shift register for the data. Wrote some fairly primitive ISA bus read/write code, but it was really slow. Eventually found out about SPI and re-wrote the code to use that and it became very fast. Had trouble with some timings, fixed those.
The card is an ISA Plug and Play card, meaning before I could use it I had to tell it what resources to use. Linux driver code and some reverse-engineering of the official Windows/DOS drivers got me past this stage.
Wired up IRQ 5 to an Arduino interrupt to deal with incoming MIDI data, with a routine that buffers it. Ran into trouble with the interrupt happening during I/O and needing to do some I/O inside the handler and had to set a flag to decide whether to disable/re-enable interrupts during I/O.
It looks like total chaos, but the various wires going across the breadboard are mainly to make it easier to deal with the 16-bit address and 8-bit data lines. The LEDs were initially used to check what addresses/data were being sent, but now only one of them is connected and indicates when the interrupt handler is executing.
There's still a lot to do after that though - MIDI and OPL3 are two completely different things so I had to write some code to manage the different "channels" of the OPL3 chip. I have it playing multiple notes at the same time but need to make it able to control the various settings over MIDI. Eventually I might add some physical controls to it and get a PCB made.
The fun part is, I only vaguely know what I'm doing with the electronics side of this. I didn't know what a "shift register" was before this project, nor anything about the workings of the ISA bus. I knew a bit about MIDI (both the protocol and generally how the MPU-401 UART works) along with the operation of a sound card from a driver/software perspective, but everything else is pretty new to me.
As a useful little extra, I made some "fake" components that I can build the software against on a PC, to run some tests before uploading it to the Arduino (mostly just prints out the addresses it is going to try and write to).46
Recently I learned that the collective noun for a group of hedgehogs is an "array".
Possibly the only kind of array where we can all agree, you'd have to start counting it from 1.
Or I guess you could just name a pet hedgehog "Element Zero" if that's how you prefer your arrays2
I think I'm a good developer. I have pretty decent debugging skills, including pulling apart disassembled x86 and other architecture code.
I'm fascinated by how things work.
But almost everything is catered for by a library. Or has already been done.
I find it enjoyable to create a library or program myself, but get disheartened when I find some library or program that is written seemingly very well, compared to my own code. And then I start to think I'm not a good developer after all.
Sort of relates to my previous rant about repeatedly rewriting code.
Applies to me doing programming as a hobby but probably affects my code at work as well... I just can't help but think my code is probably awful compared to what someone else might write.
...then I see incredibly ugly, messy, badly written code by other people and I feel better...
I suppose it is like an artist who sees amazing works but cannot paint to that standard, but is well beyond drawing stick figures with crayons.
Sounds like a trivial problem but it probably impedes my progress with a lot of things.3
My development process seems to go:
1. Write code
2. Believe that said code is amazing
3. Write more code
4. Revisit earlier code and start to doubt it's amazing-ness
5. Get frustrated that it could be done better
6. Redo 1 and repeat cycle
Seems a massive waste of time but I tend to like taking a different approach as soon as I find I'm getting stuck with the previous one.
I then get encouraged to take the quick/easy approach which seems like a backwards step and not worthwhile because I know it won't be as fast/efficient.2
One of the big ISP/entertainment companies dug up the roads a few months back and laid fibre optic cables (cutting through a power cable in the process but that's another story).
Recently had someone turn up at my door to chat about their services. All sounded very good, I took a card and gave it some thought and did some research.
So, it'd be a little cheaper than my current provider (FTTC setup). It'd be faster for downloads, slightly slower for uploads (I want fast upload). IPv6 is only on their business packages. I use IPv6 a lot. I also have several static IPv4 addresses.
It would involve getting a cable in to where my equipment rack is, and one to where the TV is (which I spent ages building a TV unit with power, network etc.)
To record/watch TV in another room with their service, I'd need to pay extra. The service just provides HD channels that I can already get, unless I pay more. At the moment I have MythTV handling all the recording of TV shows I want, and Kodi to play them back on different TVs, via CAT6 I spent ages installing into the walls.
Then there's the uncertainty of how nicely their equipment will play with my relatively complicated setup.
I decided, it isn't worth it really for me. I would have to change a load of stuff just to end up with what I already have... But with more limitations.
Anyway, the guy turned up again a few days later, I told him of my decision and away he went.
Since then I have been visited by 2 other employees of this company to try to sell me the service.
It is probably great and convenient if you are not like me and DIY all your home network and media distribution setup...
Also the ISP I'm with is quite small. They are very knowledgeable and friendly and I can get through to someone quickly if i phone. What I use meets my needs, so I prefer to support the smaller company in this case.
Contemplating ideas for a game that will involve some exploration and puzzles (aimed at teaching some low-level computer stuff like binary etc.) Replayed an old 2D game in an emulator, looked at some old adventure games, decided a 2D platformer might work for what I'm aiming for.
So I start making some pixel art, simple things like 32x32 tiles for bricks, some bigge ones for doors etc. And I discuss some ideas with my girlfriend for what kind of scenarios would fit into this game world.
Anyway, she normally draws and paints, but seemed interested in trying pixel art so I gave her a link to Piskel and a rough idea of some decorative items I'd want to put around the map. Within a few hours she created a flower pot with flowers, a coffee machine, a light with lightshade, a small pile of books, and a couple of other things - all shaded and detailed beyond any of my attempts, including lighting going from left to right (which I wanted but didn't specify).
I mean, I could've expected this but pixel art is quite a different beast to drawing or painting as you have to do more with less.
Now I just need to make my game engine. So far I have an SDL program with a flowerpot that you can move around xD1
What's the most sensible way to build and use 32/64-bit libraries with MSYS on Windows? Specifically, I am wondering about zlib and libpng along with SDL2.
I know there are pre-built versions available, but I am inevitably going to need to build other libraries in future.
I'm expecting things to go into /usr/local (which they do), but I'd like to have separate builds for 32-bit and 64-bit. I know I can put things into "lib32" or "lib64" using ./configure options pretty easily, but DLLs (e.g. SDL) seem to end up in "bin" so I assume I should create a "bin32" and "bin64" for those?
Then there's the issue of e.g. libpng not being able to find zlib's headers when using its MSYS makefile... Should I be editing these makefiles? It looks as though I should (things are commented-out etc.) but when I want to update to a newer version, I'll need to modify the makefile again.
It probably sounds like a really silly set of questions but I've always found that building and installing libraries on Windows feels really clumsy and I just want to make sure I'm not making a really messy dev environment.
For a long time I was of the opinion that pointer variables in C/C++ should have the asterisk immediately after the type name (e.g. int* foo).
Eventually I became convinced that it makes more sense to have it before the variable (e.g. int *foo).
Now I find routines that return pointers look weird, e.g.: void *allocate_something() so I am considering adopting the original style I used.
The only advantage of having the asterisk before the variable name I am aware of is that it is easier to remember to add an asterisk if you define more than one pointer on that line.
Anyone else find it hard to settle on code style guidelines for their own personal projects?15
Quite a few years ago (late 90s, early 00s maybe) I remember watching a TV show where they demonstrated what virtual reality might be like. It was all rough polygons, no lighting or texturing etc.
I'd heard about the Oculus Rift and considered trying it. I get motion sickness sometimes from certain 3D games (Deus Ex, Portal, sometimes even Minecraft) so was hesitant. Last week, decided to just get one and see how it went.
Didn't expect it to be as good as it is - compared to what was envisaged ~20 years ago. No motion sickness. Not only was the graphics detail amazing but the responsiveness is insane. In another 20 years time what will there be?
Anyway on dev topic: Now it makes me want to play with a 3D/VR engine. Considering Unreal Engine but not really sure where to start learning. Maybe a book? Though reviews tend to say they go out of date quick, I do prefer a physical book for learning tech stuff.1
Linux software RAID and LVM are pretty powerful.
Bought a new server case for my home file server / VM host. 3U with 16 hotswap bays. Had 2x software RAID1 mirrors already with everything on them. Inserted 2 new disks with system running. Created new RAID10 array using these, with their mirrors as "missing".
Created new physical volume. Extended volume group into it, then used pvmove to transfer every logical volume across. Shrunk volume group to no longer use the old RAID1 array, disassembled that array, added its disks to the new array... Now just waiting for the mirror disks to sync up.
All this, with the system and several VMs still running.
And with a backup, of course ;)3
Why is accidentally uploading a binary file in ASCII mode via FTP still something people do? Aside from the obvious point that FTP needs to die and something else needs to be used instead, isn't it about time binary was the default?11
In my Inbox, a mail trail with 3 people who concluded: "This is not working properly"
Me: "Looks like a config issue..."
Someone else: "Hey we've now checked the config, it looks fine"
Me: /goes and looks
Me: "But the required line is commented-out..."
One of these days my Windows 10 system will actually figure out how to obtain an IPv6 address without needing me to manually run ipconfig /renew6 or disable/reenable the network adapter... For now, static IPv6 it is
I like my log messages to indicate automatically where in the code something happened, so that I can easily identify where a message originated from while tracking down problems.
In C/C++ this is nice and easy - write a logging routine, wrap it in macros for the different log levels and have that automatically output __FILE__, __LINE__ etc.
I wanted to do something similar in NodeJS, as I'd found myself manually writing the file name in the log message and then splitting functionality out into new files and it became a mess.
The only way I found to be able to do this was to create an "Error" object and access the "stack" member of it. This is a string containing a stack backtrace, suitable for writing to console/file. I just wanted the filename/line/routine.
So I ended up splitting the string into lines, then for each of the lines, trimming the surrounding spaces (or tabs?), and parsing them to see if the stack entry is inside my logger module. The first entry outside of that module must therefore be the thing that called it, so I then parse out the routine or object and method, filename and line number.
It's a lot of clumsy work but the output is pretty neat. I just wish it were simpler!2
Whenever Facebook decides to do one of its fancy animations about all the things you've posted pictures of in the past month etc. I'm sure they expected people to be posting pictures of parties, holidays etc.
I only post either pictures of my pets or something I'm working on (running cables in walls, cutting up bits of wood, decorating etc.) So it looks utterly ridiculous when one of those animations plays.2
Back in 2005, I had quite a few bits of music I was working on (just as a hobby). A lot of these had not been finished, but I'd sent excerpts in medium-quality MP3 format to a friend. I had an external backup drive - a regular hard drive in an USB enclosure. After a while, this drive started making unpleasant whining sounds so I sent it off for replacement.
During that time I made the foolish decision to try and plug a floppy drive in while the PC was powered on. Something touched the bottom of the hard drive and the power went off. I powered it back on again and heard a fizzing sound, there were some flashes from the hard drive and a burning smell. Yep, the disk was dead - and my backup drive was gone.
I'm still not entirely sure what happened, my best guess is that I had an exposed piece of wire from one of my hacky case mods (I had a thing for blue LEDs) which touched the circuitry of the hard drive. Almost every project, piece of software I'd created, every photo I'd taken, and most unfinished music I'd made up until that point - gone. I was pretty devastated about it. I only had a handful of things survived which I'd burned onto CD previously.
I managed to get some excerpts back from my friend, and re-created my favourite pieces of music based on those. I've moved on to other projects and write much better code now, so mostly I am no longer bothered. I do wish I could re-listen to some of the music I had made back then though.
Needless to say, I no longer fiddle around with the innards of my computers while they are on, store everything on mirrored drives and also ensure I always have a backup somewhere (and am working on remote backups and having several days of backups...)
I never want that to happen again