Ad_Feed

Saturday, September 14, 2019

How-to merge or consolidate many excel worksheets into one

Insert in MS Excel VBA the code below and run. It will combine all worksheets in one called "Combined_worksheet"
==
Sub Combine()
'UpdatebyExtendoffice
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined_worksheet"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
==


Wednesday, May 2, 2018

Guide for installing DHIS2 on Ubuntu 16.04 LTS 

Thanks to https://dhis-2.blogspot.com.ng/

Works up to DHIS 2.28

This guide assumes Ubuntu 16.04 LTS is installed on a local machine/VPS with 4GB of RAM and DHIS2 is used for testing purposes. This is based on the official DHIS2 documentation, correcting some of it's mistakes in the commands.

Login with the Ubuntu 'root' account or any account in the Ubuntu sudoers list.

  1. Setting server time zone
    sudo dpkg-reconfigure tzdata
  2. Creating an Ubuntu user to run DHIS2
    Create a new user called 'dhis' by invoking:
    sudo useradd -d /home/dhis -m dhis -s /bin/false

    Then set the password for the account by invoking:
    sudo passwd dhis
    Make sure you set a strong password
  3. Creating the configuration directory
    sudo mkdir /home/dhis/config

    Set ownership of the directory to 'dhis' user created above
    sudo chown dhis:dhis /home/dhis/config
  4. PostgreSQL installation
    sudo apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-9.5-postgis-2.2
    Create a non-privileged PostgreSQL user called 'dhis' by invoking:
    sudo -u postgres createuser -SDRP dhis

    Create a database by invoking:
    sudo -u postgres createdb -O dhis dhis2

    Create the PostGIS extension
    sudo -u postgres psql -c "create extension postgis;" dhis2

  5. Creating DHIS2 configuration file
    sudo -u dhis nano /home/dhis/config/dhis.conf

    Insert following lines to the file (update PostgreSQL dhis user password according what you set above):

    # Hibernate SQL dialect
    connection.dialect = org.hibernate.dialect.PostgreSQLDialect

    # JDBC driver class
    connection.driver_class = org.postgresql.Driver

    # Database connection URL
    connection.url = jdbc:postgresql:dhis2

    # Database username
    connection.username = dhis

    # Database password
    connection.password =
    xxxx

    # Database schema behavior, can be validate, update, create, create-drop
    connection.schema = update

    # Encryption password (sensitive)
    encryption.password = xxxx

  6. Java installation
    Oracle Java will need to be installed manually because it no longer supports installation via apt-get.

    Create a directory to install Java

    mkdir /usr/java/

    cd /usr/java/

    wget -O java-linux-x64.tar.gz http://oracle-java-download-link
    (You need to replace http://oracle-java-download-link with "Linux x64" download link from this page: https://www.java.com/en/download/linux_manual.jsp
    It will be something like: http://javadl.oracle.com/webapps/download/AutoDL?BundleId=233162_512cd62ec5174c3487ac17c61aaa89e8)

    tar zxvf java-linux-x64.tar.gz



  7. Tomcat and DHIS2 installation
    sudo apt-get install tomcat7-user

    To create a Tomcat instance for DHIS2 move to the dhis folder created above:
    cd /home/dhis/

    Create Tomcat instance:
    sudo tomcat7-instance-create tomcat-dhis

    Set ownership of the created folder to dhis user
    sudo chown -R dhis:dhis /home/dhis/tomcat-dhis/

    Edit setenv.sh:
    sudo nano /home/dhis/tomcat-dhis/bin/setenv.sh

    Add the following lines to the bottom of the file:

    export JAVA_HOME='/usr/lib/jvm/java-8-oracle/'
    export JAVA_OPTS='-Xmx2000m -Xms1000m'
    export DHIS2_HOME='/home/dhis/config'


    The next step is to download the DHIS2 WAR file and place it into the webapps directory of Tomcat:
    wget https://www.dhis2.org/download/releases/2.28/dhis.war

    Move the WAR file into the Tomcat webapps directory. We want to call the WAR file ROOT.war in order to make it available at localhost directly without a context path:
    sudo mv dhis.war tomcat-dhis/webapps/ROOT.war

    DHIS2 should never be run as a privileged user, so edit the startup.sh:
    sudo nano /home/dhis/tomcat-dhis/bin/startup.sh

    Replace everything in the file with the following lines:

    #!/bin/sh
    set -e

    if [ "$(id -u)" -eq "0" ]; then
       echo "This script must NOT be run as root" 1>&2
       exit 1
    fi

    export CATALINA_BASE="/home/dhis/tomcat-dhis"
    /usr/share/tomcat7/bin/startup.sh
    echo "Tomcat started"
  8. Running DHIS2
    DHIS2 can now be started by invoking:
    sudo -u dhis tomcat-dhis/bin/startup.sh

    To monitor the behavior of Tomcat, the log is the primary source of information. The log can be viewed with the following command:
    tail -f tomcat-dhis/logs/catalina.out

    DHIS2 can be stopped by invoking:
    sudo -u dhis tomcat-dhis/bin/shutdown.sh
    Assuming that the WAR file is called ROOT.war, you can now access your DHIS2 instance at:

    http://localhost:8080 or
    http://your.server.ip.address:8080

    Default login details:
    Username: admin
    Password: district
  9. Starting DHIS2 at server startup
    Create init scripts:
    sudo nano tomcat

    Enter the following lines:

    #!/bin/sh
    #Tomcat init script

    HOME=/home/dhis/tomcat-dhis/bin

    case $1 in
    start)
       sudo -u dhis ${HOME}/startup.sh
       ;;
    stop)
       sudo -u dhis ${HOME}/shutdown.sh
       ;;
    restart)
       sudo -u dhis ${HOME}/shutdown.sh
       sleep 5
       sudo -u dhis ${HOME}/startup.sh
       ;;
    esac
    exit 0


    Move the script to the init script directory and make it executable by invoking:
    sudo mv tomcat /etc/init.d
    sudo chmod +x /etc/init.d/tomcat


    Next make sure the tomcat init script will be invoked during system startup and shutdown:
    sudo /usr/sbin/update-rc.d -f tomcat defaults 81

