Skip to content

Instantly share code, notes, and snippets.

View rderoldan1's full-sized avatar
🇨🇴

Ruben Espinosa rderoldan1

🇨🇴
  • Medellin, Colombia
View GitHub Profile
@rderoldan1
rderoldan1 / formater.java
Created October 10, 2012 16:02
Method to format long numbers in GB, MB and KB
private String format_long(long number){
String formatted;
if (number > 1000000000) {
String re = "^(.*)\\d{9}$";
Matcher m = Pattern.compile(re).matcher(Long.toString (number));
if (m.find()) {
formatted = m.group(1) + " Gb";
} else {
formatted = "0";
}

Stepts to install and configure Apache, MySql, Phpmyadmin, Git, Ruby, Rails in Ubuntu

1. Apache

sudo apt-get install apache2

2. MySql

sudo apt-get install mysql-server

Set a password for the root user, please remember it.

3. phpmyadmin

@rderoldan1
rderoldan1 / nodo.rb
Created November 20, 2012 00:58
probando
def find_number(number, index)
puts "Buscando el numero #{index} en #{number.inspect}"
number.join.scan(/#{index}/).count
#number.to_s.scan(/#{index}/).count
([a-zA-Z0-9]+(\d|[a-zA-Z])+)@([a-zA-Z]+)(\.([a-zA-Z]+(\d|[a-zA-Z])+)){1,2}
[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+){1,2}
@rderoldan1
rderoldan1 / application_helper.rb
Last active December 16, 2015 21:29
image_tag with blank url
module ApplicationHelper
def image_tag(img , options={})
path = "#{Rails.root}/app/assets/images/#{img}"
img = "missing.png" unless img.present? and File.file?(path)
super(img, options)
end
end
@rderoldan1
rderoldan1 / wicked_pdf.rb
Created May 14, 2013 17:15
wicked pdf configuration
module WickedPdfHelper
def wicked_pdf_stylesheet_link_tag(*sources)
sources.collect { |source|
"<style type='text/css'>#{Rails.application.assets.find_asset("#{source}.css")}</style>"
}.join("\n").gsub(/url\(['"](.+)['"]\)(.+)/,%[url("#{wicked_pdf_image_location("\\1")}")\\2]).html_safe
end
def wicked_pdf_image_tag(img, options={})
image_tag wicked_pdf_image_location(img), options
end
@rderoldan1
rderoldan1 / application_helper.rb
Last active December 17, 2015 10:18
fetch all countries via web service in rails in order to choose in a select_tag using http://api.worldbank.org
module ApplicationHelper
def select_country
countries = JSON.parse(open('http://api.worldbank.org/v2/es/countries?format=json&&per_page=250').read).last
countries.map {|key, val|[key["name"], key["iso2Code"]] unless key["name"].blank? }.compact!
end
end
@rderoldan1
rderoldan1 / filter.js.coffee
Created June 18, 2013 21:56
Search in a table with coffeescript, hide not matched
$ ->
$('#search').keyup ->
searchTable($(this).val())
searchTable = (inputVal) ->
table = $('.table')
table.find('tr').each (index, row) ->
if index != 0
allCells = $(row).find('td')
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@rderoldan1
rderoldan1 / README.md
Last active February 7, 2021 19:04
Install libffi-devel

The problem

While I was configuring Ruby on Rails in a Red Hat (CentOS) with RVM I found a problem with the library libffi-devel because the package wasn't available via yum install, after search for a couple of days I found this solution.

Add rpmforge as a repository

  1. Create a repo file in /etc/yum.repos.d/rpmforge.repo, you need to be an admin
  2. Copy the following text.