Sunday, February 4, 2018

How to migrate your emails from Yahoo to Gmail (even though Yahoo will try it’s best not to let you do it)

I had been trying to move my last 2k or so email messages off my Yahoo inbox for the last 3 days. It should be a very simple process: just enable POP in the Yahoo mail donor account then setup a POP account in the target Gmail and wait for both of them do their magic.

For (not so) unknown reasons that doesn't work. With a thousand mails sitting in my Yahoo inbox, Gmail POP fetcher will just fail with the error message:

[SYS/TEMP] Server error - Please try again later.

If you search for this error you will find out you are not alone in this boat. This is actually a widely reported issue and happens with any kind of email client such as Outlook, Thunderbolt and so - and not only Gmail. Fact is, people have had this problem for a long time and they managed to fix that in a lot of different (random) ways.

For me this is clearly a problem in Yahoo side alone and I am about to believe there is absolutely nothing we can do to fix that. In the example below I am using `openssl` to directly talk to Yahoo POP3 server and run a little experiment:
$ openssl s_client -quiet -connect 
depth=2 C = US, O = "VeriSign, Inc.", OU = VeriSign Trust Network, OU = "(c) 2006 VeriSign, Inc. - For authorized use only", CN = VeriSign Class 3 Public Primary Certification Authority - G5
verify error:num=20:unable to get local issuer certificate
verify return:0

+OK Hello from jpop-0.1
-ERR Invalid Command.
USER mybeautifulnal
+OK Password required.
PASS mysecretpassword
+OK Maildrop ready, (JPOP server ready).
+OK 5760 octets.
RETR 500
-ERR [SYS/TEMP] Server error - Please try again later.
RETR 500
+OK 9438 octets.

As you can see the first time we tried to retrieve message #500, server failed with exactly the same error message Gmail has been reporting. Then we try it for a second time and it works. I have been tinkering with this issue for the past 3 days trying to find a pattern on which messages it would most likely fail or how small should I keep my inbox to minimize the risks.

Problem is I came to no conclusion and that behavior just seems completely random to me. By the other hand, to make things worse Gmail will just drop all the work done on the first error it encounters when importing email from Yahoo.

So it was clear to me what I had to try next: make my own machine collect all my Yahoo messages and then deliver them to Gmail.

Step #1: pulling email from Yahoo

Note: tools needed for this step are not available in a standard MacOS High Sierra anymore, so you might want to try a Linux distro.

We are using `fetchmail` and `procmail` for that matter and will start with the creation of ~/.fetchmailrc:
protocol pop3 
user 'mybeautifulname' 
password 'mysecretpassword' 
mda '/usr/bin/procmail'

We are basically telling fetchmail which server to look for, what our credentials are and what to do with the downloaded email (handle them to `procmail`). Note the `uidl` option is used to keep track of work already done so we can retry the failed messages in later runs.

We now point `procmail` to a custom mbox file within ~/.procmailrc

We know that Yahoo will fail to deliver a few random messages each time we try a download. That's why we are running `fetchmail` for 10 consecutive times:
$ mkdir /tmp/mail
$ for i in {1..10}; do fetchmail; done

Read the mbox file and make sure the message count matches the number of messages in your webmail:
$ mailx -f /tmp/mail/pulled_email.mbox
Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/tmp/mail/origin.mbox": 1067 messages 1067 unread

If you are missing messages then run `fetchmail` again until you get enough.

Step #2: pushing email to Google

Theres a really nice tool called Got Your Back to get that work done. So we head to Github to download and install it:

$ wget 
$ tar -xf gyb-1.0-linux-x86_64.tar.xz 
$ cd gyb
$ touch nobrowser.txt

Or if you are running MacOS:

$ curl -LO
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   610    0   610    0     0    758      0 --:--:-- --:--:-- --:--:--   757
100 7492k  100 7492k    0     0  1021k      0  0:00:07  0:00:07 --:--:-- 1599k

$ tar -xf gyb-1.0-macos.tar.xz 
$ cd gyb
$ touch nobrowser.txt

Fire GYB pointing it to the place where your mbox file is located. You don't need to explicitly tell the name of your file since GYB will automatically find and load all mbox files inside the working directory.

$ ./gyb --email --action restore-mbox --local-folder /tmp/mail --label-restored GYB
You might want to pick option Zero because we will need read access in case any message fails to upload.
Select the actions you wish GYB to be able to perform for

