Tuesday, March 6, 2012

SUBLIME TEXT 2 UBUNTU PPA

— SkyHi @ Tuesday, March 06, 2012
Sublime Text 2 is a pretty neat text editor which will remind you of TextMate. It runs on Linux, Windows and Mac OSX and while it's not free, you can evaluate it for an unlimited period of time. Check out our Sublime Text 2 review for more info.

Sublime Text 2 is currently in alpha and there are new builds available for download quote often so I wanted to create an Ubuntu PPA for a while now but I couldn't find out what license it uses. I've emailed the Sublime Text 2 developer and got no reply so I decided to package it like Adobe Flash: the .deb will download Sublime Text 2 from its website so the .deb doesn't come with the actual files.

While Sublime Text 2 automatically checks for updates and prompts you to download the latest version, I like getting the updates through a PPA. Further more, using this PPA, Sublime Text 2 will get a proper .desktop file so you can right click files to open in Sublime Text 2 as well as showing up properly in the Unity launcher. You can also open files from the command line (run "sublime-text-2 /path/to/file" or "subl /path/to/file").


This is the first version of the Sublime Text 2 packaging so there might be bugs. The deb doesn't check if the download was successful; also, it will probably fail to install behind a proxy. Use it at your own risk!


Add the PPA and install Sublime Text 2 in Ubuntu


Before installing, please note that initially, Sublime Text 2 used "~/.Sublime Text 2" for the configuration files while the latest versions use "~/.config/sublime-text-2". Because of a bug with having 2 configuration folders, the deb will remove "~/.Sublime Text 2" so if you have some configuration files you want to keep in there, move them to "~/.config/sublime-text-2".

Add our Sublime Text 2 PPA and install it in Ubuntu using the following commands:
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text-2
I've set up the PPA for personal use but of course, anyone can use it. If you find any bugs, please report them in the comments below.

For what's new in the latest Sublime Text 2 builds, check out its homepage.
Sublime Text 2 Linux

Sublime Text 2 is a TextMate-like text editor currently in alpha which is now available for Linux too (as well as Windows and Mac OSX). The application is not free but its evaluation period does not expire.


Sublime Text 2 comes with a very interesting interface: a sidebar for projects or files and Chrome-style tabs as well as multi-pane editing which includes horizontal, vertical and even a quad pane mode:


Sublime Text 2 double pane


A very interesting feature is "Goto Anything": press Ctrl+P and type something - this will search in both filenames and lines of code across currently open files as well as recently close files. Start your search by using "#" to go to that word line, "@" for symbol or ":" for line:

Sublime Text 2 goto anything


The user interface also comes with a cool minimap which shows you an an overview of your files:

Sublime Text 2 minimap


Other features include macros, various find tools (find in files, find in open files, incremental find), easily switch between project, multiple selection, autocomplete and lots more. And of course, everything is customizable.


Since Sublime Text 2 is currently in alpha, some features are missing. These include distraction free editing, spell checker, bookmarks, a full python API and more - but all these will be coming in the next months.


Download Sublime Text 2 alpha for Linux, Windows and Mac OSX | To run it on Linux, simply extract the downloaded archive and double click the "sublime_text" file.

Update: Sublime Text 2 is now available in a PPA for Ubuntu!


REFERENCES
http://www.webupd8.org/2011/03/sublime-text-2-ubuntu-ppa.html
http://www.webupd8.org/2011/01/sublime-text-2-is-nice-textmade.html
http://www.mylinuxrig.com/post/18755288267/the-linux-setup-noah-lorang-37signals

Monday, March 5, 2012

In Mac OS X, how do I get the Mail application to remove messages I delete?

— SkyHi @ Monday, March 05, 2012
Warning: When mail is deleted from Mac OS X Mail, the messages go to the Trash folder as usual. However, messages deleted from that folder do not go to the Exchange retention area, and they are not recoverable. Additionally, mail that is hard-deleted viaOption-Delete skips the Trash folder and also does not go into the retention area.
For IMAP accounts, Mac OS X Mail has two methods of handling deleted messages: moving them to a designated deleted items folder or marking and hiding them in the message index.

Moving deleted messages to a folder

Note: For accounts accessed in Exchange mode, this is the only option.
To configure OS X Mail to move deleted messages to a folder:
  1. From the Mail menu, select Preferences... .
  2. In the preferences window, click Accounts.
  3. Click the name of the account for which you want to set a deleted messages folder.
  4. Click the Mailbox Behaviors tab, and in the "Trash" section, make sure that Move deleted messages to the Trash mailbox and Store deleted messages on the server are checked.
  5. In the pop-up menu underneath "Permanently erase deleted messages when:", select how often Mail will empty your deleted mail folder.
  6. Close the preferences window and click Save if prompted.
  7. Back in the mail viewer window, look for your list of folders. If you don't see it, from the View menu, select View Mailbox List or View Mailboxes. Click the folder you want to use as a deleted messages folder. From the Mailbox menu, select Use This Mailbox For or Use Selected Mailbox For and then choose Trash.
