Skip to content

Instantly share code, notes, and snippets.

View marvinahv's full-sized avatar

Marvin Herrera marvinahv

View GitHub Profile
@marvinahv
marvinahv / fontsquirrel-font mixin.scss
Last active September 29, 2015 21:48
A little mixin to add fonts from Font Squirrel
// Mixin to use fonts generated by Font Squirrel (http://www.fontsquirrel.com)
@mixin font_squirrel_font($font-name, $file-name){
$font-url: "/font/#{$file-name}";
@font-face {
font-family: $font-name;
src: "#{$font-url}.eot";
src: local("#{$font-name}"), url("#{$font-url}.eot?#iefix") format("embedded-opentype"),
url("#{$font-url}.woff") format("woff"),
@marvinahv
marvinahv / gist:4021802
Created November 6, 2012 01:13
Bourbon in Sinatra
bourbon_bin = Gem::Specification.find_by_name("bourbon").gem_dir
bourbon_path = File.join(bourbon_bin, 'app', 'assets', 'stylesheets')
Compass.configuration.add_import_path(bourbon_path)
Stasis::Options.set_template_option 'sass', { :load_paths => Compass.configuration.sass_load_paths }
@marvinahv
marvinahv / recursive_drive.rb
Created November 14, 2012 23:46
Belongs_to Functionality for Google Drive
require 'google_drive'
def recursive(i=0)
$arr[i].each do |row|
subs = []
recursive(i+1) if $arr[i+1]
if (i+1) < ($arr.length)
$arr[i+1].each do |sub_row|
@marvinahv
marvinahv / json_table.rb
Created November 17, 2012 01:16
Google Drive JSON Table
require 'google_drive'
require 'json'
def get_json_table(key, username, password)
# Create Columns
columns = []
labels = ["id", "Manager", "ToolTip"]
labels.each do |column|
@marvinahv
marvinahv / drawChart.coffee
Created November 18, 2012 00:50
Google Org Visualization from JSON
drawChart = ->
$.getJSON '/js/org.json', (json) ->
data = new google.visualization.DataTable(json)
chart = new google.visualization.OrgChart(document.getElementById('org'))
chart.draw data,
allowHtml: true
nodeClass: 'org-node'
selectedNodeClass: 'org-node-selected'
@marvinahv
marvinahv / layout.slim
Last active October 5, 2016 14:27
Minimalistic slim layout
doctype html
html lang="en"
head
meta charset="utf-8"
meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"
title
meta name="description" content=""
meta name="author" content=""
meta name="keywords" content=""
meta name="viewport" content="width=device-width, initial-scale=1.0"
@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
@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 / 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 / file.slim
Last active August 28, 2020 23:57
Render Slim template with variables in Ruby
h1 This #{foo} is here.