Infinite Lifetimes

All of the interesting technological, artistic or just plain fun subjects I'd investigate if I had an infinite number of lifetimes. In other words, a dumping ground...

Friday 26 August 2011

Building Fedora

http://magazine.redhat.com/2007/08/07/fedora-7-community-remix/

Fedora 7: Community remix

by Mike McGrath

One of the popular features of Fedora 7 is the ability to remix Fedora and build your own custom version. Now don't get me wrong–building a new distribution is nice. But what about those who wish to create their own Fedora-based project? How do you grow a complete community in an enterprise environment or in the general public? Thanks to some of the lesser-known features, anyone can use the exact same tools that make Fedora, well… Fedora.

Fedora development is generally US-based and, as a result, must follow all applicable US law regarding intellectual property, copyrights, and patents. Additionally, Fedora prides itself on being free in every sense of the word. Not only are our developers free but we encourage our users to be free as well. And one part of being free is allowing our code to be used by others–even if they want to build something less free. Revisor and Pungi are perfect examples of Fedora allowing it's user base to customize Fedora simply and freely.

With Revisor, users can easily create any spin of Fedora imaginable. Add codecs for a media center, strip out games, or add additional training applications to build a specific corporate version of Fedora. This new custom version, however, isn't useful for very long without maintainence and distribution.

It's not only possible to create a custom operating system based off of Fedora's code base, but it's also possible to copy the Fedora Project's community methods and best practices. From source to build system to distribution and communication, everything the Fedora Project needs is 100% open source. Users and developers can tweak the operating system and leave everything else alone. Enterprises can create RPMs or rolll their own custom operating system–with everyone using the exact same methods as the Fedora Project.

The first thing someone needs to create their own community is a home. Typically, this home is a simple web page. In Fedora we have a MoinMoin wiki. The wiki provides a central place to collect all Fedora information. It houses packaging guidelines, download locations, and sometimes provides work-flow. It also documents Fedora's governance, provides information about various teams or groups, and gives developers a place to share a bit about themselves. More than anything, though, it is Fedora's home and gives the community a opportunity to speak up and say "we're here."

The next essential item is communication. Initially, straight email is a good way to get things going. When the community grows (even to just a few people), something more will be needed; most (like the Fedora group) will turn to a mailing list or even a forum. When people think about lists and open source software, they think mailman. Most communities try to separate email discussion into different relevant subjects. Two lists are typically sufficient, one for development and one for users. The number of lists may scale quickly, depending on the size and scope of your project. At present, Fedora has around 70 lists.

The Fedora Project also uses IRC for more immediate communications. It is not necessary to host IRC directly–in fact the Fedora community relies on Freenode. Other communities convene there and it's valuable (and convenient) to have all of these open source people in the same place. Since telephone communication is not always possible or desirable, IRC provides a great inexpensive alternative for real-time communication. Again, it's appropriate to create separate channels based on topic or need. Fedora has many different channels, with #fedora, #fedora-devel, and #fedora-meeting being among the most popular.

Once everyone has a place to go for information on the community and can communicate openly with one another, then it's time to get down to business. Most communities will wish to customize Fedora in some way. To do that, they'll need to compile RPMs. Fortunately, with Fedora 7 every part of the build process is 100% open and available for others to duplicate.

Fedora is built from RPMs. The idea behind an RPM is that a packager takes pristine source from upstream, adds patches, creates a spec file, and builds a binary RPM to be distributed. RPMs are aware of dependencies for both the build process and at install time. Building RPMs is a tricky and time-consuming process. Fedora has many package maintainers to help do the job right. Fortunately all of Fedora's official RPMs are maintained by Fedora so others don't have to worry about keeping them up-to-date.

The easiest way to determine if a developer's custom RPM is compatible with Fedora is to actually get it accepted by Fedora. Becoming a Fedora contributor is a well-documented process, but most people needing to create their own community based on Fedora probably can't get their packages into the official Fedora operating system. This is typically because of legal reasons. However, just because something is illegal in the United States doesn't mean its illegal in other areas of the world. This situation is a perfect use-case for customizing and creating a localized version of Fedora.

