Skip to content

Instantly share code, notes, and snippets.

View wachunei's full-sized avatar
🧔
being

Pedro Pablo Aste Kompen wachunei

🧔
being
View GitHub Profile
@wachunei
wachunei / main.js
Last active September 4, 2015 14:05 — forked from lopezjurip/main.js
Repartidor web js
var turn = 0;
var teams = ['Rupie', 'TheTeam', 'Veritas', 'ImaginApp', 'Nebuchadnezzar', 'InternalServerError'];
var patoTeams = ['YisusPlusOne', 'ZipCity2000', 'tqzptscsaj'];
var pedroTeams = ['String.random','ToPa'];
var thomasTeams = ['LosExtraterrestresMusicales', 'Rock and Prog', 'PW:Software'];
var result = teams.sort(function(){return 0.5 - Math.random();})
.reduce(function(previous, current) {
previous[['pato', 'thomas', 'pedro'][turn++ % 3]].push(current);
return previous;
@wachunei
wachunei / cherylbd.rb
Last active August 29, 2015 14:19
Cheryl Birthday Ruby
def print_dates(dates, answer_text)
puts "\nAnswers left:" if answer_text
puts dates.join("; ")
print "\n"
end
class Day
attr_accessor :month, :day
def initialize(month, day)
@day = day;
@wachunei
wachunei / numeric_for_django_templates.html
Last active October 27, 2022 13:41
Numeric for loop in Django Templates
<!-- Iterate N times (replace N with a number -->
{% for i in "x"|ljust:"N" %}
<!-- Access numeric variable (0-based index) -->
{{ forloop.counter0 }}
<!-- Access numeric variable (1-based index) -->
{{ forloop.counter }}
{% endfor %}
<!-- For example, iterate from 0 to 3 -->
@wachunei
wachunei / rut.rb
Last active August 29, 2015 14:10
RUT Chile: obtener dígito verificador, validar y formatear
def obtener_dv rut
rut = rut.to_s.tr(".-", "").reverse
suma = 0
for index in 0..rut.size
suma+= rut[index].to_i * (2+index%6)
end
res = 11 - suma % 11
res = (res == 11)? 0 : (res == 10)? "K" : res
res.to_s
end