Wednesday, October 22, 2014

Amazon Glacier Backup tools on your server | cPanel, Virtualmin, Directadmin, ...

Amazon Glacier is a cost-effective way to store your backup data.
Recently I set up a cPanel server for weekly database backups on glacier. Here are the steps:

First, install glacier-cmd:

yum install git python
cd /usr/src
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
# For cpanel:
ln -s /usr/local/cpanel/3rdparty/bin/git /usr/bin/git
#
git clone https://github.com/uskudnik/amazon-glacier-cmd-interface
cd amazon-glacier-cmd-interface
python setup.py install

 
Open ~/.glacier-cmd and enter your credential details:

[aws]
access_key=YOUR_ACCESS_KEY
secret_key=YOUR_SECRET_KEY

[glacier]
region=us-west-1
bookkeeping=false
bookkeeping-domain-name=backups
logfile=~/.glacier-cmd.log
loglevel=INFO
output=print





Now you can use the following simple script and cronjob to set a weekly backup:
/script/backup:

#!/bin/sh
NOW=$(date +"%d-%m-%Y")
rm -fr /home/backup-tmp
mkdir /home/backup-tmp
mysqldump -A > /home/backup-tmp/backup-all-db-$NOW.sql
gzip /home/backup-tmp/backup-all-db-$NOW.sql
glacier-cmd upload --description "$NOW Backup" VAULT_NAME /home/backup-tmp/backup-all-db-$NOW.sql.gz



Cronjob:

5 8 * * 6       /script/backup







Monday, May 26, 2014

Fortran Tips

Here I've listed some common fortran tips:

-  The form of the information contained in a variable can also be declared implicitly, e.g. IMPLICIT DOUBLE PRECISION (A-H, O-Z) . [Fortran fundamentals] (Read more)
 -  A program may contain only one blank COMMON block but any number of named COMMON blocks. (Read more)

Thursday, April 17, 2014

CFD: Non-uniform grid mesh for 2D Rectangular - Fortran code

Result:

Here's part of the code I used to generate a non-uniform grid using fortran. To understand meaning of exp_x & exp_y powers, you need a piece of paper to sketch and calculate it by yourself.



exp_x=1.05 !x-axis expansion factor
exp_y=1.10 !y-axis expansion factor

a=0.
b=1.
c=0.
d=1.

!***********************************
! Constructing non-uniform grid !
!***********************************
! del_x & del_y : Uniform step size in X & Y direction
! eta_x & eta_y : First non-uniform step size in X & Y direction
! i_th step size is : eta_x*expansion_factor^step
del_x=(b-a)/n_x
del_y=(d-c)/n_y
eta_x=(b-a)*(1-exp_x)/(2*(1-exp_x**(n_x/2)))
eta_y=(d-c)*(1-exp_y)/(2*(1-exp_y**(n_y/2)))

PRINT *, "Uniform X-Step:", del_x
PRINT *, "Uniform Y-Step:", del_y
PRINT *, "First Non-uniform X-Step:", eta_x
PRINT *, "First Non-uniform Y-Step:", eta_y

x(1)=a
y(1)=c
! X_START to Middle_X
DO i=2,n_x/2+1
       x(i)=x(i-1)+eta_x*exp_x**(i-2)
END DO
! Middle_X to End
DO i=n_x/2+2,n_x+1
       x(i)=x(i-1)+eta_x*exp_x**(n_x+1-i)
END DO
! Y_START to Middle_Y
DO j=2,n_y/2+1
       y(j)=y(j-1)+eta_y*exp_y**(j-2)
END DO
! Middle_Y to Y_END
DO j=n_y/2+2,n_y+1
       y(j)=y(j-1)+eta_y*exp_y**(n_y+1-j)
END DO
!***********************************
! non-uniform grid done !
!***********************************
 

Sunday, January 5, 2014

Deactive "sort by subject" of roundcube

In roundcube webmail client when you click on "subject" column, it will sort all your mails by subject! I don't know if it's useful or not but many times occured that I uncounsioucly clicked on this and it took long time to sort all messages by subject! Here's how to deactivate column sorting by subject :
- Open file : program/steps/mail/func.inc
- Search for "./#sort", for me it's around line 443. Then replace :
'onclick' => 'return '.JS_OBJECT_NAME.".command('sort','".$col."',this)
with :
'onclick' => 'return true'

That's it!

How to export Apple Health / Google Fit training activity to TCX format

  I own a Xiaomi Smart Band 7, and recently, my Mi Fitness app stopped syncing running activities to Strava. Mi Fitness supports syncing dat...