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
var express = require('express'), app = express.createServer(); | |
var fs = require('fs'), sys = require("sys"); | |
var log = fs.createWriteStream('params.json', {'flags': 'a'}); | |
app.use(express.logger()); | |
app.get('/', function(req, res){ | |
console.log(req.query); | |
log.write(JSON.stringify(req.query)); | |
res.send('It\'s saved!'); |
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
library(gtools) | |
data <- permutations(2, 3, v = c(T,F), repeats.allowed=TRUE) | |
tt <- as.data.frame(data) | |
names(tt) <- letters[1:3] | |
tt$"! (a | b) | c" <- (!(tt$a | tt$b) | tt$c) | |
# unusual output! | |
xtable(tt) |
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
import sys | |
# Leitura do arquivo de entrada no formato especificado. Linhas iniciadas com | |
# "#" sao comentarios. Nao era necessario os alunos implementarem isso. | |
grafoin = [] | |
try: | |
infilename = sys.argv[1] | |
infile = open(infilename,'r') | |
for line in infile: |
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
def fib1(n): | |
if n == 0: | |
return 0 | |
if n == 1: | |
return 1 | |
else: | |
return fib1(n-1) + fib1(n-2) | |
def fib2(n): |
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
library(RColorBrewer) | |
library(wordcloud) | |
pal2 <- brewer.pal(8,"Set2") | |
lines <- readLines("pg32519.txt") | |
lines <- lines[45:3192] | |
text <- paste(lines, collapse = " ") | |
words <- unlist(strsplit(tolower(text), "\\s+|,|\\(|\\)|:|\\.|!|\\?|;")) |
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
(defun check-issn (str) | |
" Parse a string of 8 digits in the format NNNN-NNNN representing an | |
ISSN number. The last N can be an X representing 10. " | |
(let ((digits (remove nil (loop for char across str | |
collect (cond ((equal char #\X) 10) | |
((equal char #\-) nil) | |
(t (parse-integer (string char)))))))) | |
(if (not (equal (length digits) 8)) | |
nil | |
(equal 0 (mod (loop for i from 8 downto 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
# This script was originally written during for a summer course that I | |
# gave at FGV in January 2011. The script was used to show the | |
# students how to retrive data from Banco Central do Brasil | |
# (http://bcb.gov.br/?SERIETEMP) using SOAP protocol and R. | |
library(SSOAP) | |
library(XML) | |
library(RCurl) | |
wsdl <- getURL("https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl", |
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
portas <- function (t){ | |
teste <- 0 | |
amostra <- 0 | |
while (teste < t){ | |
# dist é a distribuição dos conteúdos das portas, 1 marca a porta | |
# premiada | |
dist <- c(1,0,0) | |
dist <- dist[sample(3)] | |
a <- sample(3,1) # a será a porta que você escolhe |
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
corpus2 <- lapply(corpus, getWords) | |
tira.erro <- sapply(corpus2, length) > 0 | |
corpus2 <- corpus2[tira.erro] | |
apcount <- table(unlist(lapply(corpus2, names))) | |
apcount.df <- as.data.frame(apcount, stringsAsFactors = FALSE) | |
apcount.df$f <- apcount.df$Freq / length(corpus2) |
OlderNewer