Posts Tagged ubuntu

Looking for someone to give me a hand

Hoping to reach someone intelligent / talented through this. Basically, I need someone for 2 weeks starting 3/8. It will just be a temporary position, with opportunities to work for us later as needed.

Position involves Linux development, and you should know php / perl. The project will involve modems and java also, and the ability to document everything would be great.

Good news about the position is I am leading the project, so anything you can’t figure out, I will. Pay will be somewhere in the $100/hr range, and we need you to be in Cincinnati for the two weeks (3/8 – 3/19), 40 hours per week.

Send me an email (you can find my info in launchpad) or post a comment here if you think you fit the bill. Anyone who has any Ubuntu development experience or contributions to visible projects will definitely take priority. Remember, you need to have the ability to be in Cincinnati, as travel is not covered.

Tags: ,

A thousand passwords

In this day and age of the internet, we have more content and interaction than ever before. This access generally comes with a price: everything requires a username and password. How does a mere mortal remember their credentials to login to thousands of websites? More importantly, I am not always on the same computer, how do I access my passwords from all of them?

The long term solution would be to see 100% adoption of OpenID. Inevitably many sites will always be behind the curve, so until that day comes, I recommend Revelation.

Revelation is an easy to use, secure and lightweight password manager for Linux. It is written in GTK so those running the GNOME desktop (the default for Ubuntu) will be right at home. You can have several different folders to help organize your passwords, and define actions based on the type of password being stored.

A picture is worth a thousand words, so here is a screenshot of Revelation in action:
revelation

What makes this great is that all of your passwords are stored encrypted. This means if someone takes your computer, without your master password your passwords would be useless. This also means we can store our password using Ubuntu One or Dropbox.

If you are curious about Dropbox I wrote a post with screenshots showing exactly how it works. Simply save your Revelation password file there, and all of your systems that have Dropbox will now have access to those passwords (once you unlock it for that session of course).

Under the preferences window in Revelation you can also adjust your default password size (when you use Revelation you simply randomly generate a new password for each website) for as long as you need, with the longer the better.

If you are running Ubuntu, you can install Revelation by clicking Applications -> Ubuntu Software Center and searching for Revelation. If you would prefer the command line version:

# sudo apt-get install revelation

There are many alternatives out there, but if you are running Linux and just need a simple, no-hassle password manager Revelation is worth five minutes to try it out.

Tags: , ,

Xorg / X11 programming update

So I have been looking into Xorg development. I posted about it a few months ago, but little to no help came of asking where to start looking. After asking several places without any useful help, I actually found a great book:

However, in my haste to order that one, I ordered 2 of these:

So if you are looking to get started with X11 / Xlib / Xorg these are handy to have around. Since I have 2 copies of the pink reference manual, if you want one, email me at sharms at ubuntu period com and I will send you my extra copy for free. Or if you want I can bring it to Ohio Linux Fest 2009 and give it to you there.

Update: Book claimed already

Tags: , , , ,

Boring Friday – What are you doing that is fun?

Suffering from a little burnout after delivering a few projects. For those coders out there, what are you working on thats fun / exciting?

I will start:

Favicon_normalFollowing up from my previous post, the most fun thing I did was compete in the Engine Yard Contest.. I created a python client, which communicated the results back to my webserver every 23 minutes via xml. On the webserver itself, I used the watch command to provide stats that auto update: ‘watch -n 30 “cat /tmp/results | sort | uniq | head”‘. The results had their score first, with lowest being the best like golf.

My favorite webpage I have viewed today has been the Arch Linux July Screenshots thread: http://bbs.archlinux.org/viewtopic.php?id=75154

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: , , ,

Fedora 11 vs. Ubuntu 9.04

Put Fedora 11 on my laptop just out of boredom, some notes:

  • Fedora 11 SELinux by default: Cool but confusing
  • Fedora 11 repositories: Better selection than previous releases, still not as many choices as Ubuntu
  • Ubuntu still wins on the default menu organization for new users (just a bit easier to navigate)
  • Fedora bootup vs. Ubuntu bootup is about a wash, they both look good and are fast
  • Default themes: Neither will win a competition on looks, Linux Mint is much better looking than both
  • Yum vs. Apt: Yum was fast, but a lot of 404’s on the repositories (which is more of an issue of Fedora’s mirror infrastructure)
  • PPAs vs. ???: This is where Fedora appears (correct me if I am wrong) to have absolutely no answer to OpenSUSE and Ubuntu. In Ubuntu we can get up to date packages that were not yet officially released using PPAs. OpenSUSE users can download packages from the build service. Fedora really has nothing this fun (I am aware OpenSUSE can build Fedora packages, but the selection is not even close).
  • Support: Fedora is a distro that is on the cutting edge. It will never compete in support, but this is intentional.
  • Community: Ubuntu community is simply the biggest Linux community on the internet. Nobody is even in the same ball park. This also means that Ubuntu has much more “noise” than Fedora (ie people who contribute nothing and are generally factually inaccurate). Experts may like Fedora more because of the lack of this noise.

So if you are looking to try out Fedora, I don’t think you will gain or miss much. Personally I am going to put Ubuntu back on as I really love software from PPAs, and I love using apt just out of habit. But hope that helps someone who wonders what the differences are or what they are missing.

