Mehigh

Mountain Lion on Gigabyte GA-Z77X-D3H Tutorial

I’ve built a CustoMac, mostly based on the recommendations from TonyMacX86 – CustoMac: Buyer’s Guide 2012

I’ve chosen Z77X-D3H over the GA-Z77-DS3H, which has a supported Realtek audio card, as this one had better over-clocking capabilities (the turbo speed of the CPU can be setup to reach higher clock speeds). The cheapest Z77X board with a similar supported audio card is GA-Z77X-UD5H ($190), which is 50% more expensive than GA-Z77X-D3H while it only offers extra features which can not be used in Mountain Lion. Since this computer was aimed at being a Mac build, those extras were not needed / useful.

The build consists of the following:

  • Mainboard: Gigabyte GA-Z77X-D3H
  • CPU: i5 3570K ( + Zalman CNPS-9700 )
  • RAM: 16 GB (2*8) Corsair Vengeance DDR3 1600MHz CL10
  • Video Card: An old Gigabyte nVidia 9500GT 512MB
    Pro-Tip: Ati Radeon 6870 should work, but it needs to be inserted after the installation of OS X (install OSX with the on-board graphics, and install the Ati graphics card afterwards)
  • Case: Corsair Carbide 400R
  • Power Supply: Corsair 430 Watt
  • SSD: Corsair Force Series 3 – 60GB

I started with the following tutorial: TonyMacX86 – Unibeast Install OS-X Mountain Lion

On an existing Mac

  • Purchased Mountain Lion from a Mac, downloaded it
  • Downloaded the latest Mountain Lion UniBeast ( 1.5.3 at the moment of writing )
  • Started Unibeast and installed ML on an 8GB USB stick (haven’t selected Legacy USB / Laptop support)
  • After the Unibeast install I copied over the latest Mountain Lion MultiBeast to the USB stick in a “Kits” folder (just in case the networking might not work out of the box)

On the CustoMac

  • Loaded optimized defaults in the Bios
  • Plug the USB stick into a USB 2.0 port on the back (it won’t work from an USB 3.0 port)
  • Boot from the USB, get the installer running (if it doesn’t start use ‘-x’, but it was not necessary for me)
  • Partition the main hard-disk
  • Install OSX
  • Reboot, boot from the USB stick and this time choose the OSX partition to continue booting from
  • Complete the OSX setup
  • Run MultiBeast with the following options:
    • UserDSDT or DSDT-Free Installation
    • Drivers & Bootloaders > Drivers > Network > maolJ’s AtherosL1cEthernet (the ethernet worked out of the box, so installing the driver is optional)
    • Customization > Identifiers > MacBook Pro 8,1 (initially I chose MacPro 5,2 and booting did not work)

After a restart you should have a functioning, bootable OSX Mountain Lion with ethernet and USB 3.0 support (only the 2 top USB 3.0 in the back work, the lower 4 USB 3.0 are not functional).

Update 3: Vinicius was not able to patch the DSDT file, so I recommended him to try installing the latest AppleHDA and see if that works. Luckily he responded back and confirmed that his audio works (he tested this on a GA-Z77X-D3H + i7, but should work on i5 just as well).

So the latest recommendation in order to setup Audio support is to install this Kext:
http://www.osx86.net/view/3674-applehda_audio_for_via2021_tested_on_ga_…html
The steps are written on the kext download page:

  • delete the voodHDA (if you have it)
  • delete the AppleHDA
  • and add these kexts from the zip using kext wizard,
  • then reboot with -v -f e tell if the sound is recognised (according to the uploader, I personally did not need to boot with any flags setup in order to get the sound working, so test this if it doesn’t work after reboot)

Update 2: For enabling audio, there’s a trickier path to go through.

I used the VIA VT2012/2020 tutorial and kexts from osX86

Later Edit: The following were required for a previous version of VIA VT2012/2020, now they’ve updated it to only require a patching of the AppleHDA kext. I’m leaving the original steps here though.

Update 1: At first, I went through the easy tutorial. Erased the AppleHDA.kext from /System/Library/Extentions. Opened up Kext Utility from osX86 and installed the AppleHDA.kext and the VIA2021.kext from the VIA VT2012/2020 from above.

Unfortunately this didn’t get me sound, so I had to go through the “Advanced Users” tutorial.

