Wednesday, March 19, 2014

work around for FB.XFBML.parse

For what ever reason due to reason update or facebook changes,
the god damn FB.XFBML.parse stop working...

found a work around:
if you are using fbml, eg:
[div id="mylike" class="fb-like" data-href="http://www.facebook.com/example"][/div];

#reload all fb like iframe:
function reloadFB() {
 FB.XFBML.parse();
 var boxes = jQuery(".fb-like iframe");
 for(var c=0; c < boxes.length; c++) {
  var box = boxes[c];
  box.src=  box.src;
 }
}

Friday, December 27, 2013

Unable to download data from https://rubygems.org/ - SSL_connect


If you are getting:

Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ...

Its most likely your gem gem is outdated.
Try updating via:
gem update --system

then try to install your gem as required

if it still fails, try using raggi brew update
brew tap raggi/ale
$ brew install openssl-osx-ca
as referred from here:

Thursday, December 12, 2013

cpanel and ruby on rails

#first, use rvm to install both ruby stable version + rails, run as root:

curl -sSL https://get.rvm.io | bash -s stable --rails


yum install curl-devel

gem install passenger

rvm list
rvm --default 

export APXS2=/usr/local/apache/bin/apxs
passenger-install-apache2-module

next, copy the configuration in the final readme when compilation is done, eg:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.27/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.27

PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby

and paste to :
/usr/local/apache/conf/includes/pre_main_2.conf

then restart apache:
/scripts/restartsrv_httpd

next, to install rails app onto 1 of the account:
mkdir -p /usr/local/apache/conf/userdata/std/2/[username]/[domain]
vi /usr/local/apache/conf/userdata/std/2/[username]/[domain]/rails.conf


ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/[username]/[path-to-rails]/public
<Directory /home/[username]/[path-to-rails]/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>

#rebuild apache config:
/scripts/rebuildhttpdconf

then restart apache:
/scripts/restartsrv_httpd

next, to be able to run bundle install as a shell user:
mkdir ~/bin
ln -s /usr/local/cpanel/3rdparty/bin/git ~/bin/git
then run bundle install at root of rails application.
this will install gems into vendor/bundle

running git to parse ssl from github seems to return certicate error,
to solve this, pre run this as shell user:
git config --global http.sslverify false

then only run bundle install

if you are using json api,
you will need nodejs installed.
install this as root

on centos:
yum install npm
for other os:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

 for reference:

Friday, November 22, 2013

mod passenger httpd.conf configuration

Example configuration:

RailsEnv "development" # to setup default environment for passenger
  PassengerEnabled on
  AllowOverride None
  Options FollowSymLinks ExecCGI
  Order allow,deny
  Allow from all
  PassengerBaseURI /mydir
  PassengerAppRoot /var/www/mydir


Tuesday, November 12, 2013

prestashop, sometimes save does not work?

Thats why i hated PHP.
It took me half a day to finally realize, prestashop was posting too much variables on the product form with my additional fields.
There wasn't any error, but the form just return back to the front page with no exception, no error logs...
just plain - "not working".

after testing

echo "keys: ".count(array_keys($_REQUEST));

i found 990 keys posted.
then i went into whm and change php.ini in /usr/local/lib
max_input_vars 5000
then i found the keys posted is 1800+ keys..

PHP sucks!

Wednesday, October 9, 2013

changing git remote origin

#to list all remote url
git remote -v

#to remove existing remote (not reversible)
git remote remove [name]
eg: git remote rm origin

#then you may add your new remote
git remote add origin ssh://git destination/...


Tuesday, October 8, 2013

rails mysql2 install fail

if you encounter No such method for Nil Class,
its due to a bug in mysql2 v0.3.13,

so try to install
gem install mysql2 -v 0.3.11

to get it installed on windows, you will need the right connector library to be installed.
first, download the zip file of the mysql connector, and extract it.
v0.3.11 requires mysql-connector-c-noinstall-6.0.2-win32

next, install using this command:
gem install mysql2 -v 0.3.11 --platform=ruby -- --with-opt-dir="C:\path-to\mysql-connector-c-noinstall-6.0.2-win32"

after installed, makesure to copy C:\path-to\mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll to c:\Ruby200\bin\

Note: nokogiri currently desnt support ruby 64bits.
so try to use 32bits if you need to use it.