I have added a screenshot which is the default screen with Gnome-Do with docky theme, but this obviously works in Ubuntu also:

Fedora11

Tags: , ,

Connecting to Ubuntu from Windows

Recently I needed to connect to a Ubuntu box from a Windows machine because FGLRX just would not work with 3 monitors in surround view. Fortunately using a few tools made it much easier to interface with my Ubuntu box again.

Assumptions

  • Ubuntu system named ubuntubox with ip 192.168.1.2
  • Windows system named windowsbox with ip 192.168.1.3

Remote Access

For those of us who are comfortable with the command line, ssh is the only way to go. To make sure you have ssh installed, you can run (on your Ubuntu box):

sudo apt-get install ssh

This service should automatically start a boot up, and will allow you to open a terminal to access the command prompt. Now to access our ssh server, we need to download a ssh client for Windows. Look no further than PuTTY, which is free, open source, and easy to use. There are a few programs PuTTY provides, we just need putty.exe and optionally plink.exe (for next post in this series).

These can be downloaded at the PuTTY download page.

putty

Once downloaded, you can put putty.exe pretty much anywhere you can remember it. I just left it on my desktop and dragged the shortcut to my quick-launch bar. Double click putty.exe, and in the dialog box labeled “Host Name” go ahead and enter your Ubuntu box’s IP address.

Click “Open” when you are ready to connect, and it will prompt you for a username and password. You should already have a username and password from your Ubuntu install.

putty2

If you want your prompt to be colorful, you need to type ‘nano .bashrc’ at the prompt, and scroll down to the line that looks like “#force_color_prompt=yes” and remove the “#” character. After logging in it should now have colors. If you want other cool tips for your shell, I suggest you check out the Ubuntu Wiki as I wrote up a specification on making it more usable: Enhanced Bash.

At this point you should have remove access to your Ubuntu system.

Sharing Files

We need a good way to share files between these two systems. A lot of people will suggest Samba / CIFS (which is really a technical way of just saying Windows File Sharing). I think that Samba / CIFS lacks any technical merit, and is harder to configure. I am going to show you two ways of sharing files, both which use SSH.

WinSCP

WinSCP is basically CuteFTP or whatever FTP program you grew up with, but instead it works with SSH. It is incredibly easy to use. Go ahead and download WinSCP from their website. You can download either the portable executable (which means you can run it from anywhere without installing) or the full installer. Either one will work for our purposes.

The download page is at: http://winscp.net/eng/download.php. To connect from Windows to our Ubuntu system, go ahead and install the program (or not if you downloaded the portable version). Once you start it up, it should look like this:

winscp

Go ahead and fill in the IP address for your system. It is going to say it doesn’t know it’s key yet, go ahead and click Yes there. You will now see your home directory on your Ubuntu box and your Windows box. You can now drag files back and forth, and better yet, encrypted.

Something More?

As a programmer, one thing I need is a great editor. I happen to use VIM to code everything I make. VIM through SSH is ok, but one problem I have is I can’t use any of the really cool color schemes out there, as PuTTY is limited to 256 colors. There are some plugins out there which are supposed to convert the color schemes, but none works reliably for me. Luckily, GVIM is available for windows, so I went to their download page: http://www.vim.org/download.php and downloaded / installed it.

This was great, but for Django development I really wanted to edit the files in place, via a shared folder, instead of using WinSCP every 10 seconds (I use test driven development, as in I may change a file 5 times a minute). How do we go about using our SSH server as a shared folder under Windows? We can use the free / open source program Dokan.

Visit their download page, and retrieve the “Dokan library” and “Dokan SSHFS”. Their download page is at http://dokan-dev.net/en/download/. Install the Dokan Library first. After installing that, install Dokan SSHFS. Once installed, Dokan SSHFS will appear under your start menu. Go ahead and run it:

dokan

This should be a familiar pattern by now. Go ahead and set the “Host” file to the ip of your Ubuntu system. You will also need to provide a username and password. In the screenshot above you can see that my SSH server will be mounted as my N: drive now.

With SSHFS up and running, I can now edit files directly on my Ubuntu server. Combining that with GVIM, I can use an editor that provides excellent syntax highlighting:

gvim

In this screen shot I am using the Wombat theme for GVIM, and the Microsoft font Consolas. Consolas is freely available for Windows XP if you download the Office 2007 compatibility pack, or PowerPoint Viewer.

Tags: , ,

Best Linux Notetaking Application

keepnote-logo

I know a lot of people out there like to take notes with Linux, and probably didn’t come across this program yet, as it look me a bit googling to find it again. The program is called KeepNote, and is a fantastic program for taking notes. I use it with Dropbox, and store all of my notes there and that way it is synchronized to all of my systems. The program itself is open source and free, and you can support it by making a donation on the homepage.

keepnote1-small

I really like KeepNote, and the ease at which I can drag and drop media to it. One thing I did set in preferences was to only autosave every few minutes, otherwise Dropbox is constantly being updated:

keepnote2

The top toolbar is well thought out and very intuitive for formatting. It also supports all of the standard keyboard shortcuts, such as CTRL-B for bold etc. If you are looking to try it out, the author has a .deb package on the homepage that installs no problem (Ubuntu Jaunty AMD64 here).

Tags: ,