Thursday, April 14, 2016

Google Has A Language Problem

Apple had a language problem, which it solved in 2014 with Swift. It is now Google's turn to be in a situation not unlike Apple's, before the introduction of Swift: Google has a language problem.

The problem is Java, which is used to develop apps on Android, and internally at Google to create many of their own apps. The issue with Java is that it is controlled by Oracle, a company Google is fighting in court, and as a 20-year language that evolves very slowly, it is now just plain obsolete. To solve this problem, Google needs a new language, and I see 3 possible contenders, Kotlin, Swift, and Scala:

Kotlin Swift Scala
Benefits compared to Java High High Very high
Controversial Low Medium High
Difficulty to target Android Low Hard Medium
Difficulty to target iOS Hard Low Medium
Difficulty to target the Web Medium High Low

Other alternatives exist, but seem less realistic, at least in the short term:
  • A new Google language - Apple created its own language: Swift. So, couldn't Google come up with their own language as well? This would be a major undertaking. It isn't something outside of Google's league, but if such a large project was underway and getting even remotely close to something they could release, Google being a fairly open company, we would by now have heard about it.
  • An existing Google language - That would be: Go or Dart:
    • Go is designed for system programming, not application programming. It doesn't compete with languages like Kotlin, Swift, or Scala, because it wasn't designed to.
    • It would be all too easy to criticize Dart as a programming language, or describe how much of a failure Dart has been as far as its adoption goes, both within and outside Google. But there is no need to go there given the question that interests us. It suffices to say that Dart, maybe even more so than Go, hasn't been designed to compete with languages like Kotlin, Swift, or Scala, but rather in an attempt to be attractive to JavaScript developers reluctant to use strongly typed languages (ultimately a market it lost to TypeScript).
