Showing posts with label OSX. Show all posts
Showing posts with label OSX. Show all posts

18 June 2019

How to dump macOS security-rights database

macOS handles some security items in a custom database, which may or may not be SQLite. The official way to interact with such database, outside of Objective-C, is the /usr/bin/security utility, with the parameter authorizationdb and specifying the required operation on the class of rights, e.g. security authorizationdb read system.login.console

Unfortunately, there is no way (that I could find) to simply list all classes. I was trying to uninstall something that might have had references in that db, but I wasn't sure about the class it might be registered under, so I wanted to dump them all.

Luckily I found what looks looks like a comprehensive list of rights. After a quick scraping job with Python, I had a list that I could use like this:

cat osxrights.txt | xargs -I % sh -c 'sudo security authorizationdb read %' | grep -B 10 myAnnoyingItemToRemove

... and the bundle wasn't anywhere, so I could just chuck it.

(Note: had the item been found, I would have had to dump the whole security class to a .plist file with security authorizationdb read the.class > my.plist , edited the file to remove it, then write it back to the db with security authorizationdb write the.class < my.plist )

14 March 2019

How to remove all bars in fullscreen mode in Firefox on MacOS/OSX ("kiosk mode")

Procedure

If you want to remove all toolbars from Firefox in fullscreen mode on Mac, this is the procedure:

  1. Type about:config: in the location bar to open advanced settings. (If it is the first time you do it, you might have to click "confirm" or something like that in the scary screen that comes up first.)
  2. search for full-screen-api.allow-trusted-requests-only and double-click the line that is found, so the value changes to false
  3. Bring up the Bookmark Toolbar if you don't have it (menu View -> Toolbars -> Bookmark Toolbar)
  4. Right-click on empty space in the Bookmark Toolbar, and select New Bookmark...
  5. In the Name field, type something like "Enter Fullscreen" (it doesn't really matter, just don't leave it blank)
  6. In the Location field, enter the following line:
    javascript:document.getElementsByTagName('html')[0].mozRequestFullScreen();void(0)
  7. Click Add to save the bookmark.
Now, when you click on that bookmark, Firefox will go "real fullscreen", hiding all toolbars. To get them back, you will have to press ESC.

Now, there is a bit of a snag. That preference in about:config: is set to true by default for a reason: it is a bit unsafe to allow any website to use fullscreen-enabling javascript. For this reason I would suggest to only do this for limited periods, then switch it back once you're done.

Long-winded explanation

FF has a preference, browser.fullscreen.autohide, that in theory should govern the behaviour of toolbars when going fullscreen. It is set to true by default, meaning toolbars should disappear. However, for some reason this property has (almost) always failed to work on MacOS/OSX builds of Firefox.

There used to be a few extensions that corrected that behaviour, but they've all gone away when Firefox switched to WebExtension APIs, which basically sandboxed extensions more rigidly and blocked them from changing the browser interface as deeply as they could before. This was the price for the dramatic performance improvement seen in Firefox 57+.

This workaround hence relies on the new Fullscreen WebAPI, which is supposed to be a new, standard way to enable fullscreen via Javascript on any browser (well, any browser that implements it - just a few at the moment). However, because of security concerns, this API is locked down by default; so, in order to use it, we first have to relax checks as described above. Once that is done, we can launch a bit of JS from a bookmark that triggers "real" fullscreen.

Credit to this AskDifferent post where I first found the trick.

31 July 2017

How to build waifu2x command-line version on osx

UPDATE 23/10/2017: recent changes seem to be incompatible with clang. I have updated the steps below to check out the last commit that is known as working.
Waifu2x is a popular image converter backed by neural-network models, typically used to upscale images from anime. The various web versions are easy to use but typically don't allow for batch-processing, because it's a relatively intensive operation. However, there is a command-line version that is fairly easy to compile on Windows and Linux. OSX support was notably absent... until now.
These are the steps required to get it working on Mac:
  1. brew tap science && brew install opencv3
    (if you don't have Homebrew, go install it now - it's wonderful)
  2. git clone https://github.com/DeadSix27/waifu2x-converter-cpp.git
  3. cd waifu2x-converter-cpp
  4. git checkout d69313040b0784662465fb1d2eca81a2b1ebccb2
  5. cmake -DOVERRIDE_OPENCV=1 -DOPENCV_PREFIX=/usr/local/Cellar/opencv3/<your version here> . (remember the dot at the end!)
  6. make -j4
