RSS

Category Archives: Linux

GNU/Linux command line tip of the day: sum of numbers in a column


More often than not, I need to quickly need to see the sum of a column of numbers when I’m doing some processing on the GNU/Linux command line. For the sake of simplicity, let’s assume that you have the following output from some command line pipe:
Read the rest of this entry »

 
1 Comment

Posted by on May 28, 2013 in awk, Linux

 

Tags: , , , , ,

How to solve the ugly font problem of Java applications in Ubuntu 12.10


Upgrading from a few years old Ubuntu GNU/Linux version to the latest Ubuntu 12.10 might hurt your eyes… that is, if you happen to code in Java, develop Swing applications, or sometimes prefer IDEs such as NetBeans to Emacs. Somehow upgrading to the latest version of Ubuntu creates a problem with fonts and in many Java applications you see very ugly, bold fonts in menus, tree labels, etc.

This has been confirmed as a bug, and you can read more details at https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/937200 or https://netbeans.org/bugzilla/show_bug.cgi?id=221778

Apparently this bug seems to be somehow related to Wine and a font package. The solution that worked for me was simply to issue the following command:

    sudo apt-get remove fonts-unfonts-core

Well, I did not need Korean TrueType fonts anyway.

 

 
2 Comments

Posted by on February 27, 2013 in java, Linux

 

Tags: , , , , ,

How to solve the ‘suspend does not work when laptop lid is closed’ problem in Ubuntu 12.10


I have recently upgraded my ThinkPad T500′s operating system to Ubuntu 12.10 and everything went very smooth except an annoying issue: the suspend functionality was not activated when I closed the laptop lid. Running pm-suspend from the command line, clicking on the Suspend from the GUI, or using the Fn+F4 key combination was working and my laptop was going into the sleep mode but somehow closing the lid was not achieving the same effect.

A quick Google search turned this bug report: https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/863834 and a simple work around: https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/863834/comments/30

So I have decided to implement a similar workaround, but instead of using pm-suspend, I preferred to use dbus-send to invoke the sleep mode (see http://ubuntuforums.org/showpost.php?p=11331634&postcount=6 for more details):

 
Leave a comment

Posted by on February 26, 2013 in Linux

 

Tags: , , ,

Variation on a theme: which Java thread consumes the most of your CPU?


Tomasz Nurkiewicz wrote a nice blog entry (“Which Java thread consumes my CPU?“) in which he shows a simple method that relies on standard GNU/Linux command-line tools to gather information about the Java threads that keep your CPU very busy.

I wondered whether it would be possible to make it slightly simpler by removing some dependencies and regular expressions and came up with the following Bash shell script:

Read the rest of this entry »

 
3 Comments

Posted by on August 28, 2012 in java, Linux, Programlama

 

Tags: , , , ,

baudline: How to solve the "all input devices disabled" error on Ubuntu GNU/Linux


Baudline is a time-frequency browser designed for scientific visualization of the spectral domain. Signal analysis is performed by Fourier, correlation, and raster transforms that create colorful spectrograms with vibrant detail. Conduct test and measurement experiments with the built in function generator, or play back audio files with a multitude of effects and filters. The baudline signal analyzer combines fast digital signal processing, versatile high speed displays, and continuous capture tools for hunting down and studying elusive signal characteristics.”

Baudline

Baudline

Unfortunately when I tried to run this interesting signal analysis program on my ThinkPad running Ubuntu GNU/Linux (11.04), it gave the famous “all input devices disabled” error on its main screen. The FAQ on its website did not help, so after a bit of tinkering I found a solution:

aptitude install alsa-oss

Installing ALSA wrapper for OSS applications seems to solve the problem by letting you run program as:

aoss ./baudline

Thanks to this tiny utility I can continue exploring baudline and analysing mystery signals. ;-)

 
4 Comments

Posted by on March 20, 2012 in Linux

 

Language detection in the Bash command line using gzip (aka Comprehension is compression)


Is it possible to write a simple command line to detect whether a given piece of text belongs to English, German, or some other natural language? Using nothing but the gzip and a few other traditional GNU/Linux utilities? Let’s give it a try!

First lets create two test files, namely some_en.txt and some_de.txt, and store some English and German texts in them respectively:

Then let’s retrieve some English and German corpus from the Gutenberg Project, and rename them as EN and DE respectively:

And now is the time for magic, natural language processing magic. Let’s build our command line for some_en.txt:

which results in EN, the correct answer. And let’s try the similar command line for some_de.txt:

