Monday, May 23, 2016

Roast peanuts at a lower temperature for a more complex flavour

Online instructions say that peanuts which aren't in a shell should be roasted for 15 to 20 minutes at 350°F, corresponding to 177°C. That can give good results, but roasting at 150°C (302°F) for 25 minutes is better. The lower temperature retains more of the raw peanut flavour while removing the "green" aspect of raw peanut flavour. It also creates plenty of roasted peanut flavour. The result has the best of both the raw and roasted peanut flavours. The lower temperature also doesn't burn the thin red peanut skins, so they don't become bitter like at 350°F. In either case, peanuts should be one layer deep, and they need to be stirred a few times while they're roasting. Fresh roasted peanuts taste noticeably better than commercially roasted peanuts.

Monday, May 16, 2016

Bash on Ubuntu on Windows 10 is fast, but Cygwin integrates better with Windows

Up to now, I used Cygwin. Having it was very important, because it allowed me to do some things which would otherwise require booting into Linux or running a Linux VM. Cygwin is quite good in terms of capability. Problems are rare, there are many packages available, and it's often not too hard to compile other Linux software in Cygwin. Its main disadvantage is that some things are a lot slower. Running ./configure shows the biggest slowdown compared to Linux, but even building via make is much slower. I think the main issue is that process creation is slower due to the more heavyweight nature of Windows process plus the tricks Cygwin does to simulate Unix processes. It can be tolerable though, and I used Cygwin for a lot of Rockbox development.

There were faster alternatives available, like MinGW, Unix tools directly compiled for Windows and Microsoft's Subsystem for UNIX-based applications (SUA). However, there were more compatibility issues with those, so although program performance is better, I would spend more more time dealing with compatibility issues.

Bash on Ubuntu on Windows excited me, and motivated me to give Windows 10 another chance. It would allow even better compatibility with Linux applications without requiring a VM, and could offer better performance. After upgrading to the Fast Ring Insider Preview, it was easy to install. It works impressively well, and is very fast. Various things are still unimplemented, but most aren't very important. The most important missing feature is lack of fully working pseudoterminal support, which prevents X terminal apps from working.

Unfortunately, Bash integrates poorly with Windows, and you almost might as well be running a Linux VM. Ubuntu files are in directories under %LOCALAPPDATA%\lxss , with the root directory hidden at %LOCALAPPDATA%\lxss\rootfs and your home folder under %LOCALAPPDATA%\lxss\home . However, if you try to use ordinary Windows apps to access files there, you run into problems. Ubuntu programs don't see what you put there, and files which are newly modified in Ubuntu are inaccessible until you leave Bash. If you want to share files, you need to use one of the Windows drives, via /mnt/c or similar. Unix permissions don't work there. Using that is similar to how a VM can mount folders from the host.

When I was using Cygwin, I would use native Windows editors, and launch them from the Cygwin command line. Whenever I wanted a GUI view of a folder, I would launch Explorer. The difference between Windows and Cygwin paths is a bit of a problem, but I set up aliases to help:

function detach {
    ( nohup "$@" < /dev/null > /dev/null 2>&1 & disown )
}
function detach_c2w()
{
detach "$1" "$(cygpath -aw "$2")"
}
startfunc()
{
/cygdrive/c/Windows/system32/cmd.exe /c start \"Title\" "$(cygpath -aw "$1")"
}
alias edit="detach_c2w /cygdrive/c/Program\ Files/Geany/bin/geany.exe"
alias fc=/cygdrive/c/Windows/system32/fc.exe
alias open=startfunc

explorerfunc()
{
if [ -d "$1" ]; then
  /cygdrive/c/Windows/explorer.exe "$(cygpath -aw "$1")"
else
  /cygdrive/c/Windows/explorer.exe "/select,$(cygpath -aw "$1")"
fi 
}
alias explorer=explorerfunc


All of that is impossible in Bash on Ubuntu on Windows, although it shouldn't be too hard to make a way to launch Windows executables from Bash. It's also impossible to compile things like Python extensions which use Windows features, and I don't see how that could be made possible. To do it you would need another separate Windows or Cygwin installation of Python. One thing you can do already is cross-compile for Windows, because you can cross-compile from Linux.

I'm sure Bash on Ubuntu on Windows is going to improve. This is just a preview release. However, I'm wondering about the extent to which its design will prevent it from integrating smoothly with Windows.

Thursday, May 12, 2016

Windows 10 may not be better than 7 for desktop use, but it is okay

Windows 8 seemed like a ridiculous sacrifice of desktop usability in an attempt to create a desktop, tablet and mobile hybrid. I didn't even feel a need to give it a chance, because it obviously sucked. Windows 8.1 didn't seem like a sufficient improvement. When I installed Windows 10 preview builds on my laptop, they were very unstable and still a mess due to various features transitioning to the Modern (Metro) user interface.

