Tuesday, May 18, 2010

SED-insert text at the top and bottom of a file using sed?

— SkyHi @ Tuesday, May 18, 2010
From the command line use
(Note that these must be completed on separate lines.)
This will insert on the first line of the file.

sed '1i\
your text goes here' file_name > new_filename


This will append on the last line of the file.
sed '$a\
your text goes here' file_name > new_filename


Note also that with sed you have to direct the output and rename the file back. So 'mv new_filename file_name' when you are done with these commands.

REFERENCES
http://www.unix.com/shell-programming-scripting/6744-sed-insert-text-top-file.html



Problem 1:

I get the error:
sed: command garbled: 1iEXEC PR_DbConfigStart 'test.txt', '10', 'DESCRIPTION'

when I try this.

Here is the script im using

#!/usr/bin/ksh
FILENAME=test2.txt
TMP=.$TMP
TMPFILENAME=$FILENAME$TMP
sed -e "1i\
EXEC PR_DbConfigStart 'some text', '10', 'DESCRIPTION' " < $FILENAME >$TMPFILENAME

=======Perderabo
You need a second backslash:
sed -e "1i\\




Problem 2:

What about for the statement that appends data to the end of the file?

sed "$a\\
PR_DbConfigEnd $FILENAME " <$FILENAME >$TMPFILENAME

I get the error message:

sed: command garbled: \


If I remove the second backslash:

sed "$a\
PR_DbConfigEnd $FILENAME " <$FILENAME >$TMPFILENAME


I get this error message:

sed: command garbled: PR_DbConfigEnd test2.txt


=======Perderabo
#! /usr/bin/ksh
FILENAME=input_file
NEWFILENAME=output_file
sed -e "\$a\\
PR_DbConfigEnd ${FILENAME}" < $FILENAME > $NEWFILENAME
exit 0


Inside single quotes, what you see is what you get. No character has any special meaning inside single quotes. So variables won't expand. A string like:
'$a'
will just be $a. The shell will not try to substitute the value of a variable called a. So in the line:
sed '$a\
we get exactly what we ask for. Inside single quotes, even the backslash is just another character. (And, btw, this means that there is no way to get a single quote inside single quotes...so 'you can't do that' won't work and there is no way to fix it with backslashes.)

When you want to use a variable inside single quotes, it won't work:
'something $var something'
isn't going to do it. So we must break that single quoted string into two single quoted string and put the variable between them:
'something '$var' something'
is actually good enough, but most folks will add {} whenever a variable touches non-blanks, not just other letters:
'something '${var}' something'

And finally, if the value of var has a string of blanks, we would need to protect them, so we would need single quotes around the variable:
'something '"${var}"' something'
And this get us to the syntax that you used. Your first single quoted string started on one line and finished on the next but otherwise it's pretty much what we have here.

How To Add a Line into the middle of a Text File

— SkyHi @ Tuesday, May 18, 2010

Here is a quick tip on how to use sed to add a line into the middle of a text file from the command line, without opening it.


To clarify, let’s say you have a text file that has four lines:



Line1Text

Line2Text

Line3Text

Line4Text


Using sed, you can append a line anywhere you want with a simple command without even knowing the line numbers.


Add a Line into the Middle of a Text File


For this example, lets say we want to append a new line under Line3Text:



# sed '/^Line3Text/a NewLineText' textFile > newFile


You’ll notice that we output the results to a newFile so that we can make sure the new line appended correctly before overwriting the original file. If you check the newFile, you should see a correct output, then you can overwrite the original textFile.



# mv newFile textFile

REFERENCES
http://www.foogazi.com/2008/06/24/quickzi-how-to-add-a-line-into-the-middle-of-a-text-file/



ADD Text to the End of file

#!/bin/bash
for File in `find . -iname "*.php"`
do
echo "Append your stuff here" >> $File
done


If -e is in effect, the following sequences are recognized:

\0NNN the character whose ASCII code is NNN (octal)

\\ backslash

\a alert (BEL)

\b backspace

\c suppress trailing newline

\f form feed

\n new line

\r carriage return

\t horizontal tab

\v vertical tab


REFERENCES
http://forums.fedoraforum.org/showthread.php?t=225470


Monday, May 17, 2010

Redhat / CentOS Install Memcached Caching System

— SkyHi @ Monday, May 17, 2010