which returns DE, proving that this command line worked correctly for two examples.
Read the rest of this entry »

 
Leave a comment

Posted by on December 19, 2011 in General, Linux, Programlama

 

Tags:

A Bash quirk on `time’ and thoughts of a programmer on its semantics


Here’s a short puzzler for GNU/Linux command line nerds:

Why, indeed? To clarify things a little bit: time is a reserved keyword in Bash and unless you explicitly call the /usr/bin/time program, Bash will execute its internal timing command (see http://www.gnu.org/s/bash/manual/html_node/Pipelines.html#Pipelines, http://linux.die.net/man/1/time, and http://www.gnu.org/s/bash/manual/html_node/Shell-Builtin-Commands.html#Shell-Builtin-Commands). Well, at least that was what I thought until I encountered the example above some time ago, when I was trying to accomplish something on the command line.

Apparently, if the time is not the first token on the command line then the built-in timing function of Bash is not executed. So if you want to change the collation as well as use the built-in timing function you have to do the following:

Another question that comes to mind: Does changing LC_COLLATE lead to some special execution environment? Does it change how Bash interprets its reserved keywords and built-ins? Well, to examine another example, take this: help is also a Bash built-in, but if you go and create a dummy /usr/bin/help and then try to run (e.g. in your home directory) LC_ALL=C help alias, you are going to see that Bash executes the built-in help and does not try to run the program in /usr/bin/*.

It seems like the time built-in has a very special situation and this creates a quirk in Bash semantics. This is not somehing that will bite you regularly, but if you thing Bash as a programming language and the command line as its REPL (Read-Eval-Print-Loop) environment (such as the REPLs for Lisp, Ruby, Python, Scala, etc.), then such inconsistencies in the semantics of a programming environment can be pretty surprising and sometimes even annoying.

*: Thanks to Debian developer Recai Oktaş for this example test.

 
Leave a comment

Posted by on December 18, 2011 in Linux, Programlama, sysadmin

 

The Architecture of Open Source Applications: A gem that belongs to every serious developer's library


The Architecture of Open Source Applications

The Architecture of Open Source Applications


The Architecture of Open Source Applications is not a typical software development book but rather a wonderful collection of essays from the veterans. The editors did a great job by providing such a wide spectrum of programs and authors. From database systems to visualization toolkits, from mail transfer agents to multi-player online games, from continuous integration systems to cutting-edge web applications and then to audio processing systems, you’ll find experienced developers talking about the internals of their well-established code bases, used by millions of people and developers worldwide.

Some of the authors have been working on the same system for more than 30 years (e.g. Eric Allman on Sendmail) and it is definitely a pleasure to hear their perspectives spanning such a long time period. Every chapter provides a brief overview of the relevant software and then the authors try to justify the choices they made, sometimes stating their regrets with reasons and sometimes reflecting on how their intuitive decisions turned out to be great strategic advantages in the long run. In some chapters such as the one by Audrey Tang (SocialCalc), you’ll learn how it becomes possible to work together for a geographically distributed team of developers and what made Tang’s job easy when she joined the team one year after the initiation of project (hint: a well-prepared Wiki becomes much more important than you can imagine).

I think this book belongs to every developer’s library to be read and re-read. Time-honored lessons when told by insiders with the help of great editors provide us with an immense value in terms of technology, craftsmanship and community.

 
2 Comments

Posted by on August 4, 2011 in Erlang, Linux, Programlama

 

On entropy and GNU/Linux


A.Kadir Altan’s blog entry on erasing disks by supplying random data (in Turkish, here’s an automatic translation into English) refreshed my curiosity about the hardware number generators on PCs, especially the ones on ThinkPad laptops and a short search led to the following links. I just wanted to note them down so that I can refer to them in the future:

 
Leave a comment

Posted by on July 26, 2011 in Linux, security, sysadmin

 

How to compile sndpeek on Ubuntu GNU/Linux


sndpeek is a very nice cross-platform real-time sound analysis and visualization utility. Unfortunately the latest version (1.3 as of this writing) is not available from official Ubuntu repositories, so I could not install it quickly on my Ubuntu GNU/Linux 11.04 running laptop for my sound processing experiments. And compiling it from the source turned out to be rather tricky. Thus, for all the poor souls struggling out there, here’s how I solved it:
Read the rest of this entry »

 
4 Comments

Posted by on July 10, 2011 in Linux

 

Tags:

 
Follow

Get every new post delivered to your Inbox.

Join 53 other followers