How-To: Fix IntelliJ / Android Studio screen display corruption

With my NVidia 980M w/ Optimus graphics card, Android Studio (which is IntelliJ-based) would often get itself in a state and the screen would get corrupted, which was incredibly frustrating to work with. Luckily there seems to be a pretty simple solution:

1 – Find your user folder

If you want to make this change on a per-user basis, then you’ll need to create a vmoptions file in the relevant user-directory. I’m doing this fix on Windows running 64-bit Android Studio so I’ve created the file: %USERPROFILE%\.{FOLDER_NAME}\studio64.exe.vmoptions

Depending on your operating system, the filename and locations are:

Windows:
%USERPROFILE%\.{FOLDER_NAME}\studio.exe.vmoptions and/or %USERPROFILE%\.{FOLDER_NAME}\studio64.exe.vmoptions

Mac:
~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions

Linux:
~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions

Where FOLDER_NAME is something like AndroidStudio1.5 or such.

If you want to make the change on a global basis (although the config file doesn’t recommend this), then you can modify the studio.exe.vmoptions configuration file in the bin folder located wherever Android Studio is installed (on Windows this is likely to be “Program Files” for 64-bit or “Program Files (x86)” for 32-bit Android Studio). So for me the ‘global’ config file is: C:\Program Files\Android\Android Studio\bin\studio64.exe.vmoptions

Source: http://tools.android.com/tech-docs/configuration

2 – Add this switch

Save the file then restart Android Studio and the display corruption should be fixed!

Source: http://stackoverflow.com/a/27768329.

Wrap up and secondary workaround

This worked fine for me in Windows, but as the settings affect Direct3D, I’m somewhat doubtful that it’ll work in Linux or Mac. However, I did read about a workaround technique where you go into the NVidia Settings panel, select your java runtime and force it to always work in maximum performance mode, thus bypassing any use of Optimus which may also be causing the screen corruption – so should the above fix not work for you, then perhaps the workaround will.

Cheers!

How To: Copy a file to a FTP server from the command line

A nice, easy way to upload files to FTP servers is via some graphical client like FileZilla, but should issues occur or you need to transfer the file without a GUI, then can also upload files via scp like this:

For example, if I want to upload a file proving bigfoot exists (in the imaginatively named file: bigfoot_exists.mp4) to the domain example.com on port 1234 to the user (on that site) somefool in their home directory (i.e. ~), then I’d use:

Job done.

Addendum – Copy from server to local

$ scp -P 1234 remote_host_username@remotehost.foo:some_file.txt /some/local/directory

For example, if remotehost.foo’s ssh daemon operates on port 1234, I could copy php.ini from /srv/ftp to the “bar” directory in my local user’s home directory as follows:

How To: Run Unreal Tournament 2004 via Wine in Linux

From: https://appdb.winehq.org/objectManager.php?sClass=version&iId=5425&iTestingId=5079

Unreal Tournament 2004

I found that I had to make these changes to get the game to work in full-screen mode. Once these changes were made it worked perfectly all the time.

In the registry set the following key:
HKEY_CURRENT_USER/Software/Wine/DirectInput/MouseWarpOverride = force

In winecfg add checkmarks to the following checkboxes:
Allow DirectX apps to stop the mouse leaving their window
Emulate a virtual desktop (enter your screens native resolution)

In UT2004/System/UT2004.ini in the [Engine.Engine] section:
Uncomment RenderDevice=OpenGLDrv.OpenGLRenderDevice
Comment out your old RenderDevice

In UT2004/System/UT2004.ini in the [WinDrv.WindowsClient] section:
Set your WindowedViewport to your native resolution
Set your FullscreenViewport to your native resolution
Set your MenuViewport to your native resolution

I didn’t have to change the MouseWarpOverride setting to fix the mouse lock issue – simply running in a virtual desktop at my native resolution fixed that. Also, I couldn’t find an “Allow DirectX apps to stop the mouse leaving their window” option in winecfg, so I didn’t do that either. I did need to install lib32-openal to get the sound to play properly though. Once done, it all plays fine under 64-bit Arch Linux using wine-1.7.54.

Hurrah! =D

P.S. There’s a native Linux client for UT2004, but rather than dig about the net finding ancient binaries, symbolic linking libs to pretend I have older versions and patching together a complete set of files from the Windows version I have, I’ve just opted to use wine. Once you’ve done the above setup it all works flawlessly.

How To: Simply Convert A Directory of FLAC files to MP3 with FFMPEG in Linux

Stick the following in a file called flac2mp3 or such, chmod +x it, then put it in somewhere like /usr/local/bin

To use it, simply go to your folder of .flac files and run flac2mp3, then perhaps rm *.flac to get rid of the (massive) flac files you don’t want anymore.

How To: Fix Unreal Tournament GOTY running too fast in Wine

I picked up Unreal Tournament GOTY edition on GoG while it was on sale for a pittance recently – but as it’s the Windows version and I wanted to run it on Linux, this means I either have to use Wine or a virtual machine. Wine happened to run the installer & the game – however it would speed up the game to ridiculous / unplayable speeds on occasion. After doing a bunch of googling about how to fix this via complex configuration file changes, limiting CPU usage etc. I saw that you could just enable VSync to fix the issue.

I have VSync enabled for OpenGL apps by default in my graphics driver settings – but it was having no effect, the game still ran too fast. It turns out that this was because UT was running in Direct3D mode, which although being translated to OpenGL calls by Wine, did not respect the VSync setting!

To fix this issue:

  1. With UT running go to the menu and choose Options | Preferences and then click [Change] under Video Driver you’ll be told that setup will occur the next time you start UT.
    UT-Change-Graphics-Driver
  2. Restart UT and in the graphics drivers screen that displays you’re likely to only see “Software Rendering” and “DirectX”… however, if you click the Show all devices radiobutton then you’ll see additional options, including OpenGL – select it.
  3. Either make sure your graphics drivers have VSync enabled under your graphics drivers OpenGL settings, or alternatively I believe you can modify the UnrealTournament.ini file and add the line:

    to the [OpenGLDrv.OpenGLRenderDevice] section.

That should be it – launch the game and it should lock to your monitors refresh, meaning zero tearing and the game runs at the correct speed. Hurrah! =D