Category: AI
When the Assistant Becomes the Attacker: Hidden Risks of Tool-Enabled LLMs
Category: Opinion
When the Assistant Becomes the Attacker: Hidden Risks of Tool-Enabled LLMs
Category: Security
When the Assistant Becomes the Attacker: Hidden Risks of Tool-Enabled LLMs
SSH : Multiplexing connections
There is a feature in OpenSSH since v3.9 which allows multiple SSH connections with the same caracteristics (host, port, remote login) to be made through a single TCP connection. This is useful because you’ll have to authenticate only once, and besides the new SSH connections will be much faster to establish.
Securing automated rsync over SSH
Quoting the RSYNC homepage : “rsync is an open source utility that provides fast incremental file transfer.”
To make rsync both secure and automated (i.e : non-interactive), you can use SSH as the transport and set up a key pair. This is what will be discussed in this post, along with a few improvements.
Network Security : Being the Man In The Middle using ARP
This post presents what is the attack known as “ARP Man in the Middle” which is basically a way for a malicious user to sniff network traffic on a fully switched network. If you don’t know this attack yet, go on reading.
MSN : get rid of Backdoor.Generic3.SAT
If you got this virus (or know someone who did), and it is spreading to all of your MSN contacts with something like the following message :
hey How are you???? this is ur pic rite?!<br /> http://www.msn- gallery.com/gallery.php?user=some_nickname.jpg
or in French something like :
http://msn-friends. iquebec.com/?photo=some_nickname<br /> ta tof fais koi sur ce site :P
Then you can use the following article (there is a removal tool) to get rid of it : How to Remove MSN Virus Project 1/ Generic2.EXO / Backdoor.Generic3.SAT
Web Security : What are XSS?
XSS (Cross Site Scripting) are a kind of attacks which are fairly popular these days and could target anyone, but are not nearly well known from most people.
In this post, I’ll try to give a short explanation of what they are.
Category: Software
SAP Hybris platform sizing guidelines
Hybris is a very widely used platform for eCommerce. It is a somewhat complex piece of software, with multiple interacting components.
When trying to obtain optimal performance, there are a few guidelines you’ll need to follow. We’ll review them in this post.
Getting Spotify to run on Gentoo/Linux: A Gross and Cruel Hack
Spotify is a great way to listen to music. Unfortunately the official client only runs on Windows and Mac machines. There is an experimental unsupported client for linux, however it’s provided as a DEB (ubuntu/debian) package.
Here’s a gross hack for whom is desperate to get it working on Gentoo.
Asterisk 101 : How to get rid of your mother-in-law …
… or anyone else really, with a little trick to implement a black list and filter unwanted callers.
Asterisk 101 – Ghetto GoogleVoice : Signing up for / using GV even if you’re not in the USA using Asterisk
GoogleVoice (GV for short) is a great service (I won’t go into the details, but you can read up about it here), but it is unfortunately accessible only if you are in the USA.
Granted there is already plenty of documentation about how to circumvent this, but I’m not aware of any of those using Asterisk.
So this post will document how to sign up for a GV account as well as how to use it with Asterisk afterwards, in the prospect of using it if you are not in the USA.
In order to be able to sign up for GV, you need to meet 2 prerequisites :
- You need to have a US IP address
- You need to have a US phone number, which will be used to validate your GV account
Step 1 is left as an exercise to the reader (“Good luck ! I’m behind 7 proxies !” :D).
Step 2 is the one we’re going to describe here, as an example of what you can pull with simple Asterisk configurations.
Asterisk 101 : How to troll telemarketers (aka automatically send hidden Caller ID to a waiting music forever)
If like me you get tons of telemarketers calls, there’s an easy way to get rid of them with a quick Asterisk hack. The following Asterisk configuration snippet will immediately send any hidden caller ID (99% telemarketers, and I have a general policy of not picking up the phone for hidden caller ID anyway) to a holding music making them waste money and time…
AutoHotkey : Copying without formatting
One of the common annoyances of copy-pasting on Windows is that it tries to copy-paste the formatting as well. This issue can easily be fixed by the following AutoHotkey macro, which will copy the selection to the clipboard as pure text.
Asterisk : Basic SOHO environment VoIP PABX configuration
Asterisk is a free telephony software. I’m posting here sample commented configuration files for reference purposes, hoping they will help you get kickstarted if needed.
This config sets up :
- SIP phones (for softphones or harware phones with SIP capabilities)
- Voice mails
- A few test phone numbers
- Forwarding of calls to a SIP provider for outbound and incoming calls (from/to PSTN)
That should be plenty already for a SOHO environment !
Note to French readers : Si votre FAI est Free, cette configuration fonctionne pour passer / recevoir des appels via le SIP de Free (Freephonie).
Firefox (Linux) : “Middle-click on page loads URL” annoyance
Firefox will load whatever URL is in the copy-paste buffer in the page if you middle click somewhere on a page. My mouse’s wheel also serves as the middle button, and I found it really annoying that when occasionally middle-clicking while scrolling the page, Firefox would try to load another page …
You can control this behaviour with this about:config property middlemouse.contentLoadURL. Set to true, the middle-click on the page will load the URL (if it is one) in the page, set to false it won’t.
Gentoo : Running Cacti with LigHTTPD
If you use Gentoo and tried to install Cacti with Lighttpd instead of Apache, chances are that you ran into this error message :
/usr/lib/python2.6/site-packages/WebappConfig/content.py:27: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5, re, os, os.path
* Fatal error: Your configuration file sets the server type "Apache"
* Fatal error: but the corresponding package does not seem to be installed!
* Fatal error: Please "emerge >=www-servers/apache-1.3" or correct your settings.
* Fatal error(s) - aborting
Xfce4 : Bug with key bindings
There is currently a little bug in Xfce4 which prevents you to bind the key combinations involving SPACE and ESCAPE. For example you can’t bind
conky : integrating rTorrent downloads monitoring
Conky is a lightweight system monitoring tool. It has many built-in probes (processor load, memory usage, temperature sensors, etc), but it is still pretty easy to extend it if you don’t find the feature you need.
In this post I’ll describe my Conky setup and explain how to extend it to monitor your rTorrent downloads.
rTorrent is a great BitTorrent client which offers an XML-RPC interface to its core functions, making it easy to get the downloads status through scripting. You can read more about that in this previous post.
rTorrent : Probing downloads status through XML-RPC
rTorrent is a very efficient BitTorrent client for linux. It has a very small memory footprint, a very customizable configuration file, and exposes it’s internals through XML-RPC. This is convenient to implement 3rd party GUI or web interfaces.
Let’s see how to setup and use XML-RPC to probe rTorrent downloads.
VIM: using the modeline for file based customized editing parameters
The “modeline” is a common way to set (or override) VIM settings on a file by file basis. Let’s see a few of the key concepts of the VIM modeline.
Linux + Amarok 1.4 : Setting up proxy configuration
If you access the internet through a proxy, you need to set up Amarok to use it to enjoy some of its amazing features such as automatic downloading of CD covers or fetching of the lyrics of the song you’re listenning to. Amarok is really a great media player. if you don’t know it you should definitely give it a try !
Setting up proxy parameters for Amarok 1.4 could be a little confusing if you don’t use the full KDE environment. In this post, I’ll explain how to manually edit KDE configuration files to fix proxy settings.
X10 Home automation : Heyu a tool for managing a CM11
I currently manage all my X10 home automation with MisterHouse which is a fantastic tool but is a bit on the heavyweight side. Plus you need to know a bit of Perl to take full advantage of it.
If you are looking for something simpler to use, you might want to consider HEYU.
Unix : the “script” command
The script command is a must for any unix sysadmin.
Once invoked, it will faithfully write anything you typed as well as any output generated in your terminal into a file of your choice (defaults to “typescript”).
This is great when you want to document everything you did on a specific server, for example.
spaghetti:~$ script<br /> Script started, file is typescript<br /> spaghetti:~$<br />
When launched, you don’t see anything, but everything displayed goes to a file as well as the terminal.
vi : replacing text globally (search and replace)
If you want to replace a text throughout a file in the vi text editor, you can use the following command :
:1,$s/text/replacement/g
Here is the breaking down of this command:
- “:” : places you in “ex mode”
- 1,$ is a range specification, meaning from the first to the last line (this can be shortened as % in some versions of VI (vim does, for instance) — Thanks Brandon !
- s means “substitute”
- /text/replacement/ means to replace the “text” pattern by “replacement”
- g : means globally, which will replace all the occurrences of the pattern instead of the first of each lines
If you want to see how to script a text replacement, check out my previous post about text replacement with sed.
Zsh is cool : stream redirections
Zsh extends the usual stream redirections with two nice features …
Process substitutions
How often have you done the following :
- Launch one or many commands and redirect their outputs into temporary files
- Launch a command which reads and processes those temporary files
- Delete the temporary files
If you occasionaly write shell scripts then it is likely that the answer is “many times”. If so, then you’ll be glad to know that Zsh can automate this for you.
bc : 2 little tricks you’ve ever wanted to know
If you’re looking for a good calculator on Linux / Unix, you can use bc. bc is “an arbitrary precision calculator” supporting bignumbers and many operators … well it will mostly do whatever you want (check the fine documentation).
Anyway, about those 2 little tricks I promised :
- change the scale variable (eg : scale=10) to set “the total number of digits after the decimal point”. Defaults to 0 -> Not cool.
- use the last variable to recall the last value you computed -> Cool.
That was it ! This is what I always need and forget, so I decided to blog it once for all…
Linux : Best picture viewer
I previously asked an open question : “which is you favorite Linux picture viewer ?” and got a few answers in the comments, but unfortunately none of them made me happy. I tried quite a few on my own but without much success, till today.
Doing some more googling, I found a great picture viewer : FEH. It’s mostly command line based, it is fast and easy to use.
Building GNUCash on Debian
I’ve just been through hell to get the HEAD revision of GNU Cash to build and run on GNU/Debian … The problem was that GNUCash depends, amongst many other dependencies, on Guile and on the SLIB library for Guile.
If you want to save you some hours, use the following Debian packages (and stick to those versions !)
<br /> guile-1.6;1.6.8-6;The GNU extension language and Scheme interpreter<br /> guile-1.6-dev;1.6.8-6;Development files for Guile 1.6<br /> guile-1.6-libs;1.6.8-6;Main Guile libraries<br /> guile-1.6-slib;1.6.8-6;Guile SLIB support<br /> libguile-ltdl-1;1.6.8-6;Guile's patched version of libtool's libltdl<br /> libqthreads-12;1.6.8-6;QuickThreads library for Guile<br /> slib;3a4-4;Portable Scheme library<br />
Linux – a decent picture viewer software ?
Today I write a blog entry to ask a question to the Linux users community.
In former time, when I had this need, I would have used xv. But I guess this tool is considered history nowadays … nonetheless, I’m looking for something in the same spirit : letting me quickly and efficiently browse my pictures, no fancy editing capabilities wanted.So people, what do you use ? Any hint ?If that can narrow down the choices, I’m using Debian GNU/Linux 4.0.
Take typing lessons with Firefox
OK, it’s friday so we can have a little fun 😉
“Addictive Typing Lessons” is a Firefox extension which helps you to practice and improve your keyboard typing skills.
It provides many different sets of exercise with growing difficulty, and collects statistics about your performance, so that you can see how you progress.
If you’re not familiar with keyboard typing, give it a try and you’ll soon type like a professional 🙂
FoxyProxy : Easy config of Firefox proxy settings
FoxyProxy is a firefox extension which allows advanced proxy configurations.
Greasemonkey : Down with web annoyances !
If you don’t know yet Greasemonkey, this is one of the most valuable Firefox plugins.
Basically, Greasemonkey runs scripts on the web page you’re browsing and modifies it’s appearance or behaviour.
Software list
Here is the list of the software I use on my personnal computer. All of them are free for personnal use :
Malware Protection
AVG Free Edition – Antivirus
Adaware – Spyware removal tool
Spybot – Spyware removal tool
Web
Firefox – Web browser
GTalk – Instant messaging
MSN Messenger – Instant Messaging
ICQ – Instant Messaging
PuTTY – Multi-protocole remote terminal
Productivity
OpenOffice – Office suite
PDF Creator – Creating PDF
Sunbird – Calendar
System
DIRMS Defrag Tools
PowerToys – Tweak UI
SysInternals – AutoRuns : displays what runs at startup
SysInternals – PageDefrag : defrag your pagefile at boot
SysInternals – ProcessExplorer : Task Manager on steroids
Home automation
This is related to one of my geek hobbies : I am playing with home automation.
Here is what I use :
- Technology : x10
- Software : MisterHouse
- Hardware : a CM11, few AM12, LM12 etc
This is really great since it allows you to control anything in your house (lights, washing machine, heaters, …) from your computer, while still being fairly simple.
Using MisterHouse requires to know at least a little bit of Perl to get the most out of it, though.
Category: Systems
SAP Hybris platform sizing guidelines
Hybris is a very widely used platform for eCommerce. It is a somewhat complex piece of software, with multiple interacting components.
When trying to obtain optimal performance, there are a few guidelines you’ll need to follow. We’ll review them in this post.
Linux RedHat / CentOS / Fedora : Uninstall a package along with dependencies
If you’ve been wondering how to delete a package you mistakenly installed (or which is no longer needed) along with all its dependencies, here’s a neat way to achieve just that.
The idea is that whenever you use yum to perform some operation on packages, a transaction is created. If you installed a package along with its dependencies, then you can undo just that by undoing that transaction.
Fedora 20 Linux + bitcoind : Setting up firewalld for running a full bitcoin node
If you feel like running a full bitcoin node on your Fedora Linux server (and it’s a great way to help the bitcoin network if you have spare capacity / bandwidth), you’ll need to update the firewalld rules in order to allow foreign nodes to connect to yours.
Here’s how…
Docker 101 : Creating an Elasticsearch image
Creating an image in Docker is rather easy and well documented.
You start by editing a file which describes the image, then run a few commands, and voilà .
In this post we’ll cover how to create a very basic Docker image which will let us spawn elasticsearch instances very easily.
Linux : Encrypted LVM quick and easy howto
The goal of this tutorial is to show you how to create an encrypted LVM on Linux. This will help you keep your data safe in the event of, for example, your laptop computer being stolen.
OpenBSD : Read only Compact Flash installation
Here are a couple of pointers to perform an installation of OpenBSD on a media which will be read-only most of the times. I hope I didn’t forget anything otherwise I’ll be in trouble next time I reinstall… 🙂
Unix 101 : Shell wildcards expansion, to quote or not to quote
Or why you usually use ls -l *txt without quotes, but use quotes in find . -name “*txt”.
Unix 101 : Showing non-printing characters in text files (ex : DOS files)
A non-printing character is a character which won’t actually get directly printed (or displayed) but rather interpreted. Such non-printing characters are for example line-feed or tabulation. The interpretation of those characters can differ from one system to the next. For example the line-feed character is different on Unix or DOS.
If you need an easy way to confirm that a text file is DOS or UNIX formatted (they differ with respect to the end of line character(s) for example) or if you wish to display normally non-printing characters of a text file, you can use the -vET command line switches of the cat utility.
As explained in the man page :
- -v : will use the ^ and M- notation for control and multibytes characters
- -E : will make ends of lines visible
- -T : will make tabulations visible
For example :
Unix 101 : Filesystem basics & Special files
This post is meant to clarify a few key concepts about Unix filesystems such as directory permissions, hardlinks and symlinks.
Linux + Xorg : Remapping caps lock key to escape
In this post I’ll revisit the classical “how to remap caps lock into something useful” once again. In this post, I’ll show how to remap the caps lock key to have an extra Escape key, which is very useful for all VI/Vim users.
Bash / zsh : Using the history expansion
One of the features of bash I’ve too long overlooked is its history expansion. In this post I’ll show a few examples to get a grip at it.
AIX : Use sar to check cpu usage
If you’re looking for CPU usage statistics and system performance on IBM AIX, sar might just be the tool your looking for. It’ll display information for 5 minutes intervals from midnight to current time. The output looks like this :
Linux / Unix : Disk usage and identifying biggest files
When working as a systems administrator, you’ll always end up having to solve a file system full error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system.
Gentoo Linux / Portage : How to know which package provided an installed file
If there’s a file installed on your disk for which you’d like to know what package provided it, you can use the equery command like below :
VirtualBox : Cloning a virtual hard disk
If you’ve got a VirtualBox VM already installed and you wish to clone/copy it, follow the steps below :
OpenSolaris : Exporting a ZFS filesystem with CIFS
If you need to export ZFS volumes through CIFS, follow this simple step by step procedure.
OpenSolaris : Switching to the /dev development branch
In OpenSolaris, switching to the /dev development branch is a bit like switching to the testing branch for some linux distros. So you might want to think twice before doing so, as it might sometimes break things.
If you still want to do that, follow those instructions :
Gentoo : Xorg X Server 3D hardware acceleration
You need to have read/write permissions to /dev/dri/cardX to benefit from 3D hardware acceleration in Xorg X Server. On a Gentoo linux machine, this file has the following permissions set by default :
ls -l /dev/dri/card0
crw-rw---- 1 root video 226, 0 2009-10-14 16:12 /dev/dri/card0
HAL + Xorg X server : Using HAL to set hardware specific configurations for Xorg Xserver
The Xorg X Server can now rely on HAL to get information about the hardware the machine is running. This allows the X Server to auto-configure most of its components such as keyboard / mouse / screen / graphic adapter. But there is still room for tweaking it if needed.
This post explains how to configure extra properties for a keyboard at the HAL level, so that X Server will correctly auto-configure it for you.
Linux : SATA hot plug / unplug
I have 3 hard disks in SATA-to-eSATA external enclosure which I occasionally need to plug to perform backups and to unplug when done. I found it annoying to have to restart the whole computer at every turn, especially when SATA is supposed to bring hotplug abilities. If you mainboard / SATA chipset and disks support hot plugging and unplugging, you can do this by following those instructions.
Xen : OpenSolaris 2008.11 DomU running on a Linux Dom0
This post is a step by step explanation about how to get an OpenSolaris 2008.11 run as a Xen DomU on a Linux Dom0.
To follow this, you’ll need a Linux machine ready for Xen (I run Xen 3.3.0), with vncviewer installed.
This post doesn’t explain the basics of Xen, so you might want to start by learning Xen if you don’t already know a bit of it.
shell tip : identify broken symlinks
If you need to identify broken symlinks, you can do the following :
find -L . -type l
The -L options instructs find to follow symlinks when possible. Hence no “working symlink” will ever get returned as the targets won’t match -type l (meaning “file is a symlink”).
On the other hand, find will not be able to follow broken symlinks, so the information will be taken from the symlink itself and not from the non-existent or otherwise unreachable target. The -type l will then be a match and the broken symlink filename will be returned.
Gentoo : Managing software packages
In this post I’ll cover the basics one needs to know to install, upgrade and remove packages on a Gentoo linux system.
Gentoo : First thoughts after the switch
I’ve recently switched to the Gentoo Linux distribution (mostly to experiment with this Linux distro) and I don’t regret it so far. This post is about my first impressions about Gentoo.
Ubuntu 8.04.1 : Xen 3.2 package broken ?
I’m trying to install xen on Ubuntu 8.04.1 and here is what I get :
spaghetti% sudo apt-get install ubuntu-xen-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
Since you only requested a single operation it is extremely likely that
the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
ubuntu-xen-server: Depends: python-xen-3.2 but it is not going to be installed
Depends: xen-utils-3.2 but it is not going to be installed
E: Broken packages
spaghetti%
I’ve tried to follow the package dependencies but without success. As for now I’m growing tired of Ubuntu and I’m considering moving away to a more robust distribution … I’d be glad to hear your point of view about that too.
Linux : find out the kernel command line
If you have multiple linux kernels with differents options in the command line in your bootloader (grub, lilo or other) and you wonder which one was used to boot, you can find out by looking in /proc/cmdline. Ex :
[root@picolo:~]# cat /proc/cmdline<br /> ro root=LABEL=/<br /> [root@picolo:~]#
NFS : see what’s exported from an NFS server
To know what directories are exported by a NFS server, you can use the showmount -e nfs_server from a NFS client.
[root@client:~]# showmount -e server<br /> Export list for server:<br /> /data/dir1 (everyone)<br /> /data/dir2 client1 client2 client3
(The /data/dir2 is exported only to specified clients)
Backups : a personnal implementation
If you’ve been following my blog for a while, you might have seen posts about SSH, RSYNC, ZFS Snapshots and so on. This article aims at describing the big picture, and to explain how I’ve been using those tools and technologies to build my own home backup system.
Sun Solaris 10 : Creating snapshots with ZFS
ZFS is a great filesystem. Amongst its many features, it has snapshots. Let’s see how to use them.
OpenSolaris 2008.05 released today
OpenSolaris 2008.05 is released today, you can grab it from the OpenSolaris website.
The distribution is a bootable CD which will let you try it before installing. It includes most of the big hits of Solaris 10 (zfs, dtrace, containers and so on).
If you never tried Solaris or OpenSolaris, this might be a good kick start !
SSH slow to connect to a Solaris 10 host
If you experience a slow SSH connection to a Solaris 10 host while after connection everything works fine, then read on !
Ubuntu 8.04 + IBM T40 = No sound
If you upgraded your Ubuntu on an IBM T40 Laptop only to find out that there is no sound anymore, you’re not alone in this 😉
Follow the bug report for more information !
Edit 2008-05-11 : As of today I don’t have this problem anymore … update your machine if you haven’t yet !
Edit 2008-06-22 : Sound vanished again … I really need to look into this before this drives me crazy !!
OpenBSD : Release 4.3 is out
The twice-a-year release of OpenBSD is out today (More details on Undeadly). You can buy the CD set or get it by FTP (in this case consider donating to the project as CD sales are the main source of income to the project).
Enjoy.
CFEngine : Checking for processes
CFEngine can do wonders to keep a cluster in shape, but it can be very useful for a single server as well. Here is a configuration sample to monitor a few common services and restart them should they fail.
Unix : shell tips
I ran into this into the following article, “Learn 10 good UNIX usage habits“. This article is mainly common sense, but there are interesting points, such as :
- avoid piping when you can, in order to save performance (the classical construct grep | wc to count the lines is useless as most versions of grep can count with grep -c)
- use awk to “grep” on a specific field of a line with “… | awk ‘$1 == “XXX”‘ which is cool and I never use
- the find | xargs construct (I’d add “find -print0 | xargs -0”, useful if your find brings back filenames with a space inside …)
All in all it is worth a reading, if only to refresh your memory.
dsh : a distributed shell
A common problem when you deal with a pool of servers (clusters or server farms, you name it) is to execute the same command line on each server. It is usual to solve this with a “for” construct such as :
for i in server1 server2 ; do ssh $i "uname -a"; done
But this is basically re-inventing the wheel everytime. Here comes Distributed Shell (DSH).
Linux : Clusters, Vitualization, High Availability, Load balancing
I’m back from a 3-day-training about clusters with Linux which was pretty exciting, and here are the main points which were covered :
- Vitualization with Xen
- Sharing data with GFS / GNBD
- Clusters with RedHat Cluster Suite
- Load Balancing with Linux Virtual Server (LVS)
Linux : Using loop devices (eg : mounting an ISO file)
If you downloaded an ISO file and you want to mount it into your filesystem, you can proceed as follows :
spaghetti% sudo losetup /dev/loop0 cdrom.iso<br /> spaghetti% sudo mount /dev/loop0 /mnt<br /> spaghetti% ls /mnt<br /> Autorun.inf setup.exe setup.ico<br /> spaghetti%<br /> [...]<br /> spaghetti% sudo umount /mnt<br /> spaghetti% sudo losetup -d /dev/loop0
This will use the feature known as “loop devices”, which lets you use a file as a device, and subsequently mount it as it would be one.
Linux + GSM : How to access your cell phone innards with Linux
This article explores your options to access your GSM cell phone from a linux system, and manipulate SMS and phonebook entries.
Doesn’t provide hints about how to unlock a GSM cell phone though 😉
Linux : Taking control of Virtual Terminals (VT) from command line
When you use Linux in text mode (as opposed to with an X server), you readily have access to multiple Virtual Terminals (aka VT for short) by hitting one of your
This lets you access one of the VTs which are initialized at boot time, but won’t let you create new ones even if your kernel configuration would allow more VTs. Furthermore, what if you want to deal with VTs from a script ?
This post covers the 3 commands which will let you control your VTs from the command line or from a script.
awk : one-liner to select a field
Getting a specific field of a line with awk is really simple. For example :
spaghetti% echo "test1 test2 test3" | awk '{print $2}'<br /> test2
A more “real life” example is as following, which will find in /etc/hosts the IP address of localhost (pick another host if you wish 🙂 ) :
spaghetti% cat /etc/hosts | awk '/localhost/ { print $1;}'<br /> 127.0.0.1<br /> ::1<br />
If the field separator is not a space, awk will let you change it with the FS variable :
spaghetti% echo "test1:test2:test3" | awk 'BEGIN { FS = ":"} { print $2 }'<br /> test2<br />
sed : replacing a text in a file
To replace a text in a file, you can invoke sed as in the following example :
% cat file.txt | sed -e 's/text/replacement/g' > result.txt
This will change all the occurences of “text” to “replacement” in “file.txt” and output the result in “result.txt”
Note : As suggested by Matthias from adminlife in the comments, if you wanted to do “in place” text replacement (that is modify the file without a temporary file in between), you can do the following :
Linux – RedHat (or CentOS) : update system and packages with yum
In order to keep your system updates (especially important for security fixes) on a RedHat linux system (or CentOS), you can simply perform the following command :
yum update
You’ll then be presented with a list of available updates for your system.
Doing so from time to time will help you to keep your system secure and to get the latest versions of your softwares.
If you wonder how to do the same with a Debian Linux system, check out my previous post about Apt, the Debian package manager.
Linux – RedHat (or CentOS) : list installed packages
If you need to list packages which are installed on a RedHat system, you can do so by issuing the following command :
rpm -aq
Alternatively, if you prefer to use the package manager, you can try this command :
yum list installed
if you want to know how to do this on Debian, check out my previous post on Apt.
Unix : Cron daemon, crontabs and where to find them
Cron is a fairly standard daemon which you’ll find on most (if not all) Unix machines. Its purpose is to schedule the execution of commands at a specified time.
Sometime you’ll log at some performance graph (CPU load for example) and find out that every day/week/month/other there is an unexpected peak and you’d like to know why. Of course if this is regular you’ll think of Cron as a good trail to follow.
Linux LVM : A short intro
If you are running Linux, then you can use LVM (Logical Volume Manager) to get an extra flexibility in the way you allocate your disk space.
Physical disks are wrapped in Physical Volumes (PVs), which are grouped in Volume Groups (VGs). Logical Volumes (LVs) can then be laid over a VG.
So, if you want do manage a disk through LVM, you start by creating a PV for it ( with pvcreate ).
Debian : update a dynamic DNS
A bit of context : I have a bind 9 DNS allowing DNS updates from clients on the LAN (ok this is fairly insecure, but still my LAN is my home LAN composed of 4 machines … let’s say that’s good enough for me ! 🙂 )
The named.conf allows those updates with this config directive in the zone config block :
allow-update {mynet; };<br />
and mynet is defined an acl directive to be my LAN.
Solaris 10 : installing … and starting SSHD
First of, you’ll have to locate and install the following packages :
- SUNWsshcu
- SUNWsshdr
- SUNWsshdu
- SUNWsshr
- SUNWsshu
The two last are the SSH client parts, it doesn’t hurt to install them.
You need to have the server keys generated in /etc/ssh. Those are the 4 files :
- ssh_host_dsa
- ssh_host_dsa.pub
- ssh_host_rsa
- ssh_host_rsa.pub
Should they not to be there, you can still generate by issuing the following command : /lib/svc/method/sshd -c.
Solaris 10: easily deal with removable media
Solaris provides vold (Volume Management Daemon) which lets you deal easily with removable media such as CDs and DVDs.
This tool is provided by the SUNWvolr and SUNWvolu packages. Once you have found those packages and installed them, accessing to your removable medias becomes a bliss : All you have to do is insert your media, and go in the configured directory (ex : /cdrom).
Solaris 10 : great doc about package management
I stumbled on the Solaris 10 training & tutorials and it holds a really nice doc about package management in Sun Solaris 10, broken in 2 parts :
- Performing Solaris 10 OS Package Administration (part1)
- Performing Solaris 10 OS Package Administration (part2)
Amongst all the information, I was especially interested in those which I always forget like how to check package installation integrity (or how to know if files have been tampered with since it was installed) with pkgchk PACKAGE_NAME (eg : pkgchk SUNWcsu) or how to check integrity of a file with pkgchk -p /path/to/file (you’ll get extra information such as which package it was installed from by adding the -l flag).
Solaris 10: On which CD is that XYZ package ?
If you want to know on which CD is a package, without :
- Mounting CD
- Searching
- Unmounting
- Swear and
- Go back to 1
Then you can :
- Mount CD #1 (mount -F hsfs /dev/dsk/
/mnt or, if you have automount cd /cdrom/cdrom0 or something like that) - Go in the Solaris_10/Product directory of the CD
- Do grep -l
.virtual_packagetoc_* which will output the .virtual_packagetoc_N where N is the number of the CD holding that package.
Exemple :
Zsh is cool : brace expansion
Quoting the zshexpn man page :
An expression of the form {n1..n2}, where n1 and n2 are integers, is expanded to every number between n1 and n2, inclusive. If either number begins with a zero, all the resulting numbers will be padded with leading zeroes to that minimum width. If the numbers are in decreasing order the resulting sequence will also be in decreasing order.
Check out this :
spaghetti% for i in {8..11}; do echo $i; done<br /> 8<br /> 9<br /> 10<br /> 11<br /> spaghetti%
ZFS = zpools + zfs filesystems : concepts of a killer filesystem
ZFS, Sun’s latest filesystem, got a well deserved fame because of it’s ease of use and powerful features.
The ZFS community at the OpenSolaris.org website provides a great introduction to Sun’s ZFS.
Those of you who have actually already setup a software RAID with Solstice DiskSuite will truly appreciate how much simpler Sun made it with ZFS. The concepts of volume management and filesystems behind ZFS are not new, but Sun brought an unprecedented ease of use administration to those.
To understand Sun’s ZFS philosophy, you have to understand that it is built over two concepts : pools and filesystems. Let’s see what they are.
Apache : using SSI
“Server Side Includes” (SSI for short) are a mechanism which will let you have Apache pre-process html pages before sending them to the browser.
OpenBSD : 4.1 is out !
As stated in the mailing list, the twice a year release of OpenBSD went out today ! Follow the link below for the full announce.
‘OpenBSD 4.1 Released’ – MARC
May 1, 2007. We are pleased to announce the official release of OpenBSD 4.1. This is our 21st release on CD-ROM (and 22nd via FTP). We remain proud of OpenBSD’s record of ten years with only two remote holes in the default install. As in our previous releases, 4.1 provides significant improvements, including new features, in nearly all areas of the system: […]
CFEngine – Installing on Debian GNU/Linux
In this post we’ll install CFEngine on a Debian system. Debian make is really simple to install any packages, so let’s follow the “standard” package installation procedure (I’ll assume that apt is correctly setup on your system ! If you have troubles with it, let me know, I’ll write a post on this topic).
CFEngine – What is it ?
CFEngine is a configuration management engine. I’m going to write a series of short posts as I’m going to use CFEngine in a current project. Let’s start with a short description of CFEngine purpose and main features.
OpenBSD : Using spamd to avoid spam (and hurt spammers)
Linux.com runs a good introduction to spamd, the spam fighting daemon which ships by default with OpenBSD.
X11: Exporting a display
How can I make my X11 display go to another machine ?
Oh well, something everyone should know, but sometimes you have surprises !
Instructions follow …
Damn Small Linux : Linux on the run
Damn Small Linux (DSL) is a Linux distribution with full blown graphical user interface, which was first designed to be small enough to fit on a business card sized CD-ROM (50MB). It still does, but it does much more !
Active Directory : User account repeatedly locked for no reason ?
There are few situations that can lead to a user account being locked out in an Active Directory environment. The following two situations are worth mentionning, because at first sight, it might have seemed like the user account was locked out “for no reason”.
Windows : Clear saved Windows networking passwords
If you sometimes access a network share and check that “remember password” box, then you might have wondered how to delete that password as well.
James Geurts gives us the trick
NetApp : SNMP request timeout ?
If you try to make an SNMP request and get a time out like this :
% snmpwalk -v 1 -c public netapp-name<br /> Timeout: No Response from netapp-name<br />
Check that SNMP is enabled (options snmp.enable) and that your host is allowed to perform SNMP queries to the netapp (options snmp.access).
By the way, do use -v 1 ( protocol version 1) : I had timeouts while using -v 2c as well…
Debian network configuration
Network configuration, on a Debian System, is stored in /etc/network.
In this directory you’ll find :
- interfaces : this file describe your NICs according to interfaces(5) (check this man page to see how to setup the interface, fixed IP or DHCP, gateway, netmask, and so on)
- if-pre-up.d : directory with scripts which will get run before bringing up an interface
- if-up.d : directory with scripts which will get run right after bringing up an interface
- if-down.d : directory with scripts which will get run before bringing down an interface
- if-post-down.d : directory with scripts which will get run after bringing down an interface
- run/ifstate : the current state of the NICs
You’ll mostly want to tweak with the interfaces file, and probably put some scripts in the various hook directories. For example the /etc/network/if-pre-up.d is great to put the script which will setup your firewall (with iptables commands and ruleset).
Keeping track of changes with cfengine and SubVersioN
Cfengine is a tool which purpose is to describe what is a healthy system and how to bring it back to normal when something fails.
I won’t go into an explanation about how cfengine works, because the project webpage already has a neat tutorial and complete reference. Instead of that, I’ll explain how I used cfengine to build a fool proof Linux firewall.
Debian GNU/Linux : apt
Debian GNU/Linux systems come with a handy tool to manage packages : apt.
These are the commands I use the most.
Active Directory : PDC Emulator FSMO role
In an Active Directory Domain, there is a special Domain Controller which holds the FSMO Role “PDC Emulator”.
As its name suggests, it is there to ease migration from NT 4 domains to Active Directory 2000 and up domains by letting this PDC Emulator DC behave like a NT4 Primary Domain Controller. This allows to keep running NT4 BDC (Backup Domain Controllers) and NT4 Clients while you migrate core DCs to Windows 2000 and up.
Solaris 10: “logical-units” for network cards (NIC)
The “interface name” part of an ifconfig command can be a simple interface name, such as eri0, bge0 and such, or a logical unit such as eri0:1, eri0:2 and so on.
This makes it easy to setup more than 1 ip address on a network card, and hence to make virtual servers.
Solaris 10: managing services with SMF
In Solaris 10, services are managed by SMF. The scripts in /etc/rcX.d are only there for legacy (and so is inetd).
To manage the services, you mainly use 2 commands : svcadm and svcs. Below are the most useful commands.
disable services :
# svcadm disable network/finger
enable services :
# svcadm enable network/finger
list all enabled services :
# svcs
list all services:
#svcs -a
list error conditions for services:
#svcs -x
Solaris : Shared libraries search path
crle is the tool which lets you manage the way Solaris searches the shares libraries.
crle -l path1:path2:path3 will make Solaris lookup for shared libraries in path1, 2 and 3.
Beware that this replaces the previous settings !!! Easy to mess with your system…
Unix : transfering a filesystem or directory
to transfer a filesystem or directory while preserving permissions, special files and such, you can use the following :
# cd sourceDirectory
# tar cpf – . | (cd destinationDirectory && tar xpf – )
The first tar will archive the source directory and pipe it out to the second one which operates the extraction in the destination directory.
OpenBSD : Creating a transparent bridge
This post will be short, because it is actually easier than I expected … Anyway, considering my memory, better blog out that for later reference 😉
A bridge is a network device used to connect two or more network segments. You can achieve this easily on OpenBSD with the following commands :
`# echo ‘up’ > /etc/hostname.if0
echo ‘up’ > /etc/hostname.if1
echo ‘add if0 add if1 up’ > /etc/bridgename.bridge0
`
Windows XP – Disable administrative shares
Windows has a bad habit of enabling by default some shares on a new installation. These are, for example, C$, D$ (they give access to your partition roots) … ADMIN$, IPC$
Those shares are accessible by the administrators, but they could be a useless security breach.
Even worse, if you delete them, they will come back at the next start of the Server service starts…
If you wish to permanently disable them then create the following key in the registry (if it already exists, set the value to 0) :
Windows XP – Repair the boot block
if your boot block got corrupted (virus, or installation which went wrong), you may want to try to repair it by using the Recovery Console of Windows XP.
To do so, boot on the Windows XP CD and when asked, choose to repair the Windows XP installation by pushing R.
This will lead you to the Recovery Console. You will be asked for the installation to repair (ex : 1: C:\Windows), and then to enter the administrator’s password.
OpenBSD : Give money !!
not to me !! 😀
The OpenBSD project needs money to hold its events (such as hackaton, where developpers gather to implement features, or usual running costs).
If you think you don’t use OpenBSD, think again ! The project OpenSSH, which implements a free, and secure SSH implementation, comes from OpenBSD. It is widely used in many OSes and appliances …
We need OpenBSD !! Don’t hesitate to make a donation !
The original post
The OpenBSD project
The OpenSSH sister project
Proxying HTTPS throught Apache/mod_proxy
To allow a proxy to act as a tunnel for SSL connection as in HTTPS, you actually need to provide the HTTP method CONNECT. It took me some time to realize 😉
If you do this with Apache/mod_proxy, that means that you have to use the mod_proxy_connect and allow the CONNECT method.
Few pointers :
- CONNECT method
- Apache mod_proxy_connect
Add disk in an AIX machine
few useful commandes :
- lsdev : allows you to list the hardware in your machine AIX knows about. For example
lsdev -C | grep scsi
will list all the SCSI interfaces of your machine
- cfgmgr : lets you change the hardware settings. For example
cfgmgr -l scsi0
will rescan the scsi0 bus to find and configure any newly attached SCSI peripheral.
Printer Setup on a Solaris 8 Workstation
Here is a little post to give a hint about setting up a printer on a Solaris 8 Workstation :
# lpadmin -p printerName -s printServer # lpadmin -p printerName -D "Printer description text" # lpadmin -d printerName # lpstat -p printerName
and then check you can print with :
# echo test | lp
Checkout this great Solaris 8 docs repository at Sun.com.
Sun T3 StorEdge : Batteries refresh …
if you get this kind of “error” :
Dec 14 02:36:31 hostname StoreX (Dec 14, 2005 2:36:31 AM FQDN):P3:System hostname-t3 (XX.XX.XX.XX) - Unit-unit-1 - Power-Module-2 (u1pcu2) : Power supply unit has switched to battery. Fru ID: u1pcu2, Model: 300-1454-01(50), Serial Number: XXXXXX<br /> Dec 14 02:58:31 hostname StoreX (Dec 14, 2005 2:58:30 AM FQDN):P3:System hostname-t3 (XX.XX.XX.XX) - Unit-unit-1 - Power-Module-2 (u1pcu2) : The FRU has some error. Fru ID: u1pcu2, Model: 300-1454-01(50), Serial Number: XXXXX
then be aware that a T3 performs a battery refresh every so and then (this is by default every 28 days, but can be modified in /etc/schd.conf). This battery refresh can provoke this kind of error messages which are no error at all …
Sun T3 StorEdge : Identifying a failure
when logged on the T3, you can see the state of each FRU with the command
fru stat
Example :
hostname-t3:/:fru stat CTLR STATUS STATE ROLE PARTNER TEMP ------ ------- ---------- ---------- ------- ---- u1ctr ready enabled master - 32.5 DISK STATUS STATE ROLE PORT1 PORT2 TEMP VOLUME ------ ------- ---------- ---------- --------- --------- ---- ------ u1d1 ready enabled data disk ready ready 34 v0 u1d2 ready enabled data disk ready ready 30 v0 u1d3 ready enabled data disk ready ready 43 v0 u1d4 ready enabled data disk ready ready 31 v0 u1d5 ready enabled data disk ready ready 39 v0 u1d6 ready enabled data disk ready ready 31 v0 u1d7 ready enabled data disk ready ready 32 v0 u1d8 ready enabled data disk ready ready 30 v0 u1d9 ready enabled standby ready ready 31 v0 LOOP STATUS STATE MODE CABLE1 CABLE2 TEMP ------ ------- ---------- ------- --------- --------- ---- u1l1 ready enabled master - - 27.5 u1l2 ready enabled slave - - 30.0 POWER STATUS STATE SOURCE OUTPUT BATTERY TEMP FAN1 FAN2 ------ ------- --------- ------ ------ ------- ------ ------ ------ u1pcu1 ready enabled line normal normal normal normal normal u1pcu2 ready enabled line normal normal normal normal normal
Category: Podcast Notes
Tim Ferriss Show – The Random Show, Ice Cold Edition – Show notes
Those are my notes regarding the podcast episode “The Random Show, Ice Cold Edition” of the Tim Ferriss Show.
Category: Inspirations
Hopes
We must invest our hopes not in the things that happen, but in our capacities to face them as human beings
— Keith Seddon
Time wasting
One of the very worst use of time is to do something very well that need not be done at all.
— Brian Tracy
Category: Web
Facebook : How to remove an event you’ve been invited to without responding
Just because I struggle every time to find how to do that, here’s the procedure to delete an event without responding :
- Click on events
- Click on the event you want to get rid of
- In the guest list you’ll see yourself as well as your invited friends. There’s a cross beside your name. Click on it to remove yourself
BAM ! DONE !
Web server optimizations : ETAGs
This is nothing new, but just in case you missed it, Yahoo! published a fairly detailed report about how to speed up your website response times : Best Practices for Speeding Up Your Web Site.
Many of the tips are common sense, some are somehow unexpected, and some I didn’t know like the HTTP/1.1 header ETAG. Let’s see what that’s about.
Apache : Perform load tests and bench Apache
If you need to simulate a load on an Apache server (or any web server actually), you can use Apache Bench, which is included in the standard Apache HTTPd distribution. This tool will launch connections to your webserver as instructed to simulate multiple users and will help you to tune your Apache settings.
You can find the synopsis at the Apache website. Most common options are :
- -n : number of requests to perform
- -c : number of concurrent requests
Other options allow you to control precisely the request to send, proxy settings, user authentication, cookies and much more.
Find good websites through ReviewMe
ReviewMe aims at connecting advertisers and publishers (including bloggers) so that publishers will get paid to write reviews on their site about a product or a website.
As obvious as this is, it is designed so that bloggers will get money from the time they spend on their blogs and advertisers will get better quality advertisement. But if you are not interested by the financial aspect, you might still be interested in using ReviewMe to find the best blogs about the subjects you like.
Google and iGoogle : about google hype and technorati
I accessed my “Google Personnalized Homepage” today morning only to discover that the page logo now displays iGoogle instead of the classic and usual Google… I was wondering what it was, as the logo is not clickable with a link to an explanation as I hoped it would be …
WordPress plugin : tan tan noodles WordPress Reports
Tan Tan Noodles’s wordpress reports plugin has just been updated as announced on the plugin’s homepage :
Bug Fixes: WordPress Reports (0.81) : tan tan noodles – msg free since 2005
A bug fix release for the WordPress Reports plugin is now available for download.
If you are using WordPress+Google Analytics+FeedBurner then this plugin is a must : it will let you get the main reports of both statistics tools directly from you WordPress admin interface.
WordPress and AdSense: Getting money from your WordPress blog
WordPress is a great blogging platform, which will let you easily publish your blog. Now, considering the amount of time you’ll probably spend writing contents, you might want to get money from it (all work deserves money, right ? 😉 ).
I’ll show you how to do this easily, by using the advertisement program of Google : AdSense.
Scripting Twitter with Perl + LWP
A little follow up on yesterday article about scripting Twitter with cURL: the solution was working, but somehow inconvenient. Not practical to have to go and fetch the user id every time you want to send a direct message !
This time, I scripted Twitter direct message with Perl and LWP (libwww-perl), for a much more convenient solution. I designed it to be used like a sort of universal paging service.
Scripting Twitter with cURL
Twitter already provides an API but it is currently very limited. It will let you fairly easily change your status, but won’t let you send a direct message.
Comes in cURL. cURL is a very versatile command line utility which is designed to script web pages interactions. As a little demo, I’ll show you how to use it to easily overcome the shortcomings of Twitter’s API.
Twitter : Send free SMS messages to your friends
If you don’t know yet about Twitter, you might want to have a look at my previous article about it.
One of its neat features is the (previously written about) ability to send direct messages to your friends.
This feature will let you easily send free SMS from your computer to any of your friends.
Twitter : Unified messaging interface
The Several Habits of Wildly Successful Twitter Users » Slacker Manager
If you just want to send a note directly to someone, you can get them via the direct messages web interface.
Damn ! I’m a twitter user myself, but how could I have overlooked that “direct message” feature ? Now you can think of twitter as a unified messaging interface. If the personne you’re sending a message didn’t configure anything then the message will wait to be read on the website. If she configured IM and cell phone, then she’ll get it on the IM when online, on the cell phone when not. Pretty cool !
MindMeister : an online collaborative mindmap tool
MindMeister is an online mind mapping tool. Even though it is in “private beta”, it seems very promising.[
My own analysis of “FeedBurner’s View of the Feed Market”
Burning Questions • FeedBurner’s View of the Feed Market
In this article, FeedBurner gave us quite a few insights about people’s habits regarding RSS feeds. Anyone having a blog or website can use this article to be more friendly to the readers, to boost RSS feed subscription, and to help growing the revenue you get from your website.
LinkedIn – Be easy to reach
LinkedIn lets you connect to people you know. This connection is made by sending someone an email with a link to allow that connection. But how to let people connect to you, if they don’t know your email address ?
Twitter is fun !
Twitter is a website where you can post things.
Just one more blog ? Not really …
WordPress Templates
WordPress is a great blogging software, which is both feature rich and simple to use. For most beginners, it will be enough to install it and start using it. For most advanced uses and to get more control, you’ll need to tweak with the templates.
Overview
A WordPress blog is composed of the following sections :
- header : this is the top of your page (usually a banner for your blog)
- footer : this is the bottom of your page (few links, statistics, …)
- page : this is where the main content goes (posts)
- sidebar : this is the sidebar (widgets, archives, recent posts, tags…)
Altering your template
Rather unsurprisingly, altering your template can be achieved by modifying the template files corresponding to the section you want to modify.
Those files are located in your theme directory (usually something like wordpress/wp-content/themes/YOUR_THEME) and their name is the section name with an extension of “.php”. So if you want to change the sidebar, then you’ll go and edit sidebar.php.
Fun with google maps
I’ve written 2 sample applications to demonstrate how easy it is to use the API v2 of Google Maps.
I was honnestly surprised to see how easy it actually is… Have a look at the source of the pages and see for yourself 😉
Using del.icio.us as a web based inventory
del.icio.us is a website where you can store your bookmarks, tag them to easily find them afterwards, and it is social bookmarking in the sense that your bookmarks can be searched, and so are others’ bookmarks, building a kind of giant directory of humanly maintained links to the world wide web.
But you can go beyond saving your bookmarks and searching others’…
Websites with Catalyst
If you like Perl and you make dynamic websites with databases backends, Catalyst is definitely worth a look.
It is basically an MVC engine for websites. It lets you nicely separate your business logic, the display and the database backend.
It has extended plugins to deal with things like authentications, sessions, templates, RSS, and God knows what 🙂
It can integrate Apache, and harness mod_cgi’s power for high-performance web applications.
It is a little bit tricky to get it right at the beginning, but there are nice tutorials.
Category: Dev
MisterHouse : Setting up “modes”
MisterHouse is a fantastic home automation software with an impressive out-of-the-box feature set, and it only gets better if you know a bit of Perl.
You can conveniently set “modes”, which are settings with states you can define and use. You can then fire events upon state change, and so are they very useful to define some sort of macros.
A few examples :
- the “Security” mode could be “on” or “off” : setting it “on” would close the shutters and activate the alarm system; setting it “off” would do the opposite;
- the “Heating” mode could be “day”, “night”, “frost protection only” : setting it on “day” would set the target temperature to 20â°C, “night” to 15â°C and “frost protection only” to 7â°C
- the “Cinema” mode could be “on” or “off” : setting it to “on” would close the blinds and dim the lights; “off” would bring those back to their former states.
Facebook API : Exporting your friends birthdays into vCards format
The following sample Facebook desktop application exports your friends birthdays in a vCard file format. This file is suitable to be imported into your GMail contacts for example.
Perl : Counting occurences of IP addresses in Apache logs
This Perl one-liner is intended to print the 10 most frequent client IP addresses in an Apache log file. It can easily be recycled to count anything, though.
Perl+Twitter : Getting @mentions from command line
This code snippet demonstrates how easy it is to collect your twitter @mentions in Perl, coupled with curl for simplicity.
Perl : Using the Finance::Quote module to get your stock prices
Finance::Quote is a Perl module which can be used to obtain stock information from various internet sources. I thought I’d rather share this code snippet as an example showing how easy it is to use, before I turn it into a bloatware with an SQL backend to compute average price per share and what not 🙂
So here is a simple snippet demonstrating how to get the price of a stock :
D-Bus introduction in Perl
As stated in Wikipedia :
D-Bus (Desktop Bus) is a simple inter-process communication (IPC) system for software applications to communicate with one another.
This post provides a simple code snippet in Perl to help you getting started with D-Bus programming.
MySQL : binary log files
MySQL uses the so called binary log files to implement master/slaves replication.
Perl : Convert time from Epoch to local time

This little Perl one-liner can get handy when you need to translate “time in seconds since the Epoch” (for example in logs) to local time :
% perl -e 'print scalar(localtime(1202484725)), "\n";'<br /> Fri Feb 8 16:32:05 2008<br /> %
This was pretty useful today when browsing through Nagios event logs, where times are given in seconds from the Epoch.
By the way, the Epoch is defined as 00:00 UTC on January, 1st, 1970.
Perl : A module to play with a GSM mobile
As you might have read in my previous post about accessing your cell phone with the AT-commands under Linux.
If not, you might want to start there for a little context.
I finally wrote and released on CPAN a Perl module which will help to automate cell phone operations such as saving/restoring the phonebook or sending an SMS.
Examples are included in the documentation. I believe I made it easy to use, but let me know if I’m wrong 😀 .
Linux + GSM : How to access your cell phone innards with Linux
This article explores your options to access your GSM cell phone from a linux system, and manipulate SMS and phonebook entries.
Doesn’t provide hints about how to unlock a GSM cell phone though 😉
Perl : Optimizing pattern searches with Regexp::Assemble
When you perform a pattern matching with multiple “or” (|) clauses, such as /pattern1|pattern2|pattern3/, Perl regexp engine will try to match each of them one after the other in sequence, resulting in poor performance if you have a long list of “or” clauses.
In order to optimize such a pattern matching, you can use the Regexp::Assemble module.
PostgreSQL : create a user, a database and grant accesses
The following step-by-step will let you create a user, a database (DB) and grant full access to the user to this DB.
Scripting Twitter with Perl + LWP
A little follow up on yesterday article about scripting Twitter with cURL: the solution was working, but somehow inconvenient. Not practical to have to go and fetch the user id every time you want to send a direct message !
This time, I scripted Twitter direct message with Perl and LWP (libwww-perl), for a much more convenient solution. I designed it to be used like a sort of universal paging service.
Scripting Twitter with cURL
Twitter already provides an API but it is currently very limited. It will let you fairly easily change your status, but won’t let you send a direct message.
Comes in cURL. cURL is a very versatile command line utility which is designed to script web pages interactions. As a little demo, I’ll show you how to use it to easily overcome the shortcomings of Twitter’s API.
Dump an entire SubVersioN repository into a flat file
There are many reasons you might want to dump your SVN repository to a flat file : for example to simplify backup operation, to transfer to another server, or to convert your repository from FSFS to BDB or the opposite.
Fun with google maps
I’ve written 2 sample applications to demonstrate how easy it is to use the API v2 of Google Maps.
I was honnestly surprised to see how easy it actually is… Have a look at the source of the pages and see for yourself 😉
DocBook
Bored of fighting with MS-Word to have proper titles numbering ? Tired of messing around styles ? Want a more “meaning oriented formating” and less “aesthetic oriented formating” ? Would like to generate HTML, PDF, WindowsHelp, or anything from the same source file ?
Have a look at DocBook ! DocBook is a document standard which lets you do all of this, and much more …
And XMLMind XML Editor is a nice free (like beer not ideas) editor which lets you edit DocBook Documents in a WYSIWYG fashion.
Websites with Catalyst
If you like Perl and you make dynamic websites with databases backends, Catalyst is definitely worth a look.
It is basically an MVC engine for websites. It lets you nicely separate your business logic, the display and the database backend.
It has extended plugins to deal with things like authentications, sessions, templates, RSS, and God knows what 🙂
It can integrate Apache, and harness mod_cgi’s power for high-performance web applications.
It is a little bit tricky to get it right at the beginning, but there are nice tutorials.
Deploying Perl apps
I usually code my perl programs on a development machine, and then ty to make in run in the production environment.
I used to manage by myself the various needed packages and tried to have them installed on the production environment as needed.
And one day I had to make a script run on a machine where Perl itself was not even installed…
This has been a nightmare until recently, that is to say until I discovered the PAR module. PAR is closed to the Java JAR files.
Character conversions in Perl
If you want to convert strings from, say, UTF-8 to Latin1, then you can do this as simply as this :
use Unicode::String qw(utf8);
print utf8(“string in utf-8”)->latin1
Easy ? 😀
Coding a Jabber Bot in Perl
I finally got it to work and it is not so difficult with the right packages (Net::XMPP) and parameters …
#! /usr/bin/perl</code>
use strict;
use warnings;
use Net::XMPP;
#################
# Config params #
#################
my $hostName = 'jaim.at';
my $portNumber = 5222;
my $componentName = 'jaim.at';
my $userName = 'totosk1008';
my $passWord = 'totosk1008';
my $resource = 'NiceLittleBot';
my $tls = 0;
my $connectionType = 'tcpip';
my $debugLevel = 0;
# Create the client
my $bot = new Net::XMPP::Client(debuglevel => $debugLevel);
$bot->SetCallBacks(
onconnect => &connectedCB, # gets called when connected
onauth => &authedCB, # when authenticated
ondisconnect => &disconnectedCB, # when disconnected
);
$bot->SetMessageCallBacks( # callback for messages
chat => &messageCB, # chat-type messages
);
$bot->Execute( # entering the main loop
hostname => $hostName,
port => $portNumber,
tls => $tls,
username => $userName,
password => $passWord,
resource => $resource,
register => 0,
connectiontype => $connectionType,
);
##############
# Callbacks #
##############
sub messageCB { # call back implementing the echo
my $sid = shift;
my $msg = shift;
my $from = $msg->GetFrom;
my $to = $msg->GetTo;
my $name;
my $data;
print "From : ", $from, "\n",
"Subject : ", $msg->GetSubject, "\n",
$msg->GetBody, "\n";
$name = $msg->GetBody;
$data = $msg->GetBody;
print ">>$name<<\n";
print $data, "\n";
$bot->MessageSend(
to => $from,
from => $to,
resource => 'Gaim',
type => $msg->GetType,
subject => $msg->GetSubject,
body => $data,
);
}
sub connectedCB {
print "Connected\n";
}
sub authedCB {
print "Authed\n";
$bot->PresenceSend;
}
sub disconnectedCB {
print "Disconnected\n";
}
me <- proud ! ;-)
I finally finished it (though I expect to have to make some changes in the future …) :
Now I can setup my home automation events in MisterHouse throught my Mozilla Calendar ! The code has been submited and accepted for being integrated in MisterHouse and will be in the next release 🙂
Code is here.
Parsing an ICal file with Perl
I finally almost got it …
Here is a code snippet for parsing and showing pieces of an ICal file :
use strict; use warnings; use Data::ICal; use Data::ICal::DateTime; use DateTime; my $cal = Data::ICal->new(filename => 'holidays.ics'); my @events = $cal->events(); foreach my $event (@events) { print "summary:", $event->property('summary')->[0]->value, "n"; print "dtstart:", $event->start, "n"; print "dtend:", $event->end, "n"; } print DateTime->now, "n";
What I want to do ? Drive my home automation events with my Mozilla Calendar !! I’ll soon be there, if I gather enough time to do it !
Category: Networks
Gentoo + OpenVPN : getting things started in the correct order
I’m running an OpenVPN server, configured in bridging mode.
I had quite a bit of trouble getting OpenVPN to start after networking is up, but before the the bridge is setup so that the tap0 device, which is created by OpenVPN can be added to the bridge.
The solution is simpler : let the tap0 be automatically created and added to the bridge by Gentoo Linux, then start OpenVPN with a config file instructing to use the already created tap0 device.
This post shows the configuration snippets to get things started in the right order on Gentoo.
Linux : Configuring a network bridge for your Virtual Machines
My new center of interest those days being virtualization, I tried quite a few software starting with Xen, then QEMU, then KVM, and finally VirtualBox. But as far as giving a network access to the VM is concerned, I’ve always sticked to a network bridge for the reason that this makes the VM appear on the network just like any other computer of your network.
This post provided a sample script to setup a bridge suitable to use with all of the named virtualization softwares.
VLAN + OpenBSD : a simple configuration
This posts gives a short intro about VLAN and a simple configuration sample on a DELL PowerConnect 5224 switch with an OpenBSD machine.
Dell PowerConnect switches – Password recovery procedure
If you are looking for a procedure to reset the password of a Dell PowerConnect switch, you’ll find it at the Dell support forum in the following thread : PowerConnect Password Recovery Procedure for managed switches.
As far as the 5224 is concerned, you mostly have to hold Ctrl-F from the power-on till the end of the boot of the switch, which will bring the “reset to factory ?” question and solve the problem of the lost password.
Debian : update a dynamic DNS
A bit of context : I have a bind 9 DNS allowing DNS updates from clients on the LAN (ok this is fairly insecure, but still my LAN is my home LAN composed of 4 machines … let’s say that’s good enough for me ! 🙂 )
The named.conf allows those updates with this config directive in the zone config block :
allow-update {mynet; };<br />
and mynet is defined an acl directive to be my LAN.
Multicast : Listing group memberships
Windows XP
To see multicast group memberships in Windows XP, you can use netsh :
U:>netsh interface ip show joins Interface Addr Multicast Group --------------- --------------- 192.168.139.1 224.0.0.1 192.168.137.1 224.0.0.1 192.168.136.1 224.0.0.1
Solaris (and probably other Unixen as well)
In Solaris, the netstat command can be used :
$ netstat -g Group Memberships: IPv4 Interface Group RefCnt --------- -------------------- ------ lo0 224.0.0.1 1 eri0 224.0.0.1 1 $
Solaris 10: “logical-units” for network cards (NIC)
The “interface name” part of an ifconfig command can be a simple interface name, such as eri0, bge0 and such, or a logical unit such as eri0:1, eri0:2 and so on.
This makes it easy to setup more than 1 ip address on a network card, and hence to make virtual servers.
OpenBSD : Creating a transparent bridge
This post will be short, because it is actually easier than I expected … Anyway, considering my memory, better blog out that for later reference 😉
A bridge is a network device used to connect two or more network segments. You can achieve this easily on OpenBSD with the following commands :
`# echo ‘up’ > /etc/hostname.if0
echo ‘up’ > /etc/hostname.if1
echo ‘add if0 add if1 up’ > /etc/bridgename.bridge0
`
Estimating network throughput / bandwidth / performance with FTP
On a Unix machine, you can use this little ftp trick to have an idea of your throughput :
ftp somehost
ftp> put “| dd if=/dev/zero bs=100000 count=100” /dev/null
200 PORT command successful.
150 ASCII data connection for /dev/null (192.168.0.1,32953).
100+0 records in
100+0 records out
226 Transfer complete.
local: | dd if=/dev/zero bs=100000 count=100 remote: /dev/null
10000000 bytes sent in 2.9 seconds (3388.52 Kbytes/s)
This will generate a stream of bytes from one host to another and give you the data rate at the end
Proxying HTTPS throught Apache/mod_proxy
To allow a proxy to act as a tunnel for SSL connection as in HTTPS, you actually need to provide the HTTP method CONNECT. It took me some time to realize 😉
If you do this with Apache/mod_proxy, that means that you have to use the mod_proxy_connect and allow the CONNECT method.
Few pointers :
- CONNECT method
- Apache mod_proxy_connect
Category: IT
Monitoring batches in IT environment : efficiently using emails
Sometimes automatically running scripts in production environments are simply monitored by emails. Those scripts may run on schedule or be triggered by events and they send an email (for example to the technical support level 1) upon completion of the job. The content of the email will then give information about the outcome of the execution of the script.
This posts lists a few ideas that you might find useful to implement when in such an environment.
Category: ThisBlog
WordPress : Error while auto-saving, saving, commenting
If you got the following error in WordPress when saving, auto-saving, or commenting on a post :
Warning: fsockopen() [function.fsockopen]: unable to connect to submissions.ask.com:80 in /path/to/blog/wp-includes/class-snoopy.php on line 1150
then keep reading 😉
WordPress : Delayed posts
A cool feature of WordPress I’ve just discovered : delayed posts.
Upgrading to WordPress 2.5
As you might have noticed, WordPress 2.5 is out, so I’ve just upgraded this blog.
Till now all I can tell is that the admin interface has changed a bit. Oh and there is a system to upgrade plugins with one click, which is way cool. Otherwise pretty much the same good old WordPress.
The upgrade went smoothly, just as for any other previous release and everything seems to be running just fine. However, at the first glance, the blog seems a bit slower than before the upgrade … (maybe this is not related to the upgrade … I’ll have to check this out).
Speedlinking : A few blogs I am a fan of
It is high time I give out a bit of link love for those blogs I always rush to when there’s a new post !
In no particular order !
- Lifehacker : Software reviews, tips, and every hack you need to enhance your productivity
- l’Oeil du web : (In French) Half technical, half fun blog of a friend who moved to the south of France
- Aashiyana – Santanu and Pamela : Life, travels, civilization blog of a friend couple who moved back to India
- Terminally Incoherent : Rants and comments, technical stuff, reviews
- My SysAd Blog — UNIX : Tips about OpenSolaris
- Get Rich Slowly : Financial tips for everyday life
- Wise Bread : Financial tips, getting the most of your money
- Ririan Project : Everyday life tips
- OpenBSD Journal : Official news for the OpenBSD “free as air” Unix system.
- OSNews : News about the world of operating systems
Hmm, that’s it for now ! This post to be a “thank you” for all the authors behind those blogs who write great posts and, well, ruin my productivity 😉
New theme up to speed !
Wow, this was a big work : I moved to a new WordPress theme with 3 columns which is, I hope, much more readable.
I quite enjoy the result, and I learnt a bit about AdSense, SEO, CSS and WordPress on the way so all in all, I would say this was worth all the efforts and the time I’ve put in this.
Let me know what you think about the new theme, and if you see more ways to improve it !
Here are the most important things to remember.
Collection pages
In case you read this blog only through the RSS feeds, you might not have noticed the few new pages on the left hand menu bar. Those pages are dynamically generated by pulling the RSS feed of my del.icio.us bookmarks for specific tag combinations (like wordpress+plugin+must).
Feel free to have a look from time to time, to check for modifications !
For now, you’ll find :
- a book list
- a list of my most used Firefox plugins
- a list of y favorite free (like beer) softwares
- and my favorite wordpress plugins
And in case you wonder, those pages are generated thanks to the wonderful inlineRSS wordpress plugin, which makes pulling RSS feeds from your blog damn easy.
About
My name is Stéphane Kattoor.
I live in France near Paris.
I work as a Systems Engineer and I am a computer hobbyist.
My main interests are around open source, operating systems (mostly Unix but Windows as well), coding (mostly in Perl these days), home automation, and many other things …
This site is a placeholder for things I learn/discover during my work or hobbies and I consider (hopefully) worth sharing.
First post !
Hello,
My name is Stephane Kattoor, I work as an IT Engineer, and I created this blog with the idea to use it to store the little technical tips or hints I find in my every day work … with the hope it will help me and perhaps some others as well !
Come from time to time, I plan to keep it updated !
Stephane
Category: Misc
RIP Randy Pausch
I barely knew the guy but the news that he passed away is all around the blogoshpere. If you have 76 minutes to spare, have a look at his Last Lecture at the Carnegie Mellon University, it’s really worth it (I won’t comment on it since it is already widely commented everywhere else). Man, I wish I had this kind of teacher; he seemed to have been the kind of life changing one !
Category: Movies
Movie Review : “Outsourced”, 2007
I don’t usually comment movies on my blog because this is really not the point, but I’ve just seen “Outsourced
” and it literally cracked me up, so I decided to make a short exception 😉 (Besides I’ve already thought of a good excuse you’ll find out later in this post)
Category: Uncategorized
How likely was that ?!
Having a look at Twitter… oh ! someone added me as a friend … who is he ? no idea … but he has like 467 “friends”… so I guess he’s adding pretty much anyone.
Looking at his “friends” I notice this LvP whose face looked familiar. Following the bread crumbs (LvP’s blog), it turns out that I really know him ! OK, more like “I once knew him”, since I sort of worked with him like 3 months, 7 years ago.
Category: ITIL
ITIL: What is the CAB ?
ITIL Methodology advises that every RFC (Request For Change) be run through the CAB (Change Advisory Board).
What’s that all about, and why ? Read on !
ITIL : What is a CMDB ?
The ITIL (IT Infrastructure Library) Methodology advocates the use of a Configuration Management DataBase or CMDB for short.
But what is a CMDB ?
Category: Books
Book review : “Programming Perl” by Larry Wall, Tom Christiansen, Jon Orwant
For those of you who are not familiar with my blog, my favorite language is Perl. “Programming Perl” (aka “the Camel Book”) is probably the most used / most useful reference book about this Perl.
Book review : “Mind Performance Hacks”, Ron Hale-Evans, O’Reilly
Mind Performance Hacks is a sort of “self improvement guide”. It offers 75 hacks which will hopefully help you think better, remember better, be more creative … be more mentally efficient generally speaking.