Programming

30 articles

How to create symbolic links via FTP

Spoiler: you cannot!

In order to use Laravel File Storage utility, I had to create a symlink in the public folder pointing to a subfolder located in the... storage folder. That is nice and easy when you can ssh to your production server. However, it is a whole other story if you only have FTP access!

So the solution was to let PHP do the work for me, by using the handy symlink function:

if (!file_exists('./storage')) {
    symlink("../storage/app/public", "./storage");
}

Create symbolic links on server without SSH available?

Insert a line in the middle of an existing configuration file

Playing with Testing a new piece of software using a Vagrant box, I created a vagrant-install.sh in which I had to insert the line sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION inside an existing MySQL config file. I had to put it inside a specific section, so I targeted a line starting with datadir.

The following sed command will add the new line above it. It will update the config file by using a temporary intermediate file.

sed -n 'H;${x;s/^\n//;s/datadir.*$/sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\n&/;p;}' /your/file.cnf > tmp && mv tmp /your/file.cnf

Accessing your application database from Android Studio

Open the Terminal window (Alt + F12) or:

Open the Terminal window

Then list your devices with the adb command. This will display both running emulators and connected devices:

$ adb devices
List of devices attached
emulator-5554   device

Use the device name to open a connection:

$ adb -s emulator-5554 shell
generic_x86:/ $

To avoid a Permission denied error while trying to access your application files, use the run-as command:

generic_x86:/ $ run-as com.your.package.example sqlite3 databases/yourdatabase.db

Accessing your application files from Android Studio

While learning to play with SQLite databases in Android, I wanted to check the .db file generated by my code in the emulator. I was unable to find it directly with the built-in Files application because it doesn't let us see system folders.

The built-in Files app

Fortunately, Android Studio 3+ comes with the Device File Explorer, which allows us to browse system files and access the root data folder. To open it, go to View > Tool Windows > Device File Explorer. My application data was stored in /data/data/.

How to display the Device File Explorer


How to see the data stored in sqlite in android studio using genymotion as emulator

[Git] List the files which have been modified between two commits/tags

git

I needed to know the exact list of files that had been modified between my last two tags:

git diff --name-only v2.0.0 v2.0.1

You can replace the tags by commits:

git diff --name-only SHA1 SHA2
git diff --name-only HEAD~10 HEAD~5

Source