At this point, you have the executable waifu2x-converter-cpp in the directory; you can make install if you really want to (I prefer to keep custom stuff in my home dir). To test it's working, the following command should return info on your system:

./waifu2x-converter-cpp --list-processor

If you need some images to test, here you can get quite a few stills from the gorgeous 5 Centimeters Per Second. Note: you might have to rename the folder "models_rgb" into "models" before converting.

BONUS: Qt GUI

If you hate the command-line, there is a simple QT wrapper. To compile it you will need Qt-Creator and Qt installed and configured. This used to be very complicated, but both items have now been packaged for Homebrew so it's all awesomely simple (well, compared to what it was, at least). Note that you still have to do the steps above - the wrapper needs the waifu2x executable to be already compiled.

Install and configure Qt and Qt-Creator

  1. brew install qt && brew cask install qt-creator
  2. Launch Qt Creator from Launchpad, then go to Qt Creator -> Preferences (Command + ,)
  3. Select Build & Run, then the Qt Versions tab
  4. Click on Add... and select “Macintosh HD”
  5. Press Command + Shift + . to show hidden directories
  6. select /usr/local/Cellar/qt5/<your version>/bin/qmake then OK and OK again to close the Preferences window
  7. Reopen Preferences -> Build & Run, select the Kits tab and click Add
  8. Set the following options:
    • Name to something like "Qt CLang Desktop" 
    • Both Compiler options to Clang X86 64bit
    • Qt Version to the version you just created
    • Click on Make Default then OK to close Preferences.