Ubuntu in Windows 10 made me want to try Windows 10 again. This time, Windows 10 seems usable. I could still list ways in which Windows 7 is better, but most of those are not a big problem. The duplication of features between the classic and modern interface may seem ridiculous, but now the Modern UI is more complete and usable. Lack of decoration in the Modern UI seemed ridiculous in screenshots, but after using it I find it remarkably okay and unoffensive. Its only big problem is bad text rendering in some apps, without subpixel anti-aliasing.

Windows 10 doesn't seem like a big improvement over Windows 7 in terms of desktop usability. Microsoft probably understands this, and offers free upgrades because of it. Otherwise, not profiting from upgrades would be ridiculous. Windows 10 mainly exists as a change of direction, still trying to unify the desktop with tablet and mobile interfaces, and trying to move applications to the Windows Store for profit. The aim is to create future profit, via smartphones, tablets and the Windows Store. I don't know if that part will be successful and worthwhile. However, the change in direction for the Windows desktop is finally succeeding. The interface seems like an alpha version in some respects, but it is usable. Many people are choosing to upgrade, or tolerating unintended Windows 10 upgrades.

There definitely are technological upgrades "under the hood". Windows 10 performs well despite running more services. It has some security improvements. It is clear however that upgrading to Windows 10 isn't going to make your applications run significantly faster generally. What Microsoft says about security seems more like persuasion to upgrade than a good argument, with no evidence of Windows 7 being successfully attacked a lot more frequently.

The most alarming changes in Windows 10 are those which reduce privacy and freedom. When you run Windows 10 you send who knows what to Microsoft. However, in practice this does not really affect you. People willingly give up privacy because they don't see real consequences. The decrease in control, for example with updates, might actually be a good thing. Those who really know what they're doing are still free to do whatever, and those who don't will find it harder to cause themselves problems.

I can't really say that I recommend upgrading from Windows 7 to Windows 10. The best I can say is that it's okay to upgrade. It's a good idea to take advantage of the upgrade offer for future use if it's really ending in late July, but you might want to go back to Windows 7 for now.

Sunday, May 08, 2016

Miranda NG Facebook plugin seems fixed in the development version

For a long time I was getting captchas when posting links in Facebook due to Miranda NG. Then I switched to the development branch so I could use the SkypeWeb plugin and ran into even worse problems.

Since then, the problem has been fixed. I have been using the Facebook plugin for over a month and I'm not getting any captcha requests on Facebook.

If you still don't want to use it, consider Pidgin with the purple-facebook plugin. It is different, using the protocol used by Facebook Messenger instead of the web interface.

Saturday, May 07, 2016

Western Digital's external drive division seems incompetent. Do not buy their drives!

Last fall I got a 5 TB Western Digital My Book drive, WDBFJK0050HBK-NESN. Looking at SMART data, I saw that attribute 192, Emergency Retract Count is increasing despite power not being cut to the enclosure.

The enclosure cuts power to the drive when the computer goes to sleep, the enclosure's sleep timer expires, or USB is unplugged. According to Western Digital support, it sends a standby immediate command before cutting power, which is the right thing to do. The problem seems to be that the enclosure cuts power too soon after the command, without giving the drive enough time to finish unloading the heads. If the drive gets a standby immediate command while the heads are unloaded due to the 8 second idle timer, it will first load and then unload heads, and that takes some time.

An emergency retract is more violent than a normal controlled retract performed while the drive has power. Heads are retracted using power generated from the disk platters' inertia. It wears out the drive more than a normal retract.

It's surprising that this problem exists in the first place. It is a Western Digital enclosure sold with a Western Digital drive inside. Surely they should know how long they need to wait after a standby immediate command before cutting power! The worst problem though is that they're not fixing this. I opened a support request on 11/29/2015. They asked for information, contacted the external drive team and gave me some information. Then all contact stopped. After a few months I escalated the case. They asked for the same information again, and there was no contact since then.

There is a workaround in Linux. Unmount the file system, sync, send a standby command with hdparm -y, wait for the drive to spin down and then unplug USB. (Don't use hdparm -Y for sleep instead, because the enclosure runs into problems when the drive is in sleep mode.) Once the drive is already in standby, nothing happens when the enclosure sends a standby immediate command and cutting power immediately is okay. I don't know how to accomplish this in Windows though.

Because of this bug and the lack of support, I'm beginning to think that it's a bad idea to buy Western Digital external drives. Another thing to consider is that the enclosure controller board encrypts data even when no password has been set. So, you cannot simply take out the drive and access data via a different enclosure or as an internal drive. If the controller board fails you need to replace it with the same model of board, and if the drive fails you will have difficulty recovering data.

Wednesday, May 04, 2016

Converting a primary partition to a logical partition

MBR partitioning only allows for 4 partitions in the MBR itself. One of those can be an extended partition, which then allows for an unlimited number of extended partitions. If you already have 4 partitions in the MBR and no extended partition, and you want to create a partition, then you must convert one of the partitions into an extended partition. This can be done manually:
  1. Shrink the partition before the partition being converted. This frees up space for the extended partition table. Shrink by at least 2 megabytes.
  2. Note the start and end sectors of the partition you are converting, and then delete it.
  3. Create the extended partition. The start sector needs to be before the start sector of the partition being converted. With Linux fdisk it normally needs to be 2048 sectors (one megabyte) before, but with the -c=dos option it can be only 63 sectors before. There is no point in aligning the partition for an SSD, as what matters is alignment of partitions with data inside them.
  4. Create a new logical partition with the exact same start and end sectors of the partition you deleted. Set it to the type the old partition had.
  5. If the partition was bootable, you may need to fix bootability by reconfiguring the boot manager.
  6. Grow the partition you shrunk at the beginning, using up all the space up to the extended partition.
When loading GRUB from a partition, it will fail to load if that partition's number changes, and you'll get the GRUB rescue prompt. It's best to just type in commands there to make GRUB work, and then reinstall GRUB once you get to the command prompt. This example is for when Linux is moved to the first logical partition, numbered 5.
set root=(hd0,msdos5)
set prefix=(hd0,msdos5)/boot/grub
insmod normal
normal 

I wrote the bootloader for chain booting Linux into the first sector of the extended partition /dev/sda4. Make sure you only write the code, which is 400 bytes in that case, and don't overwrite the partition table there. This makes Linux boot if the extended partition is set to be active. Some software doesn't like when an extended partition is active, so this is just an idea, not a recommendation.

Linux is like a video game

Right now I could say Linux is my main OS. I'm using Linux more than Windows, and I even started using it on my laptop. However, I cannot say that Linux is better in terms of user experience, or technically. The main good things about it are that it uses mostly free software (both in the money and liberty sense) and that it offers a lot of choice.

The desktop OS which people call "Linux" actually consists of a lot of components added on top of the Linux kernel itself. You can choose among many desktop environments, including KDE, GNOME, Xfce, Unity and more. There are even alternatives for various lower level packages. This is nice in terms of how it gives the user a lot of choice, but it leads to a terrible mess in terms of configuration. The same setting is affected by multiple configuration options. If you change desktop environments, you have to re-do some settings. Lower level packages have settings which conflict with desktop environment settings, leading to various results. Setting a lower-level configuration setting may cause the desktop environment to disallow changes, or it may set its own settings when it starts, overriding the lower level setting.

Another issue in Linux is that things change a lot. GNOME made a drastic change with GNOME 3, and KDE made a pretty big change with Plasma 5. I find that desktop environments are best when they intelligently evolve and improve over time. These drastic changes throw away progress and even features, and introduce bugs. Because of them I switched desktop environments several times. I used GNOME 2, then hated GNOME 3 when it came out, tried Xfce for a bit, and then switched to KDE. Then Plasma 5 sucked when it came out, and I switched to Cinnamon. Now I may be switching back to Xfce because it has improved. Lower level things also change. A lot changed when Ubuntu switched to systemd. Various settings and scripts from before needed to be moved and changed. Some packages still install scripts which are ignored since the switch to systemd.

Linux is also quite buggy. Even basic functionality like display of battery level in Cinnamon can be broken. Often there are ways around the problem, but it's still additional work you need to do to get things to work. Linux has excellent driver support in terms of the number of drivers, but bugs can be a problem there also.

In terms of performance, Linux had a much more noticeable improvement when going from 2 GB to 6 GB RAM, and when installing an SSD. It seemed slower than Windows before, and those upgrades helped it catch up. Maybe it is even a bit faster now. The fact it was slower before probably means that Linux is less efficient in terms of memory use and caching, but now that doesn't matter much anymore,

I used to judge Linux harshly based on its shortcomings. The only way to like it is to like the process of fixing these problems and customizing things to improve my experience. Because of the way things change fairly often, I don't feel that I'm learning knowledge that's valuable in a long-term way. It's more like I'm playing a video game designed by the developers. That seems okay for now.

The main factor that's driving me toward Linux is the direction Windows has taken recently. With Windows 8, Microsoft did something similar to GNOME 3. It's was a big change which made the desktop experience worse. Even the Windows 10 previews didn't seem like an improvement over Windows 7. Though I tried a recent preview to explore the Ubuntu in Windows feature, and found that Windows 10 is pretty good. I'm still not sure if it is an improvement in terms of desktop experience compared to Windows 7, but it is okay. There is still the decrease in user freedom and increased sending of data to Microsoft. So, I expect to continue using Linux as my primary OS.