0x2a

Howto Install rEFIt on Encrypted Lion Systems

There is no really good guide out there on how to install rEFIt on Macs who have a fully encrypted disk (a new FileVault feature in Lion).

Since I made the upgrade, I lived with pressing the Command (⌘) key when I wanted to reboot into Windows. Finally, I bit the bullet and here is a mini guide for you to do it yourself.

Explanation

When installing Lion, the system creates 3 partitions on your disk. 4 if you have Windows installed with bootcamp. If you run diskutil, the layout looks something like this:

1
2
3
4
5
6
7
8
9
10
11
12
$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         125.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                87.4 GB    disk0s4
   5:       Microsoft Basic Data                         106.1 GB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                 Apple_HFSX Macintosh HD           *125.2 GB   disk1
  • disk0s1 is the OSX boot partition
  • disk0s2 contains then encrypted volume, available uncompressed as disk1s0
  • disk0s3 is Lion’s recovery system that you can access with Command (⌘) + R
  • disk0s4 is your Windows partition
  • disk0s5 is my old Linux partition, you wouldn’t typically have that

The issue with the rEFIt installer is that it will install itself on disk0s2 which is still encrypted on boot. But what if we could install rEFIt on the EFI partition ?

Warning

Note that rEFIt takes 25 second to show up. But at least I can now boot on my linux partitions too. Please add a comment if you have a workaround for this and I’ll update the article.

If it takes longer than 25 seconds, you can reset to the default bootloader by keeping the Command (⌘) + Option (⌥) + P + R keys pressed on boot as explained on this Apple KB article: Resetting your Mac’s PRAM and NVRAM

Installation

Looking on the web, I found an old blog post explaining this prodedure: Installing rEFIt on the hidden EFI system partition. For the sake of this article, let me repeat the steps in my own way:

  1. Download rEFIt ( version 0.14 at this time ) on the official rEFIt website
  2. Open the .dmg file, but don’t run the bundled installer
  3. In the following steps, we’re going to mount the hidden EFI partition, copy and activate rEFIt:
