Skip to content

Instantly share code, notes, and snippets.

View aruponse's full-sized avatar

Alfonso Aguilar aruponse

View GitHub Profile
@aruponse
aruponse / gist:96b923d863f1718386b70fc5cd07f480
Created January 3, 2018 20:50 — forked from ymirpl/gist:1052094
Python unicode e-mail sending
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@aruponse
aruponse / luhn.rb
Last active April 16, 2016 14:22
Algoritmo de Luhn (Ruby)
def is_valid?(number)
digits = number.to_s.reverse.chars.map(&:to_i)
check_sum = 0
digits.each_slice(2) do |odd, even|
check_sum += odd
next unless even
even *= 2
even = even.divmod(10).inject(:+) if even > 9
check_sum += even
input = ARGV[0]
index = 0
numbers = ""
File.open(input, 'r') do |f|
while line = f.gets
if index==0
limit=line.to_i
index+=1
next
end