Skip to content

Instantly share code, notes, and snippets.

View colatusso's full-sized avatar

Rafael Colatusso colatusso

View GitHub Profile
@colatusso
colatusso / download-subtitles.py
Last active September 1, 2016 19:52 — forked from binho/download-subtitles.py
Download subtitles using subliminal lib (https://github.com/Diaoul/subliminal)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from datetime import timedelta
from babelfish import Language
from subliminal import download_best_subtitles, region, save_subtitles, scan_videos
import sys
import os
"""
import Foundation
extension String {
func removeLetter(char: Character) -> String {
var newString = ""
var alreadyRemoved = false
for c in self.characters {
if c != char || (c == char && alreadyRemoved) {
newString.append(c)
class Queue<T> {
var queue: [T] = []
func enqueue(object: T) {
self.queue.append(object)
}
func dequeue() -> T? {
if self.queue.count == 0 {
return nil
func insertionSort(arr: [Int]) -> [Int] {
var arr = arr
for i in 1..<arr.count {
var index = i
while index > 0 && arr[index] < arr[index - 1] {
swap(&arr[index], &arr[index - 1])
index -= 1
}
import UIKit
func checkPalindrome(str: String) -> Bool {
if str == "" || str.characters.count == 1 {
return true
}
else {
if str.characters.first == str.characters.last {
return checkPalindrome(str.substringWithRange(str.startIndex.successor() ..< str.endIndex.predecessor()))
}
class BTNode<T:Comparable> {
var value: T?
var left: BTNode?
var right: BTNode?
var parent: BTNode?
init(value: T) {
self.value = value
}
class Edge {
var neighbor: Node
init(n: Node) {
self.neighbor = n
}
}
class Node {
var edges: [Edge] = []
@colatusso
colatusso / linkedlist.swift
Last active September 24, 2017 14:47
linked list (swift 4)
class Node<T> {
var value: T?
var next: Node?
var previous: Node?
init(value: T) {
self.value = value
}
}