Skip to content

Instantly share code, notes, and snippets.

@ig10
ig10 / inHourFilter.js
Created October 27, 2015 13:49
Translate Minutes to hours and minutes
function inHoursFilter(mins) {
// Return String with Qty of Hours and Mins
// REFACTOR!
var total = Math.round((parseFloat(mins)/60)*100)/100,
hours = Math.floor(total),
minutes = Math.round(parseFloat('0.'+ total.toString().split('.')[1]) * 100 ) / 100,
result = "";
if( hours === 0) {
return mins + ' mins';
@ig10
ig10 / ipv4_binary.rb
Created April 21, 2016 05:55
Convert IPv4 to Binary numbers
octal, ipv4, input = [128, 64, 32, 16, 8, 4, 2, 1], [[],[],[],[]], nil
while input.nil? || input.split('.').size != 4 do
puts "Ingrese IPv4 a convertir"
input = gets.chomp
end
input = input.split('.').map(&:to_i)
ipv4.each_with_index do |binary_set, index|