rvm libz.1.2.5.dylib and zlib on Mac

Got stuck on this while following Setting up a fresh Rails 3.1 project safely and Upgrading to Rails 3 Part 1. Took the first tutorial’s tip on setting up rvm per project or per application, the latter is for the upgrade procedure.

I have 1.8.7 and 1.92 rubies installed, and the app I was upgrading is from 2.2.x. I’ve setup a new .rvmrc on the app folder so it automatically uses 1.9.2. Though in the upgrade tutorial you have to do it manually by calling rvm 1.9.2 or rvm system, my setup already loads 1.9.2 and to switch to 1.8.7 I’ll just issue rvm system.

On the part where I run gem install rails from upgrading to rails 3, I get this error:

$ Irb ruby-1.9.2-p180: 001>
  require 'zlib' LoadError: dlopen(/Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle, 9): Library not loaded: libz.1.2.5.dylib
  Referenced from: /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle
  Reason: image not found - /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle
  from /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb: 36: in `require'
  from (irb): 1 from /Users/user1/.rvm/rubies/ruby-1.9.2-p180/bin/irb: 16: in`<main>'

I tried a lot of rvm docs, gem uninstall-install, gem update, switching apps and even sudo’ing (yeah I know, it defies the purpose of using rvm), but no dice. To cut the story short, the fix was DYLD_FALLBACK_LIBRARY_PATH

export DYLD_FALLBACK_LIBRARY_PATH = $HOME/.rvm/usr/lib/

This can be in your bash profile or in .rvmrc, in case this only happens on one of you apps.

export DYLD_FALLBACK_LIBRARY_PATH = $rvm_path/usr/lib/

Found the answer here http://apribase.net/2010/11/13/macports-dyld_library_path/ (it’s in Japanese though, just use G translate). Hope this helps.

Oh, I’ll update this as well for the Mac setup I use in the office plus the gem env.

Update:

System

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.4.0]
  - INSTALLATION DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334
  - RUBY EXECUTABLE: /Users/ubertordev2/.rvm/rubies/ruby-1.8.7-p334/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-10
  - GEM PATHS:
     - /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334
     - /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

rvmrc

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.10
  - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin10.4.0]
  - INSTALLATION DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290
  - RUBY EXECUTABLE: /Users/ubertordev2/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-10
  - GEM PATHS:
     - /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290
     - /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Playing around with jQuery – prefill search input field with description

It’s been long since I made changes to my wordpress blog site, this is what happens when you have free time as a programmer.

So, I just realized the submit button on the search form on the header is not really important, I hid it now by simply display: hidden;. Then, some text might help to indicate that that form above is used for search.

Here’s the code

1
2
3
4
5
6
7
var changed = false;
$('#searchform #s')
  .addClass('quiet').val('Search...')
  .bind('change', function(){ if ( !changed ) { changed = true; } } )
  .bind('focus', function(){ $(this).removeClass('quiet'); if ( !changed ) { $(this).val(''); }  } )
  .bind('blur', function(){ if ( !changed ) { $(this).val('Search...'); $(this).addClass('quiet'); } } 
);

In wordpress, the search input field name is ‘s’, in case you find this helpful and want to use it, just replace the #searchform #s with your own selector. I might make this a plugin someday.

Using Smarty’s count_words and count_characters in design

This product page inspired me to write this post. It was launched around February last year (uh oh time flies!) and the first successful order was made around that time too. By then, there were only about 20 products or less, and really short attributes i.e. volumes in 8, 12 or 16 oz. strength like mild, regular, etc. Last monday, new products came in for addition to the site and they have quite longer attributes. It could have had a liquid width on the attribute and cart buttons but they had a really good design advisers and wanted to follow the design to the pixel.

Initially, this html code composes the product attribute and cart button, notice that <span class="c">Cherry</span> is a one word attribute for scent

<div class="cartbutton" style="background-image: url(images/button-long-add-to-bag.gif);">
  <span class="c">Cherry</span>
  <span class="c">8 oz.</span>
  <span class="c">$5.99</span>
  <span class="d">
    <a class="e" href="cart.php?product=5|33404&amp;as=5">Add to bag</a>
  </span>
  <span class="e">» ITEM: 33404</span></div>

And the new ones came with the colors “Casino Red”, “Golden Chestnut” and “Orchid Black” – long attributes, and two others “Copper” and “Spice” – short and manageable, as the column width will fit the entire word.

I was really planning to rewrite the whole attribute and cart button section, but I didn’t had much time. I figured I can make the font smaller and paddings or margins can go smaller than the regular so that two lines would fit in the box if the attribute value is a word longer. But I cannot be in PHP, its not really the way to go. So, if I can add another class that would override existing font-size and parent margin/padding, that would work. Here, I thought, word count doesn’t really need be in the PHP side and since I’m using Smarty, I found in it a variable modifier that can print the number of words in a variable, and that’s it. I can add another class in the column span like words-10 or countwords-3 in my template by the number of words that is present in the variable. Below is the generated code

