20 Linux System Monitoring Tools Every SysAdmin Should Know

Amazing list found at http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

Tags: ,

RewriteMap causing indefinite redirects

If you’re using Apache mod_rewrite with RewriteMap is causing loop and breaks, probably you had forget about conditions.

RewriteMap  links txt:/var/www/bin/rewritemap.txt
RewriteCond ${links:$1|Unknown} !Unknown
RewriteRule ^/(.*) ${links:$1} [R=301,L,NC]

Easy saying – Rule will redirect only when url is found in your mapfile

 

Tags: ,

Run PHP (and others) code in a browser – revolutionary pastebin

If you need to test a code in browser – try  http://ideone.com/

Entry found on http://alouche.net/blog/2009/11/24/ideone-compiler-pastebin/

Tags: , , ,

I’m in TOP10 on elance.com

elance-code-off-winnersI was really suprised and pleased when i found myself on elance.com in TOP10 coders!

http://www.elance.com/p/blog/2009/12/congratulations_to_our_php_code_off_winners.html

Mysql client for Ubuntu

I’ve tried TORA, which seems to be nice
sudo apt-get install tora
sudo apt-get install libqt3-mt-mysql
Any others?

Tags: , , ,

Geotagging script

Geotagging script (http://themeforest.net/user/php4ucouk)

Script converts visitor’s ip adress into :

  • country code (2 and 3 letter ISO code)
  • full english country name
  • region code and name
  • currency code used in this country
  • postal code
  • gps coordinates
  • area code
  • dma code
  • metro code

and BONUS

  • overall statitics about users from different countries
  • number or live visitors on your web page

Data is provided to you, so you can use it (display it, store in db or do whatever you need)

Live demo

Tags: , , ,

How set active item in primary links menu in Drupal

I wanted to set item to be active from my module. After research i found quite easy way to do it.

I found theme_links() which are preparing menu to be displayed. Copy that into template.php in your theme folder.

My function is quite simple:

function YOURTHEMENAME_links($links, $attributes = array('class' => 'links')) {
global $language;
$output = '';
 
/**
* Make our item active
*/
 
if (strpos($_GET['q'],'URLTOMATCH1/') !== false)
{
$org = $_GET['q'];
menu_set_active_item('node/57819'); // nid is taken from primary links
}
 
if (strpos($_GET['q'],'URLTOMATCH2') !== false)
{
$org = $_GET['q'];
menu_set_active_item('node/57789');
}
if (strpos($_GET['q'],'URLTOMATCH3') !== false)
{
$org = $_GET['q'];
menu_set_active_item('node/57829');
}
 
// inspiration
if (strpos($_GET['q'],'inspiration') !== false)
{
$org = $_GET['q'];
menu_set_active_item('node/57839');
}
 
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
 
$num_links = count($links);
$i = 1;
 
foreach ($links as $key => $link) {
$class = $key;
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language->language)) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
 
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
 
$i++;
$output .= "</li>\n";
}
 
$output .= '</ul>';
}
 
// set original value
menu_set_active_item($org);
return $output;
}

Tags: , , ,

How to modify Drupal Views SQL

I wanted to sort my views result on field which doesn’t exists in db table, so my idea was to use:

SELECT … WHERE field IN (value1, value2) … ORDER BY field = value1 DESC, field = value2 DESC  etc

Which orders my elements exactly as I need, but problem was how to modyfy views sorting options?

Simply you can implement hook_views_query_alter(&$view, &$query) in your_module.views.inc file

$query->orderby is an array of all orderby elements, so you can easily modify it.

Tags: , , ,

PHP Mail problem on Ubuntu

I’ve installed fresh version of Ubuntu 9.04 with Lamp, but I couldn’t send emails outside.

Problem was SMTP auth of outgoing server, spending time found http://dbaron.org/linux/sendmail who made my day. Thanks

Tags: , , ,

Why do I receive an “Operation aborted” error message when I visit a Web page in Internet Explorer?

I did really simple application, but still under IE7 it was crashing with Operation aborted.

First “You can turn off friendly HTTP error messages in Internet Explorer. This workaround still lets the error message appear. However, Internet Explorer does not move away from the page after the error occurs. This workaround works only for Internet Explorer 6.

To do this, follow these steps:

1. On the Tools menu, click Internet Options.
2. On the Advanced tab, click to clear the Show friendly HTTP error messages check box under the Browsing section, and then click OK.
3. Close the browser. ” according to http://support.microsoft.com/kb/927917

At least page is rendered, but it doesn’t solve a problem. When i started to dig i found that i’m using Jqwuery tooltip inside table.

Next thing i’ve added line to execute javascript when document is fully loaded.

  1. $(document).ready(function() {
  2. // put all your jQuery goodness in here.
  3. });

It solved IE7 from crashing

Tags: , , ,