Skip to content

Instantly share code, notes, and snippets.

View CarlosLCervantes's full-sized avatar

Carlos Cervantes CarlosLCervantes

View GitHub Profile
@CarlosLCervantes
CarlosLCervantes / has_sum_with_max_val.rb
Created March 1, 2018 02:42
Evaluate if array has sum equal to max value
def has_sum_with_max_val(arr)
raise "Invalid Input Array" if arr.nil? || arr.length < 3
raise "Contains Invalid Value" if arr.any? { |n| !n.is_a? Numeric || n < 0 }
has_max_sum = false
arr.sort! { |a, b| b <=> a }
max_num = arr.shift
arr.each_with_index do |num, i|
total = num
@CarlosLCervantes
CarlosLCervantes / markup
Created August 27, 2014 00:29
2 Column Floating Div Same Height CSS Solution
<div class="row two-col">
<div class="col-xs-6 col-sm-2">
<img src="https://s3-us-west-1.amazonaws.com/airenvyassets/return_key.png" class="img-responsive" />
</div>
<div class="col-xs-6 col-sm-10 contrast-box">
<span>Don't forget to return the key!</span>
1) $50 fee for unreturned keys <br />
2) Checkouts after 11AM are charged $50/hr
</div>
</div>
@CarlosLCervantes
CarlosLCervantes / gist:5608adc0079de7841ac3
Created August 18, 2014 23:41
Trust HTML in Angular
<span ng-bind-html="tip"></span>
$sce.trustAsHtml(tip)
@CarlosLCervantes
CarlosLCervantes / gist:9748816
Created March 24, 2014 20:47
2 Column Floating Div Height Fix JS
var setColumns = function() {
if ($("div.two-col").length > 0) {
var columns = $("div.two-col > div");
var leftCol = columns.first();
var rightCol = columns.last();
var padding = parseInt(rightCol.css("padding-top").replace("px", "")) + parseInt(rightCol.css("padding-bottom").replace("px", ""));
rightCol.height(leftCol.height() - padding);
}
}
@CarlosLCervantes
CarlosLCervantes / C# Mail Wrapper
Created January 4, 2014 07:56
A C# Email class that I have used for a long time. Simplifies sending emails down to less than 5 lines of code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Net;
using System.Net.Mail;
using System.Configuration;
using System.Xml.Linq;