How do I install memcached a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load under CentOS / RHEL / Fedora / Redhat Linux?

Memcached is very fast caching system for MySQL. It uses libevent or epoll (Linux runtime) to scale to any number of open connections and uses non-blocking network I/O.

Required Packages

  1. memcached : High Performance, Distributed Memory Object Cache.
  2. memcached-selinux : SELinux policy module supporting memcached.
  3. perl-Cache-Memcached : Perl client for memcached.
  4. php-pecl-memcache : Php client / extension to work with the Memcached caching daemon.
  5. python-memcached : A Python memcached client library.

Step # 1: Turn on EPEL Repo

Type the following command to enable EPEL repo which carries required memcache packages.
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
See this FAQ for further details.

Step # 2: Install memcached

Type the following command to install memcached with php extension:
# yum install memcached php-pecl-memcache memcached-selinux
Sample outputs:

Loaded plugins: downloadonly, rhnplugin, security, verify
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package memcached.x86_64 0:1.2.8-1.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Installing:
memcached x86_64 1.2.8-1.el5 epel 60 k

Transaction Summary
==============================================================================================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 60 k
Is this ok [y/N]: y
Downloading Packages:
memcached-1.2.8-1.el5.x86_64.rpm | 60 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : memcached 1/1

Installed:
memcached.x86_64 0:1.2.8-1.el5

Complete!

Step # 3: Configure memcached

Edit /etc/sysconfig/memcached, enter:
# vi /etc/sysconfig/memcached
Update it as follows:

PORT="11211"
USER="memcached"
# max connection 2048
MAXCONN="2048"
# set ram size to 2048 - 2GiB
CACHESIZE="4096"
# listen to loopback ip 127.0.0.1, for network connection use real ip e.g., 10.0.0.4
OPTIONS="-l 127.0.0.1"

The above will starts memcached up as a daemon, using 4GB of memory, and listening on IP 127.0.0.1, port 11211. Save and close the file.

Step # 4: Run memcached

Type the following command to start memcached, enter:
# chkconfig memcached on
# service memcached start

To stop / restart use the following commands:
# service memcached stop
# service memcached restart

How Do I See Memory Memcached Slabs?

Type the following command:
# memcached-tool IP_ADDRESS:Port
# memcached-tool IP_ADDRESS:Port display
# memcached-tool 127.0.0.1:11211

Sample outputs:

  #  Item_Size   Max_age  1MB_pages Count   Full?
1 104 B 5134 s 1 10 no
2 136 B 5135 s 1 40 no
3 176 B 0 s 1 0 no
4 224 B 2648 s 1 7 no
8 552 B 1810 s 1 12 no
9 696 B 1810 s 1 6 no
10 872 B 2935 s 1 8 no
11 1.1 kB 4262 s 1 18 no
12 1.3 kB 2990 s 1 23 no
13 1.7 kB 2434 s 1 22 no
14 2.1 kB 3489 s 1 11 no
15 2.6 kB 2964 s 1 16 no
16 3.3 kB 2861 s 1 14 no
17 4.1 kB 2076 s 1 5 no
18 5.2 kB 2981 s 1 5 no
20 8.1 kB 64 s 1 1 no
21 10.1 kB 1865 s 1 3 no
29 60.2 kB 1550 s 1 2 no

How Do I See Memory Memcached Stats?

Type the following command:
# memcached-tool IP_Address:Port stats
# memcached-tool 127.0.0.1:11211 stats

Sample outputs:

#127.0.0.1:11211   Field       Value
accepting_conns 1
bytes 399395
bytes_read 504797
bytes_written 17313658
cmd_flush 0
cmd_get 1141
cmd_set 248
connection_structures 9
curr_connections 5
curr_items 205
evictions 0
get_hits 898
get_misses 243
limit_maxbytes 1073741824
listen_disabled_num 0
pid 40159
pointer_size 64
rusage_system 0.227965
rusage_user 0.034994
threads 5
time 1255803547
total_connections 344
total_items 259
uptime 5829
version 1.2.8

Further readings:


REFERENCE
http://www.cyberciti.biz/faq/rhel-fedora-linux-install-memcached-caching-system-rpm/

up and running with Cassandra