Compile waifu2x-converter-qt

  1. git clone https://github.com/toyg/waifu2x-converter-qt.git (the original repo looks abandoned, so I forked it and tweaked it a bit)
  2. cd waifu-converter-qt && open waifu2x-converter-qt.pro (this should open Qt Creator; if it doesn't, launch it manually and File -> Open Project -> select the .pro file).
  3. Select Build -> Run (or Command + R). The resulting .app bundle should now be in a folder called build-waifu2x-converter-qt-<something something>, just beside your main project folder.
When you first launch the GUI, you should probably go to Preferences and set the path to your waifu2x-converter-cpp executable.

18 May 2017

How to get Ctrl-arrow shortcuts working in RDP sessions on macOS / OSX

It looks like recent versions of the official Microsoft Remote Desktop client are a bit shy when it comes to sending CTRL to the remote Windows session. I discovered this because I use Ctrl-Arrow very often to move from word to word, and it just stopped working in RDP.

The solution is to make sure you don't have any overlapping OSX shortcut - typically, CTRL is used for Mission Control actions. Just disable them from System Preferences -> Keyboard -> Shortcuts -> Mission Control and you should be good to go. Any recent Apple keyboard will have real keys dedicated to those actions anyway.

(Come on Microsoft, show some guts - have an option to bypass Mac shortcuts entirely!)

25 April 2017

how to force-refresh macOS text auto-expansions without turning off iCloud

One of the little niceties OSX has had for a while is the automatic synchronization of text-expansion shortcuts across all iCloud-enabled Apple devices (i.e. what you find in System Preferences -> Keyboard -> Text on Mac, and General -> Keyboard -> Text Replacement on iOS). Unfortunately Apple tries a bit too hard to make it look "magic", which means that there is nothing one can do when the magic somehow refuses to work.

In my case, I ended up in a situation where the mac had lost all shortcuts. Various people on the internet recommend turning iCloud Drive on and off to get them back, but that's a very disruptive step I didn't want to take.

Luckily, this worked for me:

  1. Open a command terminal
  2. rm -rf ~/Library/Mobile\ Documents/com~apple~TextInput
  3. Log off
  4. make a change to the list of expansions on some other device (e.g. iPhone)
  5. log back on
This seems to have forced a refresh, and got all my shortcuts back.

It would be nice if Apple provided some command-line tool to perform this sort of explicit management for iCloud elements. As the saying goes, cache invalidation is one of the hardest problems in Computer Science; in order to do the right thing, any system needs all the help it can get. I should be able to say "just blow all my settings for this feature and refresh from iCloud" or "these are the good settings, overwrite whatever is in iCloud for this feature". Magic is nice, but as the citizens of Troy found out so many years ago, it's better to have backup plans for when the gods are against you.

18 December 2016

OWC 12-port Thunderbolt2 dock review

As you probably know, recently the Apple world has been rocked by the release of new MacBookPro models. One of the arguments of contention is the drastic switch to USB-C / Thunderbolt 3. Not by coincidence, I've recently decided to finally splurge for a Thunderbolt dock, although a TB2 one; my 2012 MBPr only supports TB1 (the port that looks like a MiniDisplayPort), so anything more would have been a waste of money. Here is a short review for people who might wonder whether this dock is worth the price.

I've dealt with my fair share of no-name Taiwanese stuff in my life, and I didn't want to risk it this time, so I turned to OWC - a very reliable supplier of Apple accessories. Their 12-port Thunderbolt2 hub got some good press, so I went for that. First impression was slightly disappointing - the unit is well built and feels pretty sturdy, but the one I received was scratched on top, and overall looked a bit like an ex-display or returned model. Let's not be "a typical Apple user", I thought, and see how it works before we knock it.

Sure enough, it works pretty well. I went from having all MBP ports occupied, to using one with even more attached devices than before. This is what I connected:

  • External Thunderbolt drive
  • External USB2 drive
  • 4k display (via HDMI)
  • Ethernet
  • headphones
  • two Amazon Kindle
  • gamepad controller

The hub is independently powered, so it can charge devices even when the laptop is shut down. However, it's not magic; there a few trade-offs you should probably be aware of.

The first is that attached Thunderbolt devices inevitably lose a little bit of performance, since bandwidth is shared. This is probably less noticeable if your laptop supports Thunderbolt2, which supports higher speeds, but it's definitely visible with TB1. My external drive saw a 20% loss of speed, from 360 to 300 MB/sec, which is inevitable: now that we're sharing one TB bus among 8 peripherals, the drive can't max it out on its own. It's still very respectable though, and likely a blip if you use TB2 throughout (i.e. MBPr models from 2013 onwards).

The second issue is more disappointing. Having both an HDMI port and one TB/DisplayPort available (the other is used for the actual connection to the laptop), the hub supposedly supports attaching two screens. I first connected my primary monitor to the hub HDMI port; HDMI is the only way to get 4k on the 2012 MBPr. This worked fine, exactly as it did on the actual laptop port. However, as soon as I attached a second screen to the TB port on the hub, the HDMI connection was downgraded to half the native resolution. This did not happen when I had both screens attached to the laptop, so it doesn't seem to be an issue with OSX; rather, the hub must be doing some internal processing over video streams, and must have some sort of ceiling in the amount of pixels it can push down the wire (or something to that effect). In short, I would recommend to only attach one monitor to the hub, if it is a high-res screen.

A similar behaviour appears if your HDMI screen happens to have speakers. Sound quality degrades so massively, it is simply unusable: lagging, skipping, terrible sound all around. It's weird, because the analog headphone jack works perfectly, so it must have something to do (again) with HDMI stream management.

The fourth issue, and the reason I wouldn't be surprised if it turned out this is indeed a returned model, is that the whole hub suffers something like a crash if you use the "high power USB" ports for more than a couple of hours. All attached devices suddenly stop working, and reconnecting the TB cable makes no difference. The couple of times it happened, I had to power-cycle the unit (which does not have a switch, so I had to unplug the mains cord) after disconnecting all non-essential devices, in order to get it back online. I've isolated the issue to the high-powered USB ports, which I used for two Kindle units: if I detach the cables after 20 or 30 minutes, all is fine, but if I leave them there for a few hours, inevitably I'll get a crash. To be on the safe side, I moved my precious TB drive back to the second TB port on the laptop (I simply cannot afford to corrupt that drive), and mostly stopped used those ports.

The last point is not a real problem, just a little gotcha. The headphone jack is analog, but it's not an automatic passthrough. In order to actually use it, you have to go to System Preferences / Sound / Output, and select "USB audio output" as your output device. Quality seems fine, but I'm not an audiophile so I will refrain from commenting further.

Overall, the hub seems to work more or less fine (bar the power-loss scare), and it's very convenient for my setup. Thunderbolt, even in its first incarnation, is an extremely powerful standard, just on the expensive side. I won't be buying a new MBP anytime soon (new models are just not as powerful as I'd like, the British Pound is moribund, and this 2012 model is still rocking), but if you do, you should find the power of TB3/USB-C outweighs the annoyance of migrating to yet another I/O standard.

08 July 2016

How to (not) handle OneDrive/Sharepoint "Sync Now" on Mac OSX

UPDATE October 2017: This post is obsolete, the OneDrive client for Mac now handles sync correctly. If you still have issues, file a bug report.

This bugged me for a bit and finally got around (almost) fixing it yesterday, so I thought I'd record it for posterity.

Microsoft Office365 will usually include a Sharepoint implementation of some sort. Sharepoint now integrates with OneDrive (aka "Microsoft Dropbox")... on Windows. On Mac, the current state of play is as follows:
  • You should get the free OneDrive app from Mac App Store. If you have previous beta versions or anything like that (which never worked particularly well), uninstall them before installing this.
  • Once you start and connect OneDrive to your Office365 subscription, your personal files will automatically sync to the OneDrive folder. It seems to work reasonably well.
  • However, files shared by others to you will not sync. The feature is just not implemented yet.
  • If you access Sharepoint or OneDrive from the website and click on the Sync Now button, the website will generate a link that looks like this: grvopen://http-etc-etc and pass it to the browser. By default this grvopen protocol will be associated with OneDrive and do nothing, because (guess what?) the feature is not implemented yet.
  • However, if you have a virtual machine with Windows and Office installed, there is a chance that the link will be passed to the Sharepoint client running on that machine. You probably don't want that: it will likely break things once the feature lands in OneDrive for Mac. So you can follow these instructions for VmWare Fusion to stop it from happening. Make sure to click on Clean Up Applications after deselecting Open your Mac files and web links using Windows applications. (Other virtualization products will have different ways of doing this, check your docs.)
I can see a forced approach where you configure OneDrive in your virtualized Office to use the same folder that OneDrive for Mac is using, but I expect this would bring up all sorts of issues. These sync programs do a lot of dirty tricks with file metadata and I'd rather not risk precious company files. I guess I'll just wait for MS to bring feature parity to OSX, and use the website in the meantime (which is actually slowly improving as well).

25 May 2016

Change your login background in OSX

A little something for my long-suffering OSX readers: a simple script to change your login background. Note that images must be in PNG format.

Copypaste the code above, save it as /usr/local/bin/set_login_background.sh, and execute like this (the first line is necessary only on first usage):

sudo chmod a+x /usr/local/bin/set_login_background.sh
sudo set_login_background.sh /path/to/my-new-image.PNG

21 January 2016

OSX Nostalgia

I have to say, I really don’t like the direction the OSX interface is going. All this flatness is tremendously boring. I’ve found myself very nostalgic of the old ”Aqua” interface several times in the last few months.

Unfortunately, Jony Ive’s iron grip is so tight, all theming/customization hooks have been removed from recent OSX releases. There is now no application (that I know of) which could reskin windows, toolbars and scrollbars.

The only avenue left to UI tinkerers is icons. You can still use LiteIcon to override system icons, and of course copy-paste on individual folders. I’m currently using icons from the classic Iconfactory World of Aqua series, and I just love them.

Some programs will thankfully allow you to customize them. There are plenty of Aqua themes for Firefox, I use a slightly cheesy one. iTerm2 has an ”Aqua” option for its tabs.

If you are an app developer — please consider some skinning support. For all the talk about ”consistency” from UI nazis, the first thing people do on a new computer is still to customize the desktop background...

09 December 2015

how to fix jEdit 5.3.0 on OSX with Retina screen

jEdit is a great little editor: very flexible, much plugins, such macros, so java.
However, for some reason jEdit developers strenuously refuse to fix their OSX package to support Retina screens. Three years since these screens started getting popular, you still have to repeat the following procedure after each jEdit installation or update, in order to avoid getting blurry fonts everywhere:
  1. quit jEdit if open
  2. in Finder, right-click on jEdit in Applications, select Show Package Contents
  3. go to the Contents folder, then edit Info.plist by adding these two lines at the end of the file, just before </dict>:
    <key>NSHighResolutionCapable</key>
    <true/>
  4. force OSX to re-cache the plist by executing the following command in a terminal:
    defaults read /Applications/jEdit.app/Contents/Info.plist
  5. Restart jEdit. Icons will still look crappy (the "classic" theme slightly better than "tango"), but the rest will be ok.
On a more positive note, jEdit 5.3.0 (running on Java 1.8.0_66) seems to have fixed the crashes I've had for a year. Welcome back, "little editor that could".

07 November 2015

Link feeds about Weblogic, EPM, Hyperion etc

I've recently started using the excellent Pinboard bookmark manager (a wonderful throwback to the glory days of del.icio.us) to keep track of interesting posts. While I think about the best way to syndicate those links across all my public accounts, you can check out these feeds:

13 October 2015

OSX 10.11 El Capitan / Sierra and Kinesis Freestyle 2 Bluetooth little glitch

UPDATE 2017-04-25: this solution came in handy when I had another glitch with Sierra: keys would lag or repeat very erratically. Tried resetting pram etc to no avail, so then I performed these steps out of desperation and it all went back to normal.

After upgrading to El Capitan, my Kinesis Freestyle 2 Bluetooth keyboard had a small issue, which I'm documenting here in case other people hit it.

Basically, after installing the OS update, F*/special keys were dead. Solution:

  1.  Open System Preferences -> Bluetooth
  2. Click on the X icon to the right of the keyboard, in order to un-pair it.
  3. turn the Kinesis off, then on again, and press the CONNECT button at the back of the keyboard
  4. The keyboard should pop on the screen, select it and pair it again (you will have to type a few numbers shown on screen)
All done! You should now have your special keys back.

04 October 2015

"Erase Free Space" on OSX to reclaim space

Being a heavy VMWare user, my laptop disk is always very close to being full. In a perennial search for space-saving tips, I've found a few sources mentioning the "Erase Free Space" command in Disk Utility could help reclaim a few GBs.

What is this command? Most operating systems "cheat" when deleting a file: they just mark sectors containing the file as free, without actually deleting any data. "Erase Free Space" is meant to actively write zeroes on all disk sectors reported as free, in order to actually erase content that might have been written to such sectors at some point in the past. It's a privacy / security feature, not supposed to reclaim space, but hey, it won't hurt to try! So I decided to give it a spin.

My experience was as follows:
  1. Verified that I had 34 GB of free space (out of 500).
  2. Launched Disk Utility selected the disk partition  i.e. the lowest "Macintosh HD" leaf item in tree menu.
  3. Selected the Erase tab, clicked on Erase Free Space in the lower-left area. Because I have an SSD disk, I chose the "fastest" level: excessive wear should be avoided on SSD disks as much as possible, and I was not performing this operation for security reasons anyway so I didn't really care.
  4. Observed disk free space dropping to zero in about a minute. Received message that disk is full (fair enough) and then another that Disk Utility failed to erase free space. Reported free space was now 34 GB again.
  5. At this point, retrying the operation or going to First Aid -> Verify Permissions returned all sorts of errors about the disk being locked. One error was this: "This disk needs to be repaired using the Recovery HD. Restart your computer, holding down the Command key and the R key until you see the Apple logo. When the OS X Utilities window appears, choose Disk Utility."
  6. I duly followed the procedure; however, when I launched Disk Utility in Recovery mode, almost everything was greyed out except "Verify Disk". This is because I use FileVault (i.e. total disk encryption) so the generic recovery utility, by design, has no access to the actual filesystem, which it sees as a single huge chunk of garbage data spanning the entire drive. It was a welcome surprise: it looks like this security feature actually works as it should.
  7. I clicked Verify Disk where I could (on the top disk item) and it didn't report any problem. Closed Disk Utility and went to the Apple menu -> Restart.
  8. After logon, all permissions-related commands in Disk Utility were usable again.
  9. Most importantly, I now had 39 GB of free space.
Conclusion: it was a slightly scary experience, but got me back a nifty 5GB (or 1% of drive), so I guess I'll do it again in a couple of months.  I suspect the saving might actually be due to OSX reacting to a sudden lack of free space by flushing all the semi-permanent caches it can find; either that, or it forces some sort of defragmenting/fscheck routine at the following startup that results in a more optimized filesystem. To be honest I'm not terribly curious, I'm just happy I have another trick up my sleeve!

02 November 2014

What to do if Apple Mail becomes invisible in OSX 10.10

Apple Mail is a solid application, but occasionally it can be infuriating.

Today, all of a sudden, when I opened it, the main viewer window would not appear. The program seemed to work fine in the background: I received notification of new emails, the unread count on the icon would get updated, but there was no window. Trying to use Exposé, "Bring all to Front", "Arrange all to front" wouldn't bring any improvement. Right-clicking on the icon and selecting "Show all windows" would show transparent squares with actual window titles, but trying to click on them would make no difference. File -> New Viewer Window seemed to produce new "transparent" windows, so the list under the Window menu would get longer but I still wouldn't see anything. Using Applescript to resize and reposition a window gave very strange results, with the window appearing half-broken (no Preview column, no Mailbox list, missing toolbars etc) and eventually disappearing again.

Out of desperation, I quit Mail and started digging in the filesystem. I eventually managed to fix the problem by doing the following:

cd /Users/your-user/Library/Containers/com.apple.mail/Data/Library
# 'tar' is just for safety, delete the gz file if fix works
tar -czvf ~/Desktop/Preferences.tar.gz Preferences
rm -rf Preferences


When I then launched Mail, the Viewer window finally appeared and worked correctly. It had lost my original layout, so I had to set a couple of preferences again, but apart from that it seemed to work well and it didn't lose any mail or account information. 

04 January 2014

How to run Twister on ARM (Debian) and OSX

I'm growing very fond of Twister, a new project from Brazilian developer Miguel Freitas. Miguel basically leveraged Bitcoin and Bittorrent concepts (and code!) to build a fully-decentralised Twitter clone. The P2P architecture means that it's completely immune to censorship and "chilling effects": nobody in the network can hand your account over to the authorities or disclose who you are, nobody can delete your posts -- and neither can you, so be careful what you post :)

It's definitely early days (it's still a bit hacky to set up, and the html interface needs work), but I've decided to help a bit, so I managed to make it work on OSX and now on my little ARM-based always-on home server, the CuBox. Like most lightweight P2P services, Twister is perfect for long-running, low-power ARM instances (Raspberry Pi etc), so this is what you'll need to know if you want to set it up there.

  1. Download all libdb4.8* packages from Bittylicious. Berkeley DB 4.8 is a Bitcoin requirement, and at this point in time there's no way around it. Unfortunately, recent distributions (i.e. Debian Wheezy and newer) replaced it with 5.1, so apt-get won't help you (NOTE: if you don't care about wallet compatibility with already-running instances, you can just use libdb5.1). You can compile libdb4.8 from source if you want, but they'll require about 500 MB of dependencies (java, X etc); the Bittylicious packages worked fine for my vanilla Debian install. There's a chance that BDB as a whole will be dropped at some point in the future.
  2. Download other dependencies: openssl-dev, libboost-all-dev, miniupnpc (miniUPNPc is technically optional but strongly recommended, it makes it a breeze to go through firewalls). These should come down fine with apt-get. Note that OpenSSL should be version 1.0+ (check by running openssl version). NOTE: it's been reported that default Fedora openssl packages (built without support for Elliptic Curve crypto) will make Twister crash at the moment. Make sure you find alternatives until the bug is fixed.
  3. clone Twister repositories:
    git clone https://github.com/miguelfreitas/twister-core.git
    git clone https://github.com/miguelfreitas/twister-html.git
  4. prepare your configuration (note: DON'T edit user and pwd, they're hardcoded elsewhere at the moment):
    mkdir ~/.twister
    echo -e "rpcuser=user\nrpcpassword=pwd" > ~/.twister/twister.conf
    ln -s /path/to/your/twister-html ~/.twister/html
  5. Follow these instructions to build twisterd. You might want to link it under /usr/local/bin once done.
  6. Launch it. Give it 5 to 10 minutes to download the full blockchain, then connect to http://your-server:28332/home.html . You'll be prompted to create an ID - do so.
  7. After creation, make sure you backup your key by doing:
    ./twisterd dumpprivkey my-user > my-key.txt
    Backup my-key.txt (or just its content) in a safe place, it's your all-important key: you lose that, you lose access to your ID and there is no way to get it back!
  8. You should also backup ~/.twister/user_data as it contains your direct messages; these can theoretically be retrieved if lost, but it takes a while, so it's probably good practice to just back them up regularly.
  9. Enjoy! The community is very small at the moment, so feel free to go on a follow-spree. There are two mailing lists, Twister-Users (more active) and Twister-Dev (more technical). The project is brand new (Miguel released it at the end of November 2013) so expect a bumpy ride, but the community is very friendly and in need of help with HTML and jQuery as well as C++, if you can spare some cycles :)