1. Back up AppleHDA.kext before patching.

2. Patching AppleHDA: open Terminal and type the below two commands and press enter

sudo perl -pi -e ‘s|\x84\x19\xd4\x11|\x41\x04\x06\x11|g’ /System/Library/Extensions/AppleHDA.kext/Contents/MacOS/AppleHDA

sudo perl -pi -e ‘s|\x83\x19\xd4\x11|\x00\x00\x00\x00|g’ /System/Library/Extensions/AppleHDA.kext/Contents/MacOS/AppleHDA

3. Enter password when prompted

4. Copy layout12.xml.zlib & Platform.xml.zlib to /System/Library/Extensions/AppleHDA.kext/Contents/Resources/

5. Run Kext utility and install VIA2021.kext and restart system

Rebooted the computer

1. Downloaded and started the DSDT Editor by olarila .

2. Go to File -> Extract DSDT

3. Patch -> New
Paste in the patch from here: http://pastebin.com/nCAya2Uu

Click Apply

And now the ‘funny part’ starts. There’s a ton of errors showing up when trying to IASL -> Compile, and we need to get all of them solved before this would work.

First error is the DTGP method unknown.

I’ve pasted this function above the “_WAK”: http://osxonthinkpads.wikidot.com/dsdt-edits#toc1

