Is been like ages since i blogged. Is been crazy for me since i got back to Ghana, land of my birth. but i am finally in control and want to start blogging seriously. expect more now.
November 16, 2009
September 8, 2008
How do I disable the ping response?
Usually a ping is used to check if a machine is up and to check the network status.
It is a small network packet sent to the machine. If the machine is up, an answer will be sent. The time needed to get the answer is called ping time or round-trip time.
The ping response from an IP indicates the machine is up.
Unfortunately this can be used to quickly scan an IP-range for reachable hosts.
This can be used to find potential hackable machines. If your machine doesn’t answer to pings, your chance to be seen is reduced. (That doesn’t mean your machine is more secure, the machine is just not that easy to be seen from the internet. Nothing more.)
Add the following line to your init script for the network (the name depends on the distribution you use):
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
This disables ping responses.
To reenable, use the following command:
echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all
To make this permanent set the following into /etc/sysctl.conf (if you have such a file)
net.ipv4.conf.icmp_echo_ignore_all = 1
Custom teaser length by View using node.tpl.php
I have been working on this project, http://www.newsafrican.com which is a news site which focuses on everything african news. This project is been built on the Drupal CMS which is very flexible arguably.
I got into a situation where i have to customise the teaser length by View which happens to be one of the Drupal modules using node.tpl.php.
One way to vary teaser lengths is to check the current View with a modified node.tpl.php modify the output based on this
In this example a teaser of length 75 or 150 will be shown for the Views “frontpage” and “ghana_page” respectively.
I worked on this for Drupal 5 with the help of the good guys in the drupal IRC rooms, my solution is below. But this is a solution for Drupal 6 by friends on the drupal-support channel of IRC.
<div class="node<?php print ($sticky) ? " sticky" : ""; ?>">
<?php if ($page == 0): ?>
<?php else: ?>
<?php print $picture ?>
<em class="info"><?php print $submitted ?></em>
<?php endif; ?>
<?php
global $current_view;
if($teaser) {
if($current_view->name == ‘frontpage’)
{?>
<?php foreach ((array)$node->field_news_image as $item) { ?>
<div class=”field-item”><?php print $item[‘view’] ?></div>
<?php } ?>
<h2><a href=”<?php print $node_url ?>” title=”<?php print $title ?>“><?php print $title ?></a></h2>
<?php print $node->content[‘body’][‘#value’];
}
if($current_view->name == ‘ghana_page’)
{?>
<?php foreach ((array)$node->field_news_image as $item) { ?>
<div class=”field-item”><?php print $item[‘view’] ?></div>
<?php } ?>
<h2><a href=”<?php print $node_url ?>” title=”<?php print $title ?>“><?php print $title ?></a></h2>
<?php print $node->content[‘body’][‘#value’];
}
if($current_view->name == ‘africa_page’)
{?>
<?php foreach ((array)$node->field_news_image as $item) { ?>
<div class=”field-item”><?php print $item[‘view’] ?></div>
<?php } ?>
<h2><a href=”<?php print $node_url ?>” title=”<?php print $title ?>“><?php print $title ?></a></h2>
<?php print $node->content[‘body’][‘#value’];
}
if($current_view->name == ‘business_page’)
{?>
<?php foreach ((array)$node->field_news_image as $item) { ?>
<div class=”field-item”><?php print $item[‘view’] ?></div>
<?php } ?>
<h2><a href=”<?php print $node_url ?>” title=”<?php print $title ?>“><?php print $title ?></a></h2>
<?php print $node->content[‘body’][‘#value’];
}
if($current_view->name == ‘gh1’ || $current_view->name == ‘gh2’)
{?>
<?php foreach ((array)$node->field_news_image as $item) { ?>
<div class=”field-item”><?php print $item[‘view’] ?></div>
<?php } ?>
<h2><a href=”<?php print $node_url ?>” title=”<?php print $title ?>“><?php print $title ?></a></h2>
<?php print substr($node->content[‘body’][‘#value’], 0, 90). ‘ ’;
?><a href=”<?php print $node_url ?>” title=”read more”>read more</a><?php
}
} else {
print $content;
}
?>
September 2, 2008
S Leone president declares assets
President Ernest Bai Koroma has become the first head of state in Sierra Leone to declare his assets to the country’s Anti-Corruption Commission.
As i read this news item, i was wondering when all other African leaders will do follow this. Expecially in Ghana were there is been much talk about such a thing. We always here leaders saying i already had my money or wealth before i came to power.
Koroma, i hope this will not be a nine day wonder, but to go beyond that let things work in S-Leone.
Google launches internet browser
Google is launching an open source web browser to compete with Internet Explorer and Firefox.
The browser is designed to be lightweight and fast, and to cope with the next generation of web applications that rely on graphics and multimedia.
Called Chrome, it will launch as a beta for Windows machines in 100 countries, with Mac and Linux versions to come.
“We realised… we needed to completely rethink the browser,” said Google’s Sundar Pichai in a blog post.
The new browser will help Google take advantage of developments it is pushing online in rich web applications that are challenging traditional desktop programs.
Just waiting to try it out. 🙂
July 31, 2008
Changing Server Timezone On Ubuntu
Is amazing how sometimes such small issues on linux can frustrate a linux user.
I’m currently reconfiguring a machine on the other side of the globe, so I want to get it to work to IST instead of EST.
A quick google brought up a rather complex way of doing it which sounded really complex to me, so I refined my query and found the same solution in the Ubuntu documentation.
Simply run the following command as root (or using “su”):
sudo dpkg-reconfigure tzdata
And just follow the instructions.
No silly reboots or other craziness required.
To keep your server’s time in sync with the rest of civilisation setup a cronjob to poll an ntp server once every 24 hours:
/usr/sbin/ntpdate yourfavouritentpserveraddress
Problem solved 🙂
July 15, 2008
Adeona, free Laptop-Tracking System
Adeona is the first Open Source system for tracking the location of your lost or stolen laptop that does not rely on a proprietary, central service. This means that you can install Adeona on your laptop and go — there’s no need to rely on a single third party. What’s more, Adeona addresses a critical privacy goal different from existing commercial offerings. It is privacy-preserving. This means that no one besides the owner (or an agent of the owner’s choosing) can use Adeona to track a laptop. Unlike other systems, users of Adeona can rest assured that no one can abuse the system in order to track where they use their laptop.
July 14, 2008
The server encountered an internal error or misconfiguration
I encountered the following error when I uploaded an existing site to a new server.
The server encountered an internal error or misconfiguration and was unable to complete your request.
The problem was the .htaccess file. I deleted the .htaccess and the web server worked again.
Subsequently, I recreated the file directly on the server using vim and the server still worked, I think therefore the problem was likely to be an issue with DOS carriage returns / line feeds versus what the Linux server expected.
Several tools exist on the web to help create .htaccess files online, but generally any text editor will work. Do be sure to test your site thoroughly after making an adjustments to the .htaccess file.
June 2, 2008
Drupal Links
Drupal is a very powerful content management system (CMS). But it can be very confusing and fustrating to start with and get documentations.
I have been working on some drupal projects for the past 2 weeks. And i have really come a long way getting some documentation links on Drupal. So i have decided not to allow people also go through by parcelling all the documentation links i came across on the web and also got through the IRC.
And i will be updating each time somthing new comes up 🙂
For Drupal Clean URLS
http://drupal.org/node/15365
Flash Video in Drupal 5: A complete multimedia tutorial
http://www.travistidwell.com/flashvideo
How to zip files on linux
Ziping files on linux using shell is one of the most easy things to do
but today i got a bit confused when a friend asked me how to zip a file with
a different name.
example : normally i zip with the source and target name all been same.
zip -r foobar foobar
which will result in
foobar.zip
but what my friend wanted was having a different name for the result.
So i had to jump straight to the linux channel on IRC. below is what i learnt from there.
zip -r foo.zip bar
which results in foo.zip
what abt unziping too
unzip foo.zip
but what about unziping to have different name .
unzip foo.zip && mv foo bar