If you want to manually empty your deleted mail folder, from the Mailbox menu, select Erase Deleted Items or Erase Deleted Messages.

Hiding deleted messages within the same mailbox

To configure OS X Mail to hide deleted messages within the same mailbox:
  1. From the Mail menu, select Preferences... .
  2. In the Mail preferences window, click Accounts.
  3. Select the account you wish to modify.
  4. Click the Mailbox Behaviors tab and uncheck Move deleted messages to the Trash mailbox.
Once you have made these changes, when you delete a message, Mail assigns a flag that removes it from the message index. It's still there, just not visible. To show all the messages you have deleted since you last compacted your mailbox, press Command-l(the letter l). To hide the deleted messages again, press Command-l .

Removing deleted messages

To completely remove those messages you have deleted, from the Mailbox menu, select Erase Deleted Items or Erase Deleted Messages. You can configure Mail to automatically compact your IMAP mailboxes when you exit the program by making the following configuration change:
  1. From the Mail menu, select Preferences... .
  2. In the Mail preferences window, select Accounts.
  3. Select the account you want to modify.Note: If you have multiple accounts, you will need to make these changes for each one.
  4. Click the Advanced tab, and check Compact mailboxes automatically.
  5. Close the Mail preferences window, and when prompted, click Save.
REFERENCES

Removing an email account in Mail (Mac OS X v10.5 or later)

— SkyHi @ Monday, March 05, 2012
You may want to remove an email account from Mail, for example if you no longer use the account.
Important: Removing an account will permanently delete its mailboxes, messages, notes, and to do items. If you want to keep those, be sure to copy them to an On My Mac mailbox before deleting the account.
Exchange, IMAP, and MobileMe accounts store their mailboxes and messages on the server; deleting these account types in Mail will not permanently delete messages from the server. However, if you are not completely certain that your account is one of those types, be sure to copy the mailboxes and messages you want to keep into an On My Mac mailbox, or save individual messages manually by selecting them and choosing Save As from the File menu.
To remove an email account in Mail:
1) Open Mail (click it on the Dock or open it from the Applications folder).
2) From the Mail menu, choose Preferences..., or press Command-, (the Command and comma keys).

Screen shot 2010-05-07 at 5.01.42 AM.png
3) Click the "Accounts" icon.
4) Select the account you wish to remove.
Screen shot 2010-05-07 at 5.03.30 AM.png
5) Click the "-" (minus) icon. You will be alerted that "The account's setup information, mailboxes, messages, notes, and to do's will be deleted permanently from your computer."
6) If you are sure you want to remove the account and email messages from your computer, click "Remove" to complete this process.

Screen shot 2010-05-07 at 5.07.22 AM.png




REFERENCES
http://www.askdrtech.com/solutions/post/Removing-an-email-account-in-Mail-(Mac-OS-X-v105-or-later).aspx

Thursday, March 1, 2012

Howto: Performance Benchmarks a Webserver Howto

— SkyHi @ Thursday, March 01, 2012
You can benchmark Apache, IIS and other web server with apache benchmarking tool called ab. Recently I was asked to performance benchmarks for different web servers.
It is true that benchmarking a web server is not an easy task. From how to benchmark a webserver:
First, benchmarking a web server is not an easy thing. To benchmark a web server the time it will take to give a page is not important: you don't care if a user can have his page in 0.1 ms or in 0.05 ms as nobody can have such delays on the Internet.
What is important is the average time it will take when you have a maximum number of users on your site simultaneously. Another important thing is how much more time it will take when there are 2 times more users: a server that take 2 times more for 2 times more users is better than another that take 4 times more for the same amount of users."
Here are few tips to carry out procedure along with an example:

Apache Benchmark Procedures

  • You need to use same hardware configuration and kernel (OS) for all tests
  • You need to use same network configuration. For example, use 100Mbps port for all tests
  • First record server load using top or uptime command
  • Take at least 3-5 readings and use the best result
  • After each test reboot the server and carry out test on next configuration (web server)
  • Again record server load using top or uptime command
  • Carry on test using static html/php files and dynamic pages
  • It also important to carry out test using the Non-KeepAlive and KeepAlive (the Keep-Alive extension to provide long-lived HTTP sessions, which allow multiple requests to be sent over the same TCP connection) features
  • Also don't forget to carry out test using fast-cgi and/or perl tests

