node-sass ionic nodejs error fix

Posted on Updated on

Sometimes you go on a bug fixing journey and get no-where. Like always, when I find a solution to a lengthy problem, I write it up so I can remember it later.

I had this error show up, after doing an update to the latest version of Ionic, and for over an hour and a half, I upgraded NPM packages and everything, changed and updated code and got no-where.

I then went back and reverted to my last commit, rerun this command: (as found here)

node node_modules/node-sass/scripts/install.js

Where it eventually started working again.

Happy, but rather frustrated that it has to happen.

stephenmonro@SMMMacPro:~/ionicApps/project$ ionic serve
> ionic-app-scripts serve --address localhost --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser
[app-scripts] fs.js:114
[app-scripts] throw err;
[app-scripts] ^
[app-scripts] Error: ENOENT: no such file or directory, scandir '/Users/stephenmonro/ionicApps/project/node_modules/node-sass/vendor'
[app-scripts] at Object.readdirSync (fs.js:785:3)
[app-scripts] at Object.getInstalledBinaries (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/extensions.js:132:13)
[app-scripts] at foundBinariesList (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/errors.js:20:15)
[app-scripts] at foundBinaries (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/errors.js:15:5)
[app-scripts] at Object.module.exports.missingBinary (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/errors.js:45:5)
[app-scripts] at module.exports (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/binding.js:15:30)
[app-scripts] at Object.<anonymous> (/Users/stephenmonro/ionicApps/project/node_modules/node-sass/lib/index.js:14:35)
[app-scripts] at Module._compile (internal/modules/cjs/loader.js:701:30)
[app-scripts] at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
[app-scripts] at Module.load (internal/modules/cjs/loader.js:600:32)

[ERROR] ionic-app-scripts has unexpectedly closed (exit code 1).

The Ionic CLI will exit. Please check any output above for error details.
stephenmonro@SMMMacPro:~/ionicApps/project$ nodejs node_modules/node-sass/scripts/install.js
-bash: nodejs: command not found
stephenmonro@SMMMacPro:~/ionicApps/project$ node node_modules/node-sass/scripts/install.js
Downloading binary from
Download complete
Binary saved to /Users/stephenmonro/ionicApps/project/node_modules/node-sass/vendor/darwin-x64-64/binding.node
stephenmonro@SMMMacPro:~/ionicApps/project$ ionic serve
> ionic-app-scripts serve --address localhost --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser
[app-scripts] [01:26:03] ionic-app-scripts 3.2.4


Also, another fun bug you could be chasing for a long this is to do with the .subscribe method.

“ERROR TypeError: Object(…) is not a function”.

