Skip to content

Instantly share code, notes, and snippets.

View marvinahv's full-sized avatar

Marvin A. Herrera marvinahv

View GitHub Profile
@marvinahv
marvinahv / readable_helpers.rb
Created July 3, 2013 09:03
Helpers to make data Readable on Padrino Views
Stc::App.helpers do
class Readable
def self.date(utc)
utc.to_date.strftime("%B %-d, %Y")
end
def self.text_from_value(value)
_text = value.split('_')
@marvinahv
marvinahv / pretty_slim_output.rb
Created July 6, 2013 21:05
Set slim to pretty output (Sinatra/Padrino)
Slim::Engine.default_options[:pretty] = true
@marvinahv
marvinahv / .gitignore
Last active March 23, 2017 01:36
Basic gitignore for Ruby Web Projects
.DS_Store
log/**/*
tmp/**/*
bin/*
vendor/gems/*
!vendor/gems/cache/
.sass-cache/*
db/*.db
.*.sw*
.sass-cache
@marvinahv
marvinahv / slim_js.rb
Last active December 26, 2015 06:39
slim mustache
gem 'slim', :git => 'git://github.com/brennancheung/slim.git', :branch => 'angularjs_support'
@marvinahv
marvinahv / format_helpers.rb
Last active August 29, 2015 13:57
Ruby helpers to format text
AppName::App.helpers do
class FormatData
# From value to human format
def self.to_human(value)
if value =~ /_/
words = value.split('_')
words.map!{ |word| word.capitalize }
return words.join(' ')
@marvinahv
marvinahv / asset.html
Created September 29, 2014 17:49
public asset image file on amazon s3
<img src="https://bucketname.s3.amazonaws.com/path/filename.ext">
@marvinahv
marvinahv / Setup Instructions.md
Last active December 30, 2015 22:19
Setup Development Environment on Mac OSX

Local Development Environment

Download version depending on operating system.

Homebrew

  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@marvinahv
marvinahv / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
### If you get a really long list of IP addresses from a text file. Display the top 10 repeated IPs.
def top_10_ips(file)
# Select only the itmes that are repeated more than once
unique = []
repeated = []
File.open(file, 'r').each do |ip_line|
### If you get an array of numbers, sum its numbers.
def sum_array_numbers(numbers)
numbers.inject(:+)
end
sum_array_numbers([10, 24, 11, 3, 14, 24])