For OSX, the process is slightly more convoluted at the moment, so I documented it in the official doc/build-osx.md. Note that I'm not a make guru, I'm certain that there's plenty of room for improvement there -- feel free to contribute!

02 November 2013

How to easily create custom networks in VmWare Fusion 5 Standard

For a long time, creating custom networks in VmWare Fusion has been a challenge. For some bizarre reason, for years Fusion lacked the network-management GUI commonly found in the equivalent VmWare Workstation product for Windows.

Since switching to OSX last year I've had to edit each VMX file, forcing interfaces to use a custom network definition, but I've recently come across a lovely tool that greatly simplifies this task AND finally clarified for me how Fusion stores network definitions.

This tool is UBER Network Fuser, by Nicholas Weaver. It was released in 2012 when he wasn't working at VmWare yet, and it's not been updated since -- likely because Fusion 6 now offers similar functionality in the twice-as-expensive Professional version (which I think is ridiculous -- Workstation comes in one version with all features, why does the overall-less-powerful OSX equivalent have two?) but it still runs fine on OSX 10.8.5 Mountain Lion.

The tool itself is really easy to use: just go to the Networks tab to add or edit subnets, specifying whether you want to use the Fusion-provided dhcp and NAT services and to run through a virtual adapter. For some reason it won't allow you to customise subnets (you get a random 192.168.x.x net with mask 255.255.255.0), but that can be hacked-in as I'll show you later.