For example, the following code: this.globals.apiserver + "post_user_track_location.php", trackstringdata, options)
.subscribe(data => { 
this.returned = data; 
//console.log (this.items); 
console.log (data); 

If you are running off a “localhost” change it to

It may just work for you.


DOSBOX Autoexec.bat

Posted on Updated on

This took me a while to locate on my computer, but I eventually found it, and I’ll share the location and what I’ve done.

The current official wiki is here, but it seems to not reflect my current situation.

The settings for me are located here:
/Users/stephenmonro/Library/Preferences/DOSBox 0.74 Preferences

This is a text file, and it can be opened and edited easily.

This is my current dosbox preferences file:


# This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox)
# Lines starting with a # are commentlines and are ignored by DOSBox.
# They are used to (briefly) document the effect of each option.

# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back)
# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox.
# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).
# Using your monitor's native resolution with aspect=true might give the best results.
# If you end up with small window on a large screen, try an output different from surface.
# windowresolution: Scale the window to this size IF the output device supports hardware scaling.
# (output=surface does not!)
# output: What video system to use for output.
# Possible values: surface, overlay, opengl, openglnb.
# autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock)
# sensitivity: Mouse sensitivity.
# waitonerror: Wait before closing the console if dosbox has an error.
# priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized.
# pause is only valid for the second entry.
# Possible values: lowest, lower, normal, higher, highest, pause.
# mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value.
# usescancodes: Avoid usage of symkeys, might not work on all operating systems.


# language: Select another language file.
# machine: The type of machine tries to emulate.
# Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe.
# captures: Directory where things like wave, midi, screenshot get captured.
# memsize: Amount of memory DOSBox has in megabytes.
# This value is best left at its default to avoid problems with some games,
# though few games might require a higher value.
# There is generally no speed advantage when raising this value.


# frameskip: How many frames DOSBox skips before drawing one.
# aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!.
# scaler: Scaler used to enlarge/enhance low resolution modes.
# If 'forced' is appended, then the scaler will be used even if the result might not be desired.
# Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x.


# core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate.
# Possible values: auto, dynamic, normal, simple.
# cputype: CPU Type used in emulation. auto is the fastest choice.
# Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch.
# cycles: Amount of instructions DOSBox tries to emulate each millisecond.
# Setting this value too high results in sound dropouts and lags.
# Cycles can be set in 3 ways:
# 'auto' tries to guess what a game needs.
# It usually works, but can fail for certain games.
# 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails.
# (Example: fixed 4000).
# 'max' will allocate as much cycles as your computer is able to handle.
# Possible values: auto, fixed, max.
# cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12)
# cycledown: Setting it lower than 100 will be a percentage.


# nosound: Enable silent mode, sound is still emulated though.
# rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality.
# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
# blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged.
# Possible values: 1024, 2048, 4096, 8192, 512, 256.
# prebuffer: How many milliseconds of data to keep on top of the blocksize.


# mpu401: Type of MPU-401 to emulate.
# Possible values: intelligent, uart, none.
# mididevice: Device that will receive the MIDI data from MPU-401.
# Possible values: default, win32, alsa, oss, coreaudio, coremidi, none.
# midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use.
# See the README/Manual for more details.


# sbtype: Type of Soundblaster to emulate. gb is Gameblaster.
# Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none.
# sbbase: The IO address of the soundblaster.
# Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300.
# irq: The IRQ number of the soundblaster.
# Possible values: 7, 5, 3, 9, 10, 11, 12.
# dma: The DMA number of the soundblaster.
# Possible values: 1, 5, 0, 3, 6, 7.
# hdma: The High DMA number of the soundblaster.
# Possible values: 1, 5, 0, 3, 6, 7.
# sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer.
# oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'.
# Possible values: auto, cms, opl2, dualopl2, opl3, none.
# oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well).
# Possible values: default, compat, fast.
# oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly).
# Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000.


# gus: Enable the Gravis Ultrasound emulation.
# gusrate: Sample rate of Ultrasound emulation.
# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
# gusbase: The IO base address of the Gravis Ultrasound.
# Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300.
# gusirq: The IRQ number of the Gravis Ultrasound.
# Possible values: 5, 3, 7, 9, 10, 11, 12.
# gusdma: The DMA channel of the Gravis Ultrasound.
# Possible values: 3, 0, 1, 5, 6, 7.
# ultradir: Path to Ultrasound directory. In this directory
# there should be a MIDI directory that contains
# the patch files for GUS playback. Patch sets used
# with Timidity should work fine.


# pcspeaker: Enable PC-Speaker emulation.
# pcrate: Sample rate of the PC-Speaker sound generation.
# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
# tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'.
# Possible values: auto, on, off.
# tandyrate: Sample rate of the Tandy 3-Voice generation.
# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.
# disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible).


# joysticktype: Type of joystick to emulate: auto (default), none,
# 2axis (supports two joysticks),
# 4axis (supports one joystick, first joystick used),
# 4axis_2 (supports one joystick, second joystick used),
# fcs (Thrustmaster), ch (CH Flightstick).
# none disables joystick emulation.
# auto chooses emulation depending on real joystick(s).
# (Remember to reset dosbox's mapperfile if you saved it earlier)
# Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none.
# timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away).
# autofire: continuously fires as long as you keep the button pressed.
# swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks.
# buttonwrap: enable button wrapping at the number of emulated buttons.


# serial1: set type of device connected to com port.
# Can be disabled, dummy, modem, nullmodem, directserial.
# Additional parameters must be in the same line in the form of
# parameter:value. Parameter for all types is irq (optional).
# for directserial: realport (required), rxdelay (optional).
# (realport:COM1 realport:ttyS0).
# for modem: listenport (optional).
# for nullmodem: server, rxdelay, txdelay, telnet, usedtr,
# transparent, port, inhsocket (all optional).
# Example: serial1=modem listenport:5000
# Possible values: dummy, disabled, modem, nullmodem, directserial.
# serial2: see serial1
# Possible values: dummy, disabled, modem, nullmodem, directserial.
# serial3: see serial1
# Possible values: dummy, disabled, modem, nullmodem, directserial.
# serial4: see serial1
# Possible values: dummy, disabled, modem, nullmodem, directserial.


# xms: Enable XMS support.
# ems: Enable EMS support.
# umb: Enable UMB support.
# keyboardlayout: Language code of the keyboard layout (or none).


# ipx: Enable ipx over UDP/IP emulation.


# Lines in this section will be run at startup.
# You can put your MOUNT lines here.


While everything is pretty much standard, the thing you’ll be most interested in is at the bottom under the [autoexec] entry.

I have a path called DOSGAMES in my \Users\StephenMonro\ directory. This becomes my C drive when DOSBox launches.

In there, I make sure I start out and make sure I’m actually in the C drive, and then I call a batch file.

This is the contents of the batch file:

echo off
: Point & Shoot Startup File 
: Place this file in a directory in your PATH statement.
: To access Point & Shoot, type MENU
cd \MENU


That batch file opens the classic “Point and Shoot Menu”, which was, in my opinion one of the easiest and best DOS menu system. I don’t know where we got it from originally, but it worked great. It’s also a little bit of a rarity on the internet too.

I have uploaded the program here which you can download.

Point and Shoot Menu download:

Screen Shot 2019-12-12 at 12.18.05

Screen Shot 2019-12-12 at 13.22.31Screen Shot 2019-12-12 at 13.21.43Screen Shot 2019-12-12 at 13.21.00Screen Shot 2019-12-12 at 13.20.40Screen Shot 2019-12-12 at 13.20.51

Enjoy using DOSBox. 🙂





Ionic Build Scripts

Posted on Updated on

I don’t like repetitive manual work, especially if can automate or script it.

In honour of that, these are my Ionic build scripts.



Updated: 20200312

I’ve left all the rubbish workings out in there. Feel free to clean them up as required.

To make testing easier on Android, I upload them to Dropbox/Mega and then install them quickly on the device as a deployed test.
node ./node_modules/node-sass/scripts/install.js

ionic cordova platform rm android
#ionic cordova platform add android

#cordova platform add android --save

ionic cordova platform add android@7.1.4
ionic cordova build android --prod --release

#keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk my-alias
cp  ~/Library/Android/sdk/build-tools/28.0.3/zipalign platforms/android/app/build/outputs/apk/release/

cd platforms/android/app/build/outputs/apk/release/
rm c4israel_int.apk
./zipalign -v 4 app-release-unsigned.apk c4israel_int.apk

#copy to dropbox
#cp c4israel_int.apk /Volumes/Creative2HD/DropBox/Dropbox/c4i/c4israel_int_1.apk

# copy to MEGA
cp c4israel_int.apk /Volumes/Creative2HD/MEGASync/C4I/c4israel_int_1.apk

cd ..
cd ..
cd ..
cd ..
cd ..
cd ..
cd ..


# Just in case.
node ./node_modules/node-sass/scripts/install.js

ionic cordova platform remove ios
ionic cordova platform add ios
#ionic cordova platform update ios@3.9.2      #not sure which is best yet... # really old
#ionic cordova platform update ios@3.20.0    #not sure which is best yet...
#ionic cordova platform update ios@4.5.4    #not sure which is best yet...

# --buildFlag="-UseModernBuildSystem=0" is used for onsignal workaround

npm install -g ios-deploy
#npm install -g ios-deploy --save
#npm install ios-deploy@1.9.2 --save

#sudo gem install cocoapods
cd platforms
cd ios
pod install
#pod repo update
cd ..
cd ..

#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" # worked...

#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" # worked...
#ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" 
ionic cordova build ios --prod --release --buildFlag="-UseModernBuildSystem=0" --verbose

# --prod
#ionic cordova build ios --prod --buildFlag="-UseModernBuildSystem=0"

cd platforms
cd ios

pod install
#pod repo update

open "APPNAME.xcworkspace/"

open /Users/PATH/ionicApps/APPNAME/platforms/ios/APPNAME.xcworkspace/

#open APPNAME.xcodeproj/
cd ..
cd ..
ionic cordova platform remove android
ionic cordova platform add android@6.4.0 
ionic cordova build android
ionic cordova run android --no-native-run
ionic cordova run android --device





ionic cordova platform rm android
ionic cordova platform add android@6.4.0
ionic cordova build android --prod --release --debug

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks platforms/android/build/outputs/apk/release/android-release-unsigned.apk my-alias

cp ~/Library/Android/sdk/build-tools/27.0.3/zipalign platforms/android/build/outputs/apk/release/

cd platforms/android/build/outputs/apk/release/
rm app_name.apk
./zipalign -v 4 android-release-unsigned.apk app_name.apk

# copy to MEGA
cp app_name.apk /Volumes/Creative2HD/MEGASync/C4I/app_name_1.apk

cd ..
cd ..
cd ..
cd ..
cd ..
cd ..
cd ..

ionic cordova platform remove ios
ionic cordova platform add ios

cd platforms
cd ios
pod install
cd ..
cd ..

ionic cordova build ios --prod --release --buildFlag="-UseModernBuildSystem=0"

cd platforms
cd ios

pod install
pod repo update

open "APP_NAME.xcworkspace"

cd ..
cd ..


Directory listing

Posted on

A part of me feels that the art of command-line usage is leaving us.

If you’ve ever wanted to get a list of files from in a directory and stored in a text file, it’s really simple.

Just do this.

If you are on Windows, open the run box (Windows+R) and type cmd, then enter.

Navigate to the directory you want, or for this example, you’ll get a list of all the files in your home directory (or folder).

Type this: C:\Users\smonro>dir /r/s/b > files.txt

You will then get a long list of everything in the file named “files.txt”.



Running Catalina on a MacPro 4,1->5,1

Posted on Updated on

I’ll start by saying that I tried, succeeded, and then reverted to High Sierra.

This is not a how to guide, as there are plenty of sites dedicated to that, but this is my journey.

It started my journey with a new 2TB SSD which I cloned my current OS to. It rebooted fine, and everything was great.

I then proceeded to the latest and greatest of Catalina.

Following the instructions from dosdude, it eventually worked. But I ran in to a few minor hiccups.

The computer wouldn’t boot properly with my graphics card of gtx 770.

Once that came out it went to the login screen.

After that it went a little interesting.
Not everything worked.

There are the obvious 32 bit programs that won’t run, but is more than that.
My presonus studio192 wasn’t found, a show stopper, and I got a billion notifications to authorise things.
Filr crashed.

Dark and light mode are still screwy too.
There are no NVidia drivers available or compatible.

In the end I conclude that it’s just not worth the upgrade.

The gains do not outweigh the losses.

Instead of installing catalina and using vms for 32bit programs, I’ll go the other way and use catalina in a vm, and see how that goes, now that I have a 2TB ssd. 😊

As a side note, my GTX770 card has still been working these years without problems, it’s just lack of driver support that will continue now with future versions of the OS X.

Other than that, it all works well. Oh, and computer has had its cpu tray updated since the gfx card upgrade.

But, this is really just a good excuse to vacuum the insides.

Secret menu in an Ionic App

Posted on Updated on

I wanted a way for people to be able to reset the app, kind of for debugging purposes and while a “reset button” works, I don’t think it’s best to have it public.

So, after looking around, I thought that maybe a hold for 5 seconds with a counter would work. However, I came across a post asking a similar, but not the same idea and it triggered my mind to try something different.

Basically, you tap and hold 5 times on the ‘Header Text’ and then, your secret function will trigger.

Here’s my example:

Please note, WordPress source-code formatting is terrible.


<ion-title (press)="pressEvent($event)">About App {{press_text}}</ion-title>

<ion-content padding>
<h1>App Name</h1>
<p>Version: 1</p>
<p>Created with love by me </p>



import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';
import { Storage } from '@ionic/Storage';
import { StartPopupPage } from '../start-popup/start-popup';

* Generated class for the AboutPage page.

 selector: 'page-about',
 templateUrl: 'about.html',

export class AboutPage 
  publicnavCtrl: NavController,
  privatestorage: Storage,
  privatemodal: ModalController,
  publicnavParams: NavParams) 

 publicpress: number = 0;
 publicpress_text: string = "";
  this.press_text = + "";
  if ( >= 5)
   // Do something after the header has been pressed 5 times.
   // In this case, it runs the function and the resets everything
   // back to 0 ready to reset the function again if required.
   this.resetSettings(); = 0;
   this.press_text = "";

  console.log('ionViewDidLoad AboutPage');

// Doing something after the header has been pressed 5 times.
 async resetSettings()
  // clear out the data'Settings1', null);'Settings2', null);
  // Show a modal.
  // You'll need a popup html page too 
  constprofileModal = this.modal.create(StartPopupPage);
  profileModal.onDidDismiss(data => 

jVectormap the basics

Posted on Updated on

I needed to make a map with some text labels, and it was not an easy feat, as the documentation (while there) is not very clear, and the examples floating around the internet are sketchy at best as well.

Here’s my little map of Australia.

The labels are permanent, and ready to have the JS changed, to display counts, or values if required.

It’s not entirely finished, but it works.

This needs the Australia map downloaded in the same path as this code.
Here is my gist:


<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Country Map Example</title> 

<link rel="stylesheet" href="" type="text/css">
.jvectormap-region.jvectormap-element {
text-shadow: -1px -1px 3px #fff, 1px -1px 3px #fff, -1px 1px 3px #fff, 1px 1px 3px #fff;
div id="map1" style="width: 800px; height: 600px"> 

var locations = [
{ latLng: [-35.27603, 149.13435], name: "ACT", text: "This is a text of one.", style: {r: 0}},
{ latLng: [-32, 147], name: "NSW", text: "This is a text of one.", style: {r: 0} },
{ latLng: [-22, 144.25], name: "QLD", text: "This is a text of one.", style: {r: 0} },
{ latLng: [-41.5, 146.030], name: "TAS", text: "This is a text of one.", style: {r: 0} },
{ latLng: [ -36.760, 144.280], name: "VIC", text: "This is a text of one.", style: {r: 0} },
{ latLng: [-26.230, 120.380], name: "WA", text: "This is a text of one.", style: {r: 0} },
{ latLng: [-22.000, 133.380], name: "NT", text: "This is a text of one.", style: {r: 0} },
{ latLng: [-29.000, 135.380], name: "SA", text: "This is a text of one.", style: {r: 0} }, 


$(document).ready(function () {
var map = "au_mill";
map: 'au_mill', // map
zoomOnScroll: false, 
zoomButtons : false,
regionStyle: { // color of the map
initial: {
fill: '#B8E186' // standard colour
selected: {
fill: '#F4A582' // on hover
backgroundColor: '#383f47', // page color 
markers: locations, // the values
markerLabelStyle: { // the value formatting
initial: {
'font-family': 'Verdana',
'font-size': '40px',
'font-weight': 'bold',
cursor: 'default',
fill: 'red'
hover: {
cursor: 'pointer'

labels: { // this paints the labels on the map
markers: {
render: function(index){
return locations[index].name;
offsets: function(index){
var offset = locations[index]['offsets'] || [0, 0];
return [offset[0] - 7, offset[1] + 3];


I’m sick of SPAM emails!

Posted on

Not sure about you, but I get the occasional SPAM email, but in the last several weeks, it’s just going stupid.

So, if you have CPanel and have horde as your main email program you can run filters to automatically delete these emails.

I have the following rule:

Screenshot 2019-08-20 00.08.38.png

So far, it’s removed the majority of them.

To find the IP address to block (or the portion of)… show the email source headers and you’ll see something like this:

Received: from ([]:42759

As the *.200 IP is a little too specific, there’s a chance that the emails are coming for a range of IPs if that block, so just drop off the last digits of the IP address and this could/should slow your SPAM.

Good luck.


APE Tags with taglib-sharp

Posted on Updated on

I’ve been working on a solution recently to try and read and write data tags from an APE data set in an MP3.

This usually works, however, I’ve discovered a problem with the library I’ve been using when it’s returning incorrect data, of which has been confirmed by a HEX editor.

I’ve been working with a tagging  format which has various non-standard fields are saved by myself, but also one done with a third party audio program, which reads and writes the tag of “XRestrictions”, and where expected the subsequent next bytes represent data values – the data of the tag.

This has been rather interesting, firstly, because the program writing the initial tags is  written Delphi, but mainly because of how it is handling the data it’s writing.  It’s storing a sequence of string hex values, that represents dates and times, but the HEX date values are interestingly stored around the wrong way.

Let me explain further.

The is the HEX code from the file, as per a HEX editor.

Screenshot 2019-04-24 23.37.41

The 40AA value is a date value.

But, what the Delphi code has done, is invert the HEX date value.  In short, the dates are calculating the days from 31 December 1899.

If we invert those values, it is AA40, and we convert from HEX to Decimal, it’s actually 43584. Storing values like this is very efficient, but the values are swapped – I have no idea why though.

Either way, we have the following values now.

Start Date: AA400000
End Date: AA410000

You can see the workings out here for calculating how many days since 31 Dec 1899, which is 43584 and brings us to: Tuesday, 30 April 2019.

So, moving forward I can now calculate these given values. But, how did I actually get the HEX values, and what went wrong in the first place with the library?

I’ve been using the TagLib-Sharp library for VB.NET with no problems. However, once I started reading these date tags, that is where it all went wrong.

Plain ASCII data is stored nicely… the standard characters…  But, once it gets to other values, the library kind of freaks out and gives the wrong response.

Earlyier we saw what the correct HEX values should have beeen. As shown below,  these are the results of what the library gave out, and thus, you will see why I discovered that I needed to wrint my own code to extract the correct data, and how I did it – in very rough un-edited code.

This was the raw ASCII text of the “XRestrictions” APE tag  given by the  TagLib-Sharp library:

@?, , A?, , , , , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q

This can be extracted with the following:

Dim XRestriction_value As String = GetField(“XRestrictions”, Full_Path)
Console.WriteLine(“XRestriction_value: ” + XRestriction_value)

Unfortunately it was wrong, and it took me much of the day to establish what was wrong.

Next, I tried converting the raw value to HEX values, which is also incorrect via TagLib-Sharp:


This can be extracted with the following:

Dim test As String = StringToHex(GetField_Date(“XRestrictions”, Full_Path))
test = test.Replace(“2C”, “”) ‘ remove commas
test = test.Replace(“20”, “00”) ‘ remove spaces
Console.WriteLine(“raw: ” + test)

This was also incorrect for some reason. Notice the text replacements? This created a very long string with more unnecessary characters as well.

After a day of trying to figure this all out, here is the correct HEX via my search code (with a bit of help from others).


Here is my spaghetti code extracting the correct values.

So, the way I did it in the end, was to do a search in the file contents looking for the phrase “XRestrictions”. Once I got the offset, I could then read in the data in bytes at (14 characters + the offset) to get the correct starting point, and then read the data.

Dim XRestriction_value As String = GetField("XRestrictions", Full_Path)
XRestriction.Text = XRestriction_value

Console.WriteLine("XRestriction_value: " + XRestriction_value)

Dim test As String = StringToHex(GetField_Date("XRestrictions", Full_Path))

test = test.Replace("2C", "") ' remove commas
test = test.Replace("20", "00") ' remove spaces

Console.WriteLine("raw: " + test)

SPLDateRangeraw.Text = test

' works
Dim SearchOffset As Integer

Dim b2() As Byte = IO.File.ReadAllBytes(Full_Path)

Dim encoding As New System.Text.ASCIIEncoding
Dim SearchString As String = "XRestrictions"
Dim bSearch As Byte() = encoding.GetBytes(SearchString)
Dim bFound As Boolean = True

For i2 = 0 To b2.Length - bSearch.Length - 1
If b2(i2) = bSearch(0) Then
bFound = True
For j As Integer = 0 To bSearch.Length - 1
If b2(i2 + j) <> bSearch(j) Then
bFound = False
Exit For
End If
If bFound Then
'MsgBox(SearchString & " found at byte offset: " & i)
Console.WriteLine(" found at byte offset: " & i2)
SearchOffset = i2
End If
End If

' end works.

Dim helloworld As String

' Get the file name.
Dim file_name As String = Full_Path
' Open the file.

Dim fileData(100) As Byte
Dim oFileStream As New FileStream(file_name, FileMode.Open, FileAccess.Read)
Dim oBinaryReader As New BinaryReader(oFileStream)
Dim lBytes As Long = oFileStream.Length
Console.WriteLine("lBytes 2: " + lBytes.ToString)
oBinaryReader.BaseStream.Position = SearchOffset + 14 ' for the word search offset.
Dim fdi As Integer = 0
For i = 0 To 100
fileData(i) = oBinaryReader.ReadByte()
Next i
helloworld = ""
For loop1 = 0 To 80
'helloworld = helloworld & fileData(loop1) & "/"

helloworld = helloworld & Convert.ToString(Convert.ToInt32(fileData(loop1)), 16).ToUpper
Next loop1

Console.WriteLine("Correct Values: " + helloworld)

Dim StartOutput As String
StartOutput = test.Substring(test.Length - 4, 4)
Dim Startoutputleft As String = helloworld.Substring(0, 2)
Dim Startoutputright As String = helloworld.Substring(2, 2)
Dim Startnewoutput = Startoutputright + Startoutputleft
Dim FinalHEXStartDate = Startoutputright + Startoutputleft + "00" + "00"
Console.WriteLine("Start Date newoutput: " + FinalHEXStartDate)

Dim EndStartOutput As String
EndStartOutput = test.Substring(test.Length - 4, 4)
Dim EndStartoutputleft As String = helloworld.Substring(6, 2)
Dim EndStartoutputright As String = helloworld.Substring(8, 2)
Dim EndStartnewoutput = EndStartoutputright + EndStartoutputleft
Dim EndFinalHEXStartDate = EndStartoutputright + EndStartoutputleft + "00" + "00"
Console.WriteLine("End Date newoutput: " + EndFinalHEXStartDate)

It’s a crazy thing to have to figure out, but if you are working on VB.NET, then this may help a little bit with your MP3 APE metadata.

Either way, this is the full output – set for April 30, 2019.

C:\Users\steve\Desktop\test 2.mp3
XRestriction_value: @?, , A?, , , , , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q, , , , , Q
raw: 403F0000413F000000001000000007F511001000000007F511001000000007F511001000000007F511001000000007F511001000000007F511001000000007F511
found at byte offset: 279628

APE data fields are great and are totally customisable which don’t have to adhere to  ID3 name field standards. This is especially helpful when you want to embed application specific tags in files without effecting the usability of the file.

Next step, getting the data written correctly. This shouldn’t be too hard in theory.


Posted on Updated on

After playing with the Fusio project for a while, and trying it out in probably the most unorthodox way, and trying to read between the lines with the documentation, I’ve managed to get a list of data from the php_sandbox.

For example, this is the php code:

$connection = $connector->getConnection('System');

$id = (int)$request->getParameters('user_id');
$another_string =  $request->getParameters('another_string');
$todo = $connection->fetchAll('Select *, date as datecol from fusio_app where user_id = ' . $id . ' order by datecol ASC');
$count  = $connection->fetchColumn('SELECT COUNT(*) FROM fusio_app where user_id = ' . $id );

return $response->build(200, [], 
    'another_string' => $another_string,
    'totalResults' => $count,
    'results' => $todo

URI Fragments:





HTTP example GET:

And, that should then give you a response of the “apps” currently listed in the main database, if this is a fresh install.


    "another_string": {
        "user_id": "1",
        "another_string": "Steve"
    "totalResults": "3",
    "results": [
            "id": "3",
            "user_id": "1",
            "status": "1",
            "name": "YSG",
            "url": "",
            "parameters": null,
            "app_key": "xxxxxxxxxxxxxxxxxx",
            "app_secret": "xxxxxxxxxxxxxxxxxx",
            "date": "2019-03-24 14:22:36",
            "datecol": "2019-03-24 14:22:36"
            "id": "1",
            "user_id": "1",
            "status": "1",
            "name": "Backend",
            "url": "",
            "parameters": "",
            "app_key": "xxxxxxxxxxxxxxxxxx",
            "app_secret": "xxxxxxxxxxxxxxxxxx",
            "date": "2019-03-24 22:08:13",
            "datecol": "2019-03-24 22:08:13"
            "id": "2",
            "user_id": "1",
            "status": "1",
            "name": "Consumer",
            "url": "",
            "parameters": "",
            "app_key": "xxxxxxxxxxxxxxxxxx",
            "app_secret": "xxxxxxxxxxxxxxxxxx",
            "date": "2019-03-24 22:08:13",
            "datecol": "2019-03-24 22:08:13"

Of course this is just a test, and should be accompanied with better security policies and the like, with a token response or similar, but it’s a general quick request.

There is so much more room for better documentation on the site, as most what is currently written, is that it assumed you know the majority of it already.

I’ll post more and update more as I continue to discover things.

This documentation has a few examples: