Author Archives: mehigh

Samsung NP300V5Z – Mountain Lion Success

Samsung NP300V5Z – Mountain Lion Success

Hey,

After nailing another Core 2 Duo build on Mountain Lion last week I adventured into cursing a Samsung Laptop with the osx plague.

I have followed the guide to Vanilla OS X from insanelyMac:

http://www.insanelymac.com/..chameleon-dsdt-for-beginners-updated-for-mavericks/

You need to download the latest Maverick Install Guide – with Screenshots.pdf from the end of the first item in that thread (I used Mavericks install Guide – v4.2 – With Sreenshots.pdf), as that’s the latest one.

I followed part 1 step entirely to download all of the software.

I created the vanilla installer following the Part 2 with the only exception being the usage of Master Boot Record (the laptop never booted from a GUID Partition table).

For the part 2.2 I patched the installer and used a MacBook Pro 8.1 definition for the SMBios (as that was the one already using Sandy Bridge i5)

In order to cope for the Master Boot Record I followed the steps from 2.3 to add the tweaked version of the OSInstall files from there. (I only had a Mountain Lion 10.8.2 version on a stick, but it should be working just as fine with 10.8.5 and using those files).

Installing OSX

I was only able to boot on the usb stick with the -x flag on. (use the USB 2.0 ports for booting with the stick). An odd issue was the fact that I was not able to access the keyboard & touchpad at all during the installation, so you’ll have to make sure you have a USB mouse & keyboard laying around (I used a wireless keyboard plugged into the USB).

Other than formatting the hard drive using the Master Boot Record and Mac OS X Extended (Journaled) file system everything went smoothly.

After installing for making the drive bootable – it is required to boot once more into the installer and access the Utilities -> Terminal and copy the NullCPUPowerManagement.kext and FakeSMC.kext from the USB stick on the main hard drive where you already installed OSX. I encountered a little hick-ups as simple auto-completion didn’t seem to function correctly with the volume name containing a space in it (in the tutorial you have “os x” for the volume name, but I recommend using a simple, space-less volume name). After figuring out to add the quotes around the autocompleted file addresses I was able to make it bootable (without doing this, it simply gives the AppleIntelCPUPowerManagement kernel panic, don’t worry).

I had to use the -f boot flag to get into the OSX properly. (this clears the caches of the kexts, so it loads the ones we manually copied into the /System/Library/Extention folder).

Once inside, I got the proper resolution going, but no audio, no network, no keyboard, no touchpad. Now the fun begins.

Here I dropped the guide to vanilla osx and downloaded the latest MultiBeast (5.5) and installed drivers:

-  I knew it had a Realtek LAN card, so I followed my guts and installed the Lnx2Mac driver

Rebooted – had internet going.

I tried installing the VoodooHDA, but that one didn’t detect the audio card, so after googling a bit I found that the C200 audio card is quite common through laptops and ended up on this thread:

http://www.osx86.net/files/file/76-applehda-for-alc269/

Went to settings and selected for the sound the internal speakers – had audio going.

Rebooted, went again to multibeast and installed the ps/2 keyboard and touchpad driver and that activated my keyboard (the function keys work as well). I also installed the generic USB 3.0 driver.

The webcam works out of the box.

Now I still need to have the following:

  • the wireless network card
  • the touchpad (I use a wireless mouse most of the time, but I’ll still try to get this going)
  • the battery charge status (it displays 0% for now) – I get the dimmed screen when removing the power cord and goes bright when plugging it back in, so it is functional, but unknown

Not sure about nvidia.

I found another post with a similar hardware here, which I’ve followed to get Audio working and will draw inspiration onto trying to get other things I might have missed working properly.

http://www.tonymacx86.com/…asus-k43sv-a43sv-mountain-lion-working-help-needed.html

Read More

Responsive, Fast Image lightbox with gallery support – Magnific Popup

Responsive, Fast Image lightbox with gallery support – Magnific Popup

The responsive trend has gotten up and beyond being highly popular nowadays. Therefore old tools need to be replaced by the ones which are up to the latest trends.

In time I’ve gone through the following libraries:

Neither of them support responsiveness, so the toolbox need to get updated. Lately I’ve stumbled upon an article on Smashing Magazine which pointed to the new kid in town: Magnific Popup

It didn’t only impress me only with the support of responsiveness, but in fact, with it’s nifty preload capabilities built inside it – you can set it up to preload the next / previous images in the gallery as the user is viewing it. With the modern browser’s capability to load up 6 resources in parallel, it would be sad not to make use of such a feature.