— SkyHi @ Monday, May 17, 2010
Cassandra is a hybrid non-relational database in the same class as Google’s BigTable. It is more featureful than a key/value store like Dynomite, but supports fewer query types than a document store like MongoDB.
Cassandra was started by Facebook and later transferred to the open-source community. It is an ideal runtime database for web-scale domains like social networks.
This post is both a tutorial and a “getting started” overview. You will learn about Cassandra’s features, data model, API, and operational requirements—everything you need to know to deploy a Cassandra-backed service.
Jan 8, 2010: post updated for Cassandra gem 0.7 and Cassandra version 0.5.

features

There are a number of reasons to choose Cassandra for your website. Compared to other databases, three big features stand out:
  • Flexible schema: with Cassandra, like a document store, you don’t have to decide what fields you need in your records ahead of time. You can add and remove arbitrary fields on the fly. This is an incredible productivity boost, especially in large deployments.
  • True scalability: Cassandra scales horizontally in the purest sense. To add more capacity to a cluster, turn on another machine. You don’t have restart any processes, change your application queries, or manually relocate any data.
  • Multi-datacenter awareness: you can adjust your node layout to ensure that if one datacenter burns in a fire, an alternative datacenter will have at least one full copy of every record.
Some other features that help put Cassandra above the competition :
  • Range queries: unlike most key/value stores, you can query for ordered ranges of keys.
  • List datastructures: super columns add a 5th dimension to the hybrid model, turning columns into lists. This is very handy for things like per-user indexes.
  • Distributed writes: you can read and write any data to anywhere in the cluster at any time. There is never any single point of failure.

installation

You need a Unix system. If you are using Mac OS 10.5, all you need is Git. Otherwise, you need to install Java 1.6, Git 1.6, Ruby, and Rubygems in some reasonable way.
Start a terminal and run:
sudo gem install cassandra
If you are using Mac OS, you need to export the following environment variables:
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
export PATH="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin:$PATH"
Now you can build and start a test server with cassandra_helper:
cassandra_helper cassandra
It runs!

live demo

The above script boots the server with a schema that we can interact with. Open another terminal window and start irb, the Ruby shell:
irb
In the irb prompt, require the library:
require 'rubygems'
require 'cassandra'
include Cassandra::Constants
Now instantiate a client object:
twitter = Cassandra.new('Twitter')
Let’s insert a few things:
user = {'screen_name' => 'buttonscat'}
twitter.insert(:Users, '5', user) 

tweet1 = {'text' => 'Nom nom nom nom nom.', 'user_id' => '5'}
twitter.insert(:Statuses, '1', tweet1)

tweet2 = {'text' => '@evan Zzzz....', 'user_id' => '5', 'reply_to_id' => '8'}
twitter.insert(:Statuses, '2', tweet2)
Notice that the two status records do not have all the same columns. Let’s go ahead and connect them to our user record:
twitter.insert(:UserRelationships, '5', {'user_timeline' => {UUID.new => '1'}})
twitter.insert(:UserRelationships, '5', {'user_timeline' => {UUID.new => '2'}})
The UUID.new call creates a collation key based on the current time; our tweet ids are stored in the values.
Now we can query our user’s tweets:
timeline = twitter.get(:UserRelationships, '5', 'user_timeline', :reversed => true)
timeline.map { |time, id| twitter.get(:Statuses, id, 'text') }
# => ["@evan Zzzz....", "Nom nom nom nom nom."]
Two tweet bodies, returned in recency order—not bad at all. In a similar fashion, each time a user tweets, we could loop through their followers and insert the status key into their follower’s home_timeline relationship, for handling general status delivery.

the data model

Cassandra is best thought of as a 4 or 5 dimensional hash. The usual way to refer to a piece of data is as follows: a keyspace, a column family, a key, an optional super column, and a column. At the end of that chain lies a single, lonely value.
Let’s break down what these layers mean.
  • Keyspace (also confusingly called “table”): the outer-most level of organization. This is usually the name of the application. For example, 'Twitter' and 'Wordpress' are both good keyspaces. Keyspaces must be defined at startup in the storage-conf.xml file.
  • Column family: a slice of data corresponding to a particular key. Each column family is stored in a separate file on disk, so it can be useful to put frequently accessed data in one column family, and rarely accessed data in another. Some good column family names might be :P osts, :Users and :UserAudits. Column families must be defined at startup.
  • Key: the permanent name of the record. You can query over ranges of keys in a column family, like :start => '10050', :finish => '10070'—this is the only index Cassandra provides for free. Keys are defined on the fly.
