Page 1 of 2

Delphi – Retrieve Corrupted Data from DBF Databases

Delphi – Retrieve Corrupted Data from DBF Databases
0

dBase files, and several “clones” of this format, have been used for decades, and this format is no stranger to developers who use environments like Delphi and Lazarus Pascal.

Sometimes however, we run into the issue that we cannot access our data and in this article, sponsored by Devart, show how you may recover your data with one of their great tools: UniDAC.

On that note: I have used their MyDAC (database access for MySQL) in the past to develop a full fledged LIMS and can only say that Devart delivers one of the best and most reliable database access components you can find.

Keep in mind that these components are commercial products.
However, almost all of them have full-featured Trial versions and free Express versions with limited functionality available for commercial development. I highly recommend them. Also note that quite a few Devart products are suitable for application development for other platforms, for example macOS.

Lazarus Pascal – Move Items to Trash for Windows, Linux and macOS

Lazarus Pascal – Move Items to Trash for Windows, Linux and macOS
6

In this short article I’ll show how I implemented a cross platform (Windows, Linux, macOS) function for Lazarus Pascal to move files or directories to the TrashCan or Recycle Bin.

Since it took me some figuring out, I figured; why not write it down so others may benefit from this as well.
For your convenience: You can also download the Lazarus Pascal unit here, which holds the function for macOS, Linux and macOS.

MacOS – How to create bootable macOS install media

MacOS – How to create bootable macOS install media
5

In this article, I’ll show you the steps to create macOS install Media …

As most Mac users will know; each new macOS version comes with a few challenges. For some it’s nothing, for other it’s a disaster.

Catalina is one of the latter, a disaster for quite few amongst us, due to changed security rules and the lack of support of 32 bit applications.
Some of my favorite tools simply no longer work, and as a developer this makes me nervous when considering switching to the latest and greatest.

For this purpose I always create a virtual machine in VMWare Fusion, running the macOS version that I ran before the update.
This comes with challenges though, since Apple, in their infinite wisdom, does not simply provide macOS install media (eg. a DMG or ISO file) so you can install another version of macOS. We have to create our own.

Note: Here I describe how to create macOS install media, either as a bootable USB stick to do a fully clean macOS install for your Mac, or a DMG file, for example to setup a virtual machine.

MacOS – SMJobBless: Elevated Privileges in Lazarus Pascal

MacOS – SMJobBless: Elevated Privileges in Lazarus Pascal
2

As some of you know, I created ApplePi-Baker a while ago, and with a new version I wanted to get away from using command-line tools like “dd” and “diskutil“. To do this the right way I needed to know how to use SMJobBless, in order to get root access, a.k.a. elevated privileges, privileged helper tool, etc.

Back in the day, we could do this pretty easy in our application, simply by using opening, reading and writing data from/to disks as “files”, with relatively simple code in our applications. These days seem to be gone …

With all kinds of malware trying to “hack” us, companies like Apple and Microsoft keep making it increasingly more difficult to actually get admin (root) access straight from our application (not to mention the seemingly cumbersome signing of applications). Which is all good, just too bad that the now majority of the time I spend on developing an application involves adapting to these limitations, instead of doing the creative thinking towards what the application really is for.

Apple has created a poorly documented mechanism for this, referred to as “SMJobBless” or “Privileged Helper“, and focusses heavily on Objective C and Swift – neither of these I like, let alone working with XCode (yuk!) – I really prefer working in Pascal, and specifically in an awesome IDE provided by Lazarus Pascal.

So in this article, I’m documenting my own findings to get this working with Lazarus Pascal – which took a lot of work and testing.

Keep in mind – I’m definitely not an expert on this topic, and I tried to include as much of what I found out as possible. It appears no-one has done this with Lazarus Pascal yet, so please bear with me, and definitely feel free to post improvements and/or suggestions. I’m sure there may be better ways and I’m always open to improving things, including myself.

