This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtGui, QtCore, uic | |
def p(x): | |
print x | |
class MainWindow(QtGui.QMainWindow): | |
def __init__(self): | |
QtGui.QWidget.__init__(self) | |
uic.loadUi('redirect.ui', self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding=utf-8 | |
# Obtener el dígito verificador del RUT en Python. | |
# | |
# La función recibe el RUT como un entero, | |
# y entrega el dígito verificador como un entero. | |
# Si el resultado es 10, el RUT es "raya k". | |
from itertools import cycle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Point(x: Double, y: Double) { | |
def +(p: Point) = Point(x + p.x, y + p.y) | |
def *(a: Double) = Point(a * x, a * y) | |
def distTo(that: Point) = { | |
val Point(dx, dy) = this + that * -1 | |
math.sqrt(dx * dx + dy * dy) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val integers = Stream.from(0) | |
object E1 { | |
val evenIntegers = integers.filter(_ % 2 == 0) | |
} | |
object E2 { | |
val evenIntegers = integers.map(_ * 2) | |
} | |
object E3 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Move | |
case class Spin(x: Int) extends Move | |
case class Exchange(a: Int, b: Int) extends Move | |
case class Partner(a: Char, b: Char) extends Move | |
object Move { | |
val spin = """s(\d+)""".r | |
val exchange = """x(\d+)/(\d+)""".r | |
val partner = """p(\w)/(\w)""".r | |
val fromString: PartialFunction[String, Move] = { | |
case spin(x) ⇒ Spin(x.toInt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.0 | |
import sys, array, tempfile, heapq | |
assert array.array('i').itemsize == 4 | |
def intsfromfile(f): | |
while True: | |
a = array.array('i') | |
a.fromstring(f.read(4000)) | |
if not a: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
die () { | |
echo "$1" | |
exit 1 | |
} | |
get-scala-version () { | |
curl http://www.scala-lang.org/ 2> /dev/null | grep scala-version | perl -pe 's/\D*([0-9.]+)\D*/$1/' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val rut1 = 15666777 // - 3 | |
val rut2 = 23456789 // - 6 | |
val rut3 = 22333444 // - k | |
// 1 5 6 6 6 7 7 7 | |
// ...3 2 7 6 5 4 3 2 | |
// 3 10 42 36 30 28 21 14 → (+) → 184 | |
// -184 mod 11 = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////// | |
// // | |
// El patrón del match // | |
// // | |
// Roberto Bonvallet // | |
// @rbonvall // | |
// // | |
// Martes 17 de mayo de 2016 // | |
// Santiago Scala Meetup // | |
// // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////// | |
// // | |
// El patrón del match // | |
// // | |
// Roberto Bonvallet // | |
// @rbonvall // | |
// // | |
// Martes 17 de mayo de 2016 // | |
// Santiago Scala Meetup // | |
// // |
NewerOlder