After the column family level, the organization can diverge—this is a feature unique to Cassandra. You can choose either:
  • A column: this is a tuple with a name and a value. Good columns might be 'screen_name' => 'lisa4718' or 'Google' => 'http://google.com'.It is common to not specify a particular column name when requesting a key; the response will then be an ordered hash of all columns. For example, querying for (:Users, '174927') might return:
    {'name' => 'Lisa Jones',
    'gender' => 'f',
    'screen_name' => 'lisa4718'}
    In this case, name, gender, and screen_name are all column names. Columns are defined on the fly, and different records can have different sets of column names, even in the same keyspace and column family. This lets you use the column name itself as either structure or data. Columns can be stored in recency order, or alphabetical by name, and all columns keep a timestamp.
  • A super column: this is a named list. It contains standard columns, stored in recency order.Say Lisa Jones has bookmarks in several categories. Querying (:UserBookmarks, '174927') might return:
    {'work' => {
       'Google' => 'http://google.com',
       'IBM' => 'http://ibm.com'},
    'todo': {...},
    'cooking': {...}}
    Here, work, todo, and cooking are all super column names. They are defined on the fly, and there can be any number of them per row. :UserBookmarks is the name of the super column family. Super columns are stored in alphabetical order, with their sub columns physically adjacent on the disk.
Super columns and standard columns cannot be mixed at the same (4th) level of dimensionality. You must define at startup which column families contain standard columns, and which contain super columns with standard columns inside them.
Super columns are a great way to store one-to-many indexes to other records: make the sub column names TimeUUIDs (or whatever you’d like to use to sort the index), and have the values be the foreign key. We saw an example of this strategy in the demo, above.
If this is confusing, don’t worry. We’ll now look at two example schemas in depth.

twitter schema

Here is the schema definition we used for the demo, above. It is based on Eric Florenzano’s Twissandra:

 
 
    CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" />
 
    CompareSubcolumnsWith="TimeUUIDType" ColumnType="Super" />
What could be in StatusRelationships? Maybe a list of users who favorited the tweet? Having a super column family for both record types lets us index each direction of whatever many-to-many relationships we come up with.
Here’s how the data is organized:
Click to enlarge
Cassandra lets you distribute the keys across the cluster either randomly, or in order, via the Partitioner option in the storage-conf.xml file.
For the Twitter application, if we were using the order-preserving partitioner, all recent statuses would be stored on the same node. This would cause hotspots. Instead, we should use the random partitioner.
Alternatively, we could preface the status keys with the user key, which has less temporal locality. If we used user_id:status_id as the status key, we could do range queries on the user fragment to get tweets-by-user, avoiding the need for a user_timeline super column.

multi-blog schema

Here’s a another schema, suggested to me by Jonathan Ellis, the primary Cassandra maintainer. It’s for a multi-tenancy blog platform:

 
 
Imagine we have a blog named ‘The Cutest Kittens’. We will insert a row when the first post is made as follows:
require 'rubygems'
require 'cassandra'
include Cassandra::Constants

multiblog = Cassandra.new('Multiblog')

multiblog.insert(:Blogs, 'The Cutest Kittens',
 { UUID.new =>
   '{"title":"Say Hello to Buttons Cat","body":"Buttons is a cute cat."}' })
UUID.new generates a unique, sortable column name, and the JSON hash contains the post details. Let’s insert another:
multiblog.insert(:Blogs, 'The Cutest Kittens',
 { UUID.new =>
   '{"title":"Introducing Commie Cat","body":"Commie is also a cute cat"}' })
Now we can find the latest post with the following query:
post = multiblog.get(:Blogs, 'The Cutest Kittens', :reversed => true).to_a.first
On our website, we can build links based on the readable representation of the UUID:
guid = post.first.to_guid
# => "b06e80b0-8c61-11de-8287-c1fa647fd821"
If the user clicks this string in a permalink, our app can find the post directly via:
multiblog.get(:Blogs, 'The Cutest Kittens', :start => UUID.new(guid), :count => 1)
For comments, we’ll use the post UUID as the outermost key:
multiblog.insert(:Comments, guid,
 {UUID.new => 'I like this cat. - Evan'})
multiblog.insert(:Comments, guid,
 {UUID.new => 'I am cuter. - Buttons'})