Bash Script – Press Any Key To Continue

Bash Script – Press Any Key To Continue
4

In this article I’ll describe what I have used to create a “Press Any Key to Continue” in a Bash script (Linux/MacOS X).

Working with scripts in Bash (Terminal or Shell) isn’t what I do daily. The day I had to create a script to help me do an SVN update followed by a massive recompile. I wanted to see the SVN result first before proceeding with recompile, so I had to add a “Press Any Key To Continue” option in the script.

Since it took me a little effort, I figured; let’s describe this in an article. After all, it may be good reference for myself and for others.
These methods work for Linux and MacOS.

How to create empty dummy files

How to create empty dummy files
1

Sometimes we need one, a few, or a lot of empty dummy files – just for testing our application, or to hold a space.

Now you could open a text editor and save an empty file, but there are easier ways to make empty dummy files.

In this article I’ll show you how it can be done under Windows (incl. DOS and PowerShell), Linux and macOS.

Lazarus Pascal – Custom Fonts for MacOS Applications

Lazarus Pascal – Custom Fonts for MacOS Applications
4

I’m not sure about other developers, but I occasionally like to use my own custom font for my Lazarus Pascal applications. Typically I do this so I have access to better icons and symbols available in my application, instead of semi blurry bitmap icons. If you use this the right way, your icons and symbols will look much better and will scale really great.

Usually, I use a TTF font for this which I generate at IcoMoon.
IcoMoon is an awesome website where you can compile your own TTF font (or SVG or PNG images of symbols) for use with your website (Tweaking4All uses it as well) or … in your applications.

Since there are plenty examples out there how to do this in Lazarus Pascal for Windows, here an article that shows you how to do this in Lazarus Pascal under macOS.

Lazarus Pascal – Retrieve Yahoo Weather Forecast

Lazarus Pascal – Retrieve Yahoo Weather Forecast
9

I like dabbling with Lazarus Pascal, a free IDE for developing Pascal programs for Windows, MacOS X and Linux, quite similar to Delphi.

One of my projects, would look great with a weather forecast, so I went an figured out how this works by accessing the Yahoo Weather API. This took me a little bit to figure out, but I’ve got it running now, even using https.
This week I decided to put it all in a small unit, so others can use it as well.

This unit only needs Synapse, which is free as well, and uses fcl-json, which comes with Lazarus.

Lazarus Pascal – Unit to Add or Remove Autorun items (Windows/MacOSX)

Lazarus Pascal – Unit to Add or Remove Autorun items (Windows/MacOSX)
0

When developing an application, sometimes it can be useful to offer the user a way to add this application to the LoginItems (Mac) or Autorun items (Windows), so that the application starts when MacOS X or Windows starts.

Since I have developed a couple applications for which this would be helpful, and as of lately even one for both platforms, I figured, why not place this in a unit so the code can be resused easily and quickly. Sharing the code would make life easier for others as well.

So here we are – feel free to post improvements – a unit that Adds, Removes and Checks if an application build with Lazarus Pascal, from the Loginitem/Autorun items.

Lazarus – How to add data to lists with AddObject

Lazarus – How to add data to lists with AddObject
3

Some components in Lazarus Pascal (and Delphi), especially the ones that have a list of strings, allow you to add additional data by linking an object to a string. The function “AddObject” is often used for this, but it’s also the most overlooked option.

With this option you can link (add) any kind of data to rows in your string list, allowing you to add additional (non visual) data.

In this short article, I’ll show you how you can work with these objects, which allow you to extend the data stored with your lists.

App Transport Security Exceptions fixed (iOS 9+, OS X 10.11+)

App Transport Security Exceptions fixed (iOS 9+, OS X 10.11+)
1

Since I’m always looking for the “best” and “easiest” way to develop applications cross platform (so far Lazarus Pascal is the winner), I decided to give Delphi 10 Seattle a try. After I recovered from a heart-attack from seeing the price, I decided to give AppMethod a try. Mind you that AppMethod is cheaper but still very expensive.