Getting back to our 3 contenders, no clear winner emerges from the above table:
  • Swift has a lot going for it, but a large amount of work would be needed to make it a viable first-class programming language for Android (think: IDE, APIs, interop with existing code). And maybe even more importantly, how wise would it be for Google to bet on a language designed and controlled by one its competitors?
  • Scala is the best technical solution, both for the capabilities of the language itself, its IDE support (JetBrains' own IntelliJ, Eclipse, and through ENSIME in Emacs, Vim, and Atom), a rich library ecosystem, its ability to target the web through the production-ready Scala.js, and a project underway to create a LLVM backend, which would enable it to target iOS. But the complexity of the language, both real and perceived, is a big hurdle to overcome.
  • Kotlin can be seen as a lesser-Scala: from a technical perspective, it might not be as strong as Scala, but it is strong-enough, and it is less controversial than Scala, and thus easier to sell to Java developers.
If I were Google's language tzar, that is, in the unique position to decide on Google's language strategy, I could see myself go with Scala. If instead, I had to bet on what option Google would go for, assuming it goes for one, I would put my money on them adopting Kotlin.

JetBrains is, to their credit, a fiercely independent company, so I'd be surprised if Google were to acquire JetBrains, but I can see Google announce they will support Kotlin as a first-class language for Android development, along Java. And maybe even will work with JetBrains to improve their JavaScript backend, and together work a on an  LLVM backend, ultimately allowing the same code to be compiled for Android, iOS, and the web.

Sunday, November 10, 2013

Votation populaire du 24 novembre 2013


  1. Acceptez-vous l'initiative populaire "1:12 - Pour des salaires équitables"? In the US, income inequality has been consistently going up since the 70s. Too much income inequality creates a society in which I feel less comfortable living, but imposing a maximum ratio between the lowest and highest salary within a company looks to me like a flawed approach to alleviate this problem. Using a company as a unit is problematic; it opens the door to inequalities and workarounds. Say, a dental surgeon who has her own independent practice isn't too happy paying her cleaning lady 1/12 of her salary? Then she can just outsource cleaning and bypass that constraint. It is also not clear to me that the law would take into account stock given to executives (and increasingly other employees as well). Instead, if the goal is to reduce income equality, I'd rather look at the policies of countries with a low Gini coefficient and a healthy economy, like many of the Scandinavian countries. My vote: no. Expected: no. Result: n/a.
  2. Acceptez-vous l'initiative populaire "Initiative pour les familles: déductions fiscales aussi pour les parents qui gardent eux-mêmes leurs enfants"? This is a hard one, but I'll go with a yes, mostly because the arguments of the federal council are logically flawed. If the primary goal is to help families with children, why only provide this help to those who pay someone to take care of their children? Imagine you wanted to provide an incentive for people not to use their car going to work; if you were to do so by making public transportation costs deductible, you'd be discriminating against people who carpool, bike, or walk to work. (Using a deduction for such an encouragements feels flawed to me, as it disproportionately benefits people with higher salaries who are also those who need the help the least, but this is a different question.) My vote: yes. Expected: no. Result: n/a.
  3. Acceptez-vous la modification du 22 mars 2013 de la loi fédérale concernant la redevance pour l'utilisation des routes nationales (Loi sur la vignette autorouotière, LVA)? The suggested amount (CHF 100.-) doesn't seem unreasonable, and since this is a rather technical issue, I'm comfortable following the recommendation of the federal council and parliament.

Monday, October 21, 2013

Predicting the late-2013 MacBook Pro Retina performance

Some wouldn't be surprised if new MacBook Pro Retina were to be announced at tomorrow's Apple event. Whether they are indeed announced tomorrow, or in the following months, I for one wonder what their performance will be.

I'll focus on the Geekbench 3 score, because it is the most widely used, and in particular on its single-core, 64-bit score, as I think this is the number that best reflects the experience I have using the computer as a developer. Let's look at two other lines that made the move to Haswell processors over the last year:
  • The iMac, from late 2012 (3542) to late 2013 (3935), saw an 11% improvement.
  • The MacBook Air, from mid-2012 (2863) to mid-2013 (3143), saw a 10% improvement. 
I'll predicate my prediction on the MacBook Pro Retina seeing a similar relative improvement. The MacBook Pro Retina from early 2013 scored 3395, so I predict the new "late 2013" MacBook Pro Retina will score at about 3393*1.1 = 3732.

This would make the iMac only just over 5% faster than the MacBook Pro Retina, which would make it hard to for me to choose between the latest MacBook Pro Retina and latest iMac.

Update (2013-10-22): The most high-end CPU we can get on the MacBook Pro like is described as a 2.6GHz Quad-core Intel Core i7 with Turbo Boost up to 3.8GHz, which according to Wikipedia is a i7-4960HQ with  6 MB on-chip L3 cache. The high-end late-2013 iMac comes with a i7-4771, still according to Wikipedia. Based on the specs, the iMac CPU more cache (8 MB vs. 6 MB) but the memory bandwidth MacBook Pro CPU is higher (76.8 GB/s vs. 25.6 GB/s). However, at this point we don't yet have published performance scores for the i7-4960HQ on Geekbench.

Update (2013-10-23): CPU World has a useful comparison of the MacBook Pro's i7-4960HQ (left) with the iMac's i7-4771 (right). Of interest, this comparison mentioned the F16C additional instructions of the iMac's i7-4771, which provide support for doing half-precision to and from single-precision floating-point conversions, but it isn't clear that the availability of those instructions would improve the performance of tasks typically performed by developers.

Also, a few 32-bit scores for the i7-4960HQ started showing up. There are too few to draw any conclusion, and we'd like to look at 64-bit scores, but taking a value of 3405 for the 32-bit MacBook Pro's i7-4960HQ scores and of 3584 for the 32-bit i7-4771 scores, the iMac would indeed be just 5% faster.

Wednesday, April 10, 2013

Requirements for a GTD system

For a while, I've been occasionally updating a list of requirements for a software I would be able to comfortably use to manage my GTD system. So without further ado:
  • actions
    • actions are always in a context, and some actions are also tied to a project (my primary way to look at lists of actions is by context)
    • dates
      • start date (i.e. schedule a task to become current at a future date)
      • recurring tasks (e.g. every weekday, every Monday, every first Tuesday of the month…)
      • due date not important; making the task red once it passed the due date is useless to me; maybe another implementation could make this information useful
    • email
      • quick way to create an action from an email (otherwise I am more likely to leave emails in my inbox rather than create tasks)
      • quickly find email related to an action
      • special but important case of a start date: create action from an email that become current at a future date (i.e. "if no answer in 7 days, do this")
  • projects
    • lists of current projects
    • in each project
      • next actions for that project
      • reference material: notes (typically indented lists), files (PDF, screenshots)
    • ability to archive projects
  • access
    • desktop
      • web based or OS X app
    • mobile
      • Android support (bonus for also working on iOS)
      • fast read access to specific "list" (e.g. context, project)
      • editing lists from a mobile is not a priority (just having read-only access, while not ideal, would suffice)
      • offline on mobile (ideally with background sync so the offline version is used even when online for speed)
    • proven stability of the system's cloud-based component

Wednesday, December 05, 2012

Improve your web app design


There is out there a wealth of resources you can use, often for free, to improve your web app design:

Wednesday, November 28, 2012

Importing the scott schema in Oracle on Amazon RDS

Oracle Amazon RDS doesn't allow you to connect as sysdba, and you don't have access to the local file system, so you can't run the rdbms/admin/scott.sql script, as you would otherwise do. Instead:
  1. Download the demo scripts
  2. As master user:
    1. Change password of the scott user1: alter user scott identified by password ;
    2. Grant some rights to scott:
      1. grant connect to scott;
      2. grant create table to scott;
      3. grant execute any type to scott;
      4. grant unlimited tablespace to scott;
      5. grant create any trigger to scott;
  3. Connect as scott/password
  4. Run SQL in scott.sql

1 The scott user exists by default in Oracle RDS instances, but I am not sure what the password is out of the box. (It isn't tiger.)

Friday, November 09, 2012

Glassfish 3.1

  • Starting the server
    • cd glassfish
    • ./bin/asadmin start-domain --verbose
  • Changing JVM options
    • Edit domains/domain1/config/domain.xml
    • For instance, add <jvm-options>-verbose:class</jvm-options>
    • (Just adding an command line parameters to the java started in bin/startserv doesn't to the trick; I suspect this is just a loader, which then starts the real VM that will host the server)
  • Glassfish key store password
    • By default, Glassfish sets the javax.net.ssl.keyStore property (in domain.xml) to point to its own key store, in config/keystore.jks
    • That key store has a password set on it, which is the same as the Glassfish master password, by default changeit
    • However, the default domain.xml doesn't set the javax.net.ssl.keyStorePassword property
    • As a result, when establishing an SSL connection, Java fails to key store, resulting in a java.security.UnrecoverableKeyException with the message Password must not be null
    • One way to solve this is to add a <jvm-options>-Djavax.net.ssl.keyStorePassword=changeit</jvm-options> in domain.xml

Thursday, November 08, 2012

Propos sur le bonheur, Alain (1928)

A few selected quotes:
  • Je voudrais dire de la mauvaise humeur, qu’elle n’est pas moins cause qu’effet.
  • La colère est à proprement parler une sorte de maladie, tout à fait comme est la toux.
  • Le chapelet est une invention admirable qui occupe la pensée et le doigts ensemble à compter.
  • Réagir contre l’humeur, ce n’est point l’affaire du jugement; il n’y peut rien; mais il faut changer l’attitude et se donner le mouvement convenable; car nos muscles moteurs sont la seule partie de nous même sur laquelle nous ayons prise.
  • Tout religion renferme une prodigieuse sagesse pratique.
  • […] il faudrait toujours se dire: «ce n’est pas parce que j’ai réussi que je suis content, mais parce que je suis content que j’ai réussi»
  • Il y a deux espèces d’hommes, ceux qui s’habituent au bruit, et ceux qui essaient de faire taire les autres.
  • L’art de vivre consiste d’abord, il me semble, à ne point quereller soi-même sur la parti qu’on a pris ni sur le métier qu’on fait. Non pas, mais le faire bien.
  • La pensée est une espèce de jeu qui n’est pas toujours très sain. Communément, on tourne sans avancer. [...] Percevoir et agir, voilà les vrais remèdes.
  • La vrai richesse des spectacles est dans le détail. Voir, c'est parcourir les détails, s'arrêter un peu à chacun, et, de nouveau saisir l'ensemble d'un coup d'œil.
  • [...] l'intelligence à des pointes aussi pour nous piquer.
  • Ce qui nous blesse  dans des pensées inextricables, ce ne sont pas les pensées inextricables, c'est plutôt une espèce lutte et résistance contre cela même, ou, si vous voulez, un désir que les choses ne soient pas comme elles sont. 
  • La tristesse n'est jamais ni noble, ni belle, ni utile.
  • Un auteur ancien à dit que tout événement à deux anses, et qu'il n'est pas sage de choisir pour le porter celle qui blesse la main.
On doing:
  • On veut agir, on ne veut pas subir. Aussitôt que je me donne librement de la peine, me voilà content.
  • L'enfant se moque de nos jardins, il se fait un beau jardin, avec des tas de sable, et des brins de paille.
  • Tous les métiers plaisent autant que l'on gouverne, et déplaisent autant que l'on y obéit.
  • Ne demandez pas à celui qui ne sait point jouer s'il aime le jeu. La politique n'ennuie point dès que l'on sait le jeu; mais il faut apprendre; il faut apprendre à être heureux.
  • Le travail est la meilleure et la pire des choses; la meilleure, s'il est libre, lapide, s'il est serf.
  • Celui qui met toute son attention sur un acte difficile, celui-là est parfaitement heureux.
Dans la grande prairie must be read in full. Alin recounts part of Palto’s myth of Er, where after death people arrive in a large meadow, where they can choose what they want (and will get) in their next life, and so often pick exactly the oposite of what they need. Alain doesn't believe in an afterlife, and sees us making those bad choices every day.

Wednesday, November 07, 2012

iPhone 5 vs. Nexus 4: The Specs


iPhone5 Nexus 4
Price for 16 GB $700 $350
RAM 1 GB 2 GB
CPU 1.3 GHz dual core 1.5GHz quad-core
Display size 4in 4.7in
Display resolution 1136x640 1280x768
Display PPI 326 320
Front camera 1.2 MP 1.3 MP
Back camera 8 MP 8 MP
Data LTE HSPA+
Battery 1400 mAh 2100 mAh
Weight 112 g 139 g

Tuesday, November 06, 2012

MySQL

  • Administration
    • Startup on OS X: sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
    • Shutdown: sudo mysqladmin shutdown
    • Listing the content of the database in XML: mysqldump -X --user=orbeon --password=orbeon orbeon orbeon_form_data | less
    • Connecting to the database from the command line as user orbeon: mysql --user=orbeon --password=orbeon orbeon
  • DDL and testing
    • Employees test database
      • Removed from the beginning of employees.sql the lines that create the employees database
      • Import with mysql --user=orbeon --password=orbeon orbeon < employees.sql
  • XML functions
    • ExtractValue(xml, '/path/to/value')
    • UpdateXML(xml, '/path/to/node', '<new-node/>')
      • Replaces <node> by <new-node> (not the content of <node>)
    • load_file('/path/to/file')
      • Need to grant file permission
        • mysql --user=root mysql
        • grant file on *.* to 'orbeon'@'localhost';
      • File needs to be in a place where MySQL can read
        • sudo -u _mysql cat /tmp/BidForm.xml
  • Issues
    • "To deep XML"
      • Bug        
      • Verified with 5.1.15
      • On the bug thread, someone had this with 5.5.9


Thursday, November 10, 2011

The Ideal Programming Language


My requirements for the ideal programming language, roughly sorted by order of importance:

  1. Can be used equally well for code that will run on the server-side (most likely targeting the JVM) and on the client-side (for now, this means compiling to JavaScript). This is key for people to be able to use the language. Nowadays, a language that also comes with its own environment is unlikely to be adopted. [Unlike Haskell; like Dart]
  2. Strongly typed, with type inference across compilation units, i.e. not to force type declarations on "public APIs" (even if having them, most of the time, might be a good idea). [Unlike Scala; like Haskell]
  3. Provide rich constructs, like case classes, traits, partial functions, continuations… The world is complex, and our programs try to model it, and the right constructs make the programmer's job easier, and the code simpler. (See the simple vs. easy distinction made by Rich Hickey.) [Like Scala]
  4. Adhere to the off-side rule. Because syntax matters. [Like Python, Haskell, CoffeeScript, F#; unlike Scala, Dart…]
  5. Provide a rich data type library. [Like Scala; unlike JavaScript]
  6. Compilation should be fast enough that developers don't feel compiling/building as an additional, lengthy step that needs to happen before they can run code. I.e. when writing code running in the browser, programmers should be able to make a change in their editor, cmd-tab to the browser, reload the page, and see the change. [Unlike Scala]
  7. Don't force "object oriented" paradigms on programmers. E.g. the standard way to write a program shouldn't necessarily be to start defining a class. [Unlike Java, Scala]

Wednesday, August 17, 2011

Is "free will" a fallacy? (Hint: the fallacy is in its definition)

It is irrelevant how brilliant your demonstration is: if you start with an incorrect hypothesis, your conclusion has no value.

Take Daniel Miessler article concluding free will is an illusion, also mentioned by Sam Harris. His hypothesis is that "true (free) influence on the world"—whatever that "true (free)" designation means—requires the ability to change the previous state of the world or to change the laws that govern the universe.

This is very much at odd with the common understanding of the word influence. Say you fail to see a banana peel on the curb, slip on it, and fail. Wouldn't you say that the banana peel influenced your fall? You would, as without it, most likely, you wouldn't have fallen. And I assure you that the banana peel neither changed the previous state of the world nor changed the laws that govern the universe.

Unfortunately, bending the meaning of words, or even worse, completely omitting definitions, too often plagues discussions on free will.

Friday, November 26, 2010

Autocomplete and JavaScript Change Event

Different Sorts of Autocomplete

When it comes to autocomplete in browsers, you need to make distinction between autocomplete for:

  • Username/password — Once you have a username and password saved for a certain login form, the browser will pre-fill the username and password fields with the saved values.
  • General form fields — Most browsers, including Firefox, IE, and Chrome, provides a similar autocomplete interface for form fields: as you start typing in a field, the browser will provide a list of suggestions. If you select one, the value you select will be used to populate the field. (Chrome might, based on the choice you made, also populate other related fields.)

Typical autocomplete UI

The HTML Specification

When it comes to DOM event, and in particular the change event, there is a significant difference between those two cases: username/password fields are auto-filled immediately when the page is shown; for other fields, you explicitly select a value from a list and tab to another field. This is important in the context of the HTML specification. The HTML 4.01 specification says:

The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus.

My interpretation is that browsers should dispatch the change event when users select a value from a list of suggestions, but not when browsers pre-fill the username and password fields, as in that case the username and password fields don't gain and loose the focus. HTML 5 is more abstract (emphasis mine):

When the change event applies, if the element does not have an activation behavior defined but uses a user interface that involves an explicit commit action, then any time the user commits a change to the element's value or list of selected files, the user agent must queue a task to fire a simple event that bubbles named change at the input element, then broadcast formchange events at the input element's form owner.

HTML 4.01 talks about dispatching the change event when the form field looses the focus, which makes sense for text fields, but doesn't for file selection fields (<input type="file">): in that case it make more sense to dispatch the change event when the file has been selected, rather than wait for users to change the focus to another field. This is most likely why HTML5 talks about "users commiting the change" rather than "the control loosing the focus".

Even with this HTML5 definition of the change event, for the case of the username/password fields pre-filled by browsers as the page is loaded, I find it hard to argue that users "committed a change" by just loading the page. So based on my interpretation of the HTML 4.01 and HTML 5 specifications, I would expect browsers to:

  • Dispatch the change event when users select a suggested value and tab to another field.
  • Not dispatch the change event to fields they pre-filled without users tabbing through the fields, such as the username/password fields.

The Real World

Expectations are rarely in line with reality, especially when it comes to browser behavior:

  • For username/password fields:

    • Firefox 4, IE 7, and IE 8 don't dispatch the change event.
    • Safari 5 and Chrome 9 do dispatch the change event.
  • For other form fields:

    • IE 7 and IE 8 don't dispatch the change event.
    • Firefox 4 does dispatch the change change event when users select a value from a list of suggestions and tab out of the field.
    • Chrome 9 does not dispatch the change event.
    • Safari 5 does dispatch the change event.

You can test this by:

  • For username/password fields, load the login test case. Enter a username/password, submit the form, tell the browser to remember the login, reload the form. On Firefox, Chrome, and Safari the password field comes pre-filled, but the change event is dispatched only by Chrome and Safari. On IE, the password will be pre-filled only after you enter the username, but even as you tab through the password field, no change event is dispatched.
  • For other form fields, use this test case.

Workarounds

The bottom line is that your JavaScript code can't rely on the change event. If your code needs to know when the value of a field changes, you have two choices:

  1. Have some JavaScript code that runs at a regular interval, checks the value of all the fields, and calls your change handler when it notices that a value has changed.
  2. Disable autocomplete by adding autocomplete="off" on the <form> element. This technique has been supported by browsers since IE 5 (March 1999) and Netscape 6.2 (October 2001), and now made its way into HTML5.

Thursday, November 18, 2010

Making readonly form fields easier to identify

Readonly form controls, or "disabled" in the HTML parlance, can be hard to distinguish from fields users can type into. Firefox and IE are doing an equally bad job, and making the distinction would be close to impossible if the field was empty to start with:

How default readonly input and text area are rendered by IE 7 and Firefox 4

Adding a grey background to disabled fields is a good way to help users distinguish between readonly (disabled) and read-write (non-disabled) form controls:

How readonly input and text area are rendered by IE 7 and Firefox 4 using a background color

IE 7 onwards supports CSS attribute selectors, so if you don't need to support IE 6, the following CSS will do the trick:

textarea[disabled], input[disabled] { background-color: #eee }

However, if you need to support IE 6, you'll need to decorate your readonly form controls with a class. Some frameworks, such as some XForms implementations, do this automatically for you. For instance, if all your readonly form controls are automatically inside an element with the class xforms-readonly, you can write:

.xforms-readonly textarea, .xforms-readonly input { background-color: #eee }

Monday, November 15, 2010

Indemnification

(First, two words of disclaimer: IANAL—TINLA. Seriously.)

If you are selling software, your customers might occasionally ask you if you provide indemnification. In a nutshell, your customers are looking to be protected in case your software infringes on a third-party intellectual property, such as a patent or copyrighted code, and as a consequence your customers gets sued by this third party. By agreeing to provide indemnification coverage to your customers, you are telling them that if this were to happen, you would:

  1. Defend them in court, and pay for legal fees — hiring the legal team or covering legal cost.
  2. Repair or replace your product — changing your software as necessary, so it doesn't infringe anymore on any third-party intellectual property. Depending on how your indemnification clause is written, this may mean removing, instead of replacing, the infringing functionality.
  3. Pay for damages and settlement fees — those being damages you occasioned to your customers and settlement fees your customers might have to pay to a third-party as a result of you infringing on that third-party intellectual property.

Indemnification clauses often include limitations:

  1. In scope — Each one of the above points (especially number 2 and 3) may or may not be included; if it is included, coverage is often limited.
  2. In dollar amount — A cap is often set to the value of the contract. For instance, for non volume licensing contracts, Microsoft used to have a cap on damages and settlement fees. Microsoft later changed this policy to remove the cap for legal defense (point 1 above), but they are still keeping a cap for damages and settlement fees (point 3 above). Similarly, Red Hat's indemnification caps their liability to the total fees paid by their client during the previous year.
  3. In time — For instance, as mentioned earlier, Microsoft still has a cap a on how much they will pay for damages and settlement fees. That cap is set to the amount paid to them by their customer during the prior one or two years, depending on the cases. Similarly, and as mentioned earlier, Red Hat's total cumulative liability is capped to the total amount in payments made by their customer during the previous year.

Thursday, August 12, 2010

iOS Mail for multiple email accounts with Gmail

The setup

  • You use two email addresses: you@a.com and you@b.com.
  • All incoming email to both addresses is forwarded to your Gmail account: you@gmail.com.
  • You setup Gmail to be able to send messages as either you@a.com or you@b.com.

Two incoming SMTP, one IMAP

With this setup, all your email arrives in a unique Gmail account, which can also access through IMAP. When creating a new message in the Gmail web app, you can choose which email should be used as the from address (either you@a.com or you@b.com). When responding to a message, Gmail automatically preselects the address the message you are responding to was sent to, and allows you to override that choice. So far so good.

The problem

The only trouble with this setup is when using Gmail's mobile interface, in particular on the iPhone/iOS. The mobile interface behaves as the desktop interface, except it doesn't allow you to change the from address. When sending a new message, it is always sent from your default email (say you@a.com), which means you can't send a new message from you@b.com. Also, you can't override the email chosen by Gmail when responding to messages.

  1. iOS Mail only supports one email per account (unlike the OS X Mail.app) – If you want two email addresses, you'll need two incoming IMAP or POP servers. You can work around this by setting up a Dummy IMAP server as follows:

    • Account 1: you@a.com, Unique (real) IMAP, SMTP A.
    • Account 2: you@b.com, Dummy IMAP, SMTP B.
  2. When sending an email, you want a copy saved in your Sent folder on your (Unique) IMAP server. You can set this up for you@a.com. But what about you@b.com? Storing outgoing email on Dummy IMAP isn't what you want. You can use the BCC functionality of Mail, and have Mail BCC you@b.com every time you send an email with that address. Unfortunately, at least for those of us using Gmail to handle their email you@b.com, Gmail doesn't seem to be able to forward incoming mail from and to you@b.com, maybe because it doesn't consider it as incoming mail but as sent mail. So you can't forward those BCC to you@gmail.com, to have them end up in the Sent folder of your unique IMAP server.

Conclusion

When using Mail, with the best possible setup, you can't get the emails sent from one of your emails to end up on your unique IMAP server. Unless controlling what email is used when sending message is paramount to you, and you are fine with, on a regular basis, using a desktop mail client to move the Sent messages from Dummy IMAP to Unique IMAP, you are better off using the Gmail mobile web app.

Hopefully, one day, Google will add the ability for you to select the from email address in their mobile web app, as they already do in their desktop web app: we'll look back, and laugh at how complex it used to be, int the old days, to setup that old iOS Mail.

Tuesday, July 27, 2010

Spell It

Thursday, November 19, 2009

Running VirtualBox in Headless Mode

I first started using Parallels on Mac OS X, later switched to VMware, and now use VirtualBox, which I love. But I have to say that I don't particularly fancy its UI. I find it inconvenient that you need to first hit special key (by default command) to escape the VirtualBox environment. Frankly, I'd rather use Remote Desktop to connect to VirtualBox. And now I do.

The process is rather simple. I'll start assuming that you already have a working VM setup in VirtualBox:

  1. You can have multiple VMs setup in VirtualBox. In my case, I have only one, named "Windows 7". To know the name of your VM, from the command line run:
    VBoxManage list vms
  2. Once you know the name of your VM (which I'll assume to be "Windows 7"), start the VM with:
    VBoxHeadless -s "Windows 7" &
    I like to start VirtualBox in the background, hence the & at the end of the command line. This is because VBoxHeadless doesn't output anything to the standard output after it has started, and you don't want to stop it by mistake by hitting ctrl-c, as you would loose the state of you VM. Instead you'll want to save the VM state (more on this below).

  3. Start Remote Desktop. If you are on a Mac, Microsoft has a free Remote Desktop for OS X. Connect to the VM using Remote Desktop using the host name or IP of the machine running VirtualBox. For instance, if you are running VirtualBox and Remote Desktop on the same machine, that would be localhost.

  4. To stop VirtualBox while saving the state of the VM, run:
    VBoxManage controlvm "Windows 7" savestate
    Next time you start VirtualBox (as in step 2 above), it will used that saved state.

Friday, October 02, 2009

Offline Storage with Safari (Offline iPhone Webapps)

Resources can have 3 states

You can think of every resource as being assigned one of the following 3 states by Safari based on your manifest: missing, cached, online. Cached resources are stored in the Safari store; Safari can display cached resources when offline. Online resources will be retrieved from the server when offline (sometimes also called white listed). Finally missing means that the resource is not in the cache and that Safari won't try to get it from the cache when offline, so loading that resource will fail.

How states are assigned

If the HTML links to a manifest, by default the HTML is cached and all the other resources are missing. So you need to include every resource used by your page in the manifest to either tell Safari that it can be cached (images, CSS...), or that it should need to establish a connection to a server (end-points for Ajax requests).

Checking the state of resources

To see what state Safari assigned to your resources, open the Web Inspector, go to the Resources tab, and switch to the view by Time. Resources that are missing will show in gray. It is harder to see the difference between resources that are cached and online. Most likely you'll notice that online resources take a longer time, and of course you can check your server log to see if a resource is loaded as you reload the page. For missing resources, you can also open the Activity window (from the Window menu); Safari will show a message in red "The URL can't be shown" next to missing resources.

Checking if caching is happening

You can check if any caching at all is happening by looking at the value of window.applicationCache.status. In general the value will be 0 (UNCACHED) if the page isn't cached and 1 (IDLE) if it is.

The text/cache-manifest content type

What they the spec says about the text/cache-manifest content type isn't a joke ;). Make sure that your manifest is served with the appropriate content type, or it will be ignored.

Same site policy for the manifest

You need to serve the manifest from the same site from which the page is served. If you link to a manifest on another server, Safari will just ignore it. In the manifest itself, you can however list resources loaded from other sites that you would like to be cached, for instance libraries you load from the Google CDN.

Friday, September 25, 2009

IE6 Bug: Relative Box After Float Doesn't Show

Consider the following code where you have a floated element (in this case a label), followed by a div with position: relative, containing an input field with a width: 100%.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
.label { float: left; }
.div { position: relative; }
.input { width: 100%; }
</style>
</head>
<body>
<label class="label">Label</label>
<div class="div">
<input class="input" type="text"/>
</div>
</body>
</html>
The issue is that on IE6, the input field doesn't show:

This bug has been resolved in IE7, and you can easily work around it in IE6 by forcing the box to "have layout" (in IE, elements with position: absolute have layout, but elements with position: relative don't necessarily have layout). My favorite way for doing so it to add a *zoom: 1 on the box, which will give you the expected result: