Skip to content

Instantly share code, notes, and snippets.

View marvinahv's full-sized avatar

Marvin Herrera marvinahv

View GitHub Profile
@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 / 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 / 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 / .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 / 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 / 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 / file.slim
Last active August 28, 2020 23:57
Render Slim template with variables in Ruby
h1 This #{foo} is here.
@marvinahv
marvinahv / equalize_heights.coffee
Created June 26, 2013 06:57
Code Snippet to have elements with the same height.
equalize_heights = (selector) ->
max_height = 0
$(selector).each ->
height = $(this).outerHeight()
max_height = height if height > max_height
$(selector).height(max_height)
@marvinahv
marvinahv / responsive_mixin.sass
Created June 26, 2013 06:55
A Sass Mixin to add Responsiveness to a Site
// Responsive Mixin
@mixin responsive($width)
@if $width == 300
@media all and (min-width:300px)
@content
@if $width == 600
@media all and (min-width:600px)
@marvinahv
marvinahv / email_validation.rb
Created May 22, 2013 05:47
Check if String is a valid email address
class String
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
def is_valid_email?
if self.match(VALID_EMAIL_REGEX)
return true
else
return false
end
end