[*]  0)  Gmail Backup And Restore - read/write mailbox access
[ ]  1)  Gmail Backup Only - read-only mailbox access
[ ]  2)  Gmail Restore Only - write-only mailbox access and label management
[ ]  3)  Gmail Full Access - read/write mailbox access and message purge
[ ]  4)  No Gmail Access

[*]  5)  Groups Restore - write to Google Apps Groups Archive
[*]  6)  Storage Quota - Drive app config scope used for --action quota

      7)  Continue

GYB will give you an URL to copy and paste into your browser, then you need to provide the authentication token to it. Watch the magic been done after that.
Authentication successful.

Using backup folder /tmp/mail

Restoring from 16.62MB file /tmp/mail/pulled_email.mbox...
large files may take some time to open.
restoring 10 messages (30/1067)                                                 
ERROR: 400: Bad Request. Skipping message restore, you can retry later with --fast-restore
restoring 10 messages (260/1067)                                                
ERROR: 400: Bad Request. Skipping message restore, you can retry later with --fast-restore

We had a few failed messages for whatever reason and it's a little bit hard to tell them apart. You can try the trick below:

$ ./gyb --email --action backup --search "label:GYB"
$ fgrep -i 'Message-ID:' /tmp/mail/pulled_email.mbox | sort -u > all.txt
$ find . -name "*.eml" -exec fgrep -i 'Message-ID:' {} \; | sort -u | tr -d '\r' > restored.txt
$ comm -23 all.txt restored.txt

The last command will give you a list of message ids that might be missing in your restore. Take a look in your mbox file and search for them, after you identify the missing messages you can try to import them again using the regular method: head back to yahoo webmail, move all messages to any folder but the ones missing in gmail. make gmail download them thru POP3). Hopefully there are only a few handful messages missing messages for you are there were only 4 for me.

Thursday, May 22, 2014

How to bring your Time Capsule back to life

The following post is written in Brazilian Portuguese since there are already many tutorials regarding this topic in English.
Although I am describing my own experience, there isn't anything significantly new here.
If you are interested in good English materials, you can look at the bottom of the post.


Depois de seis anos de glória, minha Time Capsule finalmente bateu as botas. Como era de se esperar o problema está na fonte de energia. O ponto fraco: dois capacitores que não resistiram aos anos de calor intenso e trabalho árduo.

Comprar um equipamento novo de última geração, com quatro vezes a capacidade do meu atual de primeira geração, me custaria R$1250. Eu diria que é um bom negócio, não fosse por dois detalhes:

  1. o novo design em forma de torre não é prático e não caberia no meu suporte de parede. Para não dizer de gosto duvidoso, infelizmente.
  2. eu sou um acumulador, então não aceitaria com facilidade gerar lixo com um equipamento recuperável. principalmente em se tratando de uma pedra mágica em forma de obra de arte, um testemunho da época gloriosa da Apple de outrora.
A próxima alternativa seria reparar a fonte defeituosa. Procedimento simples, rápido e barato. Como esta é uma característica de projeto desta fonte em específico, com sorte teria que repetir o reparo daqui a 6 anos.

Como não quero contar com a mesma sorte duas vezes, parti para a terceira alternativa: comprar uma fonte nova de outro fabricante, conhecida por ser mais robusta e de maior qualidade. Quem é íntimo dos produtos da Apple sabe que seus equipamentos não são idênticos mesmo dentro de um mesmo modelo. Por inúmeras razões, os componentes de terceiros provém de mais de um fornecedor.

Já que vou trocar a fonte, aproveito também para trocar o disco, para me atualizar com a capacidade da Time Capsule atual e de quebra usar um disco de menor consumo e menor dissipação de calor.

Problema resolvido, não fosse um pequeno detalhe: não gosto de fazer as coisas pela metade. Então já que estamos trocando a fonte e o disco, agora eu tenho que resolver também o aquecimento interno do aparelho para aumentar ainda mais a vida útil da nova fonte.

Como ressuscitar sua Time Capsule

Se a sua TC de primeira geração não liga mais - sem luzes ou qualquer atividade -, as chances são grandes do problema estar na fonte de alimentação.

Até onde eu sei, a Apple trabalhou com dois fornecedores para esta peça: Flextronics e Delta. As fontes fontes da Flextronics são conhecidas por durar manos de dois anos enquanto que as Delta são mais resistentes.

O problema está basicamente na alta temperatura de trabalho desses componentes e na baixa capacidade de troca de calor da TC. O projeto de resfriamento é limitado em desempenho, em favor da estética, e voltado para proteger o disco interno.