Next, go to the Configuration tab and click on the path to your Virtual Machines (which might already look correct, but won't work until you actually set it yourself). Leave the Preferences Path alone.

Now go to the Virtual Machines tab, refresh the list, select a machine to edit, select the interface you want to assign to your custom network, and select the network. Done!

This is already a nice set of features, but the real kicker is still to come. Close the tool, start Fusion, edit another image, select your network adapter, scroll the option list… your custom network is now an option for all machines! This is because Fusion stores network definitions in /Library/Preferences/VMware Fusion/networking - open it with a text editor and you'll see it contains old and new network definitions. UBERNF manipulates this file, and Fusion is happy to go along with it. You could just change subnet values here, I believe.

Unfortunately Nicholas didn't release any source code for UBERNF (I wouldn't be surprised if some of it ended up in Fusion Professional, to be honest), so there is no way to improve it or even just fix little defects that are probably due to OSX changes between 10.7 / Lion (the version he compiled it on) and 10.8 / Mountain Lion. It would be nice if somebody could write a similar app for Mountain Lion / Mavericks and release it as open-source, or simply charging a few dollars less than the difference in cost between Fusion Standard and Professional. Silly, silly VmWare...

11 July 2013

Safari extension to show XML

A few months ago I started using Safari for most of my browsing, because I love trackpad gestures and I'm a sucker for smooth animations. However, if there's one thing that Safari gets spectacularly wrong, it's dealing with XML. As far as I know, in Safari 6.x there is no way to display raw XML, the damn browser will always try to launch an external feedreader, and even selecting which feedreader requires industrious hacking that I'd rather avoid. This is particularly annoying when some memory-hungry, battery-burning giant application hijacks this process: in my case, VmWare Fusion will always try to launch one of my images, which is just terrible.