Webserver Benchmark Examples:

Let us see how to benchmark a Apache 2.2 and lighttpd 1.4.xx web server.

Static Non-KeepAlive test for Apache web server

i) Note down server load using uptime command
$ uptime
ii) Create a static (small) html page as follows (snkpage.html) (assuming that server IP is 202.54.200.1) in /var/www/html (or use your own webroot):
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


Webserver test


This is a webserver test page.


 
Login to Linux/bsd desktop computer and type following command:
$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html
Where,
  • -n 1000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session
  • -c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a time to server 202.54.200.1
For example if you want to send 10 request, type following command:
$ ab -n 10 -c 2 http://www.somewhere.com/
Output:
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.cyberciti.biz (be patient).....done
Server Software:
Server Hostname:        www.somewhere.com
Server Port:            80
Document Path:          /
Document Length:        16289 bytes
Concurrency Level:      1
Time taken for tests:   16.885975 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      166570 bytes
HTML transferred:       162890 bytes
Requests per second:    0.59 [#/sec] (mean)
Time per request:       1688.597 [ms] (mean)
Time per request:       1688.597 [ms] (mean, across all concurrent requests)
Transfer rate:          9.59 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      353  375  16.1    386     391
Processing:  1240 1312  52.1   1339    1369
Waiting:      449  472  16.2    476     499
Total:       1593 1687  67.7   1730    1756
Percentage of the requests served within a certain time (ms)
  50%   1730
  66%   1733
  75%   1741
  80%   1753
  90%   1756
  95%   1756
  98%   1756
  99%   1756
 100%   1756 (longest request)
Repeat above command 3-5 times and save the best reading.

Static Non-KeepAlive test for lighttpd web server

First, reboot the server:
# reboot
Stop Apache web server. Now configure lighttpd and copy /var/www/html/snkpage.html to lighttpd webroot and run the command (from other linux/bsd system):
$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html
c) Plot graph using Spreadsheet or gnuplot.

How do I carry out Web server Static KeepAlive test?

Use -k option that enables the HTTP KeepAlive feature using ab test tool. For example:
$ ab -k -n 1000 -c 5 http://202.54.200.1/snkpage.html
Use the above procedure to create php, fast-cgi and dynmic pages to benchmarking the web server.
Please note that 1000 request is a small number you need to send bigger (i.e. the hits you want to test) requests, for example following command will send 50000 requests :
$ ab -k -n 50000 -c 2 http://202.54.200.1/snkpage.html

How do I save result as a Comma separated value?

Use -e option that allows to write a comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests:
$ ab -k -n 50000 -c 2 -e apache2r1.cvs http://202.54.200.1/snkpage.html

How do I import result into excel or gnuplot programs so that I can create graphs?

Use above command or -g option as follows:
$ ab -k -n 50000 -c 2 -g apache2r3.txt http://202.54.200.1/snkpage.html
Put following files in your webroot (/var/www/html or /var/www/cgi-bin) directory. Use ab command.

Sample test.php file

#!/usr/bin/perl
$command=`perl -v`;
$title = "Perl Version";
 
print "Content-type: text/html\n\n";
print "$title\n\n\n";
 
print "

$title

  \n"
; print $command;   print "\n\n";  
Run ab command as follows:
$ ab -n 3000 -c 5 http://202.54.200.1/cgi-bin/test.pl

Sample psql.php (php+mysql) file

Php+MySQL


   $link = mysql_connect("localhost", "USERNAME", "PASSWORD");
   mysql_select_db("DATABASE");
 
   $query = "SELECT * FROM TABLENAME";
   $result = mysql_query($query);
 
   while ($line = mysql_fetch_array($result))
   {
      foreach ($line as $value)
       {
         print "$value\n";
      }
   }
 
    mysql_close($link);
?>


 
Run ab command as follows:
$ ab -n 1000 -c 5 http://202.54.200.1/psql.php

Featured Articles:



Here is a way to let ab produce a CSV file that covers a range of concurrencies (like 0-1,000), saving you the hurdle of running ab 1,000 times (and merging results).
It has been used to benchmark Apache, IIS 5.1 and 7.0, Nginx, Cherokee, Rock and TrustLeap G-WAN, see:
You just have then to import the CSV file into Open Office to generate Charts!



REFERENCES
http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html

What is DomainKeys?

— SkyHi @ Thursday, March 01, 2012
DomainKeys is an email authentication technology developed by Yahoo, and is primarily used as an additional anti-spam and anti-phishing method.