Felizmente, mesmo contando com uma fonte Flextronics, minha Time Capsule trabalhou gloriosamente 24h/dia por mais de seis anos seguidos.

Além de substituir a fonte, me propus a substituir também o disco interno e a melhorar, dentro do possível e com mínima intervenção, o projeto de resfriamento.
Time Capsule de primeira geração

Abrindo a Time Capsule

O primeiro passo é utilizar um secador de cabelos de alta potência para aquecer a borracha da base e soltá-la puxando vagarosamente. O segredo é aquecer bastante uma ponta, soltá-la bem devagar e prosseguir dali.

Após remover a borracha, retire os parafusos da tampa de alumínio com uma chave Philips #0.

Remova a tampa de alumínio com cuidado, pois você encontrará resistência do fio da ventoinha conectado na placa lógica.

Desconecte a ventoinha e o disco interno. O disco interno poderá ser sacado após removidos os conectores de força e dados, bem como o sensor de temperatura da ventoinha (colado). Não há parafusos segurando o disco.

Para não danificar o acabamento aconselho apoiar a TC em pano, toalha ou até mesmo na caixa original.
Time Capsule aberta

Time Capsule aberta, em detalhe, apoiada na caixa original

Substituindo a fonte de alimentação

A entrada de força é destacável (conector de dois pinos, puxar para cima) enquanto que a saída da fonte possui dois conectores, um ao disco e o outro à placa lógica. Após removidas todas as conexões, puxe a peça para cima.

Ao retirá-la, o invólucro isolante desmanchou em minhas mãos, provavelmente devido a fadiga de tantos anos submetido a temperaturas extremas. Seja cauteloso ao manuseá-la, os capacitares de alta voltagem são perigosos quando carregados.
Fonte de alimentação Flextronics (abaixo, encapsulamento removido) x Delta (acima)
A nova fonte deve ser instalada em procedimento reverso à remoção. Ainda sem o disco interno, teste o conjunto ligando a TC na tomada. A luz de erro (âmbar) deve-se acender mas a rede WiFi deve subir.

Desconecte a tomada.
Nova fonte instalada

Teste da nova fonte

Arquivando os dados antigos

Se desejar recuperar os dados armazenados na TC antes da baixa de guerra, o momento é agora. Para tanto, reconecte o disco antigo, ligue a tomada, conecte um disco USB externo e use o Airport Utility para realizar o arquivamento.

Você vai precisar de bastante paciência... No meu caso a estimativa foi de 9h de duração.

Após o término, desligue a tomada e remova o disco interno novamente.
Disco externo conectado para arquivamento
Procedimento para arquivamento no Airport Utility do iOS

Substituindo o disco interno

Para substituir o Seagate de 500GB original, comprei o disco "verde" de 2TB da Western Digital. Esta linha consome menos energia, produz menos ruídos e esquenta menos - em detrimento do desempenho. Mesmo assim, o desempenho do disco é ainda maior do que a capacidade de banda do WiFi, o que faz dessa troca uma excelente barganha.
O novo disco deve caber perfeitamente na baia e, após conectados os cabos, não se esqueça de instalar os parafusos de fixação do disco antigo. Esses parafusos se encaixam em suportes de borracha na tampa de alumínio. Como estavam bem atarrachados e eu não tinha uma chave longa para o serviço, tive que apelar para uma chave de precisão + alicate.
Removendo os parafusos de apoio do disco antigo
Note que será necessário inicializar (formatar) o disco utilizando o Airport Utility.  Este procedimento é simples, não está contemplado aqui, e pode ser realizado como última etapa.

Melhorando o sistema interno de resfriamento

A solução consiste em redirecionar a saída de ar, abrir uma entrada de ar externa e alterar o controle para monitorar a temperatura da região mais critica: a fonte, e não o disco, como é feito atualmente.  

Repetindo, em tópicos:
  1. alterar o controle da ventoinha para monitorar a fonte
  2. redirecionar o fluxo de ar da ventoinha
  3. abrir uma nova entrada de ar
Alguns tutoriais sugerem que se elimine o sensor de temperatura da ventoinha e refaça o cabeamento de controle para que a mesma funcione o tempo todo, mas em baixa rotação. Eu preferi escolher um local mais "quentinho" para o sensor, na esperança de que a ventoinha atue por mais tempo.