To cut the story short, I wrote a small extension to prevent this horrible process. When I want to have a look at an XML file, I right-click on the link and select "Show me that feed". The result is a slightly-formatted view of the file, in a new tab.

You can download the ShowMeThatFeed Safari extension on BitBucket.

I haven't been a web-plumber for more than 10 years now, so I'm sure it can be dramatically improved -- the formatting in particular is implemented with regexes (argh). Please feel free to fork the BitBucket repository for ShowMeThatFeed, pull requests are very welcome.

UPDATE: Apologies, I've pushed quite a few updates (included some buggy ones!) in the last few hours, but now it should work fine.

07 June 2013

iTunes "File Sharing" is a ridiculous pain

There is no way to programmatically access the application-specific "File Sharing" directories on iPhone from OSX. You are forced to start iTunes and manually select the phone, select "Apps", select your app, drag&drop files.

In 2013.

With a unix-based OS talking to another unix-based OS.

This is ridiculous.

No, I will not jailbreak my phone. This is something that Apple should expose in an API, either via iTunes / Scripting Bridge or via direct Obj-C calls. iCloud simply doesn't cover all use-cases (and, reportedly, it's broken anyway).

This is the frustrating side of the Apple ecosystem: sometimes, you'll be prevented from doing something very simple and very obvious, for some obscure reason nobody cares about (except Apple, of course).

