Posts Tagged Linux

Ubuntu VS OS X

A few months back I wrote a post that had quite a few reactions, speculating on why open source developers run OS X.

Recently I have been using the newest Macbook Pro 15″, and I thought I would update my direct experience on how Ubuntu and OS X stack up.

Web Browsing
On both platforms Chrome, in my view, is the defacto standard for nerds and an ever increasing porportion of the general population. Having used Safari for the first month to try ‘the apple way’, I can say that Chrome feels faster, has better features, and was just really well thought out. Both platforms are a wash on this one.

Flash Plugin
This one is also a wash, both platforms have support for flash — I actually think Ubuntu has an edge here since Flash can be installed via the package manager, instead of an entirely separate installer in OS X.

Text Editing
Textmate is a very cool application, with tons of pre-defined bundles that allow for quick completion, and a great project view.  However for Java development, it seems that IDE autocompletion / debugger integration is hard to beat (Eclipse / Netbeans work on both platforms), while for Python / Ruby etc Vim was a better fit for both platforms, as an advanced user.  Definitely a great entry level editor that is an inbetween for Gedit / Vim.

Terminals
I think here gnome-terminal blows away terminal.app — gnome-terminal is noticeably faster and the design was clearly by people using the terminal day in and out.  I think the Mac community feels the same way, and in general uses ITerm, or the recently released ITerm2 (not same authors as ITerm oddly enough).  ITerm2 does work well, but again it feels like the terminal lacks speed in comparison.

Performance
One thing that struck me was the lack of responsiveness / speed.  This Macbook is a quad core with an ATI dedicated graphics card, but for most operations the OS feels quite sluggish.  Starting up iTunes or Safari takes much longer than you would expect for a $2000 USD piece of machinery.  I will however note that I only use Gnome 2, so Gnome 3 may suffer from a similar issue, but I am not experienced enough to write about it.

Application Installation Method
I was able to install apps through the Mac App Store, in the same manner I do in Ubuntu using the Software Center.  The Mac App store has many more commercial applications, however most of them like Photoshop are just not needed for a Linux veteran as Gimp does everything needed.  I also purchased XCode 4, but was underwhelmed other than the Iphone emulator which ran awesome in comparison to the Android emulator I was previously used to.

Email
I am sure a lot of people use Mail.app and like it, but I have always been a fan of the GMail interface.  I guess if we are comparing Apples to Apples, Evolution and Mail.app are both not very strong competitors (ie the rest of the world either runs on Outlook or Gmail).

Photo Management
iPhoto is a strong point, it is very easy, intuitive and nice looking to manage photos.   Linux alternatives here are weak.

Music Management
iTunes is a horrible, slow monster of expensive music.  One thing I miss is my Droid and the Amazon MP3 application, as that was by far a better deal, and my purchases went straight to the cloud.  iCloud is coming shortly, but Amazon is still my vendor of choice, and they already have proven to get the cloud right.

Gaming
OS X and Ubuntu both have my favorite game, Heroes of Newerth.  Mac OS X has Steam, which is definitely a benefit and World of Warcraft.  Ubuntu can’t really compete in this arena, so it is something to consider.

Conclusion
So, if you were like me, and curious about Mac OS X, you can see I am not overall impressed.  Maybe I am just biased towards Ubuntu, but I find overall it has favorable performance, and I can change out any pieces I don’t like.   I would recommend OS X if you wanted a generally worse experience but the ability to install Photoshop and a few more games (still nothing compared to Windows in this respect).

 

Tags: , , , ,

Gitorious and Fully Qualified Domain Names (FQDN)

When you want to install your own version of gitorious, a lot of people seem to run into issues where they don’t have a real DNS name for their servers. This breaks the session code of gitorious.

I just ran a ‘git diff’ on my gitorious tree, and here are the changes I made to make it work:


diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 7384f93..2409810 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -8,7 +8,8 @@ gitorious_yaml = YAML::load_file(File.join(Rails.root, "config/gitorious.yml"))[
 ActionController::Base.session = {
   :key    => '_gitorious_sess',
   :secret => gitorious_yaml['cookie_secret'],
-  :domain => ".#{gitorious_yaml["gitorious_host"]}",
+#  :domain => ".#{gitorious_yaml["gitorious_host"]}",
+  :domain => "10.80.21.73",
   :expire_after => 3.weeks,
 }

And also:

diff --git a/app/models/repository.rb b/app/models/repository.rb
index c4fd612..1df689c 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -226,7 +226,7 @@ class Repository < ActiveRecord::Base
   end

   def http_clone_url
-    "http://git.#{GitoriousConfig['gitorious_host']}/#{gitdir}"
+    "http://#{GitoriousConfig['gitorious_host']}/#{gitdir}"
   end

   def http_cloning?

If you change 10.80.21.73 to whatever your ip is, all of your troubles should go away.

Tags: , , ,

On Why Open Source Developers Run Mac OS X

A common trend among many of the best developers is to see them posting screenshots running OS X. Many of the best developers, some my personal ‘developer heroes’, have made the switch to OS X.

It’s All About the Mentality
I respect and admire programmers like @migueldeicaza, @mitsuhiko, mandrake, @dhh for all they have accomplished. One thing they all have in common, present day, is running OS X. Mandrake cowrote Enlightenment (which is the original really cool window manager for Linux), Miguel started Gnome, and the majority of code both Mitsuhiko (wrote almost every useful Python library ever) and DHH (Ruby on Rails) write run on Linux backends to say the least.

What are they most known for? Problem solving skills mixed with actually producing / releasing.

Linux is Open Source
And this, I believe, is why great developers tend to move towards OS X (yes, there are plenty of exceptions). A critical piece of writing software is focus. When a problem solver uses a Linux desktop, they are immediately confronted with the possibility of being able to modify every part of their system. When a problem solver runs OS X, their options are severely limited, by design.

I think all of us are guilty for hunting down PPAs to get a backported browser, or running ‘./configure && make && make install’ at some point. And when you have programming skills, source code can turn into a detriment to productivity when you start modifying projects outside of what you intended to accomplish. All of a sudden you start hacking a project for a few minutes, and wake up days later in a coding haze with all of that time lost.

Personally I have had experience with this while using old Linux distributions. We have SLES 9 systems and SLES 10 systems here at work, and in the past year I have spent countless hours hacking Sprint 3G wireless drivers, USB over IP, Firefox 3 and countless others to work on these older systems. Why? Not because they are the primary goal, but because I could, which in turn took up time from things I actually “wanted” to do.

Time is Valuable
Watching one of Miguel’s presentations, he mentions that he does not have enough years left to “worry about memory management” and that they leave that to the younger folks. This is the crux of the argument. For programmers, there is far too much opportunity for distraction at every avenue. We don’t know how long we will be here for, but certainly we know that nothing we care about will get done as long as our focus is spread so thin across the spectrum of Linux.

Summary
This is all just food for thought, not a judgement against any form of desktop or usage pattern. For reference, I am still running Ubuntu on my desktop, and being wildly unproductive on the tasks I want to finish.

Tags: , ,

Tenda W322P Wireless N PCI Card

Purchased this card at Microcenter (http://www.microcenter.com/single_product_results.phtml?product_id=0316296). Out of the box works on Ubuntu 9.10, supports WEP, WPA, WPA2 and has no stability issues transferring large files etc.

Attempted to install the card under Windows 7 x64, x32, and Windows XP SP3, all of which did not recognize the card without additional drivers.

Summary: PCI wireless N card that is Ubuntu compatible with a price under $25
Grade: A+

Tags: , ,

5 Things I Have Learned About Corporations

When I was younger I would email successful people and ask how they got where they were, and how I could get there. Now I get paid to work with / on Linux, and figured I would share a few things. Age is a funny thing, and as much as I thought I knew when I was 18, 10 years later gives you a much better perspective.

  1. You can’t be a expert in every field
    My whole life I have been a “computer scientist”. That meant I ran pretty much every operating system, and tried to program in as many languages possible. However, in the professional world, your advice outside of your realm is seldomly used or even asked for. Even if it is technically correct, team x does not want to have team y telling them how to do their job. Swallow it up, not everything will go the way you want it.
  2. Communication is more important than technical expertise
    If you look through the ranks of a corporation, you will notice that seldomly does the most technicially proficient employee ever even get to the ‘C’ level (CTO, CIO etc). In smaller companies, being the expert is important because everything is riding on you. When your company has thousands of employees, communicating efficiently is worth much more. Learn how to talk to non-technical people.
  3. Your manager is always right
    Never be a martyr for a specific technical feature. If your company needs something done a specific way, and you are against it, politely state your position. If they are not interested, do it their way. If the manager was wrong, they will take heat for it. However, if you make a big issue about it, your manager is still the one at the end of the day who evaluates you on your performance review.
  4. Appearance matters
    You are selling a complete package to a corporation. It is important that your outward appearance is in line with the position you are going for. If there are two applicants of similar skill levels, the one who interviews that is well dressed and clean will get that position. First impressions count, especially during interviews.
  5. Everyone has their reasons
    No matter how bad you think a choice or decision was, everyone had a reason for doing it. They thought it out, they presented it, and weighed the factors that matter to them. It is very easy to point out how dumb you think something is, but likely you don’t have all the facts of the entire scenario. If you do have all the facts, calling them out on it won’t fix anything and will likely create resentment.

Tags: ,

Encrypted Swap

This post was spawned from my own misconception that my swap partition contained no sensitive data on systems with a lot of ram.

All of my systems I work with have atleast 4GB of ram, so my swap usage is usually under 2 megabytes. Why should I worry what’s in my swap partition?

Instead of going into it, just try it yourself. My swap partition is /dev/sda5. Run the command:

$ sudo strings /dev/sda5 | more

What came up was a ton of interesting data, from files I had looked at, print jobs, and bash scripts. So yes, even if you have enough ram, your swap is still very vulnerable to storing a lot of data about you.

Good news is Ubuntu 9.10 / Karmic will have the option to encrypt swap, which is on the wiki.

Tags: , ,

Annoying people with code: A gentle introduction to C# and Mono Part 3: Creating a GUI (Graphical) Mono / C# Program

In this post we will cover how to make a basic GUI application using Mono along with Monodevelop. If you haven’t already, you will want to read part 1 and part 2 of this series before this article.

Monodevelop
Monodevelop is the tool we are using as our editor. This is Linux’s equivalent of Visual Studio. It can be used to code, debug and design your application, and can link in with revision control systems. This article was written using version 2.0, if your version is not 2.0 you may see slight differences.

Create your project
After starting Monodevelop, go to File -> New -> Solution. You will be presented with a prompt asking which kind of solution we are starting. Click on C# -> Gtk# 2.0 Project as shown below:

new-solution

Read the rest of this entry »

Tags: , , ,

MMap to null

I was reading an lwn article about an exploit: http://lwn.net/Articles/341773/

Being that I am writing posts this week about programming, and about my Fedora run down, thought people might find this interesting.

I wrote a little test code that fails on Ubuntu but works on Fedora 11 (based off lwn post):

#include <stdio.h>
#include <sys/mman.h>

int main(int argc, char **argv)
{
    // Try to write to memory location 0
    void *mem;
    mem = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);

    if(mem != NULL)
    {
        printf("Could not write to memory position 0\n");
    } else
    {
        printf("We can write to memory location 0\n");
    }

    sprintf((char *) mem, " This is a test\n");
    printf("Memory contents: %s\n", (char *)(mem + (sizeof(char))));
    return 0;
}

Fedora 11 results:

./a.out
We can write to memory location 0
Memory contents: This is a test

Ubuntu 9.04 results:

./a.out
Could not write to memory position 0
Segmentation fault

What does this mean?
As far as I can understand it, userspace programs segfault when trying to access data in the NULL (or 0) memory region. The kernel does not have this limitation. The author of the exploit said this is because GCC optimises out the null check. So if there is kernel code which references a pointer to 0, then you can have it run whatever you want. And in atleast 2.6.30, there is kernel code that does that.

Ubuntu does not let the userspace programs write to 0, but in F11 you can. Interesting stuff.

Tags: , ,

Annoying people with code: A gentle introduction to C# and Mono Part 2 – Data Types

In part one of this series we covered making a basic “Hello World” plugin in Mono / C#. Today we are going to dive into different types of data, and how to define them. Show me part 1! Also if you thought part 1 was ugly, I added a new javascript syntax highlighter so I recommend you read it on my blog instead of planet.ubuntu.com.

Variables
A variable is something that stores a value. In different programming languages, these are handled differently. C# is called a static / strongly typed language as you have to tell it what variables are. To explain, I will use python in comparison:

Python Example

x = "This is a string"
y = 5

As you can see, we didn’t have to tell Python anything about what type of variables they are. In C# / Mono, we would do this like this:

C# Example

string x = "This is a string";
int y = 5;

I will tell you, after my years of development, that I program a ton of stuff in PHP / Python today. One of the worst and best parts of these languages is that they are dynamically typed. The fact that C# requires variables to be declared with a type before using makes life easier for testing and reading. There is a stack overflow post on what static typing gives you: Read the stack overflow post.

Variable Naming
Before we continue, you will notice in the top example I used the variable names x and y (to illustrate that the variable names really mean nothing to the compiler / interpreter. If I named them myString you might have been confused). If you do this in real life, I will find you and give you a thorough verbal lashing. I generally use camel case to name variables. Just do not abbreviate them as it really serves no purpose, and makes a lot of pain for people besides yourself maintaining code.

You can read about camel case at wikipedia.

The Source
For this program, I copied our HelloWorld.cs, and just modified it. I also have a modified makefile.

dataTypes.cs

using System;

// We create a class to contain it
class dataTypes
{
    static void Main(string[] args)
    {
        // The type 'bool' is always true or false
        bool isMonoTheOnlyPatentRisk = false;

        // To check if it is true or false in program code,
        // we can use an 'if statement'
        if(isMonoTheOnlyPatentRisk)
        {
            Console.WriteLine("isMonoTheOnlyPatentRisk was set to true");
        } else
        {
            Console.WriteLine("isMonoTheOnlyPatentRisk was set to false");
        }

        // Note how I named the variables -
        // lowercaseFirstThenCapitalizeEachWorld
        // this is called camel case -- I first read about it
        // in a Charles Petzold book, but I am sure it
        // probably didn't originate there.  Either way its
        // how I code, I recommend you name variables
        // as descriptive as possible.

        // Note to only kids:  You will have the initial
        // reaction of saying: Why should I name stuff long?
        // That takes time and is stupid!
        // I used to be you 10 years ago, the problem is if
        // you need to use your code in several years of not
        // using it.  Your time will be completely wasted
        // figuring out what the heck is going on, despite
        // seeming so intuitive / easy to understand when you
        // did it

        // Integers store numbers
        int ourNumber = 5;

        // In most langauges we can evaluate these in
        // 'if statements' like bools above, but if we try in
        // C# this will fail.  In C# a bool can only be 0 for
        // false, 1 for true, or we can use the
        // Convert.ToBoolean function like this:
        if(Convert.ToBoolean(ourNumber))
        {
            Console.WriteLine("ourNumber was not 0!");
        } else
        {
            Console.WriteLine("ourNumber was 0");
        }

        // Lets see if we can compare this number
        if(ourNumber > 4)
        {
            Console.WriteLine("ourNumber was greater than 4");
        } else
        {
            Console.WriteLine("ourNumber was less than or equal to 4");
        }

        // Make a string, and output it
        string helloWorldVariable = "Hello World!";
        Console.WriteLine(helloWorldVariable);
    }
}

Makefile

COMPILER=gmcs

all: helloWorld.exe dataTypes.exe

helloWorld.exe: helloWorld.cs
	$(COMPILER) helloWorld.cs

dataTypes.exe: dataTypes.cs
	$(COMPILER) dataTypes.cs
clean:
	rm -f helloWorld.exe dataTypes.exe

.PHONY: all clean

Output from our terminal

[sharms@sparrow mono]$ make
gmcs helloWorld.cs
gmcs dataTypes.cs
[sharms@sparrow mono]$ mono dataTypes.exe
isMonoTheOnlyPatentRisk was set to false
ourNumber was not 0!
ourNumber was greater than 4
Hello World!

Bonus Tip
Did you notice in the first part the way I named the bool? If you are programming, generally, your bool’s should start with ‘is’. This becomes very important once you start making complex ‘if statements’. Trust me on this one, it’s a habit you want.

Tags: , , ,

Annoying people with code: A gentle introduction to C# and Mono

This is meant to be an introduction to C# and Mono. First, we need to download the mono runtime and compiler:

sudo apt-get install monodevelop mono-devel

For the purpose of this post, we are just going to create a simple program which prints out the text “Hello World”. Go ahead and make a directory for our project so we don’t make our home directory entirely too messy. I just make a directory called ‘mono’ under /home/sharms/mono for the duration of this post.

Go ahead and create a file called ‘helloWorld.cs’, and paste the following:

// Declare which namespace we want to use.
// This allows us to use Console.WriteLine
// instead of System.Console.WriteLine
// Basically like a python 'import' statement, or a
// php 'include' statement
using System;

// We create a class to contain it
class HelloWorld
{
    // Must have a main function as this is what is
    // first called when executing this
    static void Main()
    {
         // C# requires ; after statements
         // Actually output "Hello World"
        Console.WriteLine("Hello World");
    }
}

To compile it, run:

gmcs helloWorld.cs

This will generate a file called ‘helloWorld.exe’. To run it, type:

mono helloWorld.exe
Hello World

And there you have it. I also stumbled on a Makefile tutorial today, so we can make a simple make file (I won’t describe all of this, just look at how it’s used). The tutorial is at: http://www.wlug.org.nz/MakefileHowto

[sharms@sparrow mono]$ cat Makefile
COMPILER=gmcs

all: helloWorld.exe

helloWorld.exe: helloWorld.cs
	$(COMPILER) helloWorld.cs

clean:
	rm -f helloWorld.exe

.PHONY: all clean
[sharms@sparrow mono]$ make
gmcs helloWorld.cs
[sharms@sparrow mono]$ make clean
rm -f helloWorld.exe

Tags: , ,