Tuesday, March 3, 2020

Ubuntu delete files in subfolders recursively preserving folders

Go to the relevant folder location and execute the below command

find . -name "*.jpg" -type f -delete



Happy coding!

Tuesday, April 10, 2018

Partition table for your Ubuntu installation

Use this partition table guide when you install Ubuntu alongside windows.
  • 1 GB - primary (1024) free space
  • 20 GB - logical (20000) swap
    • Rule of thumb is to keep double the size of your RAM.
  • 40 GB - logical (40960) /
  • 500 GB - logical (512000) /home
  • Remaining - logical (26220) as external partition (for windows)
Cheers!! 


Monday, December 18, 2017

Ubuntu remove error repository from apt update

When you add a repository URL that doesn't work and later when you do 'sudo apt-get update' and it starts throwing errors; use the below command to remove it.

sudo add-apt-repository --remove <url>

Replace the <url> with error repo URL.

Ex: sudo add-apt-repository --remove http://ppa.launchpad.net/ondrej/mysql-5.6/ubuntu

Happy Coding!

Wednesday, December 13, 2017

Github clone only a sub-directory of a repository

If there is a need to download only a sub-directory of the full Github repo, you can do the following steps to clone the required directory.

  • git clone <repo root url> <name of the sub-directory>
  • cd <name of sub-directory>
  • git filter-branch --prune-empty --subdirectory-filter <path to sub-directory> HEAD 
Ex: Let's say you need to clone the apim-is-as-keymanager-sso directory from https://github.com/wso2/presales-demos GitHub repo. Execute the following commands.
  • git clone https://github.com/wso2/presales-demos apim-is-as-keymanager-sso
  • cd apim-is-as-keymanager-sso
  • git filter-branch --prune-empty --subdirectory-filter apim-is-as-keymanager-sso HEAD 
Happy Coding!

Thursday, November 2, 2017

How to run MSF4J service in Docker

In order to create your microservice project you need to have Maven and JDK installed on your developer machine. Then once you get the executable jar of the MSF4J project you can run this in any of the Docker hosting machines. For the hosting environment, you only need to have Docker installed on the hosting machine. 

  • Enter the following lines into your Dockerfile.
    • This will grab an existing docker image which will create the JDK runtime environment to run the jar file. 
    • Then the script copies the jar file into /tmp directory.
    • Next, it exposes port 8080 to run the service.
    • Finally, it runs the jar file
  • Execute the following commands in terminal to run the Dockerfile.
Happy coding!! 

Wednesday, October 25, 2017

Arduino - upload the hex file through command line terminal

Below is an example command I use to load the hex file to Arduino Uno development board by executing the command in Linux terminal.

arduino-1.6.12/hardware/tools/avr/bin/avrdude -Carduino-1.6.12/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:grbl_v0_9a_edge_328p_16mhz_9600_build20121210.hex:i

However, the command might differ depending on your development board type. To find the exact command that needs to be executed, we can use a basic sample.ino file and upload it via Arduino IDE. Then in order to see what the commands that get executed in the background we can enable logs and see them through the console.

How to enable console logs:

  • Go to File -> Preferences
  • Enable show verbose output during upload

Now check for the console output and find the appropriate command.

Cheers!!