Even if a package cannot make it into the official Fedora, it's still a good idea to follow the Fedora Packaging Guidelines. These guidelines are open and all Fedora packages are subject to it. An interesting side effect of this is that many Red Hat® Enterprise Linux® packages are also packaged using these guidelines. They are an excellent guide for anyone packaging something for an operating system in the Red Hat family. They also generally translate well for other community projects as well as for applications in the enterprise.

Once a custom set of RPMs has been developed, it's time to set up a system so they can be created the exact same way over and over again by different people. Reproducability is an extremely important aspect of software development and is especially true where an entire distribution is concerned. RPM was designed so that pristine source plus added patches and a spec file creates an RPM. The catch is that some packages will compile differently depending on what's already on the host. To overcome this limitation Fedora uses mock.

In its simplest form, Mock takes an SRPM as an argument, builds a chroot with a set of minimal packages, then spits out an RPM. Using RPMs 'BuildRequires' function ensures that any SRPM passed to it will get built the same way every time. There are some caveats to that, but it's best that beginners think of mock in this way until they becomes more familiar with it.

Building RPM's can be a time-consuming process and many will find it annoying to use their workstation for this task. This is especially true in larger communities or in an enterprise environment. To overcome this hurdle, the Fedora Project started using a build system called Koji. At it's core, Koji is a build queue manager for mock. At its most complex, it is a complete build solution for all of Fedora's building needs. Using x86_64 and ppc builders, Koji keeps track of what's building on what builders and sends tasks to each builder based on available load.

Even with only two build machine architectures, Fedora can build i386, x86_64, and ppc RPMs. This is great for the developers since they may not have access to these architectures and their machines never get tied up in the build process. It is also a very secure method, since they're pulling everything out of cvs and lookaside cache[1], which prevents people from submitting malicious code by anonymous means. It also allows Fedora administrators to recreate any build at any time.

Because mock uses yum to build its chroot for every build, it is a good idea to keep a local mirror of Fedora. Using Koji can alleviate this need, but most people test new RPMs using a local mock install. Creating a Fedora mirror is fairly easy and it's also a well-documented process.

For those with high bandwidth, Fedora is always on the lookout for more mirrors. Fedora's new Mirror Manager makes it possible to set up new mirrors. Administrators can even use Mirror Manager to direct those in your organization to a local mirror using the netblock feature. This is very handy in the enterprise, as it's possible to use a stock Fedora install without any changes to the yum configuration and yet still direct users to a local mirror.

On the ticketing and bug side of Fedora's development lies bugzilla. Bug systems provide a mechanism to get metrics about the project and, of course, track issues with software. It also provides a means for users to comment and prevents developers from getting a thousand emails about the same bug. There is no perfect bug tracking system, but those serious about their community need to have one.

Now that all of those RPM's are being built and updated, it's a good idea to use some sort of updates system to pull and manage what updates go out and when. The Fedora Project created an updates system called Bodhi. The updates system is used for test cases–making sure RPMs don't break a good repository. It also allows some control over when a package gets pushed, as well as providing notes related to each update. The system itself is targeted at more mature communities and the enterprise.

Once the systems have been set up, it is just a matter of keeping everything together and making sure users and developers are informed about new events and continue to participate. By basing a custom operating system on Fedora's already-active code base, much of the difficult work of keeping the operating system up-to-date is complete, leaving community leaders to focus on development and allowing the community to grow on its own.

Everything about Fedora's process is now in the open and can be customized to any organization or community's needs. Those already running Fedora or any operating system in the Red Hat family can now build packages and communities in the exact same way that Fedora does.


[1] lookaside cache is basically the upstream tarballs that The fedora Project store's in a separate location from the CVS.

Friday 1 July 2011

Go Lang JSON & Topsy Twitter request

I built my first Go Lang program to request some data from the Topsy Otter API that queries Twitter.
It returns JSON and requests via HTTP
It doesn't unmarshall the JSON just yet...

package main

import (
    //"io"
    "io/ioutil"
    //"strings"
    //"log"
    "http"
    "json"
    "fmt"
    )

/*
{
   "request" : {
      "parameters" : {
         "url" : "http://twitter.com/barackobama"
      },
      "response_type" : "json",
      "resource" : "authorinfo",
      "url" : "http://otter.topsy.com/authorinfo.json?url=http%3A%2F%2Ftwitter.com%2Fbarackobama"
   },
   "response" : {
      "name" : "Barack Obama",
      "url" : "http://twitter.com/barackobama",
      "type" : "twitter",
      "nick" : "barackobama",
      "description" : "44th President of the United States",
      "topsy_author_url" : "http://topsy.com/twitter/barackobama",
      "influence_level" : "5"
   }
}
*/

type OtterResponse struct {
      name string
      Url string
      Type string
      Nick string
      Description string
      Topsy_author_url string
      Influence_level string
}

func main() {
    r, err := http.Get("http://otter.topsy.com/authorinfo.json?url=http://twitter.com/barackobama")
    var b []byte;
    if err == nil {
        b, err = ioutil.ReadAll(r.Body);
        r.Body.Close();
    }

    if err != nil {
        fmt.Println(err)
           fmt.Println("Whoa we really didn't make it!")
    } else {
        fmt.Println(string(b));
        var m OtterResponse
        err := json.Unmarshal(b, &m)
        if err != nil {
           fmt.Println("Whoa we didn't make it!")
           fmt.Println(err)
        } else {
           fmt.Println("Whoa we made it!")
           fmt.Println(m.name)
        }
    }
}



The links I used:
http://blog.golang.org/2011/01/json-and-go.html
http://code.google.com/p/otterapi/wiki/Resources
http://golang.org/pkg/http/#Response
http://raycompstuff.blogspot.com/2009/11/golang-networking.html

Thursday 12 May 2011

What are important languages to learn to understand different approaches and concepts?

http://stackoverflow.com/questions/3958630/what-are-important-languages-to-learn-to-understand-different-approaches-and-conc

Matters of practicality are highly subjective, so I will simply say that learning different language paradigms will only serve to make you a better programmer. What is more practical than that?

Functional, Haskell - I know you said that you didn't want to, but you should really really reconsider. You've gotten some functional exposure with Clojure and even Python, but you've not experienced it to its fullest without Haskell. If you're really against Haskell then good compromises are either ML or OCaml.

Declarative, Datalog - Many people would recommend Prolog in this slot, but I think Datalog is a cleaner example of a declarative language.

Array, J - I've only just discovered J, but I find it to be a stunning language. It will twist your mind into a pretzel. You will thank J for that.

Stack, Factor/Forth - Factor is very powerful and I plan to dig into it ASAP. Forth is the grand-daddy of the Stack languages, and as an added bonus it's simple to implement yourself. There is something to be said about learning through implementation.

Dataflow, Oz - I think the influence of Oz is on the upswing and will only continue to grow in the future.

Prototype-based, Javascript/Io/Self - Self is the grand-daddy and highly influential on every prototype-based language. This is not the same as class-based OOP and shouldn't be treated as such. Many people come to a prototype language and create an ad-hoc class system, but if your goal is to expand your mind, then I think that is a mistake. Use the language to its full capacity. Read Organizing Programs without Classes for ideas.

Expert System, CLIPS - I always recommend this. If you know Prolog then you will likely have the upper-hand in getting up to speed, but it's a very different language.

Frink - Frink is a general purpose language, but it's famous for its system of unit conversions. I find this language to be very inspiring in its unrelenting drive to be the best at what it does. Plus... it's really fun!

Functional+Optional Types, Qi - You say you've experience with some type systems, but do you have experience with "skinnable* type systems? No one has... but they should. Qi is like Lisp in many ways, but its type system will blow your mind.