If you’re like me and want to get running really fast, this is a quick recipe to get you going without much fuss:

1. Download the CSS file from here and link to it from your page’s head section:

https://raw.github.com/dimsemenov/Magnific-Popup/master/dist/magnific-popup.css

<link rel='stylesheet' href='/path/to/magnific-popup.css' type='text/css' media='all' />

2. The Javascript

Load Zepto.js (in case you don’t have / need jQuery already).
Zepto is a lightweight framework which handles most of the things jQuery already does, in case you are not in need of the full-fledged jQuery framework. It’s 3 times smaller when gzipped (10K vs. ~30K for the latest 1.10 jQuery).

<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js" type="text/javascript"></script>

OR

<script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>

And then build the Magnific Popup JS using their provided build tool. For the most basic image + gallery support, you only need: image, gallery. (I also add in High-DPI support, Image zoom animation, fast tap for gallery arrows). Copy paste the content in a magnific_popup.min.js file, which you will link to after the zepto/jquery library call.

<script src="path/to/magnific_popup.min.js" type="text/javascript"></script>

And now you only need to trigger the script. Create a new magnific_popup.comp.js file with the following content (download from here):

jQuery(document).ready(function($) {
$.expr[':'].linkingToImage = function(elem, index, match){
return $(elem).is('a') && elem.href && (/\.(gif|jpe?g|png|bmp)$/).test(elem.href);
};

var $imageLinks = $('a:linkingToImage').filter(function() {
return $(this).closest('.pictures').length == 0
}),
$galleries = $('.pictures');

if (typeof $.fn.magnificPopup != 'undefined') {
$galleries.magnificPopup({
delegate: 'a',
type: 'image',
tLoading: 'Loading image #%curr%...',
mainClass: 'mfp-img-mobile',
gallery: {
enabled: true,
navigateByImgClick: true,
preload: [0,2] // Will preload 0 - before current, and 1 after the current image
},
image: {
tError: '<a href="%url%">The image #%curr%</a> could not be loaded.'
}
});
$imageLinks.magnificPopup({
type: 'image'
});
}
}

A couple of explanation on what it does.

  • it checks for the existance of the magnificPopup script (such that the script doesn’t break the entire JS functionality of your site if you remove the plug-in at some point in time)
  • it creates a new selector which helps in attaching the magnificPopup functionality to all links pointing to images (according to the extension of the files).
  • it starts the gallery mode of magnificPopup on links which are child of a tag with a class of ‘pictures’, adding the previous / next navigation links.
  • the pre-load is activated to pre-load the next 2 images of the currently being viewed one. I find this number to yield the best performance.

Of course you also need to embed this file as well:

<script src="path/to/magnific_popup.comp.js" type="text/javascript"></script>

Enjoy using it!

Read More

How to fix the Twitter blogger.js script and make it work with the oAuth required by the v1.1 API

How to fix the Twitter blogger.js script and make it work with the oAuth required by the v1.1 API

Since the recent deactivation of the v.1 API of Twitter, the highly popular http://twitter.com/javascripts/blogger.js script was left nonfunctional.

There is a straightforward procedure to get it back running again by replacing

<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=screennamegoeshere&include_rts=1&count=1&callback=twitterCallback2"></script>

 

By a call to a .php file that generates the same thing, but while authenticating to the proper twitter application you will be creating.

You would need to mostly follow the steps illustrated here:
http://www.webdevdoor.com/php/authenticating-twitter-feed-timeline-oauth/

In short, here’s how you can get it up and running quickly:

1. Setup a twitter application at https://dev.twitter.com/apps/ (logging in with your own credentials). Save the consumer key & secret and access token & secret.

2. Download the TwitteroAuth library from here. You are only interested in the twitteroauth folder and it’s two files, which you will place next the .php script you are creating.

3. Create a twitterfeed.php file with the content provided in the tutorial, and fill in the variables (twitteruser / number of tweets and all the keys you’ve created at step 1):

You can download my version from here: http://cl.ly/code/1e1C3u2Z1U1c

I’ve only made an adjustment to the json_encode($tweets) part of the script by adding the twitterCallback2 which calls the old blogger script, which lets you use this cross-domain regardless of the server settings.

4. Upload the twitterfeed.php along the twitteroauth with the two files inside next to it to a server running PHP 5+.

5. Replace the old http://api.twitter.com/1/statuses/user_timeline.json call by one pointing to your newly created .php file, like this:

<script type=”text/javascript” src=”http://yourdomain.com/twitterfeed.php”></script>

Read More

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