O local escolhido foi um dissipador de metal interno na extremidade traseira da fonte de energia.
Sensor de temperatura reposicionado dentro da fonte
A seguir, a ventoinha foi removida da tampa de alumínio - cortei os pés de fixação - e rotacionada 90 graus para que o fluxo de ar passe por dentro da fonte de alimentação. Note que o lado da etiqueta fica para cima.
Ventoinha reposicionada para o fluxo de ar atravessar a fonte
Optei também por tampar o lado oposto da ventoinha para que não haja desvio de ar por ali. Usei papelão por baixo do silver tape para não deixar cola exposta à poeira.
Use a embalagem do seu espresso preferido

Isolamento final da parte inferior da ventoinha
Para abrir uma nova entrada de ar utilizei uma serra copo de 51mm de aço bi-metal. O furo pode ser feito ao mesmo tempo na tampa de alumínio e na borracha da base.

Certifique-se de utilizar alguma proteção entre a tampa e a borracha da base para que o pó não chegue à cola pelos furos do alumínio. Você pode usar uma sacola plástica, papel, etc. Não utilize filme plástico de PVC ! Eu cometi este erro fatal e o filme acabou se fundindo na cola.

Utilizei lixa de parede para fazer o acabamento das rebarbas do metal. Já para borracha, um estilete comum.
Entrada para entrada de ar ambiente
Para proteger o aparelho da entrada de insetos e poeira, usei uma grade de proteção com filtro de poliuretano, retirados de um filtro de ar automotivo de alta performance.
Filtro automotivo Inflow desmontado em três componentes, fora do quadro
A grade do próprio filtro foi recortada com alicate e presa na tampa de alumínio com silver tape. A espuma pode ser colada com um pouquinho de silicone pelo outro lado da grade.
Steve Jobs que me perdoe, mas aqui o importante foi ficar bonito do lado de fora

Instalação da grade concluída

Instalação do elemento filtrante concluída

Conclusão e investimento

A fonte e o disco custaram no exterior, sem contar impostos ou frete, respectivamente US$65 e US$95. Economia excelente em relação à compra de uma nova TC.

Mas além dessas peças, precisamos também das ferramentas...

Para abrir o buraco é preciso uma serra copo (R$50). Como as lojas de ferramenta aqui no país fazem vergonha, não consegui encontrar a serra copo e o adaptador para furadeira compatíveis. Um era de uma marca e outro de outra. O jeito foi comprar um kit inteiro com 6 serras de diferentes tamanhos e os adaptadores por R$170. Além disso são necessários também dois grampos sargentos para manter a peça de alumínio imóvel durante o furo (R$30 cada).

O kit de serra copo serve apenas em furadeiras com mandril de 13mm. As furadeiras de hobbistas (aquelas mais baratas que geralmente temos em casa) são de 10mm.

A primeira alternativa é comprar uma nova furadeira de 13mm e ficar R$300 mais pobre. A segunda alternativa é trocar o mandril da furadeira atual por um maior por cerca de R$10. Mas vai saber onde se encontra mandril avulso de 13mm por aqui...

O filtro de ar automotivo custa cerca de R$100, mas esse valor não entra na conta visto que aproveitei o filtro descartado do meu veículo. Caso não tenha um desses usado, pode utilizar filtro de gabinete, de aspirador de pó, etc. Use a imaginação !

A experiência foi positiva, o passa tempo agradável e a economia razoável. Além de tudo, minha consciência ambiental está limpa... E não precisarei praticar o desapego :) 

O senhor do tempo está de volta ao trabalho


Fan Modding My Time Capsule
Using a Hole Saw On my Apple Airport Time Capsule
Apple Time Capsule Repair
The home of the Long-Time Capsule...
iFixit repair guides

Tuesday, September 25, 2012

iTunes and Apple TV slowdowns with third party DNS

A few months ago my Apple TV rentals used to take hours to get ready to watch. And I am not talking about the whole movie... that was just the loading time for the first few minutes.