1
2
3
4
$ sudo mkdir -p /efi
$ sudo mount -t msdos /dev/disk0s1 /efi
$ cp -r /Volumes/rEFIt/efi/* /efi/EFI
$ sudo bless --mount /efi --setBoot --file /efi/efi/refit/refit.efi --labelfile /efi/efi/refit/refit.vollabel

Note that the /efi/EFI folder already contains the Apple bootloader. If I where you, I wouldn’t remove it :-p

That’s it. Reboot, you’re good to go.

Google, Please Don’t Close Up the Web

Update: Yes Google+ is indexable if your bot knows how to interpret JavaScript. I still think it’s a bad idea ; not only multi-million companies should be able to scrape the web.

Update2: Google Groups now accepts views in incognito mode. Are you listening Google ?

  • https://plus.google.com/u/0/113117251731252114390/posts/EJUtbeV1YSS
  • https://groups.google.com/forum/?fromgroups#!topic/google-maps-api/Jo79ZPDVZkw

What have these two urls have in common ?

Both pages are not indexable. Google+ returns a pile of JavaScript in an HTML page, and Google Groups doesn’t allow you in unless you’re authenticated.

However, both pages ARE indexed in Google. Google+ was supposed to be a reaction to the closed Facebook world. How is that fair for the competition ?

Google, please don’t close up the web.

Mail Over IP

Idea is a new category where I put good and not so good ideas that you can use to start a business. If I had the time, I would try each of these ideas. But since I don’t, just let me know if you use one of them, I’d be curious how it turned out.

As a first entry, let me introduce you “Mail over IP”. The title almost resumes the whole idea. Provide a mean to distribute phyical letters to people, and reversely, numerize letters to emails.

Here is one of the variation on the subject:

Mailing

Some companies want to send tons of phyical mail to people. Instead of printing all those letters out, and sending them from the company’s location, provide a shortcut, so that letters can be printed in localities of the target person. It can thus be delivered faster and cheaper.

You can start with 1 letter format, company logos will have to be printed, and not wit gold ink. Then expand your offering. See lulu, they did the same, but for books.

Because the customer doesn’t have the physical result in hand, there will be more cases of people sending unwanted/malformed messages to the recipient. One way of mitigating that risk is to send a sample mail to the customer, so that he can confirm the design and content.

I’ll update this page if I have more ideas on the subject

Tmux to Manage Your Server

Today I discovered tmux, a GNU screen-like application. It allows you to keep your console sessions alive and manage multiple shells in the same window. Check out the website to get an idea: tmux.sf.net

What’s really neat about it, is that even if the SSH connection to your server breaks, you can just connect back, “tmux attach”, and you can continue where you left off.

For me, the next step, was to login by default into tmux when connecting to the server. It allows me to run long-running processes like workers and keep an eye on them (until I switch to monit or something else). Here is how I did it.

Basic configuration

Edit your ~/.tmux.conf to:

    # Restore sane default shortcut
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Default session
# make sure to have one, otherwise "tmux attach"
# will fail if there is no session
new
  

It’s just that Ctrl-A is much more accessible than Ctrl-B on my keyboard, and it’s also the GNU screen default that I learned.

Next, we want to launch “tmux attach” on new connections. For that, edit the ~/.bashrc:

    # Make sure you have this line somewhere before
# We don't want to attach tmux on non-interactive connections.
if [[ -n "$PS1" ]]; then

# Add the following line as the last commands of the file
# If $TMUX is not set (set by tmux on sub-shells),
# attach or create a session:
if [ -z "$TMUX" ]; then
  exec tmux attach
fi
  

That’s it. Now everytime you ssh to your server, your last session will be re-opened. Notice that if you have two connections, you can see the typing of one into the other.

IDEA: It would be nice if a process monitor would have such kind of feature. Just to watch the stdout and stderr and send some signals to the process.

Update: 11 déc. 2010

One of the drawbacks of this approach is that you’re loosing normal terminal behavior. For example the line history is not available to scolling. There must be a command to emulate it, but I don’t know which-one.

New Home

http://0x2a.im is my new hacker’s home

Rubygems Tips and Tricks

Follows, some tips I like to use on my boxes (MacOSX and Linux)..

Update: 5 dec. 2010

User gems

To avoid typing `sudo` all the time you want to install or upgrade your gems,
run `gem install —user-install somegem` and add the bin path to you PATH environment.

Note that you can also put it in your .gemrc to avoid typing it all the time, but don’t
if you use (RVM)[http://rvm.beginerescueend.com]. It will give you really strange results.

Shorten installs with —no-ri —no-rdoc

If you’re like me, you never use ri or rdoc for the gems. I’m always looking at the sources or on the excellent yardocs.info for that.
If you’re like me, add the following line to your `~/.gemrc` file:

gem: --no-ri --no-rdoc

That’s all folks!

Rubygems Dependencies. Please…

minimalize the number of dependencies your gem requires. This is best practice.

Since rubygems does not support notions of “optional” or “build” dependencies,
do not include them. The best is to add some checks in your code.

For example, if you need rspec to run your tests, just add tree lines in your Rakefile that ask the developer to install rspec on LoadError. Same for hoe, cucumber, rake, etc. These tools are not needed by the library user unless they want to contribute. In that case, they are able to install the dependencies themselves or run a `rake devdeps` task that installs the gems for them.

Same for optional runtime dependencies. If your web framework can use different templating engines, don’t add them all in your dependencies. Make a check when template/the_engine is required that the_engine dependency is available, or spit a message to the developper : “please `gem install the_engine` dependency”.

Thank you, zimbatm

[ANN] monkeypatch-0.1.2 (Alpha)

monkeypatch is a new ruby projects that tries to protect you from patch
collisions.

Project info

monkeypatch introduces a small API that you can use when you want to fix
external libraries. The mechanism is meant to be as straightforward as
possible. Also, by adding monkeypatch as a gem dependency, you declare that
your package is fixing other package’s code.

Version: 0.1.2
Stability: unstable
Source code: github.com
RDoc: rdoc.info

A small example

my_patch = MonkeyPatch.add_method(:to_blob) do
def to_blog; "<blob>" end

end

my_patch.patch_class(String)

"hello".to_blob #=> "<blob>"

How does it work ?

When applying a patch, there are two mechanism that enters the game ;
conditions and conflicts.

  • Conditions are not fatal. If they don’t match, the patch is simply not
    applied, and a message is passed to the MonkeyPatch.logger.
    Conditions are for library version matching for example. They are
    extensible buy using: #add_condition(msg, &cond)
  • Conflicts are fatal, in that they raise a ConflictError if they don’t
    match. Conflicts are for patch collision. They are not extensible and provided by
    the API. The idea is that if your code has conflicting patches, you will
    get notified by a crashing application, so that you can fix it as early as
    possible.

Another aspect are PatchSet (s). If you have a bundle of patches you want to
apply, you can aggregate them with the & operator. You then get a PatchSet
instance which you can use like a Patch. This is not fully done now, but
theoritically, your bundle does not apply unless all patch conditions are met.

What’s next ?

This project is intentionally unstable for now. What I’m really looking for
now, is community feedback. I also intend to look at real-world patches to
see how this library can be made more useful.

So if you have some real-world patches or any comments, please give me your
feedback ! Leave your comments on the ruby forum

Implicit Versus Explicit Return

I’m doing a bit of python right now, trying the Google Appengine .

Going from Ruby to Python is not really hard, they have lots of things in common. One error that got me, is that in Python, all return values are explicit. So instead of writing :

def render_template(name, vals)

Template.render(File.join(templ_path, name + ‘.html’), vals)
end

you write :

def render_template(name, vals):

return template.render(os.path.join(templ_path, name + ‘.html’), vals)

In python, if return is not given, a function returns Null by default.

It gets me thinking, what are the decisions behind this choice ?

Function

If you need to return a value, implicit return is nicer, because in higher-order functions, your block is often short, and it adds some characters. See:

arr2 = arr.map{|x| x.to_i}

versus

arr2 = map(lambda x: return int(x), arr)

Maybe this is why, in practice, python people tend to prefer for loops.

Procedure

If you don’t need to return a value, explicit return is nicer, because you’ll have to add a nil statement to keep the same interface.

def get(self):
self.response.out.write(render_template(‘index’))

versus

def get
response.out.write(render_template(‘index’))
nil

end

In practice, ruby people don’t bother to add that extra nil statement. In most cases it doesn’t really hurt, but interfaces more often leak internal structures, which makes them harder to change later on.

Conclusion

Done with the unscientific rambling. Both have their uses. While not statically typed, python tends to favor strictness. Ruby tends to favor “out of your way” decisions. Both languages are coherent with their goals.

E-voting Is a Solution for What ?

In this little rant, I’m going to argue that e-voting is not a good idea. Feel free to contact me if you have some good arguments.

First, let me put the ground of certain assertions. Voting, with other things, is at the root of our democratic process. And the idea behind democracy, is that it’s the persons who can vote who governs. Politicians and officials are at the service of the majority. I know it sounds utopic, but this is the definition of democracy. From that statement, follows that:

Voting should reflect the view of the majority

To make that statement clear, the primary goal of voting, is to make sure the majority has it’s voice reflected.

How “old” voting works

The paper voting system is a big map-reduce system, where people are involved in all tasks. Each local voting bureau gets the votes, collects and counts them. Then each result is aggregated higher, until we have a big total of all votes. This makes the final score, which should lead the politicians.

In the whole process, people are involved. This is the major factor that limits fraud. (People who study sociology, can you give me some informations here ?). I believe that the more people involved, the less fraud you have. The more eyes can watch the process, the less likely somebody is going to take the risks to get caught.

Hammer time

Along, comes the technician. I am a software developer so I know how it works. The ’’problem’’ should be resolved by technology ! Add layers of security, quantum cryptography, digitally sign the binaries, open source the code. Anything.

No matter how much technology you throw at the ’’problem’’, you miss the central feature: the system is less understandable. Less people can look at your system and say if it’s rotten or not. You’re making the system much more fragile to fraud.

Conclusion

Maybe you noticed I didn’t go into other arguments, like price savings, ecology by saving paper, participation factors, and so on. In my opinion, those don’t even hold when what you loose is the democratic process. So do yourself a favor : protest and let your voice be heard, before it’s too late.

PS: I’m open to criticism and will update the article if you have something to say

[SOLVED] Terminal.app Unicode Problem V2: Alt+Space

Apparently, Alt+Space is another character than Space in Terminal.app. Both have the exact same representation but don’t have the same character code. I have no idea what it is useful for but it is annoying because I often hit it inadvertendly when using unix pipes.

The symptom is like that (where   is not shown in the terminal):

$ ls | grep x
-bash:  grep: command not found

This is because the character after the pipe is Alt+Space and not Space. I believe it is related to my previous entry. I’ll update the post if I find a solution.

Update

For long, I have searched the existing keyboard layout to patch it, but didn’t find it. It turns out, it was much easier to create a new layout from an existing .keylayout. More infos below.

For the record, the Alt+Space character was the unicode no-break space

So here is how to fix your layout:

1. Get Ukulele , the graphical keyboard layout editor
2. Get an existing keyboard layout (in the Ukulele bundle or on the net)
3. Put the .keylayout in “~/Library/Keyboard Layout” or in /Library and give it a new name.
4. Open the .keylayout with Ukulele
a. While pressing Alt, double-click the space bar. Replace the no-break-space by the space character.
b. Set a keyboard name in Keyboard→Set Keyboard Name
c. Save
5. Log-off, relog.
6. Go in System Settings→International→Layouts and select your new layout

For troubleshooting, see the Apple Installable Keyboard Layouts technical note.

Notes on Programming Languages and Environments

Often, I spend time learning new programming languages and environements. It’s not that I need to. I’m curious to learn and I like to see how various orthogonal features fit together. Ideally, one day, I will build my own programming environment (I know it takes at least five years). Note that I prefer to say “programming environment”, which I will later explain. This post is an aggregate of the various knowledge I gathered from my studies which come to my mind.

Programming language versus environment

Overevaluating something happens a lot in the computer world. Maybe it’s because things are more abstract, which leaves some room for absurd ideas to overtake the rationals. Suddenly, the market decides that something is the future. This is how the market had major shift, for example balancing between thin clients and workstations. Suddenly, all software has to be “as service” and lots of computation that happened on the desktop take place on the server. Often, the right answer is right in the middle.

In the programming world, syntax of languages has often been the main comparison vector between two languages, and numerous useless threads has been started, on which language has the “nicest” or shortest implementation of the fibbonacci algorithm. If you thing for two seconds you realize that: fibonacci is mathematically pure and not an indicator of real-world code ; second, this function would be implemented once per language and put in a library. Aren’t there other things we could argue on ? Do we, software developers, miss some good metrics to compare the languages ?

Let get back to the subject. I believe the language is only a small part of the experience the developper has while developping. There are tons of other things ( from the top of my mind ) : debugging tools, virtual machine (yes/no/characteristics), space constrains, deployment tools, editor support, and a special mention ; a good help system ! How much time I loose reading the source code (hello ruby) or searching google for examples is astouning. All of these things and more is what I call a programming environment. Everything that helps between the first lines of codes and the release, and then between the releases. Heck, even the operating system or a graphical editor.

Conclusion

That’s all for today. TODO: next time, let’s talk about orthogonal feature or language metrics. If you have some ideas, send me an email since I don’t have the time to implement and handle a commenting system.

Cheers,
zimbatm

Terminal.app Unicode Support Problem (or Is It Bash ?

… because I’ve seen it on Linux too.)

For some reason, backspace (^H) removes only one byte at a time, which is problematic when characters are defined on more than one (like in UTF-8). Worse, the remaining bytes seem to “infect” the previous character and so the only way to escape is to cancel (^C) the line and rewrite it from the beginning. Annoying.