Skip to main content

Posts

Showing posts from October, 2019

Encode or decode date in 3 characters

I have developed a new way to encode/decode dates within 3 characters by using base-36 format. What is a base 36 format? Base 36 or hexatridecimal is a positional numeral system using 36 as the radix. The choice of 36 is convenient in that the digits can be represented using the Arabic numerals 0-9 and the Latin letters A-Z. In simple language, base-36 format refers to series of 0-9 followed by A-Z characters, i.e., 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ; where each character refers to the position index in series. The concept can also be represents as shown in the below table Series Character Series Character Series Character Series Character 0 0 10 A 20 K 30 U 1 1 11 B 21 L 31 V 2 2 12 C 22 M 32 W 3 3 13 D 23 N 33 X 4 4 14 E 24 O 34 Y 5 5 15 F 25 P

How to create mirrored repositories and keep it synced?

To mirror the existing git repository (i.e, src-repo ) into another git repository (i.e., dest-repo ), follow the steps given below: Create a bash file and name it as mirror-sync-repo.sh Copy the below code and paste it in your bash file #!/usr/bin/bash SourceRepositoryURL=http://src-repo.gitserver1.domain DestinationRepositoryURL=http://dest-repo.gitserver2.domain SourceRepositoryDir=src-repo.git if [ ! -d $SourceRepositoryDir ] then git clone --mirror $SourceRepositoryURL cd $SourceRepositoryDir git remote add --mirror=fetch secondary $DestinationRepositoryURL cd .. fi cd $SourceRepositoryDir git fetch origin git push secondary --all Modify the code by replacing pseudocode with the actual repository names and links Save the bash file Open the Terminal app and go to that folder where this bash file is present Execute the bash file on Terminal using sh mirror-sync-repo.sh command, you'll be asked to enter the username and password for both the repositories