17 May 2013

Apple Firewire-related update resulting in USB disk not mounting - fix

Last night Apple pushed a small OSX update, purportedly related to Firmware. It required a reboot and completed successfully. Unfortunately, it also stopped one of my external USB disks from mounting. Others were mounting fine, but this disk (which was mounted the night before, during the upgrade, and removed after shutdown) couldn't be seen.

To say I was scared to death is an understatement: there's always a chance that problems like these are due to hardware issues. Unfortunately, Solid State Device (SSD) disks have a limited life and will eventually fail. This was a 500 GB disk with a lot of very useful stuff on, programs I need every week or so, now-untrovable applications, etc. Before I'd let go of this baby, I wanted to go to the bottom of it.

Almighty Google pointed me to an old post mentioning USBProber but it didn't mention what USBProber is (a debug tool by Apple) nor where I could find it (it's not installed on OSX by default, at least not on 10.8 Mountain Lion). Luckily, another blogger mentioned it, and I could finally get it from the Apple site: you will find USBProber at the Apple Developer Site under the name "IOUSBFamily Log". I got the 10.8 version and installed the package ending in "-Log", as instructed.

USBProber.app can be found under /DevTools/Hardware. Once launched, it gives you a number of options to track USB activity. I'm not a hardware hacker, I only have a cursory knowledge of Plug and Play mechanics from my old Linux days, so I poked and prodded here and there without much luck. Eventually, what seems to have done the trick was to select "Bus Probe", ticking "Probe suspended devices", and then hitting "Refresh" several times, until the drive appeared in the list. Switching to Finder, I could see that the drive was in fact mounted, and all contents were displayed. Phew.

