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
class MeuRequest { | |
final HSR req; | |
public MeuRequest(HSR request){ | |
this.req = request; | |
} | |
public String referrer(){ | |
//Código nojento e bizarro | |
} | |
} |
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 | |
jekyll || /var/lib/gems/1.8/bin/jekyll | |
cd _site; | |
typeFor(){ | |
TYPE=`echo $1 | sed -E "s/.+\.([^$]+)$/\1/"` | |
CONTENT_TYPE="" | |
if [ $TYPE == "html" ]; then CONTENT_TYPE="text/html"; fi; |
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
package tdc | |
case class Gasto(subfuncao : String, destino : String, natureza : String, valor : Double) | |
case class GastoAgrupado(label : String, total : Double, filhos : Option[List[GastoAgrupado]]) | |
object Gastos { | |
def join(gastos : List[Gasto], filters : List[Gasto => String]) : Option[List[GastoAgrupado]] = { | |
filters.headOption.map { filter => |
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
judgedTask.success { | |
game.advance(index) { nextIndex => | |
session.saveLast("/play/%s/task/%d".format(gameName, nextIndex)) | |
result.redirectTo(this).task(gameName, nextIndex) | |
} | |
game.atEnd(index) { | |
session.endGame | |
result.include("gameEnded", "end") |
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 org.specs2.mutable.Specification | |
import org.junit.runner.RunWith | |
import org.specs2.runner.JUnitRunner | |
import org.junit.runner.RunWith | |
import org.specs2.runner.JUnitRunner | |
@RunWith(classOf[JUnitRunner]) | |
class DepsSpec extends Specification { | |
import Deps._ |
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
# Meo deus! esse require abaixo abre Array e acrescenta o método to_set !!! | |
require 'set' # Sim. Um set. Precisa de acesso O(1) | |
class Robo | |
def initialize(terreno, posicao, direcao) | |
@terreno = terreno | |
@posicao = posicao | |
@direcao = direcao | |
@andar = { :norte => [0, 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
# Certo... -1 nao compila. Precisa ser - 1 | |
# J => 10, Q => 11, K => 12, A => 13 | |
class Resultado | |
attr_reader :v, :n | |
def initialize(n, v) | |
@v = v | |
@n = n | |
end |
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 | |
rm -f controle | |
for ESTADO in `ls`; do | |
for ARQUIVO in `ls $ESTADO`; do | |
EXT=$(echo $ARQUIVO | cut -d "." -f 2) | |
DESTDIR="/home/ubuntu/dbf/$ESTADO/$ARQUIVO" | |
FILE="$ESTADO/$ARQUIVO" | |
mkdir -p $DESTDIR |
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
Não. Você produz apenas uma matriz. (https://en.wikipedia.org/wiki/Matrix_multiplication#Illustration ) | |
Se a multiplicação é AxB=C (A, B e C são matrizes), cada resultado da matriz C é produzido pela multiplicação de uma linha de A com uma coluna de B. | |
[1, 2] [5, 6] [1*5+2*7, 1*6+2*8] [19, 22] | |
[3, 4] X [7, 8] = [3*5+4*7, 3*6+4*8] = [43, 50] | |
O que você consegue fazer é fazer cada runnable pegar um número de linhas, nesse caso, 1: | |
Runnable1: [1, 2] [5, 6] [19, 0] | |
X [7, 8] = [43, 0] |
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 | |
TABELAS=`find . -path ./TABELAS_SUS -prune -o -iname *.dbf | cut -d "/" -f 4 | sed -r 's/([a-zA-Z]+)[a-zA-Z]{2}.*/\1/' | tr '[A-Z]' '[a-z]' | sort | uniq` | |
for X in $TABELAS; do | |
ARQUIVO=`find . -path ./TABELAS_SUS -prune -o -iname "$X*.dbf" | grep -i dbf | tail -n 1` | |
echo "gerando tabela $X usando $ARQUIVO" | |
dbf2mysql -d datasus -t $X -cc -U root $ARQUIVO |
OlderNewer