Friday, January 20, 2017

Warning Messages in "R" on Mac.

 When starting R (or using any IDE like RStudio), the following warning messages are displayed:
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
 To clear this error message, following the steps below:
  1. Open terminal and enter:
    defaults write org.R-project.R force.LANG en_US.UTF-8
  2. Restart R or R-studio.

Wednesday, December 30, 2015

How to backup multiple Mysql databases and automatically delete

The script below was adapted from iHRIS Backups (http://wiki.ihris.org/wiki/Backups) which was designed to backup one database. The script below will backup all databases in Mysql.

There is the option to remove database backup files older than 7days except from the first day of the month.


#!/bin/sh
MHOST=localhost
MUSER=db_username
MPASS=db_password
BACKUPDIR=/db/backup/dir

MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"

SUFFIX=`date +%F`
cd $BACKUPDIR

echo "Run MySQL backup"
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
    $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db > backup_${db}_${SUFFIX}.sql
    bzip2 -f backup_${db}_${SUFFIX}.sql
done
## Uncomment the following line to remove backup files older than 7 days except from the first day of the month.
#find $BACKUPDIR -name "backup_*.sql.bz2" -mtime +7 -not -name "backup_*-01.sql.bz2" -exec rm {} \;


Save the file, and ensure the script is executable using the command chmod a+x newfile.


Saturday, February 28, 2015

MySQL Databases - Commandline Backup and Restore

  • Backup A Single Database
    mysqldump -u root -p dbname > dbname.sql

    Where:
    dbname     = is the name of the database to backup
    dbname.sql = is the name of the backup file, can also be location of backup file

  • Restore A Single Database
    mysqldump -u root -p dbname < dbname.sql
  • Backup All Databases
    mysqldump -u root -p --all-databases > All-dbname.sql
  • Restore Single Database from All Database Backup
    mysql -u root -p --one-database dbname < All-dbname.sql

Tuesday, October 28, 2014

Perl warning Setting locale failed in Ubuntu

Perl Locale Warning.
The warnings could be irritating, especially when installing any application. The warnings are also visible when some commands are run

The warnings look like:
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory

 
and when you run Run locale from the commandline
bonkhi@sparda-coven:$ locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_NG.UTF-8
LC_TIME=en_NG.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_NG.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_NG.UTF-8
LC_NAME=en_NG.UTF-8
LC_ADDRESS=en_NG.UTF-8
LC_TELEPHONE=en_NG.UTF-8
LC_MEASUREMENT=en_NG.UTF-8
LC_IDENTIFICATION=en_NG.UTF-8
LC_ALL=

To solve this, generate the missing locale
locale-gen en_US.UTF-8

Set the missing locale
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Friday, October 3, 2014

How do you reset the circuit protection on Yamaha RX-v373?

Yamaha RX-V373 AV receiver's protection circuity is activated when there is fluctuation in power three (3) consecutive times. This protection mode disables the capability to "turn on" the device.

To disable this:

Hold "Info + Tone Control + Straight" for at least five seconds, while still holding, press the "Power" button.

Manually reboot the AVR for normal operation.

Wednesday, May 15, 2013

Using Php 5.3 on Cpanel platform

To install applications that require a higher PHP version, create a .htaccess file inside the application directory and specify which version of php you want used.


# Use PHP 5.3
AddType application/x-httpd-php53 .php



Monday, April 29, 2013

SSH permission issue - failed to add host to known hosts (/home/username/.ssh/known_hosts)

 The permission set on the .ssh folder, the private keys and public keys matter. To solve the problem of -

Failed to add the host to the list of known hosts (/home/username/.ssh/known_hosts)

.ssh folder - permission set to 700
public keys (id_rsa.pub or id_dsa.pub)- permission set to 644
private keys (id_rsa or id_dsa)- permission set to 600

Friday, November 23, 2012

Restore crashed Windows 7 (with no recovery image) after installing Ubuntu

Have you tried dual booting Ubuntu and Windows 7 and windows fails?

Did the Ubuntu installation complete successfully, and grub was properly installed but you still get the blue screen of death when you try booting windows?

Well, this is simple. The answer is with the file type of the windows partition.

I am assuming you have set up Ubuntu and grub is correctly installed. If not, please see https://help.ubuntu.com/community/Boot-Repair#A1st_option_:_get_a_CD_including_Boot-Repair for more information.

To correct this, boot your system to the Linux installation and run in root:
fdisk -l /dev/xxx


The Id for the windows partition (sda1 & sda2) is 42 which is the code for SFS. Change the file type Id to 7, which corresponds to HPFS/NTFS/exFAT, save and reboot.

fdisk /dev/xxx
In the prompt, type p to print the current partition table
To change the file type, type t in the prompt and enter the partition to change.

In my case, I will enter 1. 

For a list of the Hex code list of the file types, enter L in the prompt.

Enter 7 in the prompt, which corresponds to the HPFS/NTFS/exFAT file system.

Repeat the process for the second or third windows partition, and when done enter w in to save.

Reboot your system, and grub will load windows ! !  !


Tuesday, October 18, 2011

Install Solaris, Apache, Mysql & Php (SAMP)

You may be conversant with the terms LAMP and WAMP. This means a stack of applications.

For LAMP = Linux, Apache, Mysql and Php/Perl/Python.
For WAMP = Windows, Apache, Mysql and Php/Perl/Python.

To get your new Solaris 11 installation SAMP ready, we need to install Apache, Mysql and Php.

kilo@kilo:~$ sudo -s
Password:
root@kilo:/home/kilo#
root@kilo:/home/kilo# pkg refresh
root@kilo:/home/kilo# pkg install amp
               Packages to install:    12
           Create boot environment:    No
               Services to restart:     1
DOWNLOAD                                  PKGS       FILES    XFER (MB)
database/mysql-51                         3/12     554/729    59.0/75.2


When done, enable the apache and mysql service.
root@kilo:/home/kilo#svcadm enable apache22
root@kilo:/home/kilo#svcadm enable mysql

By default, the mysql root user has no password.
root@kilo:/home/kilo# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>;


We can set the password for the root user in mysql using
root@kilo:/home/kilo#mysqladmin -u root password "PASSWORD"

If you get the error - 
bash: mysqladmin: command not found

It means that the command mysqladmin is not in the path.
root@kilo:/home/kilo# which mysqladmin
which: no mysqladmin in (/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin)
 
To solve this, use the full path for the command.
root@kilo:/home/kilo# find / -name mysqladmin
/usr/mysql/5.1/bin/sparcv9/mysqladmin
/usr/mysql/5.1/bin/mysqladmin

/usr/mysql/5.1/bin/mysqladmin -u root password "PASSWORD"

Configure pkg in Solaris to use proxy

To configure your Solaris image packaging retrieval client (pkg) to use proxy -

kilo@kilo:~$ sudo -s   (I am using solaris 11. su - root can also be used)
Password:
root@kilo:/home/kilo# 
root@kilo:/home/kilo#export http_proxy=”http://proxyusername:proxypassword@proxyservername:port

Replace the following -
proxyusername = your proxy account username
proxypassword = your proxy account password
proxyservername = your proxy server address
port = proxy port number

Tuesday, October 11, 2011

Access scanner from LTSP server and thin clients

There seem to be a permission issue with accessing usb scanners from LTSP server and connected thin clients. Logging in as normal users, you cannot access the connected scanner.

Running the scanimage command as a normal user 
ltsp@ltsp-ProLiant-DL380-G4:~$ scanimage -L
device `hp3900:libusb:001:011' is a Unknown RTS8822 chipset based flatbed scanner

while logging in as the root user, running the scanimage command gives the parameter of the connected scanner.
root@ltsp-ProLiant-DL380-G4:~# scanimage -L
device `hp3900:libusb:001:011' is a Hewlett-Packard Scanjet 3800 flatbed scanner

You can however use any scan utility, but you will need root access to do this. To correct this - Looking at the permission for the usb character file
ltsp@ltsp-ProLiant-DL380-G4:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 005: ID 1c4f:0002 SiGma Micro
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 011: ID 03f0:2605 Hewlett-Packard ScanJet 3800c
Bus 001 Device 009: ID 03f0:5c17 Hewlett-Packard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The user/group permission to the usb character device responsible for the connected usb device has read & write for the root user and group.
ltsp@ltsp-ProLiant-DL380-G4:~$ ls -l /dev/bus/usb/001
total 0
crw-rw-r--  1 root root 189,  0 2011-10-11 00:28 001
crw-rw-r--+ 1 root lp   189,  8 2011-10-11 13:03 009
crw-rw-r--+ 1 root root 189, 10 2011-10-11 09:17 011

Change the group from root to users. (In my case, the group users has all ltsp client users in that group)
root@ltsp-ProLiant-DL380-G4:/dev/bus/usb/001# chgrp users 011
root@ltsp-ProLiant-DL380-G4:/dev/bus/usb/001# ls -al
total 0
drwxr-xr-x  2 root root      100 2011-10-11 09:10 .
drwxr-xr-x  7 root root      140 2011-10-11 00:28 ..
crw-rw-r--  1 root root  189,  0 2011-10-11 00:28 001
crw-rw-r--+ 1 root lp    189,  8 2011-10-11 13:03 009
crw-rw-r--+ 1 root users 189, 10 2011-10-11 09:17 011

And now.......
ltsp@ltsp-ProLiant-DL380-G4:~$ scanimage -L
device `hp3900:libusb:001:011' is a Hewlett-Packard Scanjet 3800 flatbed scanner
ltsp@ltsp-ProLiant-DL380-G4:~$


Ubuntu 11.04 installation hangs on timezone selection

When installing Ubuntu 11.04, the installation process hangs on time zone selection.  The installation hangs because of your network (Internet) connection.

The trick in dealing with this is disable your network connection and restart the installation.



Monday, September 12, 2011

Drupal Internal links don't work after migration

In some cases, after migrating all internal links in drupal defaults to the homepage. If you encounter this issue, enable mod_rewrite in Apache.

For Ubuntu users,
sudo a2enmod rewrite

Restart Apache
sudo /etc/init.d/apache2 restart

 
You can also.......
(a) make sure that you have Drupal's .htaccess file
(b) make sure that the apache vhost which controls your site does not contain an AllowOverrides None which disables .htaccess files in your site's directory. Change it to AllowOverrides All

Monday, August 15, 2011

Moodle 2.1.1 - Redirect to 'My Moodle' page after user logon

To redirect users to their course page referred to as 'My Moodle' page after login in moodle 2.1.1,

Click on Site administrator -> Appearance -> Navigation -> Default home page for users -> My Moodle

Thursday, August 11, 2011

Moodle 2.0 - Convert database engine from MyISAM to InnoDB

This scenario usually occurs when you upgrade moodle. If upgrading from moodle-1.9 to moodle-2.1.1, there is a database engine compatibility issue.

In the moodle notification page, the message below usually pops up:
Database tables are using MyISAM database engine, it is recommended to use ACID compliant engine with full transaction support such as InnoDB.

To convert your database engine to InnoDB, run the innodb.php script in the directory of the admin directory which is resident in the moodle directory.
http://moodlesite.domain/admin/innodb.php
 
Replace moodlesite.domain with you moodle path or IP address.

Enable Apache "public_html" for users in Ubuntu 10.04

Enable mod_userdir, which is installed by default with Apache2.  
sudo a2enmod userdir   

Create public_html directory with the user's permissions
mkdir public_html   

I don't know if that is a bug or a feature. Edit file /etc/apache2/mods-available/php5.conf and comment out lines

...IfModule mod_userdir.c...
        ...Directory /home/*/public_html..
        ...php_admin_value engine Off
        .../Directory
    .../IfModule...

Restart Apache Finally, you should restart Apache.  
sudo /etc/init.d/apache2 restart  

You can test with http://localhost/~username  or http://ip-address-of-system/~username

Monday, July 25, 2011

How to configure rpm/debian package manager to use proxy

To configure package manager to use proxy in fedora, CentOS, ubuntu or generally any rpm/debian based linux, you will need to enter your proxy login details in apt.conf (for debian based) and yum.conf (for rpm based).


For RPM Based
Create or edit /etc/yum.conf and add the details below, replacing proxy-server, port, username and password with your own login details.

# The proxy server - proxy server:port number
proxy=http://proxy-server:port 

# The proxy account details 
proxy_username=username
proxy_password=password


For DEBIAN Based
Create or edit /etc/apt/apt.conf and add the details below, replacing proxy-server, port, username and password with your own login details.

ACQUIRE {
http::proxy "http://username:password@proxy-server:port/"
}