I hope this is not something I'll have to do over and over. Hopefully I'm not the only one to see this issue, and Apple will eventually push a correction. Meanwhile, USBProbe looks like a nice find to troubleshoot problems like this, and hopefully this post will be useful to people in the same situation.

12 September 2012

Free disk space by removing TimeMachine local snapshots

Mac OSX TimeMachine's "local snapshots" are basically backup files stored on your local hard-disk (as opposed to regular ones stored on the external TimeMachine server). This is a useful feature for people who travel a lot, so they can revert files to recent versions even when they are not connected to their home TimeMachine.

Unfortunately, this feature tends to take a lot of disk space whenever you deal with big files (like movies etc). In some cases, you might want to temporarily disable it in order to claim back a few GigaBytes. Note that your regular TimeMachine backups will NOT be affected; you'll just lose the ability to revert to recent (i.e. from last week) versions without being connected to the external TimeMachine.

TimeMachine is managed from the command line with the tmutil command. You can type man tmutil to see all options. To disable the snapshots and delete those big files (which are found under /.MobileBackups, by the way), use "sudo tmutil disablelocal". Once snapshots are purged, you can restart the feature (if you need it) with "sudo tmutil enablelocal" (yeah, not exactly rocket science).

In my case, this procedure freed some 139 GB on a 512 GB disk. Not bad!