Bootstrap Glyphicons in Rails

Recently, I have add bootstrap.min.css manually, not from gem. And I got error when trying to add Bootstrap glyphicons. I’m not sure using gem does get this error or not. However, This just a trick to add Bootstrap Glyphycons to Rails manully alongside.
The first thing you need to do is add @fontface in your bootstrap file:

@font-face {
    font-family: 'Glyphicons Halflings';

    src: url('/fonts/glyphicons-halflings-regular.eot');
    src: url('/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

After that, in order to make these fonts works, I added bootstrap fonts folder to public folder

Finally, use it in you view file like this:

<span class="tag-item"><span class="glyphicon glyphicon-tag"></span> <a href="">Tag 1, </a></span>

Set Headers in Ajax Request

  ## I used Coffee Script syntax
  ## @ sign here to set this function available in .erb file

  @yourFunction = (auth_token) ->
    $.ajax({
      type: "GET",
      url: "/url/path",
      headers: { 'Authorization': 'Token token=' + auth_token }
    }).done((data) -> console.log(data)
    ).fail((jqXHR, textStatus, errorThrown) -> 
      console.log("Request failed: " + textStatus)
      console.log(errorThrown)
    });

Git: Ignore files

 

When using Git to mange source code, it is very useful and usually I use .gitignore file to mange which files and folders that should not be push to Github repository.

.gitignore file is something like this:

# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

/.idea


Continue reading Git: Ignore files

CentOS Basic Usage

After a long time using Ubuntu, I find Ubuntu interesting, easy to use, and convenient to programming Ruby on Rails. However, talking about Linux, I think CentOS is also the big candidate that should be mentioned and tried. Today, I want to summary some basic usages relating to CentOS only before starting to use it. I will update this post continuously during my usage of CentOS.

  • check your CentOS version

    cat /etc/redhat-release
    
  • Update repository

    yum update
    
  • List package name

    yum list 
    
  • Install package by console

    yum install 
    
  • Remove package

    yum remmove 
    
  • Know which version of application installed

    yum list installed | grep name_of_app
    
  • Install Ruby on CentOS via RVM

    yum groupinstall -y development
    
    curl -L get.rvm.io | bash -s stable
    source /etc/profile.d/rvm.sh
    
    rvm reload
    rvm install 2.1.0 
    
    ruby --version
    rvm list rubies
    rvm use 2.1.0 --default