This file contains hidden or 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 functools import partial | |
| def partial(funcao, argumento): | |
| def fn(arg): | |
| return funcao(argumento, arg) | |
| return fn | |
| def to_tag(tag, texto): | |
| return "<{tag}>{texto}</{tag}>".format(tag=tag, texto=texto) | |
| negrito = partial(to_tag, 'b') |
This file contains hidden or 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
| def change(n, coins): | |
| if n == 0: | |
| return 1 | |
| elif n < 0 or len(coins) == 0: | |
| return 0 | |
| else: | |
| return change(n, coins[1:]) + change(n - coins[0], coins) | |
| print change(10, [10, 5, 2, 1]) |
This file contains hidden or 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
| class Natural(object): | |
| def __init__(self, anterior): | |
| self.anterior = anterior | |
| def __str__(self): | |
| return str(self.anterior) + " + 1" | |
| def __add__(self, other): | |
| return self.anterior + other.sucessor() |
This file contains hidden or 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
| def ifilter(funcao, seq): | |
| for x in seq: | |
| if funcao(x): | |
| yield x | |
| def take(seq, n): | |
| i = 0 | |
| for x in seq: | |
| if i < n: |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
| <title> - jsFiddle demo</title> | |
| <script type='text/javascript' src='/js/lib/dummy.js'></script> | |
| <link rel="stylesheet" type="text/css" href="/css/normalize.css"> | |
| <link rel="stylesheet" type="text/css" href="/css/result-light.css"> |
This file contains hidden or 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
| PriorityQueue <- function() { | |
| keys <<- values <<- NULL | |
| insert <- function(key, value) { | |
| temp <- c(keys, key) | |
| ord <- order(temp) | |
| keys <<- temp[ord] | |
| values <<- c(values, list(value))[ord] | |
| } | |
| pop <- function() { | |
| key <- keys[[1]] |
This file contains hidden or 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
| # http://badhessian.org/2012/09/lessons-on-exponential-random-graph-modeling-from-greys-anatomy-hook-ups/ | |
| library(ergm) | |
| path <- "/Users/juarez.bochi/Dropbox/mestrado/inf2035/Random Graphs/fbergm" | |
| friends_path <- paste(path, "friends_manual.tsv", sep="/") | |
| relationships_path <- paste(path, "relationships.tsv", sep="/") | |
| friends <- read.table(friends_path, sep="\t", header=T, stringsAsFactors=F, strip.white=F, as.is=T) |
This file contains hidden or 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
| import sys | |
| import time | |
| delay = float(sys.argv[1]) | |
| for line in sys.stdin: | |
| sys.stdout.write(line) | |
| time.sleep(delay) |
This file contains hidden or 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
| import urllib | |
| from time import sleep | |
| from hashlib import md5 | |
| import sys | |
| def bell(): | |
| sys.stdout.write('\a') | |
| sys.stdout.flush() | |
| def dig(): |
This file contains hidden or 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
| Port 8081 | |
| BindAddress 0.0.0.0 | |
| MaxClients 10 | |
| MaxBandwidth 50000 | |
| NoDaemon | |
| <Feed feed.ffm> | |
| file /tmp/feed.ffm | |
| FileMaxSize 20M | |
| </Feed> |