Laur IVAN

Change the File Extension in Typescript – Using Path

Posted by in Software, Tutorial

Following from my previous post, I’ve updated the function to use only the path module. Now, the code looks like:

I’ve updated the workflow presented previously to: isolate the dir, ext and root components of the path replace the ext with the new extension return the normalized version of the composed path Now, our function accepts complete paths, not only filenames. Note: The path.normalize() function does NOT calculate the absolute path. It only changes the path separators. A little experiment: If you find this post and ad below useful,…read more

Change the File Extension in Typescript (or Javascript)

Posted by in Software, Tutorial

TL;DR: You need to get the root name (without the extension) and append the new extension. Then, it only depends on how tolerant you are. The other day I figured I needed a function to change the file extension (from a .jpg to a .nfo). Since I haven’t found a ready made function to do this, I decided to create my own (it’s also a good exercise for my neurons…). The function ended up having the following steps: Prerequisite: the function input parameters are the file name (not the full…read more

Access Data Files for Local Tests in Android

Posted by in Software

TL;DR: Put your data files in test/resources and access it with:

I’ve got an android application with a module performing data processing (HTML scraping in fact). This part is pure java and all its tests are in the src/test path. My particular problem is that I have a set of (large-ish) files to be parsed by the tests and I need a reliable way to access these files. I know that best practice would be to keep the files inline, but dumping 300k-ish content in strings for a 10-line…read more

Get Access to Files in Genymotion

Posted by in Software

Genymotion is a fine emulator. I’m using it as any normal user and once in a while I need to get a file from the VM to analyse (a DB file or a trace usually). Normally, the way I go is via the Device Monitor (which, in turn goes via adb). Granted, this is the universal method (read: works both on emulators and on real devices). However, it’s quite slow. So, here’s a faster way: Close your emulator Open the VirtualBox Manager. You’ll have the emulator listed there. Select the…read more

Split a Gradle Build File

Posted by in Software

TL;DR: If you can, use ext {} with constants (hash). You can do call pointer things too! In the past days I’ve been trying to add some functionality to my Gradle build file so the version would be determined from the git tag. I’ve found this excellent entry showing how to get the actual string. My code ended up being like this:

Long build file The problem I have is that with every custom thing, the build file increases. Then, finding an error of a particular thing becomes more and…read more