When I decided to look deeper into this problem, I found out Google DNS service was the cause (It is not Google's fault though).

Then I switched to Open DNS and everything turned into heaven again. But it looks like more and more Apple TV owners were switching to Open DNS as well. A few weeks later things went pretty bad to me again.

Now I am switching back to my ISP DNS which I hope will fix the problem permanently (or at least as long as it is up and running).

It doesn't only helps Apple TV to go faster, but boosts iTunes as well.

For a good explanation on why it happens, please read here.

PS: The DNS switch also had the benefit of fixing my iOS 6 Passbook, which wouldn't work even after the clock ugly hack.

Friday, September 16, 2011

Mac OS X 10.7 Lion and PHP

Since Lion upgrade, I have noted that sometimes the pager utility less was misbehaving. That's what happens when I try php -i | less:

th-png-dir=/BinaryCache/apache_mod_php/apache_mod_php-66.1~51/Root/usr/local' '--enable-gd-native-ttf' '--with-icu-dir=/usr' '--with-iodbc=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-libedit=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-readline=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-suhosin' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/:j
usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex=/usr' '--with-pgsql=/usr' '--with-pdo-pgsql=/usr'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20090626
PHP Extension => 20090626

And that's what I would expect:

Build Date => Sep 16 2011 21:54:05
Configure Command =>  './configure'  '--prefix=/opt/php536' '--enable-cli' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-dba' '--enable-exif' '--enable-ftp' '--with-iodbc=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex' '--with-pgsql=/usr' '--with-pdo-pgsql=/usr' '--enable-pcntl' '--with-gmp'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /opt/php536/lib
Loaded Configuration File => /opt/php536/lib/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20090626
PHP Extension => 20090626
Zend Extension => 220090626
Zend Extension Build => API220090626,NTS

In both cases I tried to go down by pressing the key j five times.

At first I thought it was some change in a newer version of less so I was missing some command line option to make it behave like the old good way. But after spending an hour reading its manual, I was convinced it was not a feature - but a bug somewhere.

It turns out that Mac OS X 10.7 Lion (and other operating systems as well) comes with a borked libedit version. Unfortunately in that case Lion's PHP is shipped with libedit enabled, as we can see below:

$ otool -L `which php` | grep libedit
	/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)

So when you try to output PHP's stdout to less, libedit and less starts fighting for stdin in a not very healthy way - so you get a bad user experience (i.e. screen doesn't redraws well).

The first way I found around it is :

$ php -i < /dev/null | less

which is not practical in my opinion. The second way is to custom build PHP yourself:

cd /usr/src

# download and extract php 5.2.6
tar -jxf php-5.3.6.tar.bz2

# go to source dir
cd php-5.3.6

# configure
CFLAGS='-arch x86_64' \
CXXFLAGS='-arch x86_64' \
LDFLAGS='-arch x86_64' \
'./configure'  '--prefix=/opt/php536' '--enable-cli' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-dba' '--enable-exif' '--enable-ftp' '--with-iodbc=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex' '--with-pgsql=/usr' '--with-pdo-pgsql=/usr' '--enable-pcntl' '--with-gmp'

# build and install
make install

I usually do this as a regular user. You might want to give yourself permissions over /usr/src and /opt.

Also, note that Lion's PHP comes with a few improvements such as suhosin patch which we are not contemplating here.

Monday, January 17, 2011

Reading the PlayStation 3 registry with PHP

Sony Brasil took way too long to release the PS3 console on my country (something around august 2010). A long time before that happened, many foreign versions of the console (mostly of them american) were already available all around the country. So when I bought mine, I had no choice but a DVD region 1 PS3.

Brazil and United States shares the same Blu-ray region, so I am fine on that matter. DVD playback wasn't an issue for me either as I used to play them on my MacBook. But I have recently replaced it with the new MacBook Air 11" which has no DVD drive built-in, and now I am left with only the PS3 to watch my DVD movies.

Even though Brazil is DVD region 4 and my console is region 1, most recent DVDs play fine on it - it seems that region lock has been removed from those discs on factory. But a recent purchase showed an exception: my 40 DVDs box of the complete series of "Friends" (from Warner) just won't play on my PS3. Now that is bothering me.

I have been searching for weeks on how to watch my original, and expensive, DVDs region 4 on my console region 1, bought on a region 4 country at a time when only region 1 console was available. I couldn't overcome that limitation, I couldn't even find a way to opt for a region change (like my old MacBook let me do). But still, I found out about a really interesting stuff: the PS3 has a registry file with all of its settings - including the DVD region.

The registry file is called xRegistry.sys and can not be obtained by normal ways - you have to jailbreak your console to have access to it. It is a binary file, but a few guys managed to reverse engineer it here and here.

A GUI editor is available at the last link above, but it is target on a platform I have no access to. So I wrote a small piece of PHP code to help me with the task of manually editing the registry file - based on the specifications on the PS3 wiki and also on the code by stoker25.

A sample output is:

[3933] => Array
[0] => /setting/bddvd/mnrForDvdRom
[1] => Array
[flags] => 0
[xxx] => 27415
[length] => 4
[type] => 01
[data] => 0x00000000