How DomainKeys works
  • Sending emails
    • The domain owner generates a public / private key pair to use for signing all outgoing messages (multiple key pairs are allowed). The public key is published in DNS, and the private key is made available to their DomainKey-enabled outbound email servers.
    • When each email is sent by an account within the domain, the DomainKey-enabled email server automatically uses the stored private key to generate a digital signature of the message. This signature is embedded as a header in the sent email, and the email is sent on to the target recipient's mail server.
  • Receiving emails
    • The DomainKeys-enabled receiving email server extracts the signature and claimed From: domain from the email headers and fetches the public key from DNS for the claimed From: domain.
    • The public key from DNS is then used by the receiving mail server to verify that the signature was generated by the matching private key. This proves that the email was indeed sent by, and with the permission of, the claimed sending From: domain and that its headers and content weren't altered during the transfer.
    • The receiving email server applies the local policies based on the results of the signature test. If the domain is verified and no other antispam tests catch it, the email can be delivered to the user's inbox. If the signature fails to verify, or there isn't one, the email can be dropped, flagged or quarantined.
How to check your mail server uses this technology correctly
Send an email to the following randomly generated email address:GOJCCCFFNKTQNHCAJQPH@dk.mailradar.com Once you have sent your message, click the "View Results" button below to see your message results. Please note that it may take a few minutes to receive the message.
 
 


REFERENCES
http://www.mailradar.com/domainkeys/

What is a glue record?

— SkyHi @ Thursday, March 01, 2012
A glue record in simplest terms is an IP address that is "glued" to a specific domain or subdomain in the registry. Glue records are most commonly needed for users that are trying to use name server addresses that are subdomains of the domain itself. To explain a little further: 

John has a domain registered named domain.com. John wants to set up his own name servers (DNS) using the addresses ns1.domain.com and ns2.domain.com. The problem with this is that because of the way that DNS works, every time someone tries to access domain.com, they will have to check with one of the subdomains (ns1.domain.com or ns2.domain.com) for the address which are both "under" the domain. Since you can't get to a subdomain before getting to the domain, and the domain is what we are looking for in the first place, we seem to be stuck. Let's personify the process for finding the correct address for a domain in the DNS lookup process:


Q: "I am trying to find domain.com. What is the IP address for the website domain.com?"
A: "I do not have the address. Check the name server for domain.com. You will find the address there."
Q: "Okay. What is the name server for domain.com?"
A: "ns1.domain.com"
Q: "Okay. What is the address for ns1.domain.com so I can check there?"
A: "I do not have the address. ns1.domain.com is a subdomain of domain.com. So check the name server for domain.com."
Q: "Okay.... What is the name server for domain.com?"
A: "ns1.domain.com"
Q: "You just said that. So you know the name of the name server but don't have the address?"
A: "Yes, only the name server has the address of the name server!"
Q: "So if only the name server knows the address for the name server, how am I supposed to get the address?!"   


The solution to this is to set up a glue record. A glue record will glue the IP address to the domain/subdomain so that the process is a bit more like:



Q: "I am trying to find domain.com. What is the IP address for the website domain.com?"
A: "I do not have the address. Check the name server for domain.com. You will find the address there."
Q: "Okay. What is the name server for domain.com?"
A: "ns1.domain.com(127.0.0.1)"   



This time the name came with an address since they were "glued" together! Now that's helpful!




This process may seem very technical but setting up a glue record in the 1&1 Control Panel is actually quite easy and may have already happened without you even knowing it. Any time a subdomain is created with "ns" at the beginning, a glue record is automatically created for this subdomain. Follow the next steps to get a better understanding:

Step 1:

Log in to the 1&1 Control Panel using your Customer ID OR domain name and your password

If you have only one package, you will land on the Administration page. If you have more than one package, select the package in question to reach its Administration page.

selectLinux.png
Step 2:

Click the Domains link from the Domains & Webspace panel.

selectDomains.png
Step 3:

Click the down arrow button next to New and select Create Subdomain.

newSubdomain1.png
Step 4:

Enter a subdomain that starts with "ns" such as ns1, ns2, etc. and select the appropriate domain from the drop-down box.
Click the OK button when finished to create the subdomain.

newSubdomain2.png
Step 5:

The subdomain should be set up within the next 15 minutes or so. The glue record will be applied to the subdomain since it starts with "ns" however since the glue record is a DNS record, it may take 24-48 hours until fully updated and recognized by all servers/computers on the Internet.

You must have at least two name server addresses. Repeat this process to create another subdomain that starts with "ns" such as ns2.

If you need to change the IP address that the subdomain points to, please reference How do I edit/change a domain's IP Address (A record)?


REFERENCE
http://faq.1and1.co.uk/domains/domain_admin/dns_settings/3.html