RubyGuides
Share this post!

All posts by Jesus Castello

Clearing your terminal, the elegant way.

You may think this is a trivial issue, but it still hurts my eyes every time I see someone (youtube video or w/e) type ‘clear’ to clear the screen. When there is a faster and more elegant way: CTRL + L

This is possible thanks to the readline library which is also used by other command line tools like the mysql client.

Dynamic Arrays in C – part 2

In the first part we left off laying the foundations for our dynamic array. Now it’s time to test it, this is the code responsible for that:

Continue reading

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:

locked
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

1 16 17 18 19 20 23