Sunday, December 7, 2014

LF will be replaced by CRLF warning on Git when committing to Repo


When I commit code to GitHub using my local repository I have these errors below:

warning: LF will be replaced by CRLF in app/assets/javascripts/application.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in app/models/something.rb.
The file will have its original line endings in your working directory.

"In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have a LF. It's nothing to worry about."

http://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important

If you want, you can deactivate this in your git core config, just type this command.
"git config core.autocrlf true"

Tuesday, November 11, 2014

npm update -g has broken npm

After install my NodeJS in my app directory on Mac OS X using this link http://nodejs.org

I tried running npm install -g ember-cli but with no luck. Then I search solutions and found a command to fix my problem


curl -L http://npmjs.org/install.sh | sudo sh

npm install npm -g --ca=null

Monday, November 3, 2014

PSLQ could not connect to server: No such file or directory (No PSQL installed from brew and no pg gem)

I encounter an issue when tying to run my Rails App using Postgres and where PSLQ could not connect to server. What I did was just few steps to fix the problem and it solved the issue running in my Rails app on PSQL Database.

> Go To Terminal and follow these few steps (Note: my PSQL latest ver is 9.3.5_1)

$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

$ brew uninstall postgresql
Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...

$ brew uninstall postgresql
Error: No such keg: /usr/local/Cellar/postgresql

$ psql --version
-bash: /usr/local/bin/psql: No such file or directory

$ brew install postgresql
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
==> Pouring postgresql-9.3.5_1.mavericks.bottle.1.tar.gz
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/issue/2510

To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.3/static/upgrading.html

When installing the postgres gem, including ARCHFLAGS is recommended:
  ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

To have launchd start postgresql at login:
    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres
==> Summary
🍺  /usr/local/Cellar/postgresql/9.3.5_1: 2927 files, 38M

$ mkdir -p ~/Library/LaunchAgents

$ cp /usr/local/Cellar/postgresql/9.3.5_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl: another server might be running; trying to start server anyway
server starting

$ env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.17.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.17.1
Done installing documentation for pg after 1 seconds
1 gem installed

$ psql --version

psql (PostgreSQL) 9.3.5

$ psql
psql: FATAL:  database "tech3" does not exist

$ sudo mkdir /var/pgsql_socket/
Password:

$ sudo ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/

$ rake db:create

$ rake db:migrate

$ rails server



Sunday, November 2, 2014

Dyld issue when setting up new Rails repository

Problem:  I have updated OS X Mavericks and setup new Rails environment with latest gems in the GemFile. When running bundle install I got his issue below:
dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib
  Referenced from: /Users/tech3/.rvm/rubies/ruby-2.1.4/bin/ruby
  Reason: image not found

Trace/BPT trap: 5
Solution: brew update && brew install gmp && rvm reinstall 2.1.4

Friday, September 26, 2014

Autostart App on Macintosh, just load PLIST files at LaunchAgents such as (Mysql, Mongod and Redis)

Mysql 


brew info mysql
mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/*mysql*.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/*mysql*.plist

or 

cp /usr/local/opt/mysql/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist



Mongod 

Create a file call org.mongo.mongod.plist in /Library/LaunchDaemons/

If you use vim you can do like this:
sudo vim /Library/LaunchDaemons/org.mongo.mongod.plist  

Copy and paste this:
 
 
"1.0">  
 
    Label
    org.mongo.mongod
    RunAtLoad
   
    ProgramArguments
   
        /usr/local/bin/mongod
        --dbpath
        /var/lib/mongodb/
        --logpath
        /var/log/mongodb.log
   
 


Also, you will need to create a file for the log and a directory for the database.
sudo touch /var/log/mongodb.log  
sudo mkdir /var/lib/mongodb  

And run this in your terminal:
sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist  
sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist  
sudo launchctl start org.mongo.mongod  


Redis

To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf

Tuesday, July 15, 2014

Incorrect MySQL client library version!

Recently I upgraded my OS X from Snow Leopard to Mavericks in preparation for Yosimate. A lot of dependencies have changed in the latest OS X that breaks my gems for my previous RVM environment (still ruby-1.9.3-p125)

I had this case whereby my I test and rake script "announcement" like I used to run on my development mode in Ruby on Rails.

bundle exec rake announcement:announce_bcc RAILS_ENV=development

Development mode on Rails. Unfortunately I got an error stating that:

Incorrect MySQL client library version! This gem was compiled for 5.5.14 but the client library is 5.6.19.

What I did to solve the issue was to upgrade my gems such as (bundle and rake).

gem update bundler
gem update rake

What solve the issues was to update my mysql2 gem. So what I saw from an article at
Install the mysql2 for a specific mysql client so I just update the mysql2 using gem prestine command.

gem pristine mysql2

This solves the problems and I was able to run the normal RAKE SCRIPT file in my local development.

Comment in if you have similar issues and wants to share insites for us both. ciao c",)

Thursday, July 3, 2014

Learning Paypal API

Recently I'm learning the API of Paypal because it is important on developing applications when payment made by clients using Paypal. Currently i'm residing in Singapore and this link will help me or you when you want to explore Paypal integration on your web applications.

https://developer.paypal.com/docs/api/