Skip to content

Instantly share code, notes, and snippets.

@vkobel
vkobel / import.py
Created April 19, 2013 11:41
Import file which do: - SSH Download of a .sql.gz.gpg file - Decrypting it using GPG - Decompress line by line using gzip - Create requests (separated by ";" and run it on mysql) It also has a retry and try_once function to handle errors and automatically re-run a determined amount of time if needed
import sys
from datetime import datetime
import paramiko
import gzip
import gnupg
import MySQLdb
# apt-get install:
# python-paramiko
# python-mysqldb
@vkobel
vkobel / parenthesesBalancing.scala
Created March 28, 2013 13:21
Simple parentheses balancing method using tailrec
package week1
import scala.annotation.tailrec
object parenthesesBalancing {
def balance(chars: List[Char]): Boolean = {
def analyse(c: Char) =
if (c == '(') 1
@vkobel
vkobel / pascalTriangle.scala
Last active December 15, 2015 12:48
Simple scala function to compute the pascal triangle
package week1
object pascalTriangle {
def pascal(c: Int, r: Int): Int = {
if (r == 0 && c == 0) 1
else if (c < 0 || c > r + 1) 0
else pascal(c - 1, r - 1) + pascal(c, r - 1)
} //> pascal: (c: Int, r: Int)Int