[3966] => Array
[0] => /setting/bddvd/dvdRegionCode
[1] => Array
[flags] => 0
[xxx] => 35494
[length] => 4
[type] => 01
[data] => 0x00000001


Which tells me, for instance, that at the decimal offset 3966 (0xF7E) I have the setting /setting/bddvd/dvdRegionCode which holds a value of 0x1. With that information in hand I can open xRegistry.sys with my favorite HEX editor and change that value to 0x4, for instance, and then upload the file back to my PS3.

Note that the registry file is divided in two sections: settings and data. The outer array keys on the output above are offsets to the settings. The data section is located below the settings, and points directly (with a delta of 0x10) to its parent setting. So in the example above I would search for 0x0000076E (which is 0x7E - 0x10) and hopefully I would end up on the value of the dvdRegionCode setting. To make sure you are on the right place, check the other fields as well - flags, length, type and the unknown field "xxx".

For more information on the structure of the registry file, please check the PS3 wiki.

Note that I have successfully changed my dvdRegionCode setting from 0x1 to 0x4 using the method above, but it had no real effect. I still can not play region 4 DVDs. But other people reported it worked for them - perhaps my american console is doing hardware checks while other versions don't.

Monday, October 12, 2009

Mac OS X 10.6 Snow Leopard, iPhone USB Tethering and Bad Carriers

Since iPhone OS 3.0 it is possible to [officially] use your 3G internet connection right into your laptop. That works very well for the all new Snow Leopard, with one single drawback: it is not possible to set name resolution servers when tethering via USB.

You might think it is a small issue but I would say you can be wrong, sorry. Relying on carrier's default DNS can be very annoying when they are faulty. And thats exactly what happens with me all the time. My carrier DNS frequently stops resolving top hit domains such as and many more.

Of course I can switch to bluetooth, in which case Snow Leopard "weirdly" allows you to set your own DNS. But keep in mind that sometimes the phone might have no battery for that. Again, I could just let the phone plugged in a power outlet and bring bluetooth up, but that would have any fun ! I like to have choices, and not being able to tether via USB is something that annoys me and challenged me for quite some time.

No more bla bla bla, I could fix my problem when I found about something called configd and scutil. You can find a bit of information about them here and here. Going straight to the point, I could manage to overwrite my default DNS (with the address for opendns) using scutil and a little of bash scripting. That is what I came up with:

# Replaces current DNS with the one you want in Mac OS X
# Author: Igor Feghali 

STATE=`echo "list State:/Network/Service/[^/]+/DNS" | scutil | awk '{print $4}'`

(echo "d.init"; echo "d.add ServerAddresses * $DNS"; echo "set $STATE";) | sudo scutil

You can set the contents of the variable DNS in the above script to whichever you want. But don't get too excited. This solution will work only for a few moments. I guess that's because configd rebuilds the network configuration periodically.

A short visit to configd man page led me to the right place: /Library/Preferences/SystemConfiguration/preferences.plist stores the preferences for all the network interfaces. The first thing to do is to find out the HEX code of which one we want to modify.

That would be BB6EBCF-861B-4A73-94FE-E08F7EEEE5EE for me. Now open preferences.plist (in the above path) and look for the key string somewhere in the file between a <key> and a </key>. Now replace:




Just be sure to edit the file as root ($sudo vim for instance), save and reboot. That should do the trick.

I couldn't manage to reload the system configuration without a reboot, just let me know if you do.

Monday, June 22, 2009

PHP'n Rio 09

The PHP Local User Group of Rio de Janeiro - PHP Rio are pleased to announce their 1st PHP'n Rio conference. It will be held July 03rd at the
Infnet Institute, Rio de Janeiro. It is a one day mini conference, aimed on providing experienced developers and beginners a chance to learn more about PHP frameworks, web
applications built in PHP and testing code.

The keynote speaker is Jan Schneider that will talk about the Horde project. We will also have sessions about other frameworks and a PHP TestFest.

PHP'n Rio sessions goes from 6pm to 9pm. Then PHP TestFest follows up
to 10pm. No fees or subscription required. Participation is entirely
free !

Whether you live here or are around just enjoying the marvelous city,
come and join us :)

For more information please visit the official site (portuguese only).

We are looking for sponsors so we can bring even more speakers from
around the country while keeping a great conference for free. If you
see your company fits as our partner, please email Igor Feghali <ifeghali at>