Number to Word
Filed in Fun, March 11, 2010, 10:55 pm10 = deca
100 = hecto
1,000 = kilo
1,000,000 = mega
1,000,000,000 = giga
1,000,000,000,000 = tera
1,000,000,000,000,000 = peta
1,000,000,000,000,000,000 = exa
1,000,000,000,000,000,000,000 = zetta
1,000,000,000,000,000,000,000,000 = yotta
Disable Bell in VIM
Filed in Linux, Programming, March 9, 2010, 10:22 am" Disable both beep and visual flash set visualbell t_vb=
Nothing Could Fail in C
Filed in Programming, January 27, 2010, 3:50 amBest comment of the C programming language ever!
via:reddit
Here is the whole story:
Going back to C
by buddhabrotWhen I was 12 someone gave me a Metrowerks IDE to learn programming on my mac. I learned a lot with it, and got programming in C. I never really wrote a large program in it, only things like ROM hacks that extracted levels and models from snes/psx games I liked. Later, I got a windows PC and messed around with MFC in C++. That was the end for me, programming UI’s was too much work in C++ and I couldn’t handle the encyclopedic knowledge needed to program the Microsoft framework.
Later, I learned Java, which was also the language most commonly in my college. Making UI’s was a blast with it, I could factorize anything and really loved making as generic code as possible with it, even for small projects. Everything I made was made in Java.
Later in uni, I started learning functional languages, we used Haskell in one class. I got intrigued with Haskell and started solving Euler problems, up to this day I still have not written anything useful in Haskell but I love using it.
In the mean time I did some jobs for writing web sites. I used perl and php. After a while I only used php and used it more frequently.
After working for a while as a programmer I started to love higher-level languages, most of all Ruby. I became convinced that higher-level interpreted languages were the future because the slower execution times were to become meaningless. For any web projects I started using Ruby on Rails and to this day it still is my favourite framework.
Then, I learned Erlang because everyone was talking about it, and it showed me how to unleash parallellization, in whole new ways. I still think Erlang is the most amazing language I have ever seen. But then I found out it was also rather slow for the things I had in mind with it. I just didn’t find any use for it and never completely learned the language.
Last week I wanted to make a big poster of a fractal. I wanted to compute it on a friend’s octocore, and write a fast parallellized program. At first, I used Ruby, thinking it would perform better than I thought. And I quickly abandoned the idea because it was too slow.
Then I rewrote the same single-threaded algorithm in Haskell and saw that it was much, much quicker. But when I tried to parallallize it, I couldn’t fathom how to do it in Haskell and abandoned the idea. I tried to write a parallellized version in Erlang, and while it spreak across the machine nicely, each individual process was way too slow, the parallellized algorithm was hundreds of times slower than the single-threaded haskell.
Because I really wanted that poster, I decided to switch to C because I had this idea that nothing could fail in C. And I started to code in a language I hadn’t used for years, even a decade. And suddenly it hit me, everything made sense. Sure, I was writing so much boilerplate but it didn’t bother me. I suddenly realized that everything I wrote would be inside the program’s code, and that nothing more would. It was a great feeling.
I used simple pthreads to do the parallellization, and I used libgd to output my data to a png file. I started learning about mutex lock hierarchies to make the parallellizations overlap without endangering thread safety, it was all ugly code and the API’s felt horrible compared to what I was used to.. but it all worked out. The resulting program was thousands of times faster than anything I had written.And now, I am seriously wondering where I have been all this time. Sure, I still think C is incredibly clunky. But now I got the dust off of my old course on writing compilers (Modern compiler implementation in C), and I want to write a compiler in C for a small programming language. I want to get down to earth again, and write things that are efficient and just run very quickly. I want to write lots and lots of code and know exactly what every line does.
Has anyone else had this feeling, this evolution? Am I going mad? Do you think C will last, and there are intersting jobs left for pure C developers?
I have the same question: Are there intersting jobs left for pure C developers?
“–” (Double-hyphen) in Bash
Filed in Notes, Programming, November 24, 2009, 2:09 pm
$cat out
if [ $# -eq 0 ]
then
echo "Usage: out [-v] filenames..." 1>&2
exit 1
fi
if [ "$1" = "-v" ]
then
shift
less -- "$@"
else
cat -- "$@"
fi
In out the
--arguments to cat and less tells these utilities that no more options follow on the command line and not to consider leading hyphen (-) in the following list as indicating options. Thus--allows you to view a file with a name that starts with a hyphen…--argument works with all Linux utilities that use the getopts builtin… This argument is particularly useful when used in conjunction with rm to remove a file whose name starts with a hyphen (rm -- -fname)…
A Practical Guide to Linux Commands, Editors and Shell Programming (p. 442)
Handle Filenames with Spaces Properly in Bash Loops
Filed in Programming, , 5:44 am
find ~ -name '* *' | while read FILE
do
echo "$FILE rocks."
done
via Handling Filenames with Spaces in Bash