<div class="cartbutton" style="background-image: url(images/button-long-add-to-bag.gif);">
  <span class="c col-color words-2">Casino Red</span>
  <span class="c col-volume">8 oz.</span>
  <span class="c">$11.39</span>
  <span class="d">
    <a class="e" href="cart.php?product=28|33825&amp;as=14">Add to bag</a>
  </span>
  <span class="e">» ITEM: 33825</span></div>

CSS rules

/* default rules */
.cartbutton { height: 23px; background: url('/images/button-add-to-bag.gif') no-repeat left center; color: #333; }
.cartbutton span { display: block; text-align: center; float: left; font-weight: bold; font-size: 10px; padding-top: 5px; }
.cartbutton span.c { width: 45px;  }
.cartbutton span.d { width: 80px;}
.cartbutton span.d a { color: #fff; text-decoration: none; }
.cartbutton span.e { margin-left: 10px; width: 100px; }
/* special rule for two word attribute */
span.words-2 { padding-top: 3px; line-height: 98%; font-size: 9px; }

And this is how it is setup in the template.

<div class="cartbutton" style="background-image: url(images/button-long-add-to-bag.gif);">
{if $attr[at].color}
  <span class="c col-color words-{$attr[at].color|count_words}">{$attr[at].color}</span>
{/if}
{if $attr[at].strength}
  <span class="c col-strength words-{$attr[at].strength|count_words}">{$attr[at].strength}</span>
{/if}
{if $attr[at].scent}
  <span class="c col-scent">{$attr[at].scent}</span>
{/if}
{if $attr[at].volume}
  <span class="c col-volume">{$attr[at].volume}</span>
{/if}
<span class="c">
  $ {if !$attr[at].amount} {$results[r].amount} {else} {math equation="x" x=$attr[at].amount format="%.2f"} {/if}
</span>
<span class="d">
  <a class="e" href="cart.php?product={$results[r].id}|{if $results[r].sku &amp;&amp; !$attr[at].sku}{$results[r].sku}{elseif $attr[at].sku}{$attr[at].sku}{/if}&amp;as={$attr[at].pas_id}">Add to bag</a>
</span>
<span class="e">» ITEM: {if $results[r].sku &amp;&amp; !$attr[at].sku}{$results[r].sku}{elseif $attr[at].sku}{$attr[at].sku}{/if}</span></div>

Those extra class names like col-volume, col-scent and col-strength are only for future use, who knows what other formatting and adjustments on the data and theme will happen. Its really fun working with MVC model. Hope it helps :)

Happy coding!

List of Philippine Holidays for 2010

Regular Holidays

  • New Year’s Day – January 1 (Friday)
  • Maundy Thursday / Good Friday – April 1 / 2 (Thursday / Friday)
  • Araw ng Kagitingan – April 9 (Friday)
  • Labor Day – May 1 (Saturday)
  • Independence Day – June 14 (Monday), moved from June 12
  • National Heroes Day – August 30 (Monday)
  • Bonifacio Day – November 29 (Monday), moved from November 30
  • Christmas Day – December 25 (Saturday)
  • Rizal Day – December 27 (Monday), moved from December 30

Special (non-working) holidays

  • Ninoy Aquino Day – August 23 (Monday), moved from August 21
  • All Saints’ Day – November 1 (Monday)
  • Christmas Eve – December 24 (Friday)
  • New Year’s Eve – December 31 (Friday)

Others

  • 1986 EDSA People Power Revolution anniversary – Special holiday for schools – February 22 (Monday), moved from February 25
  • Eid’l Fitr and Eid’l Adha 2010 – To be announced later
  • Founding Anniversary of Iglesia ni Cristo – July 27, 2010 – Special national working holiday

Source : http://www.pinoymoneytalk.com/philippine-holidays-2008/

If Windows, Linux and OSX Opened Cafes

What if really… LOL! I found this from DaniWeb, it’s short and entertaining! Read on…

The New York Times reported today that Apple has opened its first Apple Store in Paris, underneath the Louvre no less, and just two weeks after Microsoft opened up a Windows 7 cafe in Paris in another location. The idea of these two companies competing in a retail environment, and especially a Windows-themed cafe, got me thinking about what would happen if three cafes opened each run in the same style of the operating system it was named for. I figure it might look something like this:

Windows Cafe

The Windows Cafe is in a bland store front. The furniture consists of straight wooden chairs with tables with sharp angles. Unfortunately, every so often when you sit in a chair it crashes the to the floor, but you get used to this and figure it’s just part of the experience of going to the Windows Cafe. (To be fair they have been testing chairs from a new manufacturer and they are reportedly less prone to breaking in this fashion.) Pictures of a smiling Bill Gates and Windows logos adorn the walls. The coffee tastes fine most of the time, but a surprising number of patrons get sick there, so that it’s become standard practice to use hand sanitizer before you go in to protect yourself. The coffee is expensive, and refills are definitely not free, but it’s a known quantity, and many people are comfortable going there.

Linux Cafe

The Linux Cafe is a funky place in an artsy neighborhood with eclectic furniture donated by the patrons. It doesn’t match, but it’s comfortable and the walls are covered with donated pictures and paintings by local artists. The coffee is free, served in black cups (or you can just bring your own), but you need to make it yourself. If you can’t do it yourself, the cafe has consultants available to help you for a fee. It’s great for people who know about coffee brewing, but many people are intimidated by the idea of making their own coffee and stay away, even though very few people ever get sick who go there.

Apple Cafe

The Apple Cafe is a modern, state-of-the-art facility. The tables are stainless steel and the chairs are ultra-contemporary. Shrines to Apple CEO Steve Jobs are dotted around the wide space. The cups are cool and come in a variety of bright colors. The coffee is well made by a highly trained staff, and even though it costs a lot more, people line up around the block for a chance to drink it. Just don’t ask the staff about their coffee-making techniques because they are extremely tight lipped about this. People occasionally get sick there, but it’s rare enough for the cafe to brag about its safety record.

So there you have it. Three cafes with three distinct personalities just like the operating systems they represent

Source: http://www.daniweb.com/news/story236836.html?urlhash=yp4q&trk=nus_ritm-title by Ron Miller

Quickie Visitors Country WP Plugin

This plugin is dependent on WP/GeoTrack by Johannes Lietz, this is NOT a stand-alone plugin, it won’t work if WP/GeoTrack is not installed anyway, so it’s safe.

And don’t look for it in WP Plugins repo, you won’t find it there :D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Plugin Name: Top Visitors Flag
Plugin URI: http://www.marvinmarcelo.com/
Description: This plugin displays visitors on sidebar as widget dependent on <a href="http://dadabase.de/weblog/archives/2006/05/23/wordpress-geotrack-plugin">WP/GEO-Track plugin</a>.
Author: Marvin Marcelo
Author URI: http://www.marvinmarcelo.com/
Version: 1.0.0
*/
function tvf_get_topvisits()
{
  global $wpdb, $table_prefix;
  $sql = "select count(*) as `rows` , `country` , `flagname` from `".$table_prefix."geotrack` group by `country` order by `rows` desc limit 0 , 12";
  $flagstats = $wpdb->get_results($sql);
 
  $html = "<li id='top-country-flags'><h2>Top Visiting Countries</h2><div>\n"; /*  id string */
  foreach ($flagstats as $cf)
  {
    $cf->rows = number_format($cf->rows, 0, "", ",");
    $html .= "<img src=\"". GEOTRACK_URL . "flags/" . $cf-/>flagname . ".png\" alt=\"Flag of $cf->country with $cf->rows visits\" title=\"$cf->country with $cf->rows visits\" />\n";
  }
  $html .= "</div></li>";
  echo $html;
}
 
function init_tvf_init(){
	register_sidebar_widget("Top Visitors Flags", "tvf_get_topvisits");
}
 
if (defined('GT_NOT_INSTALLED'))
{
  echo "<!-- You need \"http://dadabase.de/weblog/archives/2006/05/23/wordpress-geotrack-plugin\" installed first-->";
}
else
{
  add_action("plugins_loaded", "init_tvf_init");
}

Also, you have to forgive the function, constants, and variables names, we all struggle for a better and sensible one :) Happy coding!

Windows Social, didn’t complain

2qa6yp0Ok, this is actually the first post I did about Windows. I haven’t used it as my working platform for more than 2 years, though honestly, it’s also where I started, back in Windows 95 in my school years. Even if that’s the only available version we had in 1999, it was huge then! I am now more in the FOSS community, and have been enjoying doing my stuff in Ubuntu Desktop. But what I really wanted to point out in this post is the new Windows Social, it is just like any social media but it runs real time feeds, “popping in” every second into the stream area with streams coming from different major social media out there – Facebook, Flickr, Twitter, etc. And that is a “WOW”, I admit. That’s the feature Facebook Developers haven’t really implemented in full capacity. But Facebook already rolled out their version with that feature, sort of saying “we’re on the way!”, as they had also announced in that release.

Windows Social

I still remember way back the upgrade of MSN’s Hotmail (or not exactly sure if older versions work smoothly on Firefox), it was always complaining that it’s not compatible with my browser. But this one, this one is really good, so Kudo’s to Windows Social team. When I found this in the Twitter’s box in popurls, posts just started popping in, sweet! Though I suppose it would do the same as on MS and IE platform. But if someone knew of a “flaw”, “fail” or “weak link”, complain about it properly to their support, and if you can bother to let me know ;) LOL