I had to erase a HD function (duplication error). Since there were two functions with the same name, one coming from the pastebin patch, and the other was already there. I had left the one with the DTGP (Arg0, Arg1,… call, and erased the other one.

I had to adjust the digits on a value (it required to be hex and it had ABCDEFGH as a value, while GH are invalid hex characters, so I got them replaced them with characters ABCDEF00 or ABCDEFF0), removed some functions that gave an error ‘object does not exist’ (probably referencing the duplicate function that I had to erase… did all this pretty much using my intuition. This is the hardest part from my point of view, as it might not be very clear for everybody on how to solve these errors.

I end up with this dsdt.aml

I copied it into the /Extra folder..

And rebooted again (while crossing fingers, an important aspect of the process)

… Houston, we have ignition ! The sound started.

If you’re making a build with the same main-board, do share your experience, as it might help others as well.

 

Later Edit: I’ve updated ML to 10.8.1 using the regular software update. All went smoothly.

Later Edit: I’ve updated ML to 10.8.2. I had to first erase AppleHDA.kext (and put back the AppleHDA.kext.backup) and VIA2021.kext as well. I ran the Kext Utility afterwards and rebooted. Then upgraded ML to 10.8.2, rebooted and the system stared up without audio (as expected). I’ve took the updated VIA VT2021/2020 kext, patched it as they required in the tutorial and installed it with Kext Utility. After a reboot I got proper sound, like before.

Read More

Morning boosters

Morning boosters

Ever felt in the need of a little Duracell power-up in the morning? Well, I found one and thought about sharing its ‘variations’ with you.
All you need is: a blender and a citrus juicer.

The basics are common throughout all the ‘recipes’.

  • 1 glass of bottled water (you can vary this depending on how thick or thin you want the smoothie to be)
  • First, the water is put into the blender along the leaves. After ~ 30 seconds, you need to filter out water that has become green through a strainer (you might want to move the foam from one side to another with a table spoon to avoid blocking the flow of liquid). That’s how you get your ‘chlorophyll essence’.
  • If any citrus fruits are used in the recipe, I prefer to squeeze them in the citrus juicer (as it keeps away all the seeds easily)
  • Regular fruits are pealed and get their seeds removed before putting them into the blender.
  • After you get the – chlorophyll essence, the citrus juice, and the pealed pile of fruits, put them all together in the blender and let it do it’s thing.

To get a maximum enjoyment from this, try to use your best looking glasses for your morning routine. It will make you feel better, treated like a king.

I will be updating this post with smoothies that I liked the most… and also grade them.

May 19th – Spinach-Orange-Pear (7)

  1. greens – 1 hand of spinach leaves
  2. citrus – 1 orange
  3. fruits – 1 large pear

May 20nd – Parsley-Apple-Cinnamon (5)

  1. greens – 1 hand of parsley leaves
  2. fruits – 3 apples
  3. extra – a spoon of cinnamon, a spoon of honey

May 22nd – Radish-Orange-Apple (8)

  1. greens – 1 hand of radish leaves
  2. citrus – 1 orange
  3. fruits – 4 small apples
  4. extra – added some small mint leaves for decoration.

May 24th – Carrot-Radish-Orange-Apple-Chocolate (7)

  1. greens – 1 hand of radish and carrot leaves (mixed)
  2. citrus – 1 orange
  3. fruits – 2 apples
  4. extra – sprinkled some chocolate chips on top

May 25th – Carrot-Apple (5)

  1. greens – 1 hand of carrot leaves
  2. fruits – 4 apples
  3. extra – 2 tablespoons of honey
Read More

Bias Lightning – dramatically improves screen viewing experience in the dark

Bias Lightning – dramatically improves screen viewing experience in the dark

After reading all the positive reviews about bias lightning, I thought to give it a try… so I started off with the theory.

The basics that you need are the following:

  • a light source with cold natural light (ideal is to have a temperature of 6500K)
  • the light source to be powerful enough such that the reflected amount of light would be at least 10% the maximum light the screen can produce (under normal viewing conditions, not talking about dynamic contrasts or other such gimmicks)
  • a neutral gray or white wall behind the screen (I didn’t have the luxury to get this, but we’ll get to that a bit later)
  • patience to set it all up and do a bit of math

The light

I found my screen to emit 130 cd/m2 under the settings I use it (THX).

I’ve computed the surface of my screen (42′ 10:9) – 93cm (width) * 52.3cm (height) ~ 0.48 m2.

130 cd / m2 * 0.48 m2 = 62.4 cd

Most light sources (like LEDs) have their power measured in lumen. And since 1 cd = 12.57 lumen, we get to a computed 784 lumen emitted by my screen.

Then we get the amount of light required to bounce off the surface behind the screen to be of at least 10% of 784 lumen, which is ~79 lumen.

Since I don’t have a 100% reflective surface, I assume about 50% of the light is reflected, which means I would need a light source of at least 160 lumen.

The light source choice

In order to obtain a better spread light, the best choice would be to have an array of LEDs going around the perimeter of the screen, in the back.

On my particular setup I required 3 meters of LED band.

There are two options for the LEDs:

  • SMD 3528 (cheaper, emit a lower amount of light, best for bias lightning if you have a neutral colored background – they come in single colors)
  • SMD 5050 (or the so called RGB LEDs, have a higher light output, in the 30 leds / meter setup they emit around 250 lumen / meter, while in the 60 leds / meter denser array most emit around 500 lumen / meter)

To make a paralel of the amount of light with the regular light bulbs – an ‘old-school’ 100 Watts incandescent light-bulb emits about 1400 lumen)


I had chosen SMD 5050 over the SMD 3528, as I would be able to tackle their coloring in order to obtain a much more neutral color after bouncing from the back of the screens material coloring.

I’ve went with a 3m stripe of SMD 5050 RGB leds, with a density of 30 leds per meter, and although that would add up to 750 lumens (which is way too much), the controller allowed 10 steps of lower / increase the light emitted. (down to 10% of the maximum light output).

Setting it all up


I’ve bought a stripe of 5 meters of 5050 RGB SMD LEDs, of which I had cut of 3 meters (it can be cut at each 3 LEDs, easily with a pair of scissors).

I’ve powered it with a 5A, 12V power adapter (capable of powering up to 10 meters of 5050 LEDs).

I used an RGB Led controller which had an infrared remote capable to store color / intensity preferences.

The LED stripe had an adhesive tape, which I glued to the back of the screen.

The result

Indeed, as per my calculations going for 20%-30% of their power source (which would go to 150 – 225 lumen) was indeed providing the best experience.

To take out some of the pink in the background, I setup the LEDs to go with a bit of a colder color to compansate, and I am really pleased with the end result:

Disclaimer: This is not a professional advice, I had gotten to the conclusions listed in this post after browsing the web and reading various people opinions on forums. If you want the best quality out of your setup, you should hire a professional.

If you had made a similar setup, or are going to, let me know your thoughts by commenting below. Do share what’s your experience with bias lightning.

Read More

Avoid Initial Slow Loading Times of Rails apps under Apache & Passenger

If you have enough RAM on your server, then you will probably want to avoid the lengthy booting times you experience after an application idles.

There are 2 solutions I could find used to solve this problem:

1. Use a cron job to access the application every couple of minutes to keep it in memory.

One of the ‘raw’ solutions used are setting up a cron job to automatically access the application every few minutes and therefore keep it in memory.

crontab -e

And use nano (or your favorite editor) to add this at the end of the cron jobs:

*/5 * * * * wget http://www.example.com > /dev/null

This issues a wget request every 5 minutes and trashes the response.

2. Setup passenger not to automatically kill the rails processes.

But, on the other hand, if you have access to the server’s configuration, a better approach is to modify a few of Passenger’s constants:

PassengerMaxPoolSize 30 (use 15 if you have a machine with 1GB, 30 if you have 2GB of RAM, etc.). This will enable more processes to be spawned if necessary.

PassengerPoolIdleTime 0 (using 0, application instances will not be shutdown unless it’s really necessary – when the available resources on the server are low)

On an Ubuntu machine, you would have to edit the /etc/apache2/httpd.conf file by adding these two lines:

PassengerMaxPoolSize 30
PassengerPoolIdleTime 0

Restart apache

sudo /etc/init.d/apache2 restart

And you should not have that slow boot problem anymore.

*3. Use nginx + thin

Read More

Windows Mac-alike Rails Development Environment

As I already been using e-texteditor (for quite a few years), which is a clone of Mac-only Textmate, I thought to give setting up a mac-alike rails development environment a go.

Since I had a ton of compatibility problems when developing under vanilla Windows (with Ruby1.9 and rails3, a lost of gems failed to work, etc.), I hope the Unix-path is much smoother.

Let’s see how we can get it going…

Step 1: Install cygwin

You will need in to select the following in addition to the the default selected configuration (italic = requirements for the Nokogiri gem):

  • make
  • gcc
  • libiconv
  • openssl
  • ruby
  • libiconv
  • libxml2
  • libxml2-devel
  • libxslt
  • libxslt-devel

Step 2: Use Console with Cygwin by default

Console was one of the tips I didn’t know about ( http://sourceforge.net/projects/console/ ), it’s much nicer than the old ‘cmd’, and most of all you can set it up to start a cygwin console by default

Quote from http://garbageburrito.com/blog/entry/391/a-macesque-rails-development-environment-on-windows:

You’ll want to setup cygwin as a Console Tab. Just go into the settings and click “Add” under “Tabs”. Use the following as the “Shell”.

c:\cygwin\bin\bash --login -i

If you want it to automatically open cygwin when you start Console, just move it to the top of the Tabs list.

Just in case you encounter errors with

rvm install 1.8.7

Checkout this post about readline: http://rvm.beginrescueend.com/packages/readline/.

rvm package install readline

Step 3a: Ruby 1.8.7

Ruby 1.8.7 is already installed in cygwin, so if you want to use this one, you’re ready to go.

Step 3b: If you want RVM

Follow the instructions from http://rvm.beginrescueend.com/rvm/install/

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Modify ~/.bash_profile by appending at the very end, after all path loads etc:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

Install ruby with

rvm install 1.8.7
rvm install 1.9.2

Step 3c: Compile Latest Ruby (without RVM)

Download the Ruby 1.9 source from http://www.ruby-lang.org/en/downloads/ (downloaded the latest stable Ruby 1.9.2-p136 at the time of writing)

tar xvf ruby-1.2.2-p136.tar.gz
cd ruby-1.9.2-p136
./configure

(lasts ~5-10 minutes)

make -j 3

(use 3 if you have 2 cores, 5 if you have 4 cores, etc.)

make install
ruby -v

to confirm the new version

(find more in-depth instructions here: http://www.curphey.com/2010/05/installing-and-configuring-ruby-1-9-from-source-using-cygwin/)

Step 4: Avoid the default installation of ri and rdoc from ruby gems

To avoid the installing of documentation (as I usually check the online documentation):
create .gemrc file in your cygwin home directory (~) with the following contents:

gem: --no-ri --no-rdoc

Step 5: Install sqlite

Downloaded the latest sqlite tarball containing the amalgamation for SQLite 3 from http://www.sqlite.org/download.html.

tar xvf sqlite-autoconf-3070400.tar.gz
cd sqlite-autoconf-3070400
./configure
make -j 3

(use 3 if you have 2 cores, 5 if you have 4 cores, etc.)

make install

Step 6. Install Rails 3

gem install rails

Step 7. Create & start the first Rails3 app

rails new testapp
cd testapp
bundle install

(this will install sqlite3-ruby gem)

rails s

That’s it!

Read More

WordPress – get_search_link() enhancer

You already know that when performing the search in WordPress, the URL becomes something with:
/?s=lorem+ipsum in the end.

An odd fact was that get_search_link() returns something like /search/lorem+ipsum. So if you’re using a theme that creates a link to the search results page you’ll receive a different URL compared to the one that you receive when performing an actual search (two pages at different URLs showing the exact same content is no good).

Therefore I created a small snippet that fixes this when inserted in the functions.php file from your theme – making get_search_link() return the exact same URL that one would receive when performing a search.


function simple_search_link($link)
{
$link = str_replace('/search/','/?s=',$link);
$link = rtrim($link, '/');
return $link;
}
add_filter('search_link','simple_search_link');

I’ve used the str-replace to replace the /search/ with /?s=, and the rtrim function to strip the trailing /.
Now the exact same URL is used for both the get_search_link as actual searches.

This would also mean a better performance if you’re using caching.

Read More

Enhance reCaptcha accessibility with disabled images

I’ve encountered an accessibility problem these days… default reCaptcha isn’t properly accessible when the images are disabled.

A solution is to detect the availability of images, and if they are disabled to manually adjust the styling of the problematic elements.
Basically doing this:
reCaptcha made accessible

Now to share how that was accomplished.

1. Uploaded 2 files:

  • blank.gif to the root of the domain
  • captcha-accessiblity-enhancer to the root of the domain (it’s better to store all your JS file in a designated folder, but that is irrelevant for demo purposes)

2. Embeded the JS (before the body closing tag – </body>)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="/captcha-accessiblity-enhancer.js" type="text/javascript"></script>

And that’s it. The people with disabled images will be able to properly use the reCaptcha now.

Read More

Internet Explorer & Elements with an ID get a matching global variable in JS

Object doesn't support this property or method

If you’re getting an odd behavior on your scripts in Internet Explorer, try adjusting their name (for example by adjusting their names with a unique prefix) just to make sure that there isn’t any element in the page you’re working on with the same ID as your variable name.

Object doesn't support this property or method

If you want to read a much elaborate explanation, go check out Rick Strahl’s post here: Internet Explorer Global Variable Blow ups, but the above should get you going in no time (and help you avoid some headaches).

Read More

Adding wmode transparent to WordPress 3 media embeds

In case you have a website that uses dropdowns you probably noticed the dropdown panel might get under the flash media (like Youtube video embeds). The fix to this is to setup the wmode attribue to transparent… but how do we do it in WordPress?

Since WordPress 2.9 has enabled us to easily embed videos ( codex.wordpress.org/Embeds ), it also means we don’t have the ability to change the embed code (to add the wmode transparent for example), and that’s why we have to rely on applying a filter that does that for us.

Simply paste the following at the beginning of your theme’s functions.php (after <?php ), and the wmode attribute will be setup automatically:

function add_video_wmode_transparent($html, $url, $attr) {
   if (strpos($html, "<embed src=" ) !== false) {
    	return str_replace('</param><embed', '</param><param name="wmode" value="transparent"></param><embed wmode="transparent" ', $html);
   } else {
        return $html;
   }
}
add_filter('embed_oembed_html', 'add_video_wmode_transparent', 10, 3);

Update

As Theo pointed out, the videos can come in in iframes instead of object elements. To make the videos transparent in those cases as well, here’s the updated snippet:

function add_video_wmode_transparent($html, $url, $attr) {

if ( strpos( $html, "<embed src=" ) !== false )
   { return str_replace('</param><embed', '</param><param name="wmode" value="opaque"></param><embed wmode="opaque" ', $html); }
elseif ( strpos ( $html, 'feature=oembed' ) !== false )
   { return str_replace( 'feature=oembed', 'feature=oembed&wmode=opaque', $html ); }
else
   { return $html; }
}
add_filter( 'embed_oembed_html', 'add_video_wmode_transparent', 10, 3);

A demo video embedded using built-in oEmbed:

Read More