Actors+Fault-tolerance, Erlang - Erlang's process model gets a lot of the buzz, but its fault-tolerance and hot-code-swapping mechanisms are game-changing. You will not learn much about FP that you wouldn't learn with Clojure, but its FT features will make you wonder why more languages can't seem to get this right.

Enjoy!


Tuesday 3 May 2011

Secrets of Power Negotiating

http://www.korokithakis.net/posts/secrets-power-negotiating/

Nibbling. This is the principle of getting something extra, after everything else has been agreed upon. For example, you agree to buy a couch for a price, and then say "can you throw in that pillow as well?". The other person has made up their mind, so they're more receptive to adding something extra.

Higher authority. Always have a "higher authority" that you have to "check with" before you can make a decision. This ensures both that you will have more time to think about the deal, and that you will be able to put more pressure on the other party without leading to confrontation (as you do not appear to be the one responsible for the pressure).

Good guy, bad guy. This is the well-known technique of saying "I think this is a great offer, but X doesn't think so", and can be used effectively with the higher authority technique.

Impasse. If the negotiations reach an impasse, you can try to set the specific matter aside and talk about the other points of the negotiation, even if they are the minor ones. This establishes momentum and makes it easier for both parties to settle the point they were at an impasse on earlier.

Agree with people. No matter what peolpe say, agree with them and then gently nudge them to another direction. Arguing makes them go on the defensive and impedes the negotiation.

Flinch. This one is self-explanatory. Always flinch and act indignant at the first offer, no matter how good it may be. This leads the other party to believe that the offer is not good enough.

Play dumb. Don't show your hand, it's better to play dumb than to flaunt your intelligence to the other party. This makes them underestimate and sympathize with you

Be prepared to walk away. Once you decide to close the deal at any cost, you have lost the negotiation. Always be prepared to walk away.

The power of writing. Seeing something in writing is much more powerful than just hearing about it. Always use writing (the more official-looking the better) when possible.

Don't make the first offer. If you make the first offer, you're revealing the range you want to go for. Always let the other person make the first offer, if possible.

Congratulate at the end. Never gloat after a negotiation, congratulate the other person and make them feel good about the negotiation.

Be the one who writes the contract. Try to be the person who writes the contract. This allows you to add a few details that the other party has to negotiate out of the contract afterwards.

Fait accompli. This is the principle of sending the other party a proposal with the assumption that they are going to accept it exactly the way it's written. For example, you can send a contract and a cheque to the other party, thus putting them in the position that they have to either decide whether to take the slightly modified offer, or come back to the negotiation and draw it out, risking failure.

Think in real money. Convert quotes to scales that make sense. If, for example, someone quotes you a price in cents per day for a contract that will last for years, it can add up to a significant cost increase. Always think in terms of real money.

Red herring. Add terms to the negotiation that you don't really care about, just so you can give them away later to gain something else from the other party.

Puppy dog. This is the practice of letting people try products before buying them, at which point they will be hooked to the product and have a much higher chance at purchasing it. Try to make people think about the benefits of the deal in the long term, this way they will be more likely to forgo the short-term costs.

Reluctant buyer. Act like you aren't very interested in the offer. This gives you leverage.

Want it all. Ask for as many things as you can, even things you don't want. This way, you set the other person up to "win" by making you relinquishing terms you didn't even care for. It also helps you get more things than you initially planned for.

Don't split the difference. Never split the difference yourself, but always try to get the other person to split their offer. This way you can split the difference over and over again on their end without relinquishing anything of yours.

These are the points in the book that come to mind. I haven't explained them in nearly as much detail as the book does, and I haven't provided ways to counter each technique when other people use it on you. So, if you felt that this list is interesting, I would urge you to buy the book. I heavily recommend it.

Friday 29 April 2011

c-ares


c-ares is a C library that performs DNS requests and name resolves asynchronously.

 


tim's shared items

Add to Google Reader or Homepage