Windows and linux information and one stop centre for myself. Having difficulties to remember all things at once. This blog will remain be my references on the internet. Other people can take benefit from it. Thank you for visiting
Saturday, July 26, 2008
Hilang menubar dari excel 2003 ( mungkin boleh diaplikasikan dalam excel version lain )
2. Tekan ALT + F11 untuk akses ke visual basic editor
3. Bina MODULE dari menu INSERT -> MODULE
4. Masukkan arahan ini:-
Sub kawe()
On Error Resume Next
With Application
.DisplayFullScreen = False
.CommandBars("Worksheet Menu Bar").Enabled = True
.CommandBars("Standard").Enabled = True
.CommandBars("Formatting").Enabled = True
.CommandBars("Drawing").Enabled = True
.CommandBars("Borders").Enabled = True
.CommandBars("Chart").Enabled = True
.CommandBars("Control Toolbox").Enabled = True
.CommandBars("External Data").Enabled = True
.CommandBars("Forms").Enabled = True
.CommandBars("Formula Auditing").Enabled = True
.CommandBars("List").Enabled = True
.CommandBars("Picture").Enabled = True
.CommandBars("PivotTable").Enabled = True
.CommandBars("Protection").Enabled = True
.CommandBars("Reviewing").Enabled = True
.CommandBars("Task Pane").Enabled = True
.CommandBars("Text To Speech").Enabled = True
.CommandBars("Visual Basic").Enabled = True
.CommandBars("Watch Window").Enabled = True
.CommandBars("Web").Enabled = True
.CommandBars("Web Art").Enabled = True
End With
On Error GoTo 0
End Sub
5. Dwi-Klik pada Sheet 1 dan masukkan arahan ni
Private Sub Workbook_Activate()
Run "kawe"
End Sub
6. Tekan F5 untuk run micro
7. Ok sekarang menubar sudah keluar dalam View -> Toolbar. Sila buat pilihan pada toolbar tersebut contoh "Standard".
Save file tersebut ( boleh delete selepas ini ) kemudian buka semula excel untuk sahkannya
selamat mencuba!
Thursday, July 24, 2008
Skrip berguna untuk backup Mysql setiap hari
=========== mula ==============
#!/bin/bash
##### SETTING #####
MYUSER="dbuser"
MYPWD="password"
DB="database"
DIR_PATH="/var/mysql-backup"
FAIL=mybck_$(date +%d-%m-%Y)
###################
#check DIR_PATH
if [ ! -d $DIR_PATH ]
then
mkdir $DIR_PATH
fi
#Running MySQL dump
cd /tmp
mysqldump -c -x --add-drop-table --add-locks --database $DB -u $MYUSER -p$MYPWD > $FAIL.sql
#Compress result
if [ -e $DIR_PATH/mytoday_$(date +%d-)* ]
then
rm -f $DIR_PATH/mytoday_$(date +%d-)*
tar -jcf $DIR_PATH/$FAIL.tgz $FAIL.sql
rm -f $DIR_PATH/latest.tgz
ln -s $DIR_PATH/$FAIL.tgz $DIR_PATH/latest.tgz
else
tar -jcf $DIR_PATH/$FAIL.tgz $FAIL.sql
rm -f $DIR_PATH/latest.tgz
ln -s $DIR_PATH/$FAIL.tgz $DIR_PATH/latest.tgz
fi
rm -f $FAIL.sql
===================== tamat ====================
Monday, July 21, 2008
Lighttpd and AWSTATS
Step 1. Download and Extract AWStats
- Download AWStats
- Extract the archive to the web directory on your system, e.g. /var/www/
Step 2. Configure lighttpd.conf
Fire up lighttpd.conf in your favorite editor. Make sure that mod_cgi is in your modules configuration.
server.modules = ( "mod_rewrite", "mod_fastcgi", "mod_status", "mod_cgi", "mod_accesslog" )
Add a separate host entry for your AWStats instance.
$HTTP["host"] =~ "awstats.YOURDOMAINNAMEHERE" {
cgi.assign = (
".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl"
)
server.document-root = "/YOUR_PATH_TO/awstats/wwwroot/"
}
Restart Lighttpd and point your browser to:
http://awstats.YOURDOMAINNAMEHERE/cgi-bin/awstats.plYou should get an error message from AWStats, continue on to Step 3. If you get a 404 error message or Lighttpd didn't start, check your configuration file for syntax errors and correct paths.
Step 3. Configure AWStats
Copy cgi-bin/awstats.model.conf to cgi-bin/awstats.YOURDOMAINNAMEHERE.conf, and open that file in an editor.
- Set the path to your log file
LogFile="/path/to/your/log/file"
- Set your Domain Name
SiteDomain="YOURDOMAINNAMEHERE"
http://awstats.YOURDOMAINNAMEHERE/cgi-bin/
awstats.pl?config=YOURDOMAINNAMEHERE
You can add new configuration files for each site you would like AWStats to parse.
Step 4. Analyze Log Files
To update the stats, run the following command in the cgi-bin directory:
perl awstats.pl -update -config=YOURDOMAINHERE
Friday, July 18, 2008
scp - Linux command line tool to copy files over ssh
scp stands for secure cp (copy), which means that you can copy files across an ssh connection that will be encrypted, and therefore secured.
You can this way copy files from or to a remote server, you can even copy files from one remote server to another remote server, without passing through your PC.
Usage
scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
Description of options
- from-host
- Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command
- user
- Is the user which have the right to access the file and directory that is supposed to be copied in the cas of the from-host and the user who has the rights to write in the to-host
- source-file
- Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory
- destination-file
- Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to maintain its names
Options
- -p
- Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
- -q
- Do not display the progress bar
- -r
- Recursive, so it copies the contents of the source-file (directory in this case) recursively
- -v
- Displays debugging messages
Examples
scp *.txt user@remote.server.com:/home/user/
This will copy all files with .txt extension to the directory /home/user in the remote.server.com host
scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/
This is going to recursively copy all files from miguel's Home directory on 10.1.2.2 host to his Home directory in 10.1.2.3 host.
Note
To use this command you need to have open-ssh installed in the hosts.
The UltraMonkey Solution
Ultra Monkey is a project to create load balanced and highly available services on a local area network using Open Source components on the Linux operating system, including heartbeat and ldirectord from the Linux-HA project.
Configuration example
Now we're going to using UltraMonkey to contruct a highly-available VS/NAT web cluster with two load balancers and three web servers. The topology is illustrated in the following figure. In the example, virtual IP address and gateway IP address are 10.23.8.80 and 172.18.1.254, which are floating between the two load balancers (LD1 and LD2), and the ip addresses of three real servers are 172.18.1.11, 172.18.1.12 and 172.18.1.13 respectively.
The configuration files of UltraMonkey are the same at LD1 and LD2. The configuration files for above examples are as follows:
/etc/ha.d/ha.cf:
logfacility local0
keepalive 2
deadtime 10
warntime 10
initdead 10
nice_failback on
udpport 694
bcast eth1
node ld1
node ld2
/etc/ha.d/haresources:
ld1 IPaddr::10.23.8.80/24/eth1 IPaddr::172.18.1.254/24/\
eth1 ldirectord::ldirectord.cf
/etc/ha.d/ldirectord.cf:
checktimeout=10
checkinterval=2
autoreload=no
logfile="local0"
quiescent=yes
virtual=10.23.8.80:80
fallback=127.0.0.1:80
real=172.18.1.11:80 masq
real=172.18.1.12:80 masq
real=172.18.1.13:80 masq
service=http
request="index.html"
receive="Test Page"
scheduler=wlc
persistent=600
protocol=tcp
checktype=negotiate
Load balancing with a script in linux
When you have two ISPs you may want to make your linux machine balance the load of your internet access, you can use ip route
The package needed for this is iproute, if you are using debian you can install it with
apt-get install iproute
or go to this page and download the source of iproute
Let's use this Load Balance Script which work for Centos, Fedora, Ubuntu, Debian and should work for all distributions.
-----------cut here--------------
#!/bin/bash
#IPs of the def gateways
IP1=192.168.1.1
IP2=192.168.2.1
REDLOCAL=10.1.1.0/24
IPLOCAL=10.1.1.1
# NICs
IF1=eth0
IF2=eth1
ip rule add from $IP1 lookup T1
ip route add $REDLOCAL via $IPLOCAL table T1
ip route add 0/0 via $IP1 table T1
ip route add from $IP2 lookup T2
ip route add $REDLOCAL via $IPLOCAL table T2
ip route add 0/0 via $IP1 table T1
ip route default equalize nexthop via $IP1 dev $IF1 nexthop via $IP2 dev $IF2
--------------cut here ---------------------
that should do the job, off course make the changes on the variables according to your needs.
Wednesday, July 16, 2008
Find and fix weak OpenSSL/OpenSSH keys: Debian-based Linux vulnerability
A recent vulnerability was found in the OpenSSL package as provided by Debian and Debian-based Linux distributions, such as Ubuntu, that broke the effectiveness of the OpenSSL PRNG (Predictable Random Number Generator). This vulnerability caused OpenSSL to generate weak keys for anything relying on OpenSSL, including SSL certificates, OpenSSH keys, and OpenVPN keys. Any OpenSSL-based key generated on a Debian-based system since September 2006 by the openssl, ssh-keygen, or openvpn –keygen commands are vulnerable to this issue.
Debian and Ubuntu have already issued updates that correct the flaw and provide a blacklist of keys known to be weak. Unfortunately, exploits to take advantage of this flaw exist as well. Likewise, while the affected OpenSSL packages are only on Debian and Debian-derived distributions, it could affect other operating systems as well if those keys were generated on a Debian system. For instance, if your system provides SSH access to external users, and one of them created an SSH keypair using Debian or Ubuntu, then your system, or more particularly those user accounts, should be considered compromised, whether it is running Mandriva, Fedora, or even a BSD variant.
The Debian team has provided a tool that can be used to determine if any such weak keys exist on the system, and it can be run by anyone, regardless of whether they use Debian or not. To begin, download the dowkd.pl perl script and use it to test SSH keys of the host system:
$ cd ~/tmp $ curl -O -L http://security.debian.org/project/extra/dowkd/dowkd.pl.gz $ curl -O -L http://security.debian.org/project/extra/dowkd/dowkd.pl.gz.asc $ gpg --keyserver subkeys.pgp.net --recv-keys 02D524BE $ gpg --verify dowkd.pl.gz.asc $ gunzip dowkd.pl.gz $ perl dowkd.pl host localhost This will download the dowkd.pl perl script and also import a Debian security team member’s key from subkeys.pgp.net. If the archive verifies okay with gpg, unarchive it, and then run the script in host-checking mode against the localhost.
If the script detects that the host key is weak, it will indicate such. Next, run the script against user keys on the system:
# perl dowkd.pl user This check should be run as root in order to obtain access to every user’s keys. The script will check the keys and also the authorized_keys file and will alert you if the fingerprint to a remote host indicates a vulnerable key as well. If you wish to check a specific user, append the user name to the command:
# perl dowkd.pl user joe If the script indicates that any keys are weak, they should be removed and regenerated immediately.
More information on exactly what types of keys and how to test them all is available at http://wiki.debian.org/SSLkeys.
Get the PDF version of this tip here.
tips :
to regenerate key for openssh
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
see http://wiki.debian.org/SSLkeys for details
Simple Python Calculator This script will allows your to calculate the integers given with the chosen operation. You can add, substract, mu...
-
when trying to apt-get update i got this error message :- W: There is no public key available for the following key IDs xxxxxxxxxxxx t...
-
Skrip ini aku guna kat server aku.. backup mysql setiap hari. Hanya perlu ubah pada bahagian setting sahaja. chmod dan set cron untuk daily ...
-
This tutorial will help you get AWStats and Lighttpd working together. AWStats is an excellent log analyzer, and works well with Lighttpd. T...