Now we can get all comments (oldest first) for a post by calling:
multiblog.get(:Comments, guid)
We could paginate them by passing :start with a UUID. See this presentation to learn more about token-based pagination.
We have sidestepped two problems with this data model: we don’t have to maintain separate indexes for any lookups, and the posts and comments are stored in separate files, where they don’t cause as much write contention. Note that we didn’t need to use any super columns, either.

storage layout and api comparison

The storage strategy for Cassandra’s standard model is the same as BigTable’s. Here’s a comparison chart:

multi-file per-file intra-file
Relational server database table* primary key column value

BigTable cluster table column family key column name column value
Cassandra, standard model cluster keyspace column family key column name column value
Cassandra, super column model cluster keyspace column family key super column name column name column value
* With fixed column names.
Column families are stored in column-major order, which is why people call BigTable a column-oriented database. This is not the same as a column-oriented OLAP database like Sybase IQ—it depends on what you use the column names for.
Click to enlarge
In row-orientation, the column names are the structure, and you think of the column families as containing keys. This is the convention in relational databases.
Click to enlarge
In column-orientation, the column names are the data, and the column families are the structure. You think of the key as containing the column family, which is the convention in BigTable. (In Cassandra, super columns are also stored in column-major order—all the sub columns are together.)
In Cassandra’s Ruby API, parameters are expressed in storage order, for clarity:
Relational SELECT `column` FROM `database`.`table` WHERE `id` = key;
BigTable table.get(key, "column_family:column")
Cassandra: standard model keyspace.get("column_family", key, "column")
Cassandra: super column model keyspace.get("column_family", key, "super_column", "column")
Note that Cassandra’s internal Thrift interface mimics BigTable in some ways, but this is being changed.

going to production

Cassandra is an alpha product and could, theoretically, lose your data. In particular, if you change the schema specified in the storage-conf.xml file, you must follow these instructions carefully, or corruption will occur (this is going to be fixed). Also, the on-disk storage format is expected to change in version 0.4.0. After that things will be a bit more stable.
The biggest deployment is at Facebook, where hundreds of terabytes of token indexes are kept in about a hundred Cassandra nodes. However, their use case allows the data to be rebuilt if something goes wrong. Currently there are no known deployments of non-transient data. Proceed carefully, keep a backup in an unrelated storage engine…and submit patches if things go wrong.
That aside, here is a guide for deploying a production cluster:
  • Hardware: get a handful of commodity Linux servers. 16GB memory is good; Cassandra likes a big filesystem buffer. You don’t need RAID. If you put the commitlog file and the data files on separate physical disks, things will go faster. Don’t use EC2 or friends except for testing; the virtualized I/O is too slow.
  • Configuration: in the storage-conf.xml schema file, set the replication factor to 3. List the IP address of one of the nodes as the seed. Set the listen address to the empty string, so the hosts will resolve their own IPs. Now, adjust the contents of cassandra.in.sh for your various paths and JVM options—for a 16GB node, set the JVM heap to 4GB.
  • Deployment: build a package of Cassandra itself and your configuration files, and deliver it to all your servers (I use Capistrano for this). Start the servers by setting CASSANDRA_INCLUDE in the environment to point to your cassandra.in.sh file, and run bin/cassandra. At this point, you should see join notices in the Cassandra logs:
    Cassandra starting up...
    Node 10.224.17.13:7001 has now joined.
    Node 10.224.17.14:7001 has now joined.
    Congratulations! You have a cluster. Don’t forget to turn off debug logging in the log4j.properties file.
  • Visibility: you can get a little more information about your cluster via the tool bin/nodeprobe, included:
    $ bin/nodeprobe --host 10.224.17.13 ring
    Token(124007023942663924846758258675932114665)  3 10.224.17.13  |<--|
    Token(106858063638814585506848525974047690568)  3 10.224.17.19  |   ^
    Token(141130545721235451315477340120224986045)  3 10.224.17.14  |-->|
    Cassandra also exposes various statistics over JMX.
Note that your client machines (not servers!) must have accurate clocks for Cassandra to resolve write conflicts properly. Use NTP.

conclusion