AppMethod is pretty slick (as is Delphi 10), and supports Windows (32/64 bit), Mac OS X (I’m guessing 32 bit), Android, and iOS (32 bit and 64 bit). Development is pretty easy and deployment of your app is also very easy.

The first test I did was reading a webpage (NZBGet), which worked great on all platforms, except on iOS 9, which threw a “The resource could not be loaded because the App Transport Security policy requires the use of a secure connection” exception.

I did some research on what caused this and finally found the answer and a few work-arounds – which might be practical for other development environments as well.

How to install Lazarus Pascal on Raspberry Pi 2 (Raspbian)

How to install Lazarus Pascal on Raspberry Pi 2 (Raspbian)
290

For those of you who have visited Tweaking4All more often, you might have noticed that I really like Lazarus Pascal. I use it to develop little freeware applications for multiple platforms (if possible), like for Windows, MacOS X and Linux.

So why not on a Raspberry Pi (Raspbian)? Lazarus allows Rapid Application Development in the good old Delphi style which would be ideal for a platform like the Raspberry Pi. Specially since the Raspberry Pi  2 Model B seems to be fast enough as well.

Now me and my brother-in-law (Jean-Pierre) are planning to build an Alarm system based on a Raspberry Pi 2, use a TouchScreen and plenty of sensor. Lazarus Pascal could be ideal for this purpose.

To my disappointment, it took me a lot of time to get Lazarus to run on my new Raspberry Pi 2 Model B … so that’s why I wrote this article, which is basically a compilation of a lot of steps that I found scattered all over the Internet.

Automatic MySQL backup by using Replication

Automatic MySQL backup by using Replication
18

The past few days I have been working on setting up a second QNAP NAS as a backup for my files on my primary QNAP, using realtime syncing – which works ridiculously smooth. I have some MySQL databases on my primary QNAP as well, but syncing the data doesn’t seem to be part of the plan of the backup tools provided by QNAP.

Lucky me: MySQL has a great replication mechanism build in, so you can replicate one database (master) to another (slave). The setup is easy, albeit confusing when you just start looking into this. Synchronisation is done asynchronous, meaning: changes in the data on the master will be applied to the data on the slave, but the slave doesn’t need to be permanently connected. Missed changes, when not connected, will be “saved” and when a connection is established again, will be applied.

In this article I’ll show you how to do this for two MySQL setups (QNAP), where one serves as Master (Original) and the other as Slave (Backup).

MySQL Export and Import Data: How to backup databases

MySQL Export and Import Data: How to backup databases
2

MySQL is one of the most commonly used database engines, not just because it’s free but mostly because it’s fast, reliable and widely supported. That doesn’t mean you should not make backups …

Backups of your MySQL setup can be needed for several reason. You want a backup for safe keeping, you want to move a database to another server, just before you make some major changes, or you just want to wipe your server clean and setup everything from scratch without loosing your data.

Making a one time backup of your database(s) can be a bit unclear, so in this article a description of 3 possible methods to make a backup of one or more databases and how to import them at a later time (to the same or another MySQL server).

ASCII HTML Table – DOS ASCII versus HTML Characters

ASCII HTML Table – DOS ASCII versus HTML Characters
1

I used to have a Microsoft DOS 6.0 manual laying on my desk for the sole purpose of having an ASCII reference table. I mean literally only for that purpose.

As I started dabbling in HTML, back in the day, I created a small table on the old WeetHet website for HTML codes, only to find that I every now and then run into the limitations of that table when I’m coding …

So here, for those who care for it, a table showing all 256 ASCII (DOS) characters and their HTML counter parts … including the decimal value, hexadecimal value, HTML numerical code, HTML alpha code, display as HTML character, display as DOS character, and te descriptions that go with it …

1 2