Share this post!

All posts by Jesus Castello

Dynamic Arrays in C – part 1

While working on my C programming skills I wrote a small program to simulate the functionality of dynamic arrays on other languages. That is arrays that grow as you add elements to them instead of having a fixed size. I decided that is has to be reusable and that you should be able to have multiple instances of them, so I structured my code with that in mind.

So this is the file structure:

  • main.c – initialize the array and fill it for testing purposes
  • array.h – function declarations
  • array.c – function definitons

Continue reading

Troubleshooting with lsof

Lsof is a standard Linux utility that can help you troubleshoot a range of issues related to open files. If you run it without any options it will display ALL the open files in the system, which might be a bit overwhelming.

Fortunately you can use the -p <pid> option to see all the files opened by a specific process. Another useful way to call lsof is by passing in a file name as argument, this way lsof will show you the process that has this file open.

Using lsof, an example

Have you ever been in a situation were you couldn’t do something because you got a “Resource temporarily unavailable” error or something like that? Well this is the kind of thing lsof can help you with. Let’s see an example:

Continue reading

Sorting Java Collections

Java collections are most of the data structures that come with the language. They share the same basics methods thanks to the collection interface. One of the most common things you may want to do with a collection, besides adding and removing elements, is sorting them.

Let’s see an example with ArrayList
Continue reading

Column formatting

Here is a quick tip on how to make the output of some tools prettier, for example we can use the mount command which by default looks like this:

Using the column command with the -t option we can apply some formatting so it is more readable:

Much better, isn’t it? Man page for the column command:

PHP Arrays

This is an introduction to PHP arrays, so if you are new to the language or you just need a refresher you can get up to speed pretty fast.

This is how we initialize an empty array and add some elements to it:

Then we can see it’s contents using the print_r() function. You may want to put this between <pre> tags for better formatting.
Continue reading

1 17 18 19 20 21 24