There is a misperception that if someone advocates a non-relational database, they either don’t understand SQL optimization, or they are generally a hater. This is not the case.
It is reasonable to seek a new tool for a new problem, and database problems have changed with the rise of web-scale distributed systems. This does not mean that SQL as a general-purpose runtime and reporting tool is going away. However, at web-scale, it is more flexible to separate the concerns. Runtime object lookups can be handled by a low-latency, strict, self-managed system like Cassandra. Asynchronous analytics and reporting can be handled by a high-latency, flexible, un-managed system like Hadoop. And in neither case does SQL lend itself to sharding.
I think that Cassandra is the most promising current implementation of a runtime distributed database, but much work remains to be done. We’re beginning to use Cassandra at Twitter, and here’s what I would like to happen real-soon-now:
  • Interface cleanup: the Thrift API for Cassandra is incomplete and inconsistent, which makes writing clients very irritating.
    Done!
  • Online migrations: restarting the cluster 3 times to add a column family is silly.
  • ActiveModel or DataMapper adapter: for interaction with business objects in Ruby.
    Done! Michael Koziarski on the Rails core team wrote an ActiveModel adapter.
  • Scala client: for interoperability with JVM middleware.
Go ahead and jump on any of those projects—it’s a chance to get in on the ground floor.
Cassandra has excellent performance. There some benchmark results for version 0.5 at the end of the Yahoo performance study.

further resources

Reference(cited):
http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/
http://www.facebook.com/note.php?note_id=24413138919&id=9445547199&index=9
http://nosql.mypopescu.com/post/407159447/cassandra-twitter-an-interview-with-ryan-king
http://highscalability.com/blog/2010/2/26/mysql-and-memcached-end-of-an-era.html
http://project-voldemort.com/
http://www.linux-mag.com/cache/7496/1.html
http://en.wikipedia.org/wiki/Redis_(data_store)
http://en.wikipedia.org/wiki/Cassandra_(database)
http://en.wikipedia.org/wiki/BigTable

Remote desktop connection cannot verify the identity of the computer

— SkyHi @ Monday, May 17, 2010
If you get the following error: "Remote desktop connection cannot verify the identity of the computer that
you want to connect to. try reconnecting to the windows-based computer or
contatct your administrator."

when trying to connect OS X to a Windows Machine via RDP then do the following:

1) Delete all files in /user/{username}/Documents/RDC Connections
2) Don't fill in the domain text box

for some reason when using the Mac client if the domain text box is filled then the Windows machine at the other end can't authenticate the connection. Seems to be worse with Vista, but I have read of this happening with 2003 also.

REFERENCES
http://softwarex-nz.blogspot.com/2008/12/remote-desktop-connection-cannot-verify.html

ntpdate - no server suitable for synchronization found

— SkyHi @ Monday, May 17, 2010

Fresh installation of ntp v4 on redhat 8.


Ntpd and ntpdate will not communicate with any ntp server, giving a "no server suitable for synchronization found" message.


However, doing ntpdate -d 193.2.69.11 (for instance) works fine.


It turns out I need to use an unprivileged port with the -u option. The -d option automatically does this. So this will work:

ntpdate -u 193.2.69.11


Somewhere in my setup here port 123 is a problem. But no matter, just run ntpdate from crontab once a day (rather than ntpd) and all will be well.


REFERENCES
http://www.stephensykes.com/blog_perm.html?34

Sunday, May 16, 2010

Securing your URL with Hexadecimal codes

— SkyHi @ Sunday, May 16, 2010

Hexadecimal equivalent codes of ASCII characters can be used to represent characters of a URL’s path and filename.


Each hex number is preceded by a “%” symbol to identify the following two numbers/letters as a hexadecimal representation of the character


An ASCII chart can be used for the conversion from ASCII to Hex or vice versa


One good source for ASCII to Hex charts is http://en.wikipedia.org/wiki/ASCII (both the tables below have been taken from this URL)


 



 



 


The need for typing in Hex codes into a URL is to make it possible to include special characters in a URL which would otherwise be wrongly interpreted or not allowed. A good example is SPACE which would not be able to fit into a URL in its original form and hence is represented by the Hex code 20 (prefixed by % in a URL making it %20)


 


For example, if we were to visit the URL www.bing.com , it could be written as


 


B =  %42


I = %49


N = %4e


G = %47


 


Hence, www.bing.com could be written as www.%42%49%4e%47.com


 


Note: The “slashes” in the address cannot be represented in hex; nor can the IP address be rendered using this logic (the %XX way) but the rest of the URL can be manipulated



REFERENCES

http://www.zerointellect.com/security/securing-your-url-with-hexadecimal-codes/comment-page-1/