├── .gitignore
├── 2011_02_08
├── PARTICIPANTES
├── RETROSPECTIVA
├── ocr.py
└── test_ocr.py
├── 2011_02_15
├── PARTICIPANTES
├── RETROSPECTIVA
├── test_wordwrap.py
└── wordwrap.py
├── 2011_02_22
├── PARTICIPANTES
├── README
├── RETROSPECTIVA
├── demo
│ ├── bg.gif
│ ├── index.html
│ ├── jquery.autocomplete.css
│ ├── jquery.autocomplete.js
│ ├── jquery.js
│ ├── localdata.js
│ └── main.css
└── tests
│ ├── SpecRunner.html
│ ├── fixtures
│ └── localdata.js
│ ├── lib
│ ├── jasmine-1.0.0
│ │ ├── MIT.LICENSE
│ │ ├── jasmine-html.js
│ │ ├── jasmine.css
│ │ └── jasmine.js
│ └── jquery-1.4.4
│ │ └── jquery.js
│ ├── spec
│ └── PluginSpec.js
│ ├── src
│ └── Plugin.js
│ └── stylesheets
│ ├── jquery.autocomplete.css
│ └── main.css
├── 2011_03_01
├── PARTICIPANTES
├── README.markdown
├── RETROSPECTIVA
├── primas.py
└── test_primas.py
├── 2011_03_04
├── README.rst
├── count_and_say.py
├── fizz_buzz.py
├── participantes.rst
├── retrospectiva.rst
├── test_count_and_say.py
└── test_fizzbuzz.py
├── 2011_03_10
├── PARTICIPANTES
├── README
├── RETROSPECTIVA
├── codigo.py
└── test.py
├── 2011_03_15
├── .autotest
├── .rspec
├── Gemfile
├── Gemfile.lock
├── PARTICIPANTES
├── README
├── RETROSPECTIVA
├── Rakefile
├── bowling.rb
└── spec
│ └── bowling_spec.rb
├── 2011_03_16
├── PARTICIPANTES
├── README
├── RETROSPECTIVA
├── caixa.py
└── test_caixa.py
├── 2011_03_23
├── README.rst
├── anobissexto.py
├── encotel.py
├── participantes.rst
├── retrospectiva.rst
├── test_anobissexto.py
└── test_encotel.py
├── 2011_04_13
├── codigo.py
├── readme.rst
├── retrospectiva.rst
└── test.py
├── 2011_04_20
├── codigo.py
├── count_numbers.py
├── participantes.rst
├── retrospectiva.rst
├── test.py
└── test_count_numbers.py
├── 2011_07_12
├── expressao_matematica.py
├── participantes.rst
├── retrospectiva.rst
└── test_expressao_matematica.py
├── 2011_07_19
├── Makefile
├── problem.c
└── retrospectiva.txt
├── 2011_07_26
├── Makefile
├── retrospectiva.rst
└── test.cpp
├── 2011_08_09
├── README.markdown
├── primas.py
├── problemas.markdown
├── retrospectiva.markdown
└── test_primas.py
├── 2011_08_16
├── .rvmrc
├── RETROSPECTIVA.md
├── comentarios.rb
└── spec
│ └── comentarios_spec.rb
├── 2011_08_23
├── amigos.py
├── retro.rst
└── tests.py
├── 2011_10_19
├── codigo.py
├── retrospectiva.txt
└── test.py
├── 2012_03_06
├── booleanos.py
├── problemas
├── retrospectiva
└── test_booleanos.py
├── 2012_03_14
├── .DS_Store
├── encontrar_telefone.py
├── retrospectiva.txt
└── test_encontrar_telefone.py
├── 2012_04_03
├── ano_bissexto
│ ├── ano_bissexto.py
│ └── test.py
├── caixa_eletronico
│ ├── caixa_eletronico.py
│ └── test.py
└── retrospectiva
└── README
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.swp
3 |
--------------------------------------------------------------------------------
/2011_02_08/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | Hugo Tavares
2 | Siminino
3 | Zacarias
4 | Fiuk
5 | Andrews
6 | Hugo Antunes
7 | Tarsis Azevedo
8 | Quixada
9 | Igor
10 | Vinicius
11 | Thatiana
12 | Tina
13 |
--------------------------------------------------------------------------------
/2011_02_08/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | :-)
2 |
3 | * bastante gente
4 | * nível de exercício legal
5 | * estrutura excelente
6 |
7 |
8 | -------------------------
9 |
10 | :`(
11 |
12 | * horário ruim
13 | * teclado usb
14 | * faltou explicar melhor o que estava fazendo
15 | * muitas distrações
16 |
17 |
18 | --------------------------
19 |
20 | melhorar:
21 |
22 | * menos falação
23 | * começar por volta de 19:30
24 |
25 |
26 |
27 | == Próximo organizador: Tarsis
28 |
--------------------------------------------------------------------------------
/2011_02_08/ocr.py:
--------------------------------------------------------------------------------
1 | def ocr(numero):
2 | numeros = {
3 | '\n \n |\n |\n': 1,
4 | '\n __\n __|\n|__\n': 2,
5 | '\n __\n __|\n __|\n': 3,
6 | '\n\n|__|\n |\n': 4,
7 | '\n __\n|__\n __|\n': 5,
8 | '\n __\n|__ \n|__|\n': 6,
9 | '\n __\n |\n |\n': 7,
10 | '\n __\n|__|\n|__|\n': 8,
11 | '\n __\n|__|\n __|\n': 9,
12 | '\n __\n| |\n|__|\n': 0,
13 | '\n __\n | | |\n | |__|\n':10
14 |
15 | }
16 | return numeros.get(numero, None)
17 |
--------------------------------------------------------------------------------
/2011_02_08/test_ocr.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from ocr import ocr
3 |
4 |
5 | class OCRTest(unittest.TestCase):
6 |
7 | def test_numero_um(self):
8 | numero_um = """
9 |
10 | |
11 | |
12 | """
13 |
14 | self.assertEquals(1, ocr(numero_um))
15 |
16 | def test_numero_dois(self):
17 | numero_dois = """
18 | __
19 | __|
20 | |__
21 | """
22 |
23 | self.assertEquals(2, ocr(numero_dois))
24 |
25 | def test_numero_tres(self):
26 | numero_tres="""
27 | __
28 | __|
29 | __|
30 | """
31 | self.assertEquals(3, ocr(numero_tres))
32 |
33 | def test_numero_quatro(self):
34 | numero_quatro="""
35 |
36 | |__|
37 | |
38 | """
39 |
40 | self.assertEquals(4, ocr(numero_quatro))
41 |
42 | def test_numero_cinco(self):
43 | numero_cinco = """
44 | __
45 | |__
46 | __|
47 | """
48 | self.assertEquals(5, ocr(numero_cinco))
49 |
50 | def test_numero_seis(self):
51 | numero_seis = """
52 | __
53 | |__
54 | |__|
55 | """
56 | self.assertEquals(6, ocr(numero_seis))
57 |
58 | def test_numero_sete(self):
59 | numero_sete = """
60 | __
61 | |
62 | |
63 | """
64 | self.assertEquals(7, ocr(numero_sete))
65 |
66 | def test_numero_oito(self):
67 | numero_oito = """
68 | __
69 | |__|
70 | |__|
71 | """
72 | self.assertEquals(8, ocr(numero_oito))
73 |
74 | def test_numero_nove(self):
75 | numero_nove = """
76 | __
77 | |__|
78 | __|
79 | """
80 | self.assertEquals(9, ocr(numero_nove))
81 |
82 | def test_numero_zero(self):
83 | numero_zero = """
84 | __
85 | | |
86 | |__|
87 | """
88 | self.assertEquals(0, ocr(numero_zero))
89 |
90 | def test_numero_dez(self):
91 | numero_dez = """
92 | __
93 | | | |
94 | | |__|
95 | """
96 | print repr(numero_dez)
97 | self.assertEquals(10, ocr(numero_dez))
98 |
99 | if __name__ == '__main__':
100 | unittest.main()
--------------------------------------------------------------------------------
/2011_02_15/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | 1.Tarsis Azevedo - tarsis
2 | 2.Hugo Lopes - hugobr
3 | 3.Andrews Medina - andrewsmedina
4 | 4.Fabio M. Costa - fabiomcosta
5 | 5.Vinicius Mendes - vbmendes
6 | 6.Alberto Beloni - albertobeloni
7 | 7.Gustavo Luz - gustavoluz
8 | 8.Danilo Moret - moret
9 | 9.Francisco - franciscosouza
10 | 10.Carlos Laviola - claviola
11 | 11.Alvaro Justen - turicas
12 | 12.Tatiana - tatiana
--------------------------------------------------------------------------------
/2011_02_15/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | Bom ;D
2 | ------
3 | *Exercicio ++
4 | *Todo mundo programou
5 | *Vai ter pizza no proximo dojo
6 | *Galera legal
7 | *Gente de varios times
8 | *Intrusos ;D
9 |
10 | Ruim ;(
11 | -------
12 | *Sala ocupada
13 | *Nao teve baby step
14 | *Interferencia externa
15 | *Nao teve comida
16 | *Teclado do mac
17 | *TextMate
18 | *Andrews trollou timer
19 |
20 | Melhorar
21 | --------
22 | *Falar menos
23 | *Nao pode casais perto ++
24 | *Timer melhor
--------------------------------------------------------------------------------
/2011_02_15/test_wordwrap.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from wordwrap import wrap
3 |
4 | class WordWrapTest(unittest.TestCase):
5 |
6 | def test_quebra_de_linha_no_fim_de_uma_palavra(self):
7 | self.assertEquals(wrap('word', 5), 'word')
8 |
9 | def test_quebra_de_linha_com_duas_palavras_que_excedem_o_tamanho_da_coluna(self):
10 | self.assertEquals(wrap('two words', 4), 'two\nwords')
11 |
12 | def test_palavra_maior_que_tamanho_da_coluna(self):
13 | self.assertEquals(wrap('bigword', 4), 'bigword')
14 |
15 | def test_quebra_de_linha_com_duas_palavras_maiores_que_o_tamanho_da_coluna(self):
16 | self.assertEquals(wrap('bigword bigword', 4), 'bigword\nbigword')
17 |
18 | def test_palavras_menores_que_tamanho_da_coluna(self):
19 | self.assertEquals(wrap('big word', 15), 'big word')
20 |
21 | def test_tres_palavras_com_duas_com_tamanho_menor_que_a_quantidade_de_colunas(self):
22 | self.assertEquals(wrap('quer misto quente?', 10), 'quer misto\nquente?')
23 |
24 | def test_tres_linhas(self):
25 | self.assertEquals(wrap('loren loren loren', 3), 'loren\nloren\nloren')
26 |
27 | def test_tres_linhas_com_espaco_na_primeira_linha(self):
28 | self.assertEquals(wrap('loren loren loren loren loren loren', 11), 'loren loren\nloren loren\nloren loren')
29 |
30 | def test_tres_linhas_com_mais_de_um_espaco_entre_palavras(self):
31 | self.assertEquals(wrap('loren loren', 7), 'loren\nloren')
32 |
33 | def test_duas_linhas_com_barra_n(self):
34 | self.assertEquals(wrap('loren\nloren loren', 11), 'loren\nloren loren')
35 |
36 |
37 | unittest.main()
--------------------------------------------------------------------------------
/2011_02_15/wordwrap.py:
--------------------------------------------------------------------------------
1 | def wrap(palavras, colunas):
2 | if len(palavras) < colunas:
3 | return palavras
4 | i = 0
5 | resultado = []
6 | for palavra in palavras.split():
7 | i += len(palavra)
8 | if len(resultado) > 0:
9 | if i < colunas:
10 | resultado.append(' ')
11 | resultado.append(palavra)
12 | i += 1
13 | else:
14 | resultado.append('\n')
15 | resultado.append(palavra)
16 | i = 0
17 | else:
18 | resultado.append(palavra)
19 |
20 | return ''.join(resultado)
--------------------------------------------------------------------------------
/2011_02_22/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | PARTICIPANTES:
2 | - Fábio
3 | - Thales
4 | - Andrews
5 | - Chico
6 | - Quixadá
7 | - Rômulo
8 | - Davidson
9 | - Evandro
10 |
--------------------------------------------------------------------------------
/2011_02_22/README:
--------------------------------------------------------------------------------
1 | README
2 |
3 | O problema consiste em criar um plugin jQuery de autocomplete usando BDD e a ferramenta de testes Jasmine.
4 |
5 | A versão do plugin funcionando se encontra na pasta "demo/" e o framework já ficou montado na pasta "tests/".
6 |
7 |
--------------------------------------------------------------------------------
/2011_02_22/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | :)
2 |
3 | - Interação entre as castas
4 | - Aprendizagem de javascript
5 | - Problema legal e real
6 | - Prática de BDD em Javascript
7 | - Conhecer Jasmine
8 | - Pouca gente
9 | - Gente nova
10 | - Experiência com dojo
11 | - Introdução à respeito da dinâmica (dojo)
12 |
13 |
14 | :(
15 |
16 | - Programar pouco é um problema
17 | - Anunciar a linguagem do dojo
18 | - Galera não pediu ajuda no começo da dinâmica
19 | - FALTOU A PORRA DA PIZZA!!!!!!
20 |
21 |
22 | SUGESTÕES:
23 |
24 | - Dois ou mais problemas rolando em grupos ao mesmo tempo
25 | - Fazer dojo com Node.js
26 | - Fazer dojo com Javascript puro
27 | - Fazer dojo que não é de programação: Photoshop
28 |
29 |
--------------------------------------------------------------------------------
/2011_02_22/demo/bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hltbra/dojo_globocom/022ab356a1dc9f35131cbc96d2b266d5bb9142a4/2011_02_22/demo/bg.gif
--------------------------------------------------------------------------------
/2011_02_22/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | jQuery Autocomplete Plugin
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
19 |
20 |
21 |
22 |
23 |
24 | jQuery Autocomplete Plugin
25 |
26 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/2011_02_22/demo/jquery.autocomplete.css:
--------------------------------------------------------------------------------
1 | .ac_results {
2 | padding: 0px;
3 | border: 1px solid black;
4 | background-color: white;
5 | overflow: hidden;
6 | z-index: 99999;
7 | }
8 |
9 | .ac_results ul {
10 | width: 100%;
11 | list-style-position: outside;
12 | list-style: none;
13 | padding: 0;
14 | margin: 0;
15 | }
16 |
17 | .ac_results li {
18 | margin: 0px;
19 | padding: 2px 5px;
20 | cursor: default;
21 | display: block;
22 | /*
23 | if width will be 100% horizontal scrollbar will apear
24 | when scroll mode will be used
25 | */
26 | /*width: 100%;*/
27 | font: menu;
28 | font-size: 12px;
29 | /*
30 | it is very important, if line-height not setted or setted
31 | in relative units scroll will be broken in firefox
32 | */
33 | line-height: 16px;
34 | overflow: hidden;
35 | }
36 |
37 | .ac_loading {
38 | background: white url('indicator.gif') right center no-repeat;
39 | }
40 |
41 | .ac_odd {
42 | background-color: #eee;
43 | }
44 |
45 | .ac_over {
46 | background-color: #0A246A;
47 | color: white;
48 | }
49 |
--------------------------------------------------------------------------------
/2011_02_22/demo/jquery.autocomplete.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Autocomplete plugin 1.1
3 | *
4 | * Copyright (c) 2009 Jörn Zaefferer
5 | *
6 | * Dual licensed under the MIT and GPL licenses:
7 | * http://www.opensource.org/licenses/mit-license.php
8 | * http://www.gnu.org/licenses/gpl.html
9 | *
10 | * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
11 | */
12 |
13 | ;(function($) {
14 |
15 | $.fn.extend({
16 | autocomplete: function(urlOrData, options) {
17 | var isUrl = typeof urlOrData == "string";
18 | options = $.extend({}, $.Autocompleter.defaults, {
19 | url: isUrl ? urlOrData : null,
20 | data: isUrl ? null : urlOrData,
21 | delay: isUrl ? $.Autocompleter.defaults.delay : 10,
22 | max: options && !options.scroll ? 10 : 150
23 | }, options);
24 |
25 | // if highlight is set to false, replace it with a do-nothing function
26 | options.highlight = options.highlight || function(value) { return value; };
27 |
28 | // if the formatMatch option is not specified, then use formatItem for backwards compatibility
29 | options.formatMatch = options.formatMatch || options.formatItem;
30 |
31 | return this.each(function() {
32 | new $.Autocompleter(this, options);
33 | });
34 | },
35 | result: function(handler) {
36 | return this.bind("result", handler);
37 | },
38 | search: function(handler) {
39 | return this.trigger("search", [handler]);
40 | },
41 | flushCache: function() {
42 | return this.trigger("flushCache");
43 | },
44 | setOptions: function(options){
45 | return this.trigger("setOptions", [options]);
46 | },
47 | unautocomplete: function() {
48 | return this.trigger("unautocomplete");
49 | }
50 | });
51 |
52 | $.Autocompleter = function(input, options) {
53 |
54 | var KEY = {
55 | UP: 38,
56 | DOWN: 40,
57 | DEL: 46,
58 | TAB: 9,
59 | RETURN: 13,
60 | ESC: 27,
61 | COMMA: 188,
62 | PAGEUP: 33,
63 | PAGEDOWN: 34,
64 | BACKSPACE: 8
65 | };
66 |
67 | // Create $ object for input element
68 | var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
69 |
70 | var timeout;
71 | var previousValue = "";
72 | var cache = $.Autocompleter.Cache(options);
73 | var hasFocus = 0;
74 | var lastKeyPressCode;
75 | var config = {
76 | mouseDownOnSelect: false
77 | };
78 | var select = $.Autocompleter.Select(options, input, selectCurrent, config);
79 |
80 | var blockSubmit;
81 |
82 | // prevent form submit in opera when selecting with return key
83 | $.browser.opera && $(input.form).bind("submit.autocomplete", function() {
84 | if (blockSubmit) {
85 | blockSubmit = false;
86 | return false;
87 | }
88 | });
89 |
90 | // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
91 | $input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
92 | // a keypress means the input has focus
93 | // avoids issue where input had focus before the autocomplete was applied
94 | hasFocus = 1;
95 | // track last key pressed
96 | lastKeyPressCode = event.keyCode;
97 | switch(event.keyCode) {
98 |
99 | case KEY.UP:
100 | event.preventDefault();
101 | if ( select.visible() ) {
102 | select.prev();
103 | } else {
104 | onChange(0, true);
105 | }
106 | break;
107 |
108 | case KEY.DOWN:
109 | event.preventDefault();
110 | if ( select.visible() ) {
111 | select.next();
112 | } else {
113 | onChange(0, true);
114 | }
115 | break;
116 |
117 | case KEY.PAGEUP:
118 | event.preventDefault();
119 | if ( select.visible() ) {
120 | select.pageUp();
121 | } else {
122 | onChange(0, true);
123 | }
124 | break;
125 |
126 | case KEY.PAGEDOWN:
127 | event.preventDefault();
128 | if ( select.visible() ) {
129 | select.pageDown();
130 | } else {
131 | onChange(0, true);
132 | }
133 | break;
134 |
135 | // matches also semicolon
136 | case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
137 | case KEY.TAB:
138 | case KEY.RETURN:
139 | if( selectCurrent() ) {
140 | // stop default to prevent a form submit, Opera needs special handling
141 | event.preventDefault();
142 | blockSubmit = true;
143 | return false;
144 | }
145 | break;
146 |
147 | case KEY.ESC:
148 | select.hide();
149 | break;
150 |
151 | default:
152 | clearTimeout(timeout);
153 | timeout = setTimeout(onChange, options.delay);
154 | break;
155 | }
156 | }).focus(function(){
157 | // track whether the field has focus, we shouldn't process any
158 | // results if the field no longer has focus
159 | hasFocus++;
160 | }).blur(function() {
161 | hasFocus = 0;
162 | if (!config.mouseDownOnSelect) {
163 | hideResults();
164 | }
165 | }).click(function() {
166 | // show select when clicking in a focused field
167 | if ( hasFocus++ > 1 && !select.visible() ) {
168 | onChange(0, true);
169 | }
170 | }).bind("search", function() {
171 | // TODO why not just specifying both arguments?
172 | var fn = (arguments.length > 1) ? arguments[1] : null;
173 | function findValueCallback(q, data) {
174 | var result;
175 | if( data && data.length ) {
176 | for (var i=0; i < data.length; i++) {
177 | if( data[i].result.toLowerCase() == q.toLowerCase() ) {
178 | result = data[i];
179 | break;
180 | }
181 | }
182 | }
183 | if( typeof fn == "function" ) fn(result);
184 | else $input.trigger("result", result && [result.data, result.value]);
185 | }
186 | $.each(trimWords($input.val()), function(i, value) {
187 | request(value, findValueCallback, findValueCallback);
188 | });
189 | }).bind("flushCache", function() {
190 | cache.flush();
191 | }).bind("setOptions", function() {
192 | $.extend(options, arguments[1]);
193 | // if we've updated the data, repopulate
194 | if ( "data" in arguments[1] )
195 | cache.populate();
196 | }).bind("unautocomplete", function() {
197 | select.unbind();
198 | $input.unbind();
199 | $(input.form).unbind(".autocomplete");
200 | });
201 |
202 |
203 | function selectCurrent() {
204 | var selected = select.selected();
205 | if( !selected )
206 | return false;
207 |
208 | var v = selected.result;
209 | previousValue = v;
210 |
211 | if ( options.multiple ) {
212 | var words = trimWords($input.val());
213 | if ( words.length > 1 ) {
214 | var seperator = options.multipleSeparator.length;
215 | var cursorAt = $(input).selection().start;
216 | var wordAt, progress = 0;
217 | $.each(words, function(i, word) {
218 | progress += word.length;
219 | if (cursorAt <= progress) {
220 | wordAt = i;
221 | return false;
222 | }
223 | progress += seperator;
224 | });
225 | words[wordAt] = v;
226 | // TODO this should set the cursor to the right position, but it gets overriden somewhere
227 | //$.Autocompleter.Selection(input, progress + seperator, progress + seperator);
228 | v = words.join( options.multipleSeparator );
229 | }
230 | v += options.multipleSeparator;
231 | }
232 |
233 | $input.val(v);
234 | hideResultsNow();
235 | $input.trigger("result", [selected.data, selected.value]);
236 | return true;
237 | }
238 |
239 | function onChange(crap, skipPrevCheck) {
240 | if( lastKeyPressCode == KEY.DEL ) {
241 | select.hide();
242 | return;
243 | }
244 |
245 | var currentValue = $input.val();
246 |
247 | if ( !skipPrevCheck && currentValue == previousValue )
248 | return;
249 |
250 | previousValue = currentValue;
251 |
252 | currentValue = lastWord(currentValue);
253 | if ( currentValue.length >= options.minChars) {
254 | $input.addClass(options.loadingClass);
255 | if (!options.matchCase)
256 | currentValue = currentValue.toLowerCase();
257 | request(currentValue, receiveData, hideResultsNow);
258 | } else {
259 | stopLoading();
260 | select.hide();
261 | }
262 | };
263 |
264 | function trimWords(value) {
265 | if (!value)
266 | return [""];
267 | if (!options.multiple)
268 | return [$.trim(value)];
269 | return $.map(value.split(options.multipleSeparator), function(word) {
270 | return $.trim(value).length ? $.trim(word) : null;
271 | });
272 | }
273 |
274 | function lastWord(value) {
275 | if ( !options.multiple )
276 | return value;
277 | var words = trimWords(value);
278 | if (words.length == 1)
279 | return words[0];
280 | var cursorAt = $(input).selection().start;
281 | if (cursorAt == value.length) {
282 | words = trimWords(value)
283 | } else {
284 | words = trimWords(value.replace(value.substring(cursorAt), ""));
285 | }
286 | return words[words.length - 1];
287 | }
288 |
289 | // fills in the input box w/the first match (assumed to be the best match)
290 | // q: the term entered
291 | // sValue: the first matching result
292 | function autoFill(q, sValue){
293 | // autofill in the complete box w/the first match as long as the user hasn't entered in more data
294 | // if the last user key pressed was backspace, don't autofill
295 | if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
296 | // fill in the value (keep the case the user has typed)
297 | $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
298 | // select the portion of the value not typed by the user (so the next character will erase)
299 | $(input).selection(previousValue.length, previousValue.length + sValue.length);
300 | }
301 | };
302 |
303 | function hideResults() {
304 | clearTimeout(timeout);
305 | timeout = setTimeout(hideResultsNow, 200);
306 | };
307 |
308 | function hideResultsNow() {
309 | var wasVisible = select.visible();
310 | select.hide();
311 | clearTimeout(timeout);
312 | stopLoading();
313 | if (options.mustMatch) {
314 | // call search and run callback
315 | $input.search(
316 | function (result){
317 | // if no value found, clear the input box
318 | if( !result ) {
319 | if (options.multiple) {
320 | var words = trimWords($input.val()).slice(0, -1);
321 | $input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
322 | }
323 | else {
324 | $input.val( "" );
325 | $input.trigger("result", null);
326 | }
327 | }
328 | }
329 | );
330 | }
331 | };
332 |
333 | function receiveData(q, data) {
334 | if ( data && data.length && hasFocus ) {
335 | stopLoading();
336 | select.display(data, q);
337 | autoFill(q, data[0].value);
338 | select.show();
339 | } else {
340 | hideResultsNow();
341 | }
342 | };
343 |
344 | function request(term, success, failure) {
345 | if (!options.matchCase)
346 | term = term.toLowerCase();
347 | var data = cache.load(term);
348 | // recieve the cached data
349 | if (data && data.length) {
350 | success(term, data);
351 | // if an AJAX url has been supplied, try loading the data now
352 | } else if( (typeof options.url == "string") && (options.url.length > 0) ){
353 |
354 | var extraParams = {
355 | timestamp: +new Date()
356 | };
357 | $.each(options.extraParams, function(key, param) {
358 | extraParams[key] = typeof param == "function" ? param() : param;
359 | });
360 |
361 | $.ajax({
362 | // try to leverage ajaxQueue plugin to abort previous requests
363 | mode: "abort",
364 | // limit abortion to this input
365 | port: "autocomplete" + input.name,
366 | dataType: options.dataType,
367 | url: options.url,
368 | data: $.extend({
369 | q: lastWord(term),
370 | limit: options.max
371 | }, extraParams),
372 | success: function(data) {
373 | var parsed = options.parse && options.parse(data) || parse(data);
374 | cache.add(term, parsed);
375 | success(term, parsed);
376 | }
377 | });
378 | } else {
379 | // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
380 | select.emptyList();
381 | failure(term);
382 | }
383 | };
384 |
385 | function parse(data) {
386 | var parsed = [];
387 | var rows = data.split("\n");
388 | for (var i=0; i < rows.length; i++) {
389 | var row = $.trim(rows[i]);
390 | if (row) {
391 | row = row.split("|");
392 | parsed[parsed.length] = {
393 | data: row,
394 | value: row[0],
395 | result: options.formatResult && options.formatResult(row, row[0]) || row[0]
396 | };
397 | }
398 | }
399 | return parsed;
400 | };
401 |
402 | function stopLoading() {
403 | $input.removeClass(options.loadingClass);
404 | };
405 |
406 | };
407 |
408 | $.Autocompleter.defaults = {
409 | inputClass: "ac_input",
410 | resultsClass: "ac_results",
411 | loadingClass: "ac_loading",
412 | minChars: 1,
413 | delay: 400,
414 | matchCase: false,
415 | matchSubset: true,
416 | matchContains: false,
417 | cacheLength: 10,
418 | max: 100,
419 | mustMatch: false,
420 | extraParams: {},
421 | selectFirst: true,
422 | formatItem: function(row) { return row[0]; },
423 | formatMatch: null,
424 | autoFill: false,
425 | width: 0,
426 | multiple: false,
427 | multipleSeparator: ", ",
428 | highlight: function(value, term) {
429 | return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "$1");
430 | },
431 | scroll: true,
432 | scrollHeight: 180
433 | };
434 |
435 | $.Autocompleter.Cache = function(options) {
436 |
437 | var data = {};
438 | var length = 0;
439 |
440 | function matchSubset(s, sub) {
441 | if (!options.matchCase)
442 | s = s.toLowerCase();
443 | var i = s.indexOf(sub);
444 | if (options.matchContains == "word"){
445 | i = s.toLowerCase().search("\\b" + sub.toLowerCase());
446 | }
447 | if (i == -1) return false;
448 | return i == 0 || options.matchContains;
449 | };
450 |
451 | function add(q, value) {
452 | if (length > options.cacheLength){
453 | flush();
454 | }
455 | if (!data[q]){
456 | length++;
457 | }
458 | data[q] = value;
459 | }
460 |
461 | function populate(){
462 | if( !options.data ) return false;
463 | // track the matches
464 | var stMatchSets = {},
465 | nullData = 0;
466 |
467 | // no url was specified, we need to adjust the cache length to make sure it fits the local data store
468 | if( !options.url ) options.cacheLength = 1;
469 |
470 | // track all options for minChars = 0
471 | stMatchSets[""] = [];
472 |
473 | // loop through the array and create a lookup structure
474 | for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
475 | var rawValue = options.data[i];
476 | // if rawValue is a string, make an array otherwise just reference the array
477 | rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
478 |
479 | var value = options.formatMatch(rawValue, i+1, options.data.length);
480 | if ( value === false )
481 | continue;
482 |
483 | var firstChar = value.charAt(0).toLowerCase();
484 | // if no lookup array for this character exists, look it up now
485 | if( !stMatchSets[firstChar] )
486 | stMatchSets[firstChar] = [];
487 |
488 | // if the match is a string
489 | var row = {
490 | value: value,
491 | data: rawValue,
492 | result: options.formatResult && options.formatResult(rawValue) || value
493 | };
494 |
495 | // push the current match into the set list
496 | stMatchSets[firstChar].push(row);
497 |
498 | // keep track of minChars zero items
499 | if ( nullData++ < options.max ) {
500 | stMatchSets[""].push(row);
501 | }
502 | };
503 |
504 | // add the data items to the cache
505 | $.each(stMatchSets, function(i, value) {
506 | // increase the cache size
507 | options.cacheLength++;
508 | // add to the cache
509 | add(i, value);
510 | });
511 | }
512 |
513 | // populate any existing data
514 | setTimeout(populate, 25);
515 |
516 | function flush(){
517 | data = {};
518 | length = 0;
519 | }
520 |
521 | return {
522 | flush: flush,
523 | add: add,
524 | populate: populate,
525 | load: function(q) {
526 | if (!options.cacheLength || !length)
527 | return null;
528 | /*
529 | * if dealing w/local data and matchContains than we must make sure
530 | * to loop through all the data collections looking for matches
531 | */
532 | if( !options.url && options.matchContains ){
533 | // track all matches
534 | var csub = [];
535 | // loop through all the data grids for matches
536 | for( var k in data ){
537 | // don't search through the stMatchSets[""] (minChars: 0) cache
538 | // this prevents duplicates
539 | if( k.length > 0 ){
540 | var c = data[k];
541 | $.each(c, function(i, x) {
542 | // if we've got a match, add it to the array
543 | if (matchSubset(x.value, q)) {
544 | csub.push(x);
545 | }
546 | });
547 | }
548 | }
549 | return csub;
550 | } else
551 | // if the exact item exists, use it
552 | if (data[q]){
553 | return data[q];
554 | } else
555 | if (options.matchSubset) {
556 | for (var i = q.length - 1; i >= options.minChars; i--) {
557 | var c = data[q.substr(0, i)];
558 | if (c) {
559 | var csub = [];
560 | $.each(c, function(i, x) {
561 | if (matchSubset(x.value, q)) {
562 | csub[csub.length] = x;
563 | }
564 | });
565 | return csub;
566 | }
567 | }
568 | }
569 | return null;
570 | }
571 | };
572 | };
573 |
574 | $.Autocompleter.Select = function (options, input, select, config) {
575 | var CLASSES = {
576 | ACTIVE: "ac_over"
577 | };
578 |
579 | var listItems,
580 | active = -1,
581 | data,
582 | term = "",
583 | needsInit = true,
584 | element,
585 | list;
586 |
587 | // Create results
588 | function init() {
589 | if (!needsInit)
590 | return;
591 | element = $("")
592 | .hide()
593 | .addClass(options.resultsClass)
594 | .css("position", "absolute")
595 | .appendTo(document.body);
596 |
597 | list = $("").appendTo(element).mouseover( function(event) {
598 | if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
599 | active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
600 | $(target(event)).addClass(CLASSES.ACTIVE);
601 | }
602 | }).click(function(event) {
603 | $(target(event)).addClass(CLASSES.ACTIVE);
604 | select();
605 | // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
606 | input.focus();
607 | return false;
608 | }).mousedown(function() {
609 | config.mouseDownOnSelect = true;
610 | }).mouseup(function() {
611 | config.mouseDownOnSelect = false;
612 | });
613 |
614 | if( options.width > 0 )
615 | element.css("width", options.width);
616 |
617 | needsInit = false;
618 | }
619 |
620 | function target(event) {
621 | var element = event.target;
622 | while(element && element.tagName != "LI")
623 | element = element.parentNode;
624 | // more fun with IE, sometimes event.target is empty, just ignore it then
625 | if(!element)
626 | return [];
627 | return element;
628 | }
629 |
630 | function moveSelect(step) {
631 | listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
632 | movePosition(step);
633 | var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
634 | if(options.scroll) {
635 | var offset = 0;
636 | listItems.slice(0, active).each(function() {
637 | offset += this.offsetHeight;
638 | });
639 | if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
640 | list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
641 | } else if(offset < list.scrollTop()) {
642 | list.scrollTop(offset);
643 | }
644 | }
645 | };
646 |
647 | function movePosition(step) {
648 | active += step;
649 | if (active < 0) {
650 | active = listItems.size() - 1;
651 | } else if (active >= listItems.size()) {
652 | active = 0;
653 | }
654 | }
655 |
656 | function limitNumberOfItems(available) {
657 | return options.max && options.max < available
658 | ? options.max
659 | : available;
660 | }
661 |
662 | function fillList() {
663 | list.empty();
664 | var max = limitNumberOfItems(data.length);
665 | for (var i=0; i < max; i++) {
666 | if (!data[i])
667 | continue;
668 | var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
669 | if ( formatted === false )
670 | continue;
671 | var li = $("").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
672 | $.data(li, "ac_data", data[i]);
673 | }
674 | listItems = list.find("li");
675 | if ( options.selectFirst ) {
676 | listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
677 | active = 0;
678 | }
679 | // apply bgiframe if available
680 | if ( $.fn.bgiframe )
681 | list.bgiframe();
682 | }
683 |
684 | return {
685 | display: function(d, q) {
686 | init();
687 | data = d;
688 | term = q;
689 | fillList();
690 | },
691 | next: function() {
692 | moveSelect(1);
693 | },
694 | prev: function() {
695 | moveSelect(-1);
696 | },
697 | pageUp: function() {
698 | if (active != 0 && active - 8 < 0) {
699 | moveSelect( -active );
700 | } else {
701 | moveSelect(-8);
702 | }
703 | },
704 | pageDown: function() {
705 | if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
706 | moveSelect( listItems.size() - 1 - active );
707 | } else {
708 | moveSelect(8);
709 | }
710 | },
711 | hide: function() {
712 | element && element.hide();
713 | listItems && listItems.removeClass(CLASSES.ACTIVE);
714 | active = -1;
715 | },
716 | visible : function() {
717 | return element && element.is(":visible");
718 | },
719 | current: function() {
720 | return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
721 | },
722 | show: function() {
723 | var offset = $(input).offset();
724 | element.css({
725 | width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
726 | top: offset.top + input.offsetHeight,
727 | left: offset.left
728 | }).show();
729 | if(options.scroll) {
730 | list.scrollTop(0);
731 | list.css({
732 | maxHeight: options.scrollHeight,
733 | overflow: 'auto'
734 | });
735 |
736 | if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
737 | var listHeight = 0;
738 | listItems.each(function() {
739 | listHeight += this.offsetHeight;
740 | });
741 | var scrollbarsVisible = listHeight > options.scrollHeight;
742 | list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
743 | if (!scrollbarsVisible) {
744 | // IE doesn't recalculate width when scrollbar disappears
745 | listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
746 | }
747 | }
748 |
749 | }
750 | },
751 | selected: function() {
752 | var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
753 | return selected && selected.length && $.data(selected[0], "ac_data");
754 | },
755 | emptyList: function (){
756 | list && list.empty();
757 | },
758 | unbind: function() {
759 | element && element.remove();
760 | }
761 | };
762 | };
763 |
764 | $.fn.selection = function(start, end) {
765 | if (start !== undefined) {
766 | return this.each(function() {
767 | if( this.createTextRange ){
768 | var selRange = this.createTextRange();
769 | if (end === undefined || start == end) {
770 | selRange.move("character", start);
771 | selRange.select();
772 | } else {
773 | selRange.collapse(true);
774 | selRange.moveStart("character", start);
775 | selRange.moveEnd("character", end);
776 | selRange.select();
777 | }
778 | } else if( this.setSelectionRange ){
779 | this.setSelectionRange(start, end);
780 | } else if( this.selectionStart ){
781 | this.selectionStart = start;
782 | this.selectionEnd = end;
783 | }
784 | });
785 | }
786 | var field = this[0];
787 | if ( field.createTextRange ) {
788 | var range = document.selection.createRange(),
789 | orig = field.value,
790 | teststring = "<->",
791 | textLength = range.text.length;
792 | range.text = teststring;
793 | var caretAt = field.value.indexOf(teststring);
794 | field.value = orig;
795 | this.selection(caretAt, caretAt + textLength);
796 | return {
797 | start: caretAt,
798 | end: caretAt + textLength
799 | }
800 | } else if( field.selectionStart !== undefined ){
801 | return {
802 | start: field.selectionStart,
803 | end: field.selectionEnd
804 | }
805 | }
806 | };
807 |
808 | })(jQuery);
--------------------------------------------------------------------------------
/2011_02_22/demo/localdata.js:
--------------------------------------------------------------------------------
1 | var cities = [
2 | "Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron",
3 | "Albany", "Alexandria", "Alger", "Alledonia", "Alliance", "Alpha", "Alvada",
4 | "Alvordton", "Amanda", "Amelia", "Amesville", "Amherst", "Amlin", "Amsden",
5 | "Amsterdam", "Andover", "Anna", "Ansonia", "Antwerp", "Apple Creek", "Arcadia",
6 | "Arcanum", "Archbold", "Arlington", "Ashland", "Ashley", "Ashtabula", "Ashville",
7 | "Athens", "Attica", "Atwater", "Augusta", "Aurora", "Austinburg", "Ava", "Avon",
8 | "Avon Lake", "Bainbridge", "Bakersville", "Baltic", "Baltimore", "Bannock",
9 | "Barberton", "Barlow", "Barnesville", "Bartlett", "Barton", "Bascom", "Batavia",
10 | "Bath", "Bay Village", "Beach City", "Beachwood", "Beallsville", "Beaver",
11 | "Beaverdam", "Bedford", "Bellaire", "Bellbrook", "Belle Center", "Belle Valley",
12 | "Bellefontaine", "Bellevue", "Bellville", "Belmont", "Belmore", "Beloit", "Belpre",
13 | "Benton Ridge", "Bentonville", "Berea", "Bergholz", "Berkey", "Berlin",
14 | "Berlin Center", "Berlin Heights", "Bethel", "Bethesda", "Bettsville", "Beverly",
15 | "Bidwell", "Big Prairie", "Birmingham", "Blacklick", "Bladensburg", "Blaine",
16 | "Blakeslee", "Blanchester", "Blissfield", "Bloomdale", "Bloomingburg",
17 | "Bloomingdale", "Bloomville", "Blue Creek", "Blue Rock", "Bluffton",
18 | "Bolivar", "Botkins", "Bourneville", "Bowerston", "Bowersville",
19 | "Bowling Green", "Bradford", "Bradner", "Brady Lake", "Brecksville",
20 | "Bremen", "Brewster", "Brice", "Bridgeport", "Brilliant", "Brinkhaven",
21 | "Bristolville", "Broadview Heights", "Broadway", "Brookfield", "Brookpark",
22 | "Brookville", "Brownsville", "Brunswick", "Bryan", "Buchtel", "Buckeye Lake",
23 | "Buckland", "Bucyrus", "Buffalo", "Buford", "Burbank", "Burghill", "Burgoon",
24 | "Burkettsville", "Burton", "Butler", "Byesville", "Cable", "Cadiz", "Cairo",
25 | "Caldwell", "Caledonia", "Cambridge", "Camden", "Cameron", "Camp Dennison",
26 | "Campbell", "Canal Fulton", "Canal Winchester", "Canfield", "Canton", "Carbon Hill",
27 | "Carbondale", "Cardington", "Carey", "Carroll", "Carrollton", "Casstown",
28 | "Castalia", "Catawba", "Cecil", "Cedarville", "Celina", "Centerburg",
29 | "Chagrin Falls", "Chandlersville", "Chardon", "Charm", "Chatfield", "Chauncey",
30 | "Cherry Fork", "Chesapeake", "Cheshire", "Chester", "Chesterhill", "Chesterland",
31 | "Chesterville", "Chickasaw", "Chillicothe", "Chilo", "Chippewa Lake",
32 | "Christiansburg", "Cincinnati", "Circleville", "Clarington", "Clarksburg",
33 | "Clarksville", "Clay Center", "Clayton", "Cleveland", "Cleves", "Clifton",
34 | "Clinton", "Cloverdale", "Clyde", "Coal Run", "Coalton", "Coldwater", "Colerain",
35 | "College Corner", "Collins", "Collinsville", "Colton", "Columbia Station",
36 | "Columbiana", "Columbus", "Columbus Grove", "Commercial Point", "Conesville",
37 | "Conneaut", "Conover", "Continental", "Convoy", "Coolville", "Corning", "Cortland",
38 | "Coshocton", "Covington", "Creola", "Crestline", "Creston", "Crooksville",
39 | "Croton", "Crown City", "Cuba", "Cumberland", "Curtice", "Custar", "Cutler",
40 | "Cuyahoga Falls", "Cygnet", "Cynthiana", "Dalton", "Damascus", "Danville",
41 | "Dayton", "De Graff", "Decatur", "Deerfield", "Deersville", "Defiance",
42 | "Delaware", "Dellroy", "Delphos", "Delta", "Dennison", "Derby", "Derwent",
43 | "Deshler", "Dexter City", "Diamond", "Dillonvale", "Dola", "Donnelsville",
44 | "Dorset", "Dover", "Doylestown", "Dresden", "Dublin", "Dunbridge", "Duncan Falls",
45 | "Dundee", "Dunkirk", "Dupont", "East Claridon", "East Fultonham",
46 | "East Liberty", "East Liverpool", "East Palestine", "East Rochester",
47 | "East Sparta", "East Springfield", "Eastlake", "Eaton", "Edgerton", "Edison",
48 | "Edon", "Eldorado", "Elgin", "Elkton", "Ellsworth", "Elmore", "Elyria",
49 | "Empire", "Englewood", "Enon", "Etna", "Euclid", "Evansport", "Fairborn",
50 | "Fairfield", "Fairpoint", "Fairview", "Farmdale", "Farmer", "Farmersville",
51 | "Fayette", "Fayetteville", "Feesburg", "Felicity", "Findlay", "Flat Rock",
52 | "Fleming", "Fletcher", "Flushing", "Forest", "Fort Jennings", "Fort Loramie",
53 | "Fort Recovery", "Fostoria", "Fowler", "Frankfort", "Franklin",
54 | "Franklin Furnace", "Frazeysburg", "Fredericksburg", "Fredericktown",
55 | "Freeport", "Fremont", "Fresno", "Friendship", "Fulton", "Fultonham",
56 | "Galena", "Galion", "Gallipolis", "Galloway", "Gambier", "Garrettsville",
57 | "Gates Mills", "Geneva", "Genoa", "Georgetown", "Germantown", "Gettysburg",
58 | "Gibsonburg", "Girard", "Glandorf", "Glencoe", "Glenford", "Glenmont",
59 | "Glouster", "Gnadenhutten", "Gomer", "Goshen", "Grafton", "Grand Rapids",
60 | "Grand River", "Granville", "Gratiot", "Gratis", "Graysville", "Graytown",
61 | "Green", "Green Camp", "Green Springs", "Greenfield", "Greenford",
62 | "Greentown", "Greenville", "Greenwich", "Grelton", "Grove City",
63 | "Groveport", "Grover Hill", "Guysville", "Gypsum", "Hallsville",
64 | "Hamden", "Hamersville", "Hamilton", "Hamler", "Hammondsville",
65 | "Hannibal", "Hanoverton", "Harbor View", "Harlem Springs", "Harpster",
66 | "Harrisburg", "Harrison", "Harrisville", "Harrod", "Hartford", "Hartville",
67 | "Harveysburg", "Haskins", "Haverhill", "Haviland", "Haydenville", "Hayesville",
68 | "Heath", "Hebron", "Helena", "Hicksville", "Higginsport", "Highland", "Hilliard",
69 | "Hillsboro", "Hinckley", "Hiram", "Hockingport", "Holgate", "Holland",
70 | "Hollansburg", "Holloway", "Holmesville", "Homer", "Homerville", "Homeworth",
71 | "Hooven", "Hopedale", "Hopewell", "Houston", "Howard", "Hoytville", "Hubbard",
72 | "Hudson", "Huntsburg", "Huntsville", "Huron", "Iberia", "Independence",
73 | "Irondale", "Ironton", "Irwin", "Isle Saint George", "Jackson", "Jackson Center",
74 | "Jacksontown", "Jacksonville", "Jacobsburg", "Jamestown", "Jasper",
75 | "Jefferson", "Jeffersonville", "Jenera", "Jeromesville", "Jerry City",
76 | "Jerusalem", "Jewell", "Jewett", "Johnstown", "Junction City", "Kalida",
77 | "Kansas", "Keene", "Kelleys Island", "Kensington", "Kent", "Kenton",
78 | "Kerr", "Kettlersville", "Kidron", "Kilbourne", "Killbuck", "Kimbolton",
79 | "Kings Mills", "Kingston", "Kingsville", "Kinsman", "Kipling", "Kipton",
80 | "Kirby", "Kirkersville", "Kitts Hill", "Kunkle", "La Rue", "Lacarne",
81 | "Lafayette", "Lafferty", "Lagrange", "Laings", "Lake Milton", "Lakemore",
82 | "Lakeside Marblehead", "Lakeview", "Lakeville", "Lakewood", "Lancaster",
83 | "Langsville", "Lansing", "Latham", "Latty", "Laura", "Laurelville",
84 | "Leavittsburg", "Lebanon", "Lees Creek", "Leesburg", "Leesville",
85 | "Leetonia", "Leipsic", "Lemoyne", "Lewis Center", "Lewisburg",
86 | "Lewistown", "Lewisville", "Liberty Center", "Lima", "Limaville",
87 | "Lindsey", "Lisbon", "Litchfield", "Lithopolis", "Little Hocking",
88 | "Lockbourne", "Lodi", "Logan", "London", "Londonderry",
89 | "Long Bottom", "Lorain", "Lore City", "Loudonville", "Louisville",
90 | "Loveland", "Lowell", "Lowellville", "Lower Salem", "Lucas",
91 | "Lucasville", "Luckey", "Ludlow Falls", "Lynchburg", "Lynx",
92 | "Lyons", "Macedonia", "Macksburg", "Madison", "Magnetic Springs",
93 | "Magnolia", "Maineville", "Malaga", "Malinta", "Malta", "Malvern",
94 | "Manchester", "Mansfield", "Mantua", "Maple Heights", "Maplewood",
95 | "Marathon", "Marengo", "Maria Stein", "Marietta", "Marion",
96 | "Mark Center", "Marshallville", "Martel", "Martin", "Martins Ferry",
97 | "Martinsburg", "Martinsville", "Marysville", "Mason", "Massillon",
98 | "Masury", "Maumee", "Maximo", "Maynard", "Mc Arthur", "Mc Clure",
99 | "Mc Comb", "Mc Connelsville", "Mc Cutchenville", "Mc Dermott",
100 | "Mc Donald", "Mc Guffey", "Mechanicsburg", "Mechanicstown",
101 | "Medina", "Medway", "Melmore", "Melrose", "Mendon", "Mentor",
102 | "Mesopotamia", "Metamora", "Miamisburg", "Miamitown", "Miamiville",
103 | "Middle Bass", "Middle Point", "Middlebranch", "Middleburg",
104 | "Middlefield", "Middleport", "Middletown", "Midland", "Midvale",
105 | "Milan", "Milford", "Milford Center", "Millbury", "Milledgeville",
106 | "Miller City", "Millersburg", "Millersport", "Millfield",
107 | "Milton Center", "Mineral City", "Mineral Ridge", "Minerva",
108 | "Minford", "Mingo", "Mingo Junction", "Minster", "Mogadore",
109 | "Monclova", "Monroe", "Monroeville", "Montezuma", "Montpelier",
110 | "Montville", "Morral", "Morristown", "Morrow", "Moscow",
111 | "Mount Blanchard", "Mount Cory", "Mount Eaton", "Mount Gilead",
112 | "Mount Hope", "Mount Liberty", "Mount Orab", "Mount Perry",
113 | "Mount Pleasant", "Mount Saint Joseph", "Mount Sterling",
114 | "Mount Vernon", "Mount Victory", "Mowrystown", "Moxahala",
115 | "Munroe Falls", "Murray City", "Nankin", "Napoleon", "Nashport",
116 | "Nashville", "Navarre", "Neapolis", "Neffs", "Negley",
117 | "Nelsonville", "Nevada", "Neville", "New Albany", "New Athens",
118 | "New Bavaria", "New Bloomington", "New Bremen", "New Carlisle",
119 | "New Concord", "New Hampshire", "New Haven", "New Holland",
120 | "New Knoxville", "New Lebanon", "New Lexington", "New London",
121 | "New Madison", "New Marshfield", "New Matamoras", "New Middletown",
122 | "New Paris", "New Philadelphia", "New Plymouth", "New Richmond",
123 | "New Riegel", "New Rumley", "New Springfield", "New Straitsville",
124 | "New Vienna", "New Washington", "New Waterford", "New Weston",
125 | "Newark", "Newbury", "Newcomerstown", "Newport", "Newton Falls",
126 | "Newtonsville", "Ney", "Niles", "North Baltimore", "North Bend",
127 | "North Benton", "North Bloomfield", "North Fairfield",
128 | "North Georgetown", "North Hampton", "North Jackson",
129 | "North Kingsville", "North Lawrence", "North Lewisburg",
130 | "North Lima", "North Olmsted", "North Ridgeville", "North Robinson",
131 | "North Royalton", "North Star", "Northfield", "Northwood", "Norwalk",
132 | "Norwich", "Nova", "Novelty", "Oak Harbor", "Oak Hill", "Oakwood",
133 | "Oberlin", "Oceola", "Ohio City", "Okeana", "Okolona", "Old Fort",
134 | "Old Washington", "Olmsted Falls", "Ontario", "Orangeville",
135 | "Oregon", "Oregonia", "Orient", "Orrville", "Orwell", "Osgood",
136 | "Ostrander", "Ottawa", "Ottoville", "Otway", "Overpeck",
137 | "Owensville", "Oxford", "Painesville", "Palestine", "Pandora",
138 | "Paris", "Parkman", "Pataskala", "Patriot", "Paulding", "Payne",
139 | "Pedro", "Peebles", "Pemberton", "Pemberville", "Peninsula",
140 | "Perry", "Perrysburg", "Perrysville", "Petersburg", "Pettisville",
141 | "Phillipsburg", "Philo", "Pickerington", "Piedmont", "Pierpont",
142 | "Piketon", "Piney Fork", "Pioneer", "Piqua", "Pitsburg",
143 | "Plain City", "Plainfield", "Pleasant City", "Pleasant Hill",
144 | "Pleasant Plain", "Pleasantville", "Plymouth", "Polk",
145 | "Pomeroy", "Port Clinton", "Port Jefferson", "Port Washington",
146 | "Port William", "Portage", "Portland", "Portsmouth", "Potsdam",
147 | "Powell", "Powhatan Point", "Proctorville", "Prospect", "Put in Bay",
148 | "Quaker City", "Quincy", "Racine", "Radnor", "Randolph", "Rarden",
149 | "Ravenna", "Rawson", "Ray", "Rayland", "Raymond", "Reedsville",
150 | "Reesville", "Reno", "Republic", "Reynoldsburg", "Richfield",
151 | "Richmond", "Richmond Dale", "Richwood", "Ridgeville Corners",
152 | "Ridgeway", "Rio Grande", "Ripley", "Risingsun", "Rittman",
153 | "Robertsville", "Rock Camp", "Rock Creek", "Rockbridge", "Rockford",
154 | "Rocky Ridge", "Rocky River", "Rogers", "Rome", "Rootstown", "Roseville",
155 | "Rosewood", "Ross", "Rossburg", "Rossford", "Roundhead", "Rudolph",
156 | "Rushsylvania", "Rushville", "Russells Point", "Russellville", "Russia",
157 | "Rutland", "Sabina", "Saint Clairsville", "Saint Henry", "Saint Johns",
158 | "Saint Louisville", "Saint Marys", "Saint Paris", "Salem", "Salesville",
159 | "Salineville", "Sandusky", "Sandyville", "Sarahsville", "Sardinia",
160 | "Sardis", "Savannah", "Scio", "Scioto Furnace", "Scott", "Scottown",
161 | "Seaman", "Sebring", "Sedalia", "Senecaville", "Seven Mile", "Seville",
162 | "Shade", "Shadyside", "Shandon", "Sharon Center", "Sharpsburg",
163 | "Shauck", "Shawnee", "Sheffield Lake", "Shelby", "Sherrodsville",
164 | "Sherwood", "Shiloh", "Short Creek", "Shreve", "Sidney", "Sinking Spring",
165 | "Smithfield", "Smithville", "Solon", "Somerdale", "Somerset",
166 | "Somerville", "South Bloomingville", "South Charleston", "South Lebanon",
167 | "South Point", "South Salem", "South Solon", "South Vienna",
168 | "South Webster", "Southington", "Sparta", "Spencer", "Spencerville",
169 | "Spring Valley", "Springboro", "Springfield", "Stafford", "Sterling",
170 | "Steubenville", "Stewart", "Stillwater", "Stockdale", "Stockport",
171 | "Stone Creek", "Stony Ridge", "Stout", "Stoutsville", "Stow", "Strasburg",
172 | "Stratton", "Streetsboro", "Strongsville", "Struthers", "Stryker",
173 | "Sugar Grove", "Sugarcreek", "Sullivan", "Sulphur Springs", "Summerfield",
174 | "Summit Station", "Summitville", "Sunbury", "Swanton", "Sycamore",
175 | "Sycamore Valley", "Sylvania", "Syracuse", "Tallmadge", "Tarlton",
176 | "Terrace Park", "The Plains", "Thompson", "Thornville", "Thurman",
177 | "Thurston", "Tiffin", "Tiltonsville", "Tipp City", "Tippecanoe", "Tiro",
178 | "Toledo", "Tontogany", "Torch", "Toronto", "Tremont City", "Trenton",
179 | "Trimble", "Trinway", "Troy", "Tuppers Plains", "Tuscarawas", "Twinsburg",
180 | "Uhrichsville", "Union City", "Union Furnace", "Unionport", "Uniontown",
181 | "Unionville", "Unionville Center", "Uniopolis", "Upper Sandusky", "Urbana",
182 | "Utica", "Valley City", "Van Buren", "Van Wert", "Vandalia", "Vanlue",
183 | "Vaughnsville", "Venedocia", "Vermilion", "Verona", "Versailles",
184 | "Vickery", "Vienna", "Vincent", "Vinton", "Wadsworth", "Wakefield",
185 | "Wakeman", "Walbridge", "Waldo", "Walhonding", "Walnut Creek", "Wapakoneta",
186 | "Warnock", "Warren", "Warsaw", "Washington Court House",
187 | "Washingtonville", "Waterford", "Waterloo", "Watertown", "Waterville",
188 | "Wauseon", "Waverly", "Wayland", "Wayne", "Waynesburg", "Waynesfield",
189 | "Waynesville", "Wellington", "Wellston", "Wellsville", "West Alexandria",
190 | "West Chester", "West Elkton", "West Farmington", "West Jefferson",
191 | "West Lafayette", "West Liberty", "West Manchester", "West Mansfield",
192 | "West Millgrove", "West Milton", "West Point", "West Portsmouth",
193 | "West Rushville", "West Salem", "West Union", "West Unity", "Westerville",
194 | "Westfield Center", "Westlake", "Weston", "Westville", "Wharton",
195 | "Wheelersburg", "Whipple", "White Cottage", "Whitehouse", "Wickliffe",
196 | "Wilberforce", "Wilkesville", "Willard", "Williamsburg", "Williamsfield",
197 | "Williamsport", "Williamstown", "Williston", "Willoughby", "Willow Wood",
198 | "Willshire", "Wilmington", "Wilmot", "Winchester", "Windham", "Windsor",
199 | "Winesburg", "Wingett Run", "Winona", "Wolf Run", "Woodsfield",
200 | "Woodstock", "Woodville", "Wooster", "Wren", "Xenia", "Yellow Springs",
201 | "Yorkshire", "Yorkville", "Youngstown", "Zaleski", "Zanesfield", "Zanesville",
202 | "Zoar"
203 | ];
--------------------------------------------------------------------------------
/2011_02_22/demo/main.css:
--------------------------------------------------------------------------------
1 | body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0}
2 | table{border-collapse:collapse;border-spacing:0}
3 | fieldset,img{border:0}
4 | address,caption,cite,code,dfn,th,var{font-style:normal;font-weight:normal}
5 | ol,ul{list-style:none}
6 | caption,th{text-align:left}
7 | h1,h2,h3,h4,h5,h6{font-size:100%;font-style:normal;font-weight:normal}
8 | q:before,q:after{content:''}
9 | body{font:13px arial,helvetica,clean,sans-serif;font-size:small;}
10 | select,input,textarea{font:99% arial,helvetica,clean,sans-serif}
11 | pre,code{font:115% monospace;font-size:100%}
12 | body * {line-height:1.22em}
13 | body {
14 | color: #202020;
15 | }
16 |
17 | h1 {
18 | color: #fff;
19 | background: #06b;
20 | padding: 10px;
21 | font-size: 200%;
22 | }
23 |
24 | h2 {
25 | color: #000;
26 | font-size: 150%;
27 | padding: 10px 0;
28 | }
29 |
30 | h3 {
31 | color: #000;
32 | font-size: 120%;
33 | padding: 10px 0;
34 | }
35 |
36 | ul {
37 | list-style: disc inside;
38 | margin-left: 1em;
39 | }
40 |
41 | #content {
42 | padding: 10px;
43 | }
44 |
45 | label {
46 | float: left;
47 | width: 12em;
48 | }
49 | input[type=text] { width: 15em; }
50 |
51 | #banner { padding: 15px; background-color: #06b; color: white; font-size: large; border-bottom: 1px solid #ccc;
52 | background: url(bg.gif) repeat-x; text-align: center }
53 | #banner a { color: white; }
--------------------------------------------------------------------------------
/2011_02_22/tests/SpecRunner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Jasmine Test Runner
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/2011_02_22/tests/fixtures/localdata.js:
--------------------------------------------------------------------------------
1 | var cities = [
2 | "Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron",
3 | "Albany", "Alexandria", "Alger", "Alledonia", "Alliance", "Alpha", "Alvada",
4 | "Alvordton", "Amanda", "Amelia", "Amesville", "Amherst", "Amlin", "Amsden",
5 | "Amsterdam", "Andover", "Anna", "Ansonia", "Antwerp", "Apple Creek", "Arcadia",
6 | "Arcanum", "Archbold", "Arlington", "Ashland", "Ashley", "Ashtabula", "Ashville",
7 | "Athens", "Attica", "Atwater", "Augusta", "Aurora", "Austinburg", "Ava", "Avon",
8 | "Avon Lake", "Bainbridge", "Bakersville", "Baltic", "Baltimore", "Bannock",
9 | "Barberton", "Barlow", "Barnesville", "Bartlett", "Barton", "Bascom", "Batavia",
10 | "Bath", "Bay Village", "Beach City", "Beachwood", "Beallsville", "Beaver",
11 | "Beaverdam", "Bedford", "Bellaire", "Bellbrook", "Belle Center", "Belle Valley",
12 | "Bellefontaine", "Bellevue", "Bellville", "Belmont", "Belmore", "Beloit", "Belpre",
13 | "Benton Ridge", "Bentonville", "Berea", "Bergholz", "Berkey", "Berlin",
14 | "Berlin Center", "Berlin Heights", "Bethel", "Bethesda", "Bettsville", "Beverly",
15 | "Bidwell", "Big Prairie", "Birmingham", "Blacklick", "Bladensburg", "Blaine",
16 | "Blakeslee", "Blanchester", "Blissfield", "Bloomdale", "Bloomingburg",
17 | "Bloomingdale", "Bloomville", "Blue Creek", "Blue Rock", "Bluffton",
18 | "Bolivar", "Botkins", "Bourneville", "Bowerston", "Bowersville",
19 | "Bowling Green", "Bradford", "Bradner", "Brady Lake", "Brecksville",
20 | "Bremen", "Brewster", "Brice", "Bridgeport", "Brilliant", "Brinkhaven",
21 | "Bristolville", "Broadview Heights", "Broadway", "Brookfield", "Brookpark",
22 | "Brookville", "Brownsville", "Brunswick", "Bryan", "Buchtel", "Buckeye Lake",
23 | "Buckland", "Bucyrus", "Buffalo", "Buford", "Burbank", "Burghill", "Burgoon",
24 | "Burkettsville", "Burton", "Butler", "Byesville", "Cable", "Cadiz", "Cairo",
25 | "Caldwell", "Caledonia", "Cambridge", "Camden", "Cameron", "Camp Dennison",
26 | "Campbell", "Canal Fulton", "Canal Winchester", "Canfield", "Canton", "Carbon Hill",
27 | "Carbondale", "Cardington", "Carey", "Carroll", "Carrollton", "Casstown",
28 | "Castalia", "Catawba", "Cecil", "Cedarville", "Celina", "Centerburg",
29 | "Chagrin Falls", "Chandlersville", "Chardon", "Charm", "Chatfield", "Chauncey",
30 | "Cherry Fork", "Chesapeake", "Cheshire", "Chester", "Chesterhill", "Chesterland",
31 | "Chesterville", "Chickasaw", "Chillicothe", "Chilo", "Chippewa Lake",
32 | "Christiansburg", "Cincinnati", "Circleville", "Clarington", "Clarksburg",
33 | "Clarksville", "Clay Center", "Clayton", "Cleveland", "Cleves", "Clifton",
34 | "Clinton", "Cloverdale", "Clyde", "Coal Run", "Coalton", "Coldwater", "Colerain",
35 | "College Corner", "Collins", "Collinsville", "Colton", "Columbia Station",
36 | "Columbiana", "Columbus", "Columbus Grove", "Commercial Point", "Conesville",
37 | "Conneaut", "Conover", "Continental", "Convoy", "Coolville", "Corning", "Cortland",
38 | "Coshocton", "Covington", "Creola", "Crestline", "Creston", "Crooksville",
39 | "Croton", "Crown City", "Cuba", "Cumberland", "Curtice", "Custar", "Cutler",
40 | "Cuyahoga Falls", "Cygnet", "Cynthiana", "Dalton", "Damascus", "Danville",
41 | "Dayton", "De Graff", "Decatur", "Deerfield", "Deersville", "Defiance",
42 | "Delaware", "Dellroy", "Delphos", "Delta", "Dennison", "Derby", "Derwent",
43 | "Deshler", "Dexter City", "Diamond", "Dillonvale", "Dola", "Donnelsville",
44 | "Dorset", "Dover", "Doylestown", "Dresden", "Dublin", "Dunbridge", "Duncan Falls",
45 | "Dundee", "Dunkirk", "Dupont", "East Claridon", "East Fultonham",
46 | "East Liberty", "East Liverpool", "East Palestine", "East Rochester",
47 | "East Sparta", "East Springfield", "Eastlake", "Eaton", "Edgerton", "Edison",
48 | "Edon", "Eldorado", "Elgin", "Elkton", "Ellsworth", "Elmore", "Elyria",
49 | "Empire", "Englewood", "Enon", "Etna", "Euclid", "Evansport", "Fairborn",
50 | "Fairfield", "Fairpoint", "Fairview", "Farmdale", "Farmer", "Farmersville",
51 | "Fayette", "Fayetteville", "Feesburg", "Felicity", "Findlay", "Flat Rock",
52 | "Fleming", "Fletcher", "Flushing", "Forest", "Fort Jennings", "Fort Loramie",
53 | "Fort Recovery", "Fostoria", "Fowler", "Frankfort", "Franklin",
54 | "Franklin Furnace", "Frazeysburg", "Fredericksburg", "Fredericktown",
55 | "Freeport", "Fremont", "Fresno", "Friendship", "Fulton", "Fultonham",
56 | "Galena", "Galion", "Gallipolis", "Galloway", "Gambier", "Garrettsville",
57 | "Gates Mills", "Geneva", "Genoa", "Georgetown", "Germantown", "Gettysburg",
58 | "Gibsonburg", "Girard", "Glandorf", "Glencoe", "Glenford", "Glenmont",
59 | "Glouster", "Gnadenhutten", "Gomer", "Goshen", "Grafton", "Grand Rapids",
60 | "Grand River", "Granville", "Gratiot", "Gratis", "Graysville", "Graytown",
61 | "Green", "Green Camp", "Green Springs", "Greenfield", "Greenford",
62 | "Greentown", "Greenville", "Greenwich", "Grelton", "Grove City",
63 | "Groveport", "Grover Hill", "Guysville", "Gypsum", "Hallsville",
64 | "Hamden", "Hamersville", "Hamilton", "Hamler", "Hammondsville",
65 | "Hannibal", "Hanoverton", "Harbor View", "Harlem Springs", "Harpster",
66 | "Harrisburg", "Harrison", "Harrisville", "Harrod", "Hartford", "Hartville",
67 | "Harveysburg", "Haskins", "Haverhill", "Haviland", "Haydenville", "Hayesville",
68 | "Heath", "Hebron", "Helena", "Hicksville", "Higginsport", "Highland", "Hilliard",
69 | "Hillsboro", "Hinckley", "Hiram", "Hockingport", "Holgate", "Holland",
70 | "Hollansburg", "Holloway", "Holmesville", "Homer", "Homerville", "Homeworth",
71 | "Hooven", "Hopedale", "Hopewell", "Houston", "Howard", "Hoytville", "Hubbard",
72 | "Hudson", "Huntsburg", "Huntsville", "Huron", "Iberia", "Independence",
73 | "Irondale", "Ironton", "Irwin", "Isle Saint George", "Jackson", "Jackson Center",
74 | "Jacksontown", "Jacksonville", "Jacobsburg", "Jamestown", "Jasper",
75 | "Jefferson", "Jeffersonville", "Jenera", "Jeromesville", "Jerry City",
76 | "Jerusalem", "Jewell", "Jewett", "Johnstown", "Junction City", "Kalida",
77 | "Kansas", "Keene", "Kelleys Island", "Kensington", "Kent", "Kenton",
78 | "Kerr", "Kettlersville", "Kidron", "Kilbourne", "Killbuck", "Kimbolton",
79 | "Kings Mills", "Kingston", "Kingsville", "Kinsman", "Kipling", "Kipton",
80 | "Kirby", "Kirkersville", "Kitts Hill", "Kunkle", "La Rue", "Lacarne",
81 | "Lafayette", "Lafferty", "Lagrange", "Laings", "Lake Milton", "Lakemore",
82 | "Lakeside Marblehead", "Lakeview", "Lakeville", "Lakewood", "Lancaster",
83 | "Langsville", "Lansing", "Latham", "Latty", "Laura", "Laurelville",
84 | "Leavittsburg", "Lebanon", "Lees Creek", "Leesburg", "Leesville",
85 | "Leetonia", "Leipsic", "Lemoyne", "Lewis Center", "Lewisburg",
86 | "Lewistown", "Lewisville", "Liberty Center", "Lima", "Limaville",
87 | "Lindsey", "Lisbon", "Litchfield", "Lithopolis", "Little Hocking",
88 | "Lockbourne", "Lodi", "Logan", "London", "Londonderry",
89 | "Long Bottom", "Lorain", "Lore City", "Loudonville", "Louisville",
90 | "Loveland", "Lowell", "Lowellville", "Lower Salem", "Lucas",
91 | "Lucasville", "Luckey", "Ludlow Falls", "Lynchburg", "Lynx",
92 | "Lyons", "Macedonia", "Macksburg", "Madison", "Magnetic Springs",
93 | "Magnolia", "Maineville", "Malaga", "Malinta", "Malta", "Malvern",
94 | "Manchester", "Mansfield", "Mantua", "Maple Heights", "Maplewood",
95 | "Marathon", "Marengo", "Maria Stein", "Marietta", "Marion",
96 | "Mark Center", "Marshallville", "Martel", "Martin", "Martins Ferry",
97 | "Martinsburg", "Martinsville", "Marysville", "Mason", "Massillon",
98 | "Masury", "Maumee", "Maximo", "Maynard", "Mc Arthur", "Mc Clure",
99 | "Mc Comb", "Mc Connelsville", "Mc Cutchenville", "Mc Dermott",
100 | "Mc Donald", "Mc Guffey", "Mechanicsburg", "Mechanicstown",
101 | "Medina", "Medway", "Melmore", "Melrose", "Mendon", "Mentor",
102 | "Mesopotamia", "Metamora", "Miamisburg", "Miamitown", "Miamiville",
103 | "Middle Bass", "Middle Point", "Middlebranch", "Middleburg",
104 | "Middlefield", "Middleport", "Middletown", "Midland", "Midvale",
105 | "Milan", "Milford", "Milford Center", "Millbury", "Milledgeville",
106 | "Miller City", "Millersburg", "Millersport", "Millfield",
107 | "Milton Center", "Mineral City", "Mineral Ridge", "Minerva",
108 | "Minford", "Mingo", "Mingo Junction", "Minster", "Mogadore",
109 | "Monclova", "Monroe", "Monroeville", "Montezuma", "Montpelier",
110 | "Montville", "Morral", "Morristown", "Morrow", "Moscow",
111 | "Mount Blanchard", "Mount Cory", "Mount Eaton", "Mount Gilead",
112 | "Mount Hope", "Mount Liberty", "Mount Orab", "Mount Perry",
113 | "Mount Pleasant", "Mount Saint Joseph", "Mount Sterling",
114 | "Mount Vernon", "Mount Victory", "Mowrystown", "Moxahala",
115 | "Munroe Falls", "Murray City", "Nankin", "Napoleon", "Nashport",
116 | "Nashville", "Navarre", "Neapolis", "Neffs", "Negley",
117 | "Nelsonville", "Nevada", "Neville", "New Albany", "New Athens",
118 | "New Bavaria", "New Bloomington", "New Bremen", "New Carlisle",
119 | "New Concord", "New Hampshire", "New Haven", "New Holland",
120 | "New Knoxville", "New Lebanon", "New Lexington", "New London",
121 | "New Madison", "New Marshfield", "New Matamoras", "New Middletown",
122 | "New Paris", "New Philadelphia", "New Plymouth", "New Richmond",
123 | "New Riegel", "New Rumley", "New Springfield", "New Straitsville",
124 | "New Vienna", "New Washington", "New Waterford", "New Weston",
125 | "Newark", "Newbury", "Newcomerstown", "Newport", "Newton Falls",
126 | "Newtonsville", "Ney", "Niles", "North Baltimore", "North Bend",
127 | "North Benton", "North Bloomfield", "North Fairfield",
128 | "North Georgetown", "North Hampton", "North Jackson",
129 | "North Kingsville", "North Lawrence", "North Lewisburg",
130 | "North Lima", "North Olmsted", "North Ridgeville", "North Robinson",
131 | "North Royalton", "North Star", "Northfield", "Northwood", "Norwalk",
132 | "Norwich", "Nova", "Novelty", "Oak Harbor", "Oak Hill", "Oakwood",
133 | "Oberlin", "Oceola", "Ohio City", "Okeana", "Okolona", "Old Fort",
134 | "Old Washington", "Olmsted Falls", "Ontario", "Orangeville",
135 | "Oregon", "Oregonia", "Orient", "Orrville", "Orwell", "Osgood",
136 | "Ostrander", "Ottawa", "Ottoville", "Otway", "Overpeck",
137 | "Owensville", "Oxford", "Painesville", "Palestine", "Pandora",
138 | "Paris", "Parkman", "Pataskala", "Patriot", "Paulding", "Payne",
139 | "Pedro", "Peebles", "Pemberton", "Pemberville", "Peninsula",
140 | "Perry", "Perrysburg", "Perrysville", "Petersburg", "Pettisville",
141 | "Phillipsburg", "Philo", "Pickerington", "Piedmont", "Pierpont",
142 | "Piketon", "Piney Fork", "Pioneer", "Piqua", "Pitsburg",
143 | "Plain City", "Plainfield", "Pleasant City", "Pleasant Hill",
144 | "Pleasant Plain", "Pleasantville", "Plymouth", "Polk",
145 | "Pomeroy", "Port Clinton", "Port Jefferson", "Port Washington",
146 | "Port William", "Portage", "Portland", "Portsmouth", "Potsdam",
147 | "Powell", "Powhatan Point", "Proctorville", "Prospect", "Put in Bay",
148 | "Quaker City", "Quincy", "Racine", "Radnor", "Randolph", "Rarden",
149 | "Ravenna", "Rawson", "Ray", "Rayland", "Raymond", "Reedsville",
150 | "Reesville", "Reno", "Republic", "Reynoldsburg", "Richfield",
151 | "Richmond", "Richmond Dale", "Richwood", "Ridgeville Corners",
152 | "Ridgeway", "Rio Grande", "Ripley", "Risingsun", "Rittman",
153 | "Robertsville", "Rock Camp", "Rock Creek", "Rockbridge", "Rockford",
154 | "Rocky Ridge", "Rocky River", "Rogers", "Rome", "Rootstown", "Roseville",
155 | "Rosewood", "Ross", "Rossburg", "Rossford", "Roundhead", "Rudolph",
156 | "Rushsylvania", "Rushville", "Russells Point", "Russellville", "Russia",
157 | "Rutland", "Sabina", "Saint Clairsville", "Saint Henry", "Saint Johns",
158 | "Saint Louisville", "Saint Marys", "Saint Paris", "Salem", "Salesville",
159 | "Salineville", "Sandusky", "Sandyville", "Sarahsville", "Sardinia",
160 | "Sardis", "Savannah", "Scio", "Scioto Furnace", "Scott", "Scottown",
161 | "Seaman", "Sebring", "Sedalia", "Senecaville", "Seven Mile", "Seville",
162 | "Shade", "Shadyside", "Shandon", "Sharon Center", "Sharpsburg",
163 | "Shauck", "Shawnee", "Sheffield Lake", "Shelby", "Sherrodsville",
164 | "Sherwood", "Shiloh", "Short Creek", "Shreve", "Sidney", "Sinking Spring",
165 | "Smithfield", "Smithville", "Solon", "Somerdale", "Somerset",
166 | "Somerville", "South Bloomingville", "South Charleston", "South Lebanon",
167 | "South Point", "South Salem", "South Solon", "South Vienna",
168 | "South Webster", "Southington", "Sparta", "Spencer", "Spencerville",
169 | "Spring Valley", "Springboro", "Springfield", "Stafford", "Sterling",
170 | "Steubenville", "Stewart", "Stillwater", "Stockdale", "Stockport",
171 | "Stone Creek", "Stony Ridge", "Stout", "Stoutsville", "Stow", "Strasburg",
172 | "Stratton", "Streetsboro", "Strongsville", "Struthers", "Stryker",
173 | "Sugar Grove", "Sugarcreek", "Sullivan", "Sulphur Springs", "Summerfield",
174 | "Summit Station", "Summitville", "Sunbury", "Swanton", "Sycamore",
175 | "Sycamore Valley", "Sylvania", "Syracuse", "Tallmadge", "Tarlton",
176 | "Terrace Park", "The Plains", "Thompson", "Thornville", "Thurman",
177 | "Thurston", "Tiffin", "Tiltonsville", "Tipp City", "Tippecanoe", "Tiro",
178 | "Toledo", "Tontogany", "Torch", "Toronto", "Tremont City", "Trenton",
179 | "Trimble", "Trinway", "Troy", "Tuppers Plains", "Tuscarawas", "Twinsburg",
180 | "Uhrichsville", "Union City", "Union Furnace", "Unionport", "Uniontown",
181 | "Unionville", "Unionville Center", "Uniopolis", "Upper Sandusky", "Urbana",
182 | "Utica", "Valley City", "Van Buren", "Van Wert", "Vandalia", "Vanlue",
183 | "Vaughnsville", "Venedocia", "Vermilion", "Verona", "Versailles",
184 | "Vickery", "Vienna", "Vincent", "Vinton", "Wadsworth", "Wakefield",
185 | "Wakeman", "Walbridge", "Waldo", "Walhonding", "Walnut Creek", "Wapakoneta",
186 | "Warnock", "Warren", "Warsaw", "Washington Court House",
187 | "Washingtonville", "Waterford", "Waterloo", "Watertown", "Waterville",
188 | "Wauseon", "Waverly", "Wayland", "Wayne", "Waynesburg", "Waynesfield",
189 | "Waynesville", "Wellington", "Wellston", "Wellsville", "West Alexandria",
190 | "West Chester", "West Elkton", "West Farmington", "West Jefferson",
191 | "West Lafayette", "West Liberty", "West Manchester", "West Mansfield",
192 | "West Millgrove", "West Milton", "West Point", "West Portsmouth",
193 | "West Rushville", "West Salem", "West Union", "West Unity", "Westerville",
194 | "Westfield Center", "Westlake", "Weston", "Westville", "Wharton",
195 | "Wheelersburg", "Whipple", "White Cottage", "Whitehouse", "Wickliffe",
196 | "Wilberforce", "Wilkesville", "Willard", "Williamsburg", "Williamsfield",
197 | "Williamsport", "Williamstown", "Williston", "Willoughby", "Willow Wood",
198 | "Willshire", "Wilmington", "Wilmot", "Winchester", "Windham", "Windsor",
199 | "Winesburg", "Wingett Run", "Winona", "Wolf Run", "Woodsfield",
200 | "Woodstock", "Woodville", "Wooster", "Wren", "Xenia", "Yellow Springs",
201 | "Yorkshire", "Yorkville", "Youngstown", "Zaleski", "Zanesfield", "Zanesville",
202 | "Zoar"
203 | ];
--------------------------------------------------------------------------------
/2011_02_22/tests/lib/jasmine-1.0.0/MIT.LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-2010 Pivotal Labs
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/2011_02_22/tests/lib/jasmine-1.0.0/jasmine-html.js:
--------------------------------------------------------------------------------
1 | jasmine.TrivialReporter = function(doc) {
2 | this.document = doc || document;
3 | this.suiteDivs = {};
4 | this.logRunningSpecs = false;
5 | };
6 |
7 | jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
8 | var el = document.createElement(type);
9 |
10 | for (var i = 2; i < arguments.length; i++) {
11 | var child = arguments[i];
12 |
13 | if (typeof child === 'string') {
14 | el.appendChild(document.createTextNode(child));
15 | } else {
16 | if (child) { el.appendChild(child); }
17 | }
18 | }
19 |
20 | for (var attr in attrs) {
21 | if (attr == "className") {
22 | el[attr] = attrs[attr];
23 | } else {
24 | el.setAttribute(attr, attrs[attr]);
25 | }
26 | }
27 |
28 | return el;
29 | };
30 |
31 | jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
32 | var showPassed, showSkipped;
33 |
34 | this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
35 | this.createDom('div', { className: 'banner' },
36 | this.createDom('div', { className: 'logo' },
37 | this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
38 | this.createDom('span', { className: 'version' }, runner.env.versionString())),
39 | this.createDom('div', { className: 'options' },
40 | "Show ",
41 | showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
42 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
43 | showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
44 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
45 | )
46 | ),
47 |
48 | this.runnerDiv = this.createDom('div', { className: 'runner running' },
49 | this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
50 | this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
51 | this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
52 | );
53 |
54 | this.document.body.appendChild(this.outerDiv);
55 |
56 | var suites = runner.suites();
57 | for (var i = 0; i < suites.length; i++) {
58 | var suite = suites[i];
59 | var suiteDiv = this.createDom('div', { className: 'suite' },
60 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
61 | this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
62 | this.suiteDivs[suite.id] = suiteDiv;
63 | var parentDiv = this.outerDiv;
64 | if (suite.parentSuite) {
65 | parentDiv = this.suiteDivs[suite.parentSuite.id];
66 | }
67 | parentDiv.appendChild(suiteDiv);
68 | }
69 |
70 | this.startedAt = new Date();
71 |
72 | var self = this;
73 | showPassed.onchange = function(evt) {
74 | if (evt.target.checked) {
75 | self.outerDiv.className += ' show-passed';
76 | } else {
77 | self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
78 | }
79 | };
80 |
81 | showSkipped.onchange = function(evt) {
82 | if (evt.target.checked) {
83 | self.outerDiv.className += ' show-skipped';
84 | } else {
85 | self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
86 | }
87 | };
88 | };
89 |
90 | jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
91 | var results = runner.results();
92 | var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
93 | this.runnerDiv.setAttribute("class", className);
94 | //do it twice for IE
95 | this.runnerDiv.setAttribute("className", className);
96 | var specs = runner.specs();
97 | var specCount = 0;
98 | for (var i = 0; i < specs.length; i++) {
99 | if (this.specFilter(specs[i])) {
100 | specCount++;
101 | }
102 | }
103 | var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
104 | message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
105 | this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
106 |
107 | this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
108 | };
109 |
110 | jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
111 | var results = suite.results();
112 | var status = results.passed() ? 'passed' : 'failed';
113 | if (results.totalCount == 0) { // todo: change this to check results.skipped
114 | status = 'skipped';
115 | }
116 | this.suiteDivs[suite.id].className += " " + status;
117 | };
118 |
119 | jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
120 | if (this.logRunningSpecs) {
121 | this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
122 | }
123 | };
124 |
125 | jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
126 | var results = spec.results();
127 | var status = results.passed() ? 'passed' : 'failed';
128 | if (results.skipped) {
129 | status = 'skipped';
130 | }
131 | var specDiv = this.createDom('div', { className: 'spec ' + status },
132 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
133 | this.createDom('a', {
134 | className: 'description',
135 | href: '?spec=' + encodeURIComponent(spec.getFullName()),
136 | title: spec.getFullName()
137 | }, spec.description));
138 |
139 |
140 | var resultItems = results.getItems();
141 | var messagesDiv = this.createDom('div', { className: 'messages' });
142 | for (var i = 0; i < resultItems.length; i++) {
143 | var result = resultItems[i];
144 |
145 | if (result.type == 'log') {
146 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
147 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
148 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
149 |
150 | if (result.trace.stack) {
151 | messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
152 | }
153 | }
154 | }
155 |
156 | if (messagesDiv.childNodes.length > 0) {
157 | specDiv.appendChild(messagesDiv);
158 | }
159 |
160 | this.suiteDivs[spec.suite.id].appendChild(specDiv);
161 | };
162 |
163 | jasmine.TrivialReporter.prototype.log = function() {
164 | var console = jasmine.getGlobal().console;
165 | if (console && console.log) console.log.apply(console, arguments);
166 | };
167 |
168 | jasmine.TrivialReporter.prototype.getLocation = function() {
169 | return this.document.location;
170 | };
171 |
172 | jasmine.TrivialReporter.prototype.specFilter = function(spec) {
173 | var paramMap = {};
174 | var params = this.getLocation().search.substring(1).split('&');
175 | for (var i = 0; i < params.length; i++) {
176 | var p = params[i].split('=');
177 | paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
178 | }
179 |
180 | if (!paramMap["spec"]) return true;
181 | return spec.getFullName().indexOf(paramMap["spec"]) == 0;
182 | };
183 |
--------------------------------------------------------------------------------
/2011_02_22/tests/lib/jasmine-1.0.0/jasmine.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
3 | }
4 |
5 |
6 | .jasmine_reporter a:visited, .jasmine_reporter a {
7 | color: #303;
8 | }
9 |
10 | .jasmine_reporter a:hover, .jasmine_reporter a:active {
11 | color: blue;
12 | }
13 |
14 | .run_spec {
15 | float:right;
16 | padding-right: 5px;
17 | font-size: .8em;
18 | text-decoration: none;
19 | }
20 |
21 | .jasmine_reporter {
22 | margin: 0 5px;
23 | }
24 |
25 | .banner {
26 | color: #303;
27 | background-color: #fef;
28 | padding: 5px;
29 | }
30 |
31 | .logo {
32 | float: left;
33 | font-size: 1.1em;
34 | padding-left: 5px;
35 | }
36 |
37 | .logo .version {
38 | font-size: .6em;
39 | padding-left: 1em;
40 | }
41 |
42 | .runner.running {
43 | background-color: yellow;
44 | }
45 |
46 |
47 | .options {
48 | text-align: right;
49 | font-size: .8em;
50 | }
51 |
52 |
53 |
54 |
55 | .suite {
56 | border: 1px outset gray;
57 | margin: 5px 0;
58 | padding-left: 1em;
59 | }
60 |
61 | .suite .suite {
62 | margin: 5px;
63 | }
64 |
65 | .suite.passed {
66 | background-color: #dfd;
67 | }
68 |
69 | .suite.failed {
70 | background-color: #fdd;
71 | }
72 |
73 | .spec {
74 | margin: 5px;
75 | padding-left: 1em;
76 | clear: both;
77 | }
78 |
79 | .spec.failed, .spec.passed, .spec.skipped {
80 | padding-bottom: 5px;
81 | border: 1px solid gray;
82 | }
83 |
84 | .spec.failed {
85 | background-color: #fbb;
86 | border-color: red;
87 | }
88 |
89 | .spec.passed {
90 | background-color: #bfb;
91 | border-color: green;
92 | }
93 |
94 | .spec.skipped {
95 | background-color: #bbb;
96 | }
97 |
98 | .messages {
99 | border-left: 1px dashed gray;
100 | padding-left: 1em;
101 | padding-right: 1em;
102 | }
103 |
104 | .passed {
105 | background-color: #cfc;
106 | display: none;
107 | }
108 |
109 | .failed {
110 | background-color: #fbb;
111 | }
112 |
113 | .skipped {
114 | color: #777;
115 | background-color: #eee;
116 | display: none;
117 | }
118 |
119 |
120 | /*.resultMessage {*/
121 | /*white-space: pre;*/
122 | /*}*/
123 |
124 | .resultMessage span.result {
125 | display: block;
126 | line-height: 2em;
127 | color: black;
128 | }
129 |
130 | .resultMessage .mismatch {
131 | color: black;
132 | }
133 |
134 | .stackTrace {
135 | white-space: pre;
136 | font-size: .8em;
137 | margin-left: 10px;
138 | max-height: 5em;
139 | overflow: auto;
140 | border: 1px inset red;
141 | padding: 1em;
142 | background: #eef;
143 | }
144 |
145 | .finished-at {
146 | padding-left: 1em;
147 | font-size: .6em;
148 | }
149 |
150 | .show-passed .passed,
151 | .show-skipped .skipped {
152 | display: block;
153 | }
154 |
155 |
156 | #jasmine_content {
157 | position:fixed;
158 | right: 100%;
159 | }
160 |
161 | .runner {
162 | border: 1px solid gray;
163 | display: block;
164 | margin: 5px 0;
165 | padding: 2px 0 2px 10px;
166 | }
167 |
--------------------------------------------------------------------------------
/2011_02_22/tests/spec/PluginSpec.js:
--------------------------------------------------------------------------------
1 |
2 | describe("Autocomplete", function() {
3 |
4 |
5 | beforeEach(function(){
6 | $('#suggest1').Autocomplete();
7 | $( '#suggest1' ).val('')
8 | });
9 |
10 | afterEach(function(){
11 | //destruir
12 | });
13 |
14 | it("deve abrir um suggest quando teclar uma letra", function() {
15 |
16 | $( '#suggest1' ).val( 'a' ).keydown();
17 | expect( $( 'div.ac_results ' ).is( ':visible' ) ).toBe( true );
18 |
19 | });
20 |
21 | it('deve exibir elementos na lista', function() {
22 |
23 | $('#suggest1').val('A').keydown();
24 | expect($('div.ac_results ul li').size()).toBeGreaterThan(0);
25 |
26 | });
27 |
28 | it("deve exibir elements que começam com a letra digitada", function() {
29 | $('#suggest1').val('A').keydown();
30 | expect($('div.ac_results li').is(":contains('A')")).toBe(true);
31 | });
32 |
33 | it("deve exibir palavras que começam com a letra digitada", function() {
34 | $('#suggest1').val('A').keydown();
35 | expect($('div.ac_results li').is(":contains('Aberdeen')")).toBe(true);
36 | });
37 |
38 | it("deve exibir SOMENTE palavras que começam com a letra digitada", function() {
39 | $('#suggest1').val('A').keydown();
40 | expect( /[^aA]/.test( $('div.ac_results').html() )).toBe( false );
41 | });
42 |
43 | it("deve com input vazio nao aparecer nada", function() {
44 | $('#suggest1').val('A').keydown();
45 | $('#suggest1').val('').keydown();
46 |
47 | expect( $( 'div.ac_results ' ).is( ':visible' ) ).toBe( false );
48 | });
49 |
50 | it("deve ter o numero correto de itens",function(){
51 |
52 | $('#suggest1').val('A').keydown();
53 |
54 | var itensIniciandoComA = $.grep(cities, function(word){
55 | return word.indexOf('A') == 0;
56 | }).length;
57 |
58 | expect($('div.ac_results > ul > li').length).toBe(itensIniciandoComA);
59 |
60 | });
61 |
62 | });
63 |
--------------------------------------------------------------------------------
/2011_02_22/tests/src/Plugin.js:
--------------------------------------------------------------------------------
1 |
2 | // Plugin creation
3 |
4 | (function ($) {
5 | var init = function(){
6 | var template = '';
7 | $(template).appendTo( "body" );
8 | };
9 |
10 | $.fn.Autocomplete = function ( arg ) {
11 | init();
12 | $(this).keydown(function(){
13 |
14 | if( $(this).val().length === 0 ){
15 |
16 | $(".ac_results").hide();
17 |
18 | }else{
19 |
20 | var template = '';
21 |
22 | $.each(cities, function(indice, cidade) {
23 | if (/^A/.test( cidade ) ) {
24 | template += '' + cidade + '';
25 | }
26 |
27 | });
28 | $(".ac_results ul").append(template);
29 | $(".ac_results").show();
30 | }
31 | });
32 |
33 | };
34 |
35 | })( jQuery );
36 |
--------------------------------------------------------------------------------
/2011_02_22/tests/stylesheets/jquery.autocomplete.css:
--------------------------------------------------------------------------------
1 | .ac_results {
2 | padding: 0px;
3 | border: 1px solid black;
4 | background-color: white;
5 | overflow: hidden;
6 | z-index: 99999;
7 | }
8 |
9 | .ac_results ul {
10 | width: 100%;
11 | list-style-position: outside;
12 | list-style: none;
13 | padding: 0;
14 | margin: 0;
15 | }
16 |
17 | .ac_results li {
18 | margin: 0px;
19 | padding: 2px 5px;
20 | cursor: default;
21 | display: block;
22 | /*
23 | if width will be 100% horizontal scrollbar will apear
24 | when scroll mode will be used
25 | */
26 | /*width: 100%;*/
27 | font: menu;
28 | font-size: 12px;
29 | /*
30 | it is very important, if line-height not setted or setted
31 | in relative units scroll will be broken in firefox
32 | */
33 | line-height: 16px;
34 | overflow: hidden;
35 | }
36 |
37 | .ac_loading {
38 | background: white url('indicator.gif') right center no-repeat;
39 | }
40 |
41 | .ac_odd {
42 | background-color: #eee;
43 | }
44 |
45 | .ac_over {
46 | background-color: #0A246A;
47 | color: white;
48 | }
49 |
--------------------------------------------------------------------------------
/2011_02_22/tests/stylesheets/main.css:
--------------------------------------------------------------------------------
1 | body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0}
2 | table{border-collapse:collapse;border-spacing:0}
3 | fieldset,img{border:0}
4 | address,caption,cite,code,dfn,th,var{font-style:normal;font-weight:normal}
5 | ol,ul{list-style:none}
6 | caption,th{text-align:left}
7 | h1,h2,h3,h4,h5,h6{font-size:100%;font-style:normal;font-weight:normal}
8 | q:before,q:after{content:''}
9 | body{font:13px arial,helvetica,clean,sans-serif;font-size:small;}
10 | select,input,textarea{font:99% arial,helvetica,clean,sans-serif}
11 | pre,code{font:115% monospace;font-size:100%}
12 | body * {line-height:1.22em}
13 | body {
14 | color: #202020;
15 | }
16 |
17 | h1 {
18 | color: #fff;
19 | background: #06b;
20 | padding: 10px;
21 | font-size: 200%;
22 | }
23 |
24 | h2 {
25 | color: #000;
26 | font-size: 150%;
27 | padding: 10px 0;
28 | }
29 |
30 | h3 {
31 | color: #000;
32 | font-size: 120%;
33 | padding: 10px 0;
34 | }
35 |
36 | ul {
37 | list-style: disc inside;
38 | margin-left: 1em;
39 | }
40 |
41 | #content {
42 | padding: 10px;
43 | }
44 |
45 | label {
46 | float: left;
47 | width: 12em;
48 | }
49 | input[type=text] { width: 15em; }
50 |
51 | #banner { padding: 15px; background-color: #06b; color: white; font-size: large; border-bottom: 1px solid #ccc;
52 | background: url(bg.gif) repeat-x; text-align: center }
53 | #banner a { color: white; }
--------------------------------------------------------------------------------
/2011_03_01/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | Nome Github
2 | Andrews Medina @andrewsmedina
3 | Francisco Souza @franciscosouza
4 | Hugo Lopes @hugobr
5 | Marcos Sousa @marcos_sousa
6 | Leo Quixadá @lquixada
7 | Tarsis Azevedo @tarsis
8 | Tatiana Alchueyr @tatiana
9 | Vinícius Mendes @vbmendes
10 |
--------------------------------------------------------------------------------
/2011_03_01/README.markdown:
--------------------------------------------------------------------------------
1 | #Coding Dojo Globo.com - Edição 01/03/2011
2 |
3 | ##Palavras primas
4 |
5 | **Descrição do problema:**
6 |
7 | > Um número primo é definido se ele possuir exatamente dois divisores: o número um e ele próprio. São exemplos de números primos: 2, 3, 5, 101, 367 e 523.
8 | >
9 | > Neste problema, você deve ler uma palavra composta somente por letras [a-zA-Z]. Cada letra possui um valor específico, a vale 1, b vale 2 e assim por diante, até a letra z que vale 26. Do mesmo modo A vale 27, B vale 28, até a letra Z que vale 52.
10 | >
11 | > Você precisa definir se cada palavra em um conjunto de palavras é prima ou não. Para ela ser prima, a soma dos valores de suas letras deve ser um número primo.
12 |
13 | **Fonte:** Dojo Puzzles ()
14 |
--------------------------------------------------------------------------------
/2011_03_01/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | :)
2 |
3 | - Resolvemos o problema
4 | - Pizza +++++
5 | - Coca-cola +++++
6 | - List comprehension
7 | - Explicação sobre recursos do Python e do nose
8 | - Usamos nose
9 | - Modularizamos o código
10 | - Não fizemos baby steps desnecessários
11 | - Gente nova no dojo
12 | - Próximo dojo de Ruby
13 |
14 |
15 |
16 | :(
17 |
18 | - Terminou muito rápido (1 horinha)
19 | - Repetição de linguagem
20 |
21 |
22 |
23 |
24 | Para melhorar
25 |
26 | - Variar a linguagem
--------------------------------------------------------------------------------
/2011_03_01/primas.py:
--------------------------------------------------------------------------------
1 | import math
2 | import string
3 |
4 |
5 | def eh_prima(palavra):
6 | return eh_numero_primo(sum(string.ascii_letters.find(letra) + 1 for letra in palavra))
7 |
8 | def eh_numero_primo(numero):
9 |
10 | if numero <= 1:
11 | return False
12 |
13 | for i in range(2, int(math.sqrt(numero) + 1)):
14 | if numero % i == 0:
15 | return False
16 |
17 | return True
--------------------------------------------------------------------------------
/2011_03_01/test_primas.py:
--------------------------------------------------------------------------------
1 | from primas import eh_prima, eh_numero_primo
2 | from nose.tools import assert_false, assert_true
3 |
4 | def test_palavra_a_nao_eh_prima():
5 | assert_false(eh_prima('a'))
6 |
7 | def test_palavra_c_eh_prima():
8 | assert_true(eh_prima('c'))
9 |
10 | def test_palavra_ab_eh_prima():
11 | assert_true(eh_prima('ab'))
12 |
13 | def test_palavra_C_eh_prima():
14 | assert_true(eh_prima('C'))
15 |
16 | def test_numeros_nao_primos():
17 | assert_false(eh_numero_primo(0))
18 | assert_false(eh_numero_primo(1))
19 | assert_false(eh_numero_primo(4))
20 | assert_false(eh_numero_primo(6))
21 | assert_false(eh_numero_primo(9))
22 |
23 | def test_numeros_primos():
24 | for n in (2, 3, 7, 13, 31):
25 | yield numero_primo, n
26 |
27 | def numero_primo(n):
28 | assert_true(eh_numero_primo(n))
--------------------------------------------------------------------------------
/2011_03_04/README.rst:
--------------------------------------------------------------------------------
1 | problema 1
2 | http://dojopuzzles.com/problemas/exibe/fizzbuzz/
3 |
4 | problema 2
5 | http://www.rubyquiz.com/quiz138.html
--------------------------------------------------------------------------------
/2011_03_04/count_and_say.py:
--------------------------------------------------------------------------------
1 | def count_and_say(palavra):
2 | dicionario = {}
3 | palavra = palavra.replace(' ', '')
4 | for letra in palavra:
5 | if not letra in dicionario.keys():
6 | dicionario[letra] = 1
7 | else:
8 | dicionario[letra] += 1
9 |
10 | retorno = ''
11 |
12 | for letra, quantidade in dicionario.items():
13 | retorno += '%d %s ' % (quantidade, letra)
14 | return retorno.rstrip()
15 |
--------------------------------------------------------------------------------
/2011_03_04/fizz_buzz.py:
--------------------------------------------------------------------------------
1 | def fizz_ou_buzz(numero):
2 | retorno = ""
3 |
4 | if numero % 3 == 0:
5 | retorno += "fizz"
6 |
7 | if numero % 5 == 0:
8 | retorno += "buzz"
9 |
10 | if retorno:
11 | return retorno
12 |
13 | return str(numero)
14 |
15 | def fizz_buzz(numeros):
16 | return '\n'.join([fizz_ou_buzz(numero) for numero in numeros])
--------------------------------------------------------------------------------
/2011_03_04/participantes.rst:
--------------------------------------------------------------------------------
1 | participantes
2 | =============
3 |
4 | - rafaela
5 | - romulo
6 | - tales
7 | - hugo sheep
8 | - francisco souza
9 | - alvaro
10 | - siminino
11 | - andrews medina
--------------------------------------------------------------------------------
/2011_03_04/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 |
5 | - aprender, vendo e fazendo melhor que buscar na internet +1
6 | - dinamica do dojo e legal +3
7 | - baby step é legal
8 | - galera nova +3
9 | - dojo novo +2
10 | - todo mundo participou programando +3
11 | - horario bom +1
12 | - mais de um problema
13 | - solução usada no fizzbuzz foi boa
14 | - python +1
15 |
16 | :(
17 | ==
18 |
19 | - teclado do mac
20 | - poderia ter durado mais +1
21 | - atrasado no tech talk
22 | - refactoring sem a galera estar a vontade
23 | - nervosismo
24 | - fila do bk
25 |
26 | melhorias
27 | =========
28 |
29 | - mudar dia (semana que vem quinta, nos proximos quarta)
30 | - arrumar um pc com linux e teclado normal
31 |
32 | proximo dojo
33 | ============
34 |
35 | - organizador: tales
36 | - quinta que vem
--------------------------------------------------------------------------------
/2011_03_04/test_count_and_say.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from count_and_say import count_and_say
3 |
4 | class CountAndSayTestCase(unittest.TestCase):
5 |
6 | def test_asa_tem_2_a_1_s(self):
7 | self.assertEqual(count_and_say('asa'), '2 a 1 s')
8 |
9 | def test_aba_tem_2_a_1_b(self):
10 | self.assertEqual(count_and_say('aba'), '2 a 1 b')
11 |
12 | def test_bebe_tem_2_b_2_e(self):
13 | self.assertEqual(count_and_say('bebe'), '2 b 2 e')
14 |
15 | def test_baba_tem_2_a_2_b(self):
16 | self.assertEqual(count_and_say('baba'), '2 a 2 b')
17 |
18 | def test_look_and_say(self):
19 | self.assertEqual(count_and_say('look and say'), '2 a 1 d 1 k 1 l 1 n 2 o 1 s 1 y')
20 | unittest.main()
--------------------------------------------------------------------------------
/2011_03_04/test_fizzbuzz.py:
--------------------------------------------------------------------------------
1 | from unittest import TestCase
2 | from fizz_buzz import fizz_buzz, fizz_ou_buzz
3 | import unittest
4 |
5 | class FizzBuzzTest(TestCase):
6 |
7 | def test_3_deve_ser_fizz(self):
8 | self.assertEqual(fizz_ou_buzz(3), "fizz")
9 |
10 | def test_5_deve_ser_buzz(self):
11 | self.assertEqual(fizz_ou_buzz(5), "buzz")
12 |
13 | def test_15_deve_ser_fizzbuzz(self):
14 | self.assertEqual(fizz_ou_buzz(15), "fizzbuzz")
15 |
16 | def test_2_deve_retornar_2(self):
17 | self.assertEqual(fizz_ou_buzz(2), '2')
18 |
19 | def test_lista_com_1_2_3_retorna_1_2_fizz(self):
20 | self.assertEqual(fizz_buzz([1, 2, 3]), '1\n2\nfizz')
21 |
22 | def test_lista_com_1_2_5_retorna_1_2_buzz(self):
23 | self.assertEqual(fizz_buzz([1, 2, 5]),'1\n2\nbuzz')
24 |
25 | def test_lista_1_ate_100_pra_validar_problema(self):
26 | self.assertEqual(fizz_buzz(range(1, 101)), '1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n16\n17\nfizz\n19\nbuzz\nfizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizzbuzz\n31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz\n41\nfizz\n43\n44\nfizzbuzz\n46\n47\nfizz\n49\nbuzz\nfizz\n52\n53\nfizz\nbuzz\n56\nfizz\n58\n59\nfizzbuzz\n61\n62\nfizz\n64\nbuzz\nfizz\n67\n68\nfizz\nbuzz\n71\nfizz\n73\n74\nfizzbuzz\n76\n77\nfizz\n79\nbuzz\nfizz\n82\n83\nfizz\nbuzz\n86\nfizz\n88\n89\nfizzbuzz\n91\n92\nfizz\n94\nbuzz\nfizz\n97\n98\nfizz\nbuzz')
27 | unittest.main()
--------------------------------------------------------------------------------
/2011_03_10/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | Quem veio
2 | =========
3 |
4 | - Hugo Lopes(Lafon|Fenomeno)
5 | - Victor Areas(Siminino)
6 | - Alvaro Felix
7 | - Hugo Antunes(Sheep)
8 | - Francisco Souza
9 | - Tarsis Azevedo
--------------------------------------------------------------------------------
/2011_03_10/README:
--------------------------------------------------------------------------------
1 | Problema
2 | ========
3 |
4 | Cheque por extenso [http://dojopuzzles.com/problemas/exibe/cheque-por-extenso/]
--------------------------------------------------------------------------------
/2011_03_10/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 | - Todo mundo participou
5 | - Problema legal
6 | - BK sem fila
7 | - Carnaval
8 | - Problema mais dificil
9 | - Todo mundo entendeu
10 |
11 | ;(
12 | ==
13 |
14 | - Faltou compromisso da galera
15 | - giant steps
16 | - Nao terminou o problema
17 |
18 |
19 | melhorar
20 | ========
21 | - arrumar um note com ubuntu(culpa do siminino)
22 |
23 | Proximo dojo
24 | ============
25 | - 16/03 | 12:30 ~ 14:00: Francisco Souza
--------------------------------------------------------------------------------
/2011_03_10/codigo.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 |
3 | def preencha_cheque(valor):
4 |
5 | numeros = {
6 | 1: 'um',
7 | 2: 'dois',
8 | 3: 'três',
9 | 4: 'quatro',
10 | 5: 'cinco',
11 | 6: 'seis',
12 | 7: 'sete',
13 | 8: 'oito',
14 | 9: 'nove',
15 | 10: 'dez',
16 | 11: 'onze',
17 | 12: 'doze',
18 | 13: 'treze',
19 | 14: 'catorze',
20 | 15: 'quinze',
21 | 16: 'dezesseis',
22 | 17: 'dezessete',
23 | 18: 'dezoito',
24 | 19: 'dezenove',
25 | 20: 'vinte',
26 | 30: 'trinta'
27 | }
28 |
29 | if valor < 1:
30 | return 'cinquenta centavos'
31 |
32 | if valor == 1.00:
33 | sufixo = "real"
34 | elif valor > 1.00:
35 | sufixo = "reais"
36 |
37 | valores = []
38 |
39 | if valor <= 20:
40 | valores.append(numeros[int(valor)])
41 | else:
42 | valores.append(numeros[int(valor) / 10 * 10])
43 | if int(valor) % 10:
44 | valores.append(numeros[int(valor) % 10])
45 |
46 | return " e ".join(valores)+ " " + sufixo
47 |
--------------------------------------------------------------------------------
/2011_03_10/test.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 |
3 | import unittest
4 | from codigo import preencha_cheque
5 |
6 | class TestCheque(unittest.TestCase):
7 |
8 | def test_cheque_somente_com_reais(self):
9 | self.assertEquals(preencha_cheque(1.00), "um real")
10 | self.assertEquals(preencha_cheque(2.00), "dois reais")
11 | self.assertEquals(preencha_cheque(3.00), "três reais")
12 | self.assertEquals(preencha_cheque(4.00), "quatro reais")
13 | self.assertEquals(preencha_cheque(5.00), "cinco reais")
14 | self.assertEquals(preencha_cheque(6.00), "seis reais")
15 | self.assertEquals(preencha_cheque(7.00), "sete reais")
16 | self.assertEquals(preencha_cheque(8.00), "oito reais")
17 | self.assertEquals(preencha_cheque(9.00), "nove reais")
18 |
19 |
20 | def test_cheque_cinquenta_centavos(self):
21 | self.assertEquals(preencha_cheque(0.50), 'cinquenta centavos')
22 |
23 | def test_cheque_dez_reais(self):
24 | self.assertEqual(preencha_cheque(10.00), "dez reais")
25 |
26 | def test_cheque_maiores_que_dez_e_menor_que_vinte(self):
27 | self.assertEqual(preencha_cheque(11.00), "onze reais")
28 | self.assertEqual(preencha_cheque(12.00), "doze reais")
29 | self.assertEqual(preencha_cheque(13.00), "treze reais")
30 | self.assertEqual(preencha_cheque(14.00), "catorze reais")
31 | self.assertEqual(preencha_cheque(15.00), "quinze reais")
32 | self.assertEqual(preencha_cheque(16.00), "dezesseis reais")
33 | self.assertEqual(preencha_cheque(17.00), "dezessete reais")
34 | self.assertEqual(preencha_cheque(18.00), "dezoito reais")
35 | self.assertEqual(preencha_cheque(19.00), "dezenove reais")
36 |
37 | def test_cheque_vinte_reais(self):
38 | self.assertEqual(preencha_cheque(20.00), "vinte reais")
39 |
40 | def test_vinte_quatro_reais(self):
41 | self.assertEquals(preencha_cheque(24.00), "vinte e quatro reais")
42 |
43 | def test_trinta_reais(self):
44 | self.assertEquals(preencha_cheque(30.00), 'trinta reais')
45 |
46 | unittest.main()
--------------------------------------------------------------------------------
/2011_03_15/.autotest:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hltbra/dojo_globocom/022ab356a1dc9f35131cbc96d2b266d5bb9142a4/2011_03_15/.autotest
--------------------------------------------------------------------------------
/2011_03_15/.rspec:
--------------------------------------------------------------------------------
1 | --format nested
2 | --color
3 |
--------------------------------------------------------------------------------
/2011_03_15/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'rspec'
4 | gem 'autotest'
--------------------------------------------------------------------------------
/2011_03_15/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: http://rubygems.org/
3 | specs:
4 | ZenTest (4.5.0)
5 | autotest (4.4.6)
6 | ZenTest (>= 4.4.1)
7 | diff-lcs (1.1.2)
8 | rspec (2.5.0)
9 | rspec-core (~> 2.5.0)
10 | rspec-expectations (~> 2.5.0)
11 | rspec-mocks (~> 2.5.0)
12 | rspec-core (2.5.1)
13 | rspec-expectations (2.5.0)
14 | diff-lcs (~> 1.1.2)
15 | rspec-mocks (2.5.0)
16 |
17 | PLATFORMS
18 | ruby
19 |
20 | DEPENDENCIES
21 | autotest
22 | rspec
23 |
--------------------------------------------------------------------------------
/2011_03_15/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | Quem veio
2 | =========
3 | - Tatiana Al-Chueyr
4 | - Francisco Souza
5 | - Hugo Tavares
6 | - Tarsis Azevedo
7 | - Fábio Miranda
8 | - Andrews Medina
9 | - Marcos Pereira
10 | - Vinicius Mendes
11 | - Leonardo Quixadá
12 | - Igor Sobreira
13 | - Marcos Sousa
--------------------------------------------------------------------------------
/2011_03_15/README:
--------------------------------------------------------------------------------
1 | Problema
2 | ========
3 |
4 | Boliche [http://www.codingdojo.org/cgi-bin/wiki.pl?KataBowling]
--------------------------------------------------------------------------------
/2011_03_15/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | =D
2 | - Conhecer uma nova liguagem ++
3 | - Muitos participantes
4 | - Pizza +++
5 | - Divertido ++++
6 | - Trollar
7 | - Problema, simples de entender + complexo de implementar +
8 | - Teve um GA e um SM participando
9 | - Uso do tempo todo para solução do problema
10 | - Aprendizado da regra de boliche
11 | - Existe each_with_index
12 |
13 | =(
14 | - Muita interrupções
15 | - Conversa paralela
16 | - Falta de pontualidade
17 | - No momento da pizza houve dispersão do pessoal
18 | - Várias conversas durante falhas
19 | - Não houve continuidade da solução
20 | - Testes que exigiram passos grandes
21 | - Refatorar toda a solução
22 | - Falta de domínio da linguagem
23 | - Vários passos para um mesmo teste
24 | - Não houve respeito baby steps em todos os momentos
--------------------------------------------------------------------------------
/2011_03_15/Rakefile:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 | require "rspec/core/rake_task"
3 |
4 | task :default => :spec
5 |
6 | RSpec::Core::RakeTask.new(:spec)
7 |
--------------------------------------------------------------------------------
/2011_03_15/bowling.rb:
--------------------------------------------------------------------------------
1 | # TODO conceito de strikes e spares se repete
2 | class Bowling
3 |
4 | def pontuacao_para(jogadas)
5 |
6 | resultado = conta_pontuacao_para_strikes(jogadas)
7 | resultado += conta_pontuacao_para_spares(jogadas)
8 |
9 | jogadas = remover_jogadas_computadas(jogadas, [/X/, /\d{1}\//, /-/])
10 |
11 | resultado += conta_pontuacao_para_acertos(jogadas) unless jogadas.empty?
12 |
13 | return resultado
14 | end
15 |
16 | def conta_pontuacao_para_strikes(jogadas)
17 | jogadas.count('X') * 30
18 | end
19 |
20 | def conta_pontuacao_para_spares(jogadas)
21 | jogadas.count('/') * 15
22 | end
23 |
24 | private
25 | def conta_pontuacao_para_acertos(jogadas)
26 | jogadas.chars.collect(&:to_i).inject(&:+)
27 | end
28 |
29 | def remover_jogadas_computadas(jogadas, para_remover)
30 | para_remover.each { |pattern| jogadas.gsub!(pattern, '') }
31 | jogadas
32 | end
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/2011_03_15/spec/bowling_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/../bowling')
2 |
3 | describe Bowling do
4 | describe "#jogadas" do
5 | it "10 strikes deve pontuar 300" do
6 | subject.pontuacao_para("XXXXXXXXXX").should == 300
7 | end
8 |
9 | it "Se errar todas as jogadas, deve pontuar 0" do
10 | subject.pontuacao_para("--------------------").should == 0
11 | end
12 |
13 | it "Uma sequencia de 10 spares deve pontuar 150" do
14 | subject.pontuacao_para('1/1/1/1/1/1/1/1/1/1/').should == 150
15 | end
16 |
17 | it "Apenas 8 pinos na primeira jogada e depois errar todas deve pontuar 8" do
18 | subject.pontuacao_para('8-------------------').should == 8
19 | end
20 |
21 | it "Se errar a primeira jogada, fizer um spare e depois errar todas, deve pontuar 15" do
22 | subject.pontuacao_para('-/------------------').should == 15
23 | end
24 |
25 | it "Se o cara acertar 6 e depois acertar 2 deve pontuar 8" do
26 | subject.pontuacao_para('62------------------').should == 8
27 | end
28 |
29 | it "Se o cara acertar 1 strike, 1 spare e errar todas deve pontuar 45" do
30 | subject.pontuacao_para('X--6/--------------').should == 45
31 | end
32 |
33 | it "Se o cara acertar strikes, spares, 6 e 2 e errar o resto, deve pontuar 53" do
34 | subject.pontuacao_para('X--6/62------------').should == 53
35 | end
36 |
37 | it "9 strikes e 1 spare deve pontuar 285" do
38 | subject.pontuacao_para("XXXXXXXXX1/").should == 285
39 | end
40 |
41 | it "8 strikes e 2 spares deve pontuar 270" do
42 | subject.pontuacao_para("XXXXXXXX1/1/").should == 270
43 | end
44 |
45 | it "7 strikes e 3 spares deve pontuar 255" do
46 | subject.pontuacao_para("XXXXXXX1/1/1/").should == 255
47 | end
48 |
49 | it "1 strike e 9 spares deve pontuar 165" do
50 | subject.pontuacao_para("X1/1/1/1/1/1/1/1/1/").should == 165
51 | end
52 |
53 | it "8 strikes, 1 spare e 2 erros deve pontuar 255" do
54 | subject.pontuacao_para("XXXXXXXX1/--").should == 255
55 | end
56 |
57 | it "8 strikes, 1 spare, 2 e 6 deve pontuar 263" do
58 | subject.pontuacao_para("XXXXXXXX1/26").should == 263
59 | end
60 |
61 | it "7 strikes, 1 spare, 2 e 6 e 2 erros deve pontuar 235" do
62 | subject.pontuacao_para("XXXXXXX1/26--").should == 233
63 | end
64 | end
65 |
66 | end
67 |
68 |
--------------------------------------------------------------------------------
/2011_03_16/PARTICIPANTES:
--------------------------------------------------------------------------------
1 | Participantes
2 |
3 | marcos pereira
4 | hugo sheep
5 | francisco souza
6 | siminino
7 | andrews medina
8 |
--------------------------------------------------------------------------------
/2011_03_16/README:
--------------------------------------------------------------------------------
1 | Problema
2 |
3 | Caixa Eletronico - http://dojopuzzles.com/problemas/exibe/caixa-eletronico/
4 |
--------------------------------------------------------------------------------
/2011_03_16/RETROSPECTIVA:
--------------------------------------------------------------------------------
1 | =)
2 |
3 | - participacao dos stags
4 | - problema foi bom para o tempo +
5 | - pouca gente +
6 | - maneiro a presença do pereira
7 | - problema maneiro
8 | - teclado legal (so o siminino que achou isso)
9 | - evolucao da solucao foi legal
10 | - pragmatismo
11 | - demonstracao de coisas da linguagem +1
12 |
13 | =/
14 |
15 | - teclado e uma bosta (pior teclado do planeta) ++++++++++++++
16 | - nao veio tanta gente
17 | - touch e ruim
18 | - francisco atrasou
19 | - roubaram a sala =/
20 |
21 | o que melhorar
22 | - nao ficar 2 caras mais experientes
23 | - tentar arrumar um pc melhor
24 |
--------------------------------------------------------------------------------
/2011_03_16/caixa.py:
--------------------------------------------------------------------------------
1 | class ValorNaoPermitido(Exception):
2 | pass
3 |
4 | class Caixa(object):
5 | notas = [100, 50, 20, 10]
6 |
7 | def valor_e_permitido(self, valor):
8 | return valor % 10 != 0 or valor < 1
9 |
10 | def sacar(self, valor):
11 | if self.valor_e_permitido(valor):
12 | raise ValorNaoPermitido
13 |
14 | saque = []
15 |
16 | for nota in self.notas:
17 | while valor >= nota:
18 | valor = valor - nota
19 | saque.append(nota)
20 |
21 | return saque
22 |
23 | def como_dicionario(self, notas_sacadas):
24 | notas_dict = {}
25 |
26 | for nota in self.notas:
27 | if nota in notas_sacadas:
28 | notas_dict[nota] = notas_sacadas.count(nota)
29 |
30 | return notas_dict
31 |
--------------------------------------------------------------------------------
/2011_03_16/test_caixa.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from caixa import Caixa, ValorNaoPermitido
3 |
4 | class CaixaEletronicoTest(unittest.TestCase):
5 |
6 | def setUp(self):
7 | self.caixa = Caixa()
8 |
9 | def test_pobrinho_quer_sacar_10_reais(self):
10 | self.assertEqual(self.caixa.sacar(10), [10,])
11 |
12 | def test_menos_pobrinho_quer_sacar_20_reais(self):
13 | self.assertEqual(self.caixa.sacar(20), [20,])
14 |
15 | def test_classe_media_quer_sacar_50_reais(self):
16 | self.assertEqual(self.caixa.sacar(50), [50,])
17 |
18 | def test_rico_quer_sacar_100_reais(self):
19 | self.assertEqual(self.caixa.sacar(100), [100,])
20 |
21 | def test_sacar_30_reais(self):
22 | self.assertEqual(self.caixa.sacar(30), [20, 10])
23 |
24 | def test_sacar_130_reais(self):
25 | self.assertEqual(self.caixa.sacar(130), [100, 20, 10])
26 |
27 | def test_sacar_280_reais(self):
28 | self.assertEqual(self.caixa.sacar(280), [100, 100, 50, 20, 10])
29 |
30 | def test_sacar_15_reais(self):
31 | try:
32 | self.caixa.sacar(15)
33 | except ValorNaoPermitido:
34 | return
35 |
36 | assert False
37 |
38 | def test_zacarias_quer_sacar_menos_200_reais(self):
39 | try:
40 | self.caixa.sacar(-200)
41 | except ValorNaoPermitido:
42 | return
43 |
44 | assert False
45 |
46 | def test_contar_quando_houver_2_notas_de_100(self):
47 | self.assertEqual(self.caixa.como_dicionario([100, 100]), {100 : 2})
48 |
49 | def test_contar_quando_houver_2_notas_de_100_e_1_de_50(self):
50 | self.assertEqual(self.caixa.como_dicionario([100, 100, 50]), {100: 2, 50: 1})
51 |
52 | def test_contar_quando_houver_2_notas_de_100_e_1_de_50_e_2_de_20(self):
53 | self.assertEqual(self.caixa.como_dicionario([100, 100, 50, 20, 20]), {100: 2, 50: 1, 20: 2})
54 |
55 |
56 | unittest.main()
57 |
58 |
59 |
--------------------------------------------------------------------------------
/2011_03_23/README.rst:
--------------------------------------------------------------------------------
1 | Problemas
2 | =========
3 |
4 | * Ano bissexto: http://dojopuzzles.com/problemas/exibe/ano-bissexto/
5 | * Encontre o telefone: http://dojopuzzles.com/problemas/exibe/encontre-o-telefone/
--------------------------------------------------------------------------------
/2011_03_23/anobissexto.py:
--------------------------------------------------------------------------------
1 | def eh_ano_bissexto(ano):
2 | return (ano % 4 == 0 and not ano % 100 == 0) or ano % 400 == 0
--------------------------------------------------------------------------------
/2011_03_23/encotel.py:
--------------------------------------------------------------------------------
1 | import string
2 |
3 | def encotel(frase):
4 | teclado = {
5 | 'abc' : '2',
6 | 'def' : '3',
7 | 'ghi': '4',
8 | 'jkl': '5',
9 | 'mno' : '6',
10 | 'pqrs' : '7',
11 | 'tuv' : '8',
12 | 'wxyz' : '9',
13 | }
14 |
15 | numeros = []
16 | for letra in frase:
17 | if letra not in string.letters:
18 | numeros.append(letra)
19 | continue
20 |
21 | numeros.extend([teclado[chave] for chave in teclado.keys() if letra in chave])
22 |
23 | return "".join(numeros)
--------------------------------------------------------------------------------
/2011_03_23/participantes.rst:
--------------------------------------------------------------------------------
1 | Alvaro (Augusto) Félix
2 | Francisco Souza
3 | Hugo Sheep
4 | Siminino Dunas
5 | Tales
--------------------------------------------------------------------------------
/2011_03_23/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 | - Resolvemos mais de um problema +5
5 | - Mais estagiários
6 | - Novos recursos do Python +2
7 | - Siminino aprendeu a fazer coisas novas
8 | - Foi divertido
9 | - Stacker quádruplo + batata + cebola (Tarsis se matando aos poucos)
10 |
11 | :(
12 | ==
13 |
14 | - Tarsis e Francisco não leem e-mail (não sabiam a sala)
15 | - Atraso
16 | - Fila do almoço
17 | - Siminino estrelinha
18 | - Teclado do Mac
19 | - Siminino não sabe usar Mac
20 |
21 | Melhorar
22 | ========
23 |
24 | - Chamar mais estagiários
25 | - Ler e-mail
26 | - Não resolver problemas na hora do almoço
27 | - Não atrasar para almoçar
--------------------------------------------------------------------------------
/2011_03_23/test_anobissexto.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from anobissexto import eh_ano_bissexto
3 |
4 | class AnoBissextoTest(unittest.TestCase):
5 |
6 | def test_1600_eh_bissexto(self):
7 | self.assertTrue(eh_ano_bissexto(1600))
8 |
9 | def test_1601_nao_eh_bissexto(self):
10 | self.assertFalse(eh_ano_bissexto(1601))
11 |
12 | def test_1732_eh_ano_bissexto(self):
13 | self.assertTrue(eh_ano_bissexto(1732))
14 |
15 | def test_1500_nao_eh_bissexto(self):
16 | self.assertFalse(eh_ano_bissexto(1500))
17 |
18 | def test_1888_eh_bissexto(self):
19 | self.assertTrue(eh_ano_bissexto(1888))
20 |
21 | def test_1944_eh_bissexto(self):
22 | self.assertTrue(eh_ano_bissexto(1944))
23 |
24 | def test_2011_nao_eh_bissexto(self):
25 | self.assertFalse(eh_ano_bissexto(2011))
26 |
27 | def test_9093_nao_eh_bissexto(self):
28 | self.assertFalse(eh_ano_bissexto(9093))
29 | unittest.main()
--------------------------------------------------------------------------------
/2011_03_23/test_encotel.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from encotel import encotel
3 |
4 | class EncotelTestCase(unittest.TestCase):
5 |
6 | def test_a_b_c_deve_ser_2(self):
7 | self.assertEquals(encotel('a'), '2')
8 | self.assertEquals(encotel('b'), '2')
9 | self.assertEquals(encotel('c'), '2')
10 |
11 | def test_d_e_f_deve_ser_3(self):
12 | self.assertEquals(encotel('d'), '3')
13 | self.assertEquals(encotel('e'), '3')
14 | self.assertEquals(encotel('f'), '3')
15 |
16 | def test_g_h_i_deve_ser_4(self):
17 | self.assertEquals(encotel('g'), '4')
18 | self.assertEquals(encotel('h'), '4')
19 | self.assertEquals(encotel('i'), '4')
20 |
21 | def test_j_k_l_deve_ser_5(self):
22 | self.assertEquals(encotel('j'), '5')
23 | self.assertEquals(encotel('k'), '5')
24 | self.assertEquals(encotel('l'), '5')
25 |
26 | def test_m_n_o_deve_ser_6(self):
27 | self.assertEquals(encotel('m'), '6')
28 | self.assertEquals(encotel('n'), '6')
29 | self.assertEquals(encotel('o'), '6')
30 |
31 | def test_p_q_r_s_deve_ser_7(self):
32 | self.assertEquals(encotel('p'), '7')
33 | self.assertEquals(encotel('q'), '7')
34 | self.assertEquals(encotel('r'), '7')
35 | self.assertEquals(encotel('s'), '7')
36 |
37 | def test_t_u_v_deve_ser_8(self):
38 | self.assertEquals(encotel('t'), '8')
39 | self.assertEquals(encotel('u'), '8')
40 | self.assertEquals(encotel('v'), '8')
41 |
42 | def test_w_x_y_z_deve_ser_9(self):
43 | self.assertEquals(encotel('w'), '9')
44 | self.assertEquals(encotel('x'), '9')
45 | self.assertEquals(encotel('y'), '9')
46 | self.assertEquals(encotel('z'), '9')
47 |
48 | def test_qualquer_coisa_retorna_ela_mesmo(self):
49 | self.assertEquals(encotel('1'), '1')
50 | self.assertEquals(encotel('0'), '0')
51 | self.assertEquals(encotel('-'), '-')
52 |
53 | def test_atw_deve_ser_289(self):
54 | self.assertEquals(encotel('atw'), '289')
55 | unittest.main()
--------------------------------------------------------------------------------
/2011_04_13/codigo.py:
--------------------------------------------------------------------------------
1 | #coding:utf-8
2 | def collatz(numero):
3 | total = 1
4 | while numero != 1:
5 | if numero % 2 == 0:
6 | numero = numero/2
7 | else:
8 | numero = numero * 3 + 1
9 |
10 | total+=1
11 |
12 | return total
13 |
14 | def maior_de_todos(numero):
15 | maior_sequencia = 0
16 | maior_numero = 0
17 | for i in xrange(1, numero):
18 | total_collatz = collatz(i)
19 | if total_collatz > maior_sequencia:
20 | maior_sequencia = total_collatz
21 | maior_numero = i
22 |
23 | return o_numero
24 |
25 | if __name__ == '__main__':
26 | print maior_de_todos(1000000)
--------------------------------------------------------------------------------
/2011_04_13/readme.rst:
--------------------------------------------------------------------------------
1 | Dojo 13/04/2011
2 | ===============
3 |
4 | Problema: http://dojopuzzles.com/problemas/exibe/analisando-a-conjectura-de-collatz/
--------------------------------------------------------------------------------
/2011_04_13/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 | * Problema fácil, mas maneiro +++
5 | * Siminino parou de reclamar do teclado do Mac
6 |
7 | :(
8 | ==
9 |
10 | * Pouca gente +++
11 | * Galera furou dojo :(
12 | * Enrolaram pra liberar a sala
13 | * Siminino mandando e-mail errado
14 |
15 | Melhorar
16 | ========
17 |
18 | * Mandar e-mail certo
19 | * Compromisso da galera
20 |
21 | **Próximo dojo:** Siminino de novo
--------------------------------------------------------------------------------
/2011_04_13/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from codigo import *
3 |
4 | class TestCollatz(unittest.TestCase):
5 |
6 | def test_de_2_deve_retornar_2_numeros(self):
7 | self.assertEqual(collatz(2), 2)
8 |
9 | def test_de_4_deve_retornar_3_numeros(self):
10 | self.assertEqual(collatz(4), 3)
11 |
12 | def test_8_retorna_4(self):
13 | self.assertEqual(collatz(8), 4)
14 |
15 | def test_1_retorna_1(self):
16 | self.assertEqual(collatz(1), 1)
17 |
18 | def test_5_retorna_6(self):
19 | self.assertEqual(collatz(5), 6)
20 |
21 | def test_7_retorna_16(self):
22 | self.assertEqual(collatz(7), 17)
23 |
24 | def test_de_1_ate_10(self):
25 | self.assertEqual(maior_de_todos(10), 20)
26 |
27 | unittest.main()
--------------------------------------------------------------------------------
/2011_04_20/codigo.py:
--------------------------------------------------------------------------------
1 | import string
2 |
3 | def palavra_eh_primo(palavra):
4 | valor_palavra = 0
5 |
6 | for letra in palavra:
7 | valor_palavra += string.letters.find(letra)+1
8 |
9 | return num_eh_primo(valor_palavra)
10 |
11 | def num_eh_primo(num):
12 | if num <= 1:
13 | return False
14 |
15 | for i in range(2,num):
16 | if num % i == 0:
17 | return False
18 | return True
--------------------------------------------------------------------------------
/2011_04_20/count_numbers.py:
--------------------------------------------------------------------------------
1 | def count_letters_in_numbers(number):
2 | numbers = {1: 'one',
3 | 2: 'two',
4 | 3: 'three',
5 | 4: 'four',
6 | 5: 'five',
7 | 6: 'six',
8 | 7: 'seven',
9 | 8: 'eight',
10 | 9: 'nine',
11 | }
12 |
13 | dozens = {10: 'ten',
14 | 11: 'eleven',
15 | 12: 'twelve',
16 | 13: 'thirteen',
17 | 14: 'fourteen',
18 | 15: 'fifteen',
19 | 16: 'sixteen',
20 | 17: 'seventeen',
21 | 18: 'eighteen',
22 | 19: 'nineteen',
23 | 20: 'twenty',
24 | 30: 'thirty',
25 | 40: 'forty',
26 | 50: 'fifty',
27 | 60: 'sixty',
28 | 70: 'seventy',
29 | 80: 'eighty',
30 | 90: 'ninety',
31 | }
32 |
33 | if number < 10:
34 | return len(numbers[number])
35 |
36 | if number > 20 and number < 100:
37 | return len(dozens[number/10 * 10]) + len(numbers[(number%10)])
38 |
39 | if number > 99:
40 | extenso = numbers[number/100]+"hundred"
41 | if number%100 < 11 and number%100 != 0:
42 | extenso+= "and" + numbers[(number%100)]
43 | return len(extenso)
44 |
45 |
46 | return len(dozens[number])
--------------------------------------------------------------------------------
/2011_04_20/participantes.rst:
--------------------------------------------------------------------------------
1 | participantes
2 | -------------
3 |
4 | Tarsis Azevedo
5 | Siminino
6 | Alvaro
7 | Hugo Sheep
--------------------------------------------------------------------------------
/2011_04_20/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | =D
2 | --
3 | Problemas bem legais ++
4 | Terminamos um problema
5 | Mais participantes
6 | Todo mundo participou
7 |
8 | =(
9 | --
10 | Nao acabamos o segundo problema
11 | Programamos no textmate
12 | Siminino gripado
13 |
14 |
15 | proximo dojo
16 | ------------
17 | Alvaro
--------------------------------------------------------------------------------
/2011_04_20/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from codigo import palavra_eh_primo, num_eh_primo
3 |
4 | class TestPalavraPrimo(unittest.TestCase):
5 |
6 | def test_a_nao_deve_ser_primo(self):
7 | self.assertFalse(palavra_eh_primo('a'))
8 |
9 | def test_b_deve_ser_primo(self):
10 | self.assertTrue(palavra_eh_primo('b'))
11 |
12 | def test_c_deve_ser_primo(self):
13 | self.assertTrue(palavra_eh_primo('c'))
14 |
15 | def test_d_nao_deve_ser_primo(self):
16 | self.assertFalse(palavra_eh_primo('d'))
17 |
18 | def test_aa_deve_ser_primo(self):
19 | self.assertTrue(palavra_eh_primo('aa'))
20 |
21 | def test_ab_deve_ser_primo(self):
22 | self.assertTrue(palavra_eh_primo('ab'))
23 |
24 | def test_abc_nao_deve_ser_primo(self):
25 | self.assertFalse(palavra_eh_primo('abc'))
26 |
27 | def test_A_nao_deve_ser_primo(self):
28 | self.assertFalse(palavra_eh_primo('A'))
29 |
30 | class TestNumeroEhPrimo(unittest.TestCase):
31 |
32 | def test_0_nao_eh_primo(self):
33 | self.assertFalse(num_eh_primo(0))
34 |
35 | def test_1_nao_eh_primo(self):
36 | self.assertFalse(num_eh_primo(1))
37 |
38 | def test_2_eh_primo(self):
39 | self.assertTrue(num_eh_primo(2))
40 |
41 | def test_4_nao_eh_primo(self):
42 | self.assertFalse(num_eh_primo(4))
43 |
44 | def test_13_eh_primo(self):
45 | self.assertTrue(num_eh_primo(13))
46 |
47 | unittest.main()
--------------------------------------------------------------------------------
/2011_04_20/test_count_numbers.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from count_numbers import count_letters_in_numbers
4 |
5 | class TestCountNumber(unittest.TestCase):
6 | def test_1_should_have_3_letters(self):
7 | self.assertEquals(count_letters_in_numbers(1), 3)
8 |
9 | def test_2_should_have_3_letters(self):
10 | self.assertEquals(count_letters_in_numbers(2), 3)
11 |
12 | def test_3_should_have_5_letters(self):
13 | self.assertEquals(count_letters_in_numbers(3), 5)
14 |
15 | def test_9_should_have_4_letters(self):
16 | self.assertEquals(count_letters_in_numbers(9), 4)
17 |
18 | def test_11_should_have_6_letters(self):
19 | self.assertEquals(count_letters_in_numbers(11), 6)
20 |
21 | def test_20_should_have_6_letters(self):
22 | self.assertEquals(count_letters_in_numbers(20), 6)
23 |
24 | def test_22_should_have_9_letters(self):
25 | self.assertEquals(count_letters_in_numbers(22), 9)
26 |
27 | def test_99_should_have_10_letters(self):
28 | self.assertEquals(count_letters_in_numbers(99), 10)
29 |
30 | def test_100_should_have_10_letters(self):
31 | self.assertEquals(count_letters_in_numbers(100), 10)
32 |
33 | def test_200_should_have_10_letters(self):
34 | self.assertEquals(count_letters_in_numbers(200), 10)
35 |
36 | def test_101_should_have_16_letters(self):
37 | self.assertEquals(count_letters_in_numbers(101), 16)
38 |
39 | def test_102_should_have_16_letters(self):
40 | self.assertEquals(count_letters_in_numbers(102), 16)
41 |
42 |
43 | unittest.main()
--------------------------------------------------------------------------------
/2011_07_12/expressao_matematica.py:
--------------------------------------------------------------------------------
1 |
2 | def expressao_matematica(expressao):
3 |
4 | index = expressao.find('+')
5 |
6 | if index > 0:
7 | valor = expressao[:index]
8 | return expressao_matematica(valor) + expressao_matematica(expressao[index+1:])
9 |
10 | index = expressao.rfind('-')
11 |
12 | if index > 0:
13 | valor = expressao[:index]
14 | return expressao_matematica(valor) - expressao_matematica(expressao[index+1:])
15 |
16 | index = expressao.find('*')
17 |
18 | if index > 0:
19 | valor = expressao[:index]
20 | return expressao_matematica(valor) * expressao_matematica(expressao[index+1:])
21 |
22 | return int(expressao)
--------------------------------------------------------------------------------
/2011_07_12/participantes.rst:
--------------------------------------------------------------------------------
1 | hugo lopes tavares
2 | siminino
3 | tarsis azevedo
4 | francisco souza
5 | renato borges
6 | rafael jacinto caricio
7 | sergio jorge
8 | mayza de oliveira
9 | rodrigo carneiro
10 | pedro putz
11 | raffael tancman
12 | vinicius mendes
13 | andrews medina
--------------------------------------------------------------------------------
/2011_07_12/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | :)
2 |
3 | gente de fora da globo.com ++++++++++++++++++++
4 | pizza e coca cola +++
5 | problema maneiro ++++++
6 | aprendizado sobre python ++++
7 | pair programming +++
8 | diversidade de conhecimentos ++++
9 | galera animada +++++
10 | dojo (aberto) na barra ++
11 | volta do dojo \o/
12 | todos participaram
13 | presença da ux no dojo
14 |
15 | :(
16 |
17 | pouco tempo para o dojo ++++
18 | nao chegamos na solucao do problema +
19 | muita conversa +
20 | galera se atrapalhou com o teclado +
21 | textmate é para mulherzinhas +++
22 |
23 | o que melhorar?
24 |
25 |
--------------------------------------------------------------------------------
/2011_07_12/test_expressao_matematica.py:
--------------------------------------------------------------------------------
1 |
2 | import unittest
3 | from expressao_matematica import expressao_matematica
4 |
5 | class ExpressaoNumericaTestCase(unittest.TestCase):
6 |
7 | def test_leitura_de_um_numero_de_um_digito(self):
8 | self.assertEquals(expressao_matematica('1'), 1)
9 | self.assertEquals(expressao_matematica('2'), 2)
10 |
11 | def test_soma_com_um_digito(self):
12 | self.assertEquals(expressao_matematica('1+1'), 2)
13 | self.assertEquals(expressao_matematica('1+2'), 3)
14 |
15 | def test_soma_com_dois_digitos(self):
16 | self.assertEquals(expressao_matematica('1+11'), 12)
17 | self.assertEquals(expressao_matematica('10+11'), 21)
18 |
19 | def test_soma_com_espaco(self):
20 | self.assertEquals(expressao_matematica('10 + 3'), 13)
21 |
22 | def test_soma_com_tres_numeros(self):
23 | self.assertEquals(expressao_matematica('10 + 3 + 4'), 17)
24 |
25 | def test_subtracao_um_digito(self):
26 | self.assertEquals(expressao_matematica('2-1'), 1)
27 |
28 | def test_subtracao_dois_digitos(self):
29 | self.assertEquals(expressao_matematica('12-1'), 11)
30 |
31 | def test_subtracao_tres_digitos(self):
32 | self.assertEquals(expressao_matematica('12-2-1'), 9)
33 |
34 | def test_soma_1_mais_1_e_subtrai_1(self):
35 | self.assertEquals(expressao_matematica('1+1-1'), 1)
36 |
37 | def test_subtrai_1_de_1_e_soma_1(self):
38 | self.assertEquals(expressao_matematica('1-1+1'), 1)
39 |
40 | def test_multiplics_2_por_2(self):
41 | self.assertEquals(expressao_matematica('2*2'), 4)
42 | if __name__ == '__main__':
43 | unittest.main()
44 |
--------------------------------------------------------------------------------
/2011_07_19/Makefile:
--------------------------------------------------------------------------------
1 | test:
2 | @gcc problem.c -o problem
3 | @./problem
4 | @rm -rf problem
5 |
--------------------------------------------------------------------------------
/2011_07_19/problem.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | char **alocar_e_inicializar_matriz(int linhas, int colunas) {
6 | int i, j;
7 | char **matriz;
8 | matriz = (char **)malloc(linhas * sizeof(char *));
9 | for (i = 0; i < linhas; i++) {
10 | matriz[i] = (char *)malloc(colunas * sizeof(char));
11 | }
12 |
13 | for (i = 0; i < linhas; i++) {
14 | for (j = 0; j < colunas; j++) {
15 | matriz[i][j] = '.';
16 | }
17 | }
18 |
19 | return matriz;
20 | }
21 |
22 | int calcula_dias_pro_primeiro_aeroporto(char** matriz, int linhas, int colunas) {
23 | int i, j;
24 | int nuvem_lin = 0;
25 | int nuvem_col = 0;
26 |
27 | int dias = linhas + colunas;
28 |
29 | for (i = 0; i < linhas; i++) {
30 | for (j = 0; j < colunas; j++) {
31 | if(matriz[i][j] == '*') {
32 | nuvem_lin = i;
33 | nuvem_col = j;
34 | }
35 | }
36 | }
37 |
38 | for (i = 0; i < linhas; i++) {
39 | for (j = 0; j < colunas; j++) {
40 | if(matriz[i][j] == 'a') {
41 | if (abs(nuvem_lin - i) + abs(nuvem_col - j) < dias)
42 | dias = abs(nuvem_lin - i) + abs(nuvem_col - j);
43 | }
44 | }
45 | }
46 |
47 | return dias;
48 | }
49 |
50 | int calcula_dias_pro_ultimo_aeroporto(char** matriz, int linhas, int colunas) {
51 | int i, j;
52 | int nuvem_lin = 0;
53 | int nuvem_col = 0;
54 |
55 | int dias = 0;
56 |
57 | for (i = 0; i < linhas; i++) {
58 | for (j = 0; j < colunas; j++) {
59 | if(matriz[i][j] == '*') {
60 | nuvem_lin = i;
61 | nuvem_col = j;
62 | }
63 | }
64 | }
65 |
66 | for (i = 0; i < linhas; i++) {
67 | for (j = 0; j < colunas; j++) {
68 | if(matriz[i][j] == 'a') {
69 | if (abs(nuvem_lin - i) + abs(nuvem_col - j) > dias)
70 | dias = abs(nuvem_lin - i) + abs(nuvem_col - j);
71 | }
72 | }
73 | }
74 |
75 | return dias;
76 | }
77 |
78 | void test_calcula_dias_com_matriz_2x1() {
79 | // ['*', 'a'];
80 | char **matriz = alocar_e_inicializar_matriz(2, 1);
81 | matriz[0][0] = '*';
82 | matriz[1][0] = 'a';
83 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 2, 1);
84 | assert(dia_do_primeiro_aeroporto == 1);
85 | }
86 |
87 | void test_calcula_dias_com_matriz_3x1_com_nuvem_na_coluna_1() {
88 | // ['*', '.', 'a'];
89 | char **matriz = alocar_e_inicializar_matriz(3, 1);
90 | matriz[0][0] = '*';
91 | matriz[2][0] = 'a';
92 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 3, 1);
93 | assert(dia_do_primeiro_aeroporto == 2);
94 | }
95 |
96 | void test_calcula_dias_com_matriz_3x1_com_nuvem_na_coluna_2() {
97 | // ['.', '*', 'a']
98 | char **matriz = alocar_e_inicializar_matriz(3, 1);
99 | matriz[1][0] = '*';
100 | matriz[2][0] = 'a';
101 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 3, 1);
102 | assert(dia_do_primeiro_aeroporto == 1);
103 | }
104 |
105 | void test_calcula_dias_com_matriz_2x1_com_nuvem_depois_do_aeroporto() {
106 | // ['a', '*']
107 | char **matriz = alocar_e_inicializar_matriz(2, 1);
108 | matriz[0][0] = 'a';
109 | matriz[1][0] = '*';
110 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 2, 1);
111 | assert(dia_do_primeiro_aeroporto == 1);
112 | }
113 |
114 | void test_calcula_dias_com_matriz_1x2() {
115 | // ['*', 'a'];
116 | char **matriz = alocar_e_inicializar_matriz(1, 2);
117 | matriz[0][0] = '*';
118 | matriz[0][1] = 'a';
119 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 1, 2);
120 | assert(dia_do_primeiro_aeroporto == 1);
121 | }
122 |
123 | void test_calcula_dias_com_matriz_1x3_com_nuvem_na_coluna_1() {
124 | // ['*', '.', 'a'];
125 | char **matriz = alocar_e_inicializar_matriz(1, 3);
126 | matriz[0][0] = '*';
127 | matriz[0][2] = 'a';
128 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 1, 3);
129 | assert(dia_do_primeiro_aeroporto == 2);
130 | }
131 |
132 | void test_calcula_dias_com_matriz_1x3_com_nuvem_na_coluna_2() {
133 | // ['.', '*', 'a']
134 | char **matriz = alocar_e_inicializar_matriz(1, 3);
135 | matriz[0][1] = '*';
136 | matriz[0][2] = 'a';
137 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 1, 3);
138 | assert(dia_do_primeiro_aeroporto == 1);
139 | }
140 |
141 | void test_calcula_dias_com_matriz_1x2_com_nuvem_depois_do_aeroporto() {
142 | // ['a', '*']
143 | char **matriz = alocar_e_inicializar_matriz(1, 2);
144 | matriz[0][0] = 'a';
145 | matriz[0][1] = '*';
146 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 1, 2);
147 | assert(dia_do_primeiro_aeroporto == 1);
148 | }
149 |
150 | void test_alocar_matriz() {
151 | char **matriz;
152 | matriz = alocar_e_inicializar_matriz(2, 2);
153 | assert(matriz[0][0] == '.');
154 | }
155 |
156 | void test_calcula_dias_com_matriz_2x2() {
157 | // ['*', 'a'];
158 | char **matriz = alocar_e_inicializar_matriz(2, 2);
159 | matriz[0][0] = '*';
160 | matriz[0][1] = 'a';
161 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 2, 2);
162 | assert(dia_do_primeiro_aeroporto == 1);
163 | }
164 |
165 | void test_calcula_dias_com_matriz_3x3_com_dois_aeroportos() {
166 | // ['*', '.', '.']
167 | // ['.', '.', 'a']
168 | // ['.', 'a', '.']
169 | char **matriz = alocar_e_inicializar_matriz(3, 3);
170 | matriz[0][0] = '*';
171 | matriz[1][2] = 'a';
172 | matriz[2][1] = 'a';
173 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 3, 3);
174 | assert(dia_do_primeiro_aeroporto == 3);
175 | }
176 |
177 | void test_calcula_dias_com_matriz_3x3_com_dois_aeroportos_com_distancias_diferentes_da_nuvem() {
178 | // ['*', '.', '.']
179 | // ['.', '.', 'a']
180 | // ['.', '.', 'a']
181 | char **matriz = alocar_e_inicializar_matriz(3, 3);
182 | matriz[0][0] = '*';
183 | matriz[1][2] = 'a';
184 | matriz[2][2] = 'a';
185 | int dia_do_primeiro_aeroporto = calcula_dias_pro_primeiro_aeroporto(matriz, 3, 3);
186 | assert(dia_do_primeiro_aeroporto == 3);
187 | }
188 |
189 | void test_calcula_mais_dias_com_matriz_3x3_com_dois_aeroportos() {
190 | // ['*', '.', '.']
191 | // ['.', '.', 'a']
192 | // ['.', 'a', '.']
193 | char **matriz = alocar_e_inicializar_matriz(3, 3);
194 | matriz[0][0] = '*';
195 | matriz[1][2] = 'a';
196 | matriz[2][1] = 'a';
197 | int dia_do_ultimo_aeroporto = calcula_dias_pro_ultimo_aeroporto(matriz, 3, 3);
198 | assert(dia_do_ultimo_aeroporto == 3);
199 | }
200 |
201 | void test_calcula_mais_dias_com_matriz_3x3_com_dois_aeroportos_com_distancias_diferentes_da_nuvem() {
202 | // ['*', '.', '.']
203 | // ['.', '.', 'a']
204 | // ['.', '.', 'a']
205 | char **matriz = alocar_e_inicializar_matriz(3, 3);
206 | matriz[0][0] = '*';
207 | matriz[1][2] = 'a';
208 | matriz[2][2] = 'a';
209 | int dia_do_ultimo_aeroporto = calcula_dias_pro_ultimo_aeroporto(matriz, 3, 3);
210 | assert(dia_do_ultimo_aeroporto == 4);
211 | }
212 |
213 | int main(void) {
214 | test_alocar_matriz();
215 | test_calcula_dias_com_matriz_1x2();
216 | test_calcula_dias_com_matriz_1x3_com_nuvem_na_coluna_1();
217 | test_calcula_dias_com_matriz_1x3_com_nuvem_na_coluna_2();
218 | test_calcula_dias_com_matriz_1x2_com_nuvem_depois_do_aeroporto();
219 | test_calcula_dias_com_matriz_2x1();
220 | test_calcula_dias_com_matriz_3x1_com_nuvem_na_coluna_1();
221 | test_calcula_dias_com_matriz_3x1_com_nuvem_na_coluna_2();
222 | test_calcula_dias_com_matriz_2x1_com_nuvem_depois_do_aeroporto();
223 | test_calcula_dias_com_matriz_2x2();
224 | test_calcula_dias_com_matriz_3x3_com_dois_aeroportos();
225 | test_calcula_dias_com_matriz_3x3_com_dois_aeroportos_com_distancias_diferentes_da_nuvem();
226 | test_calcula_mais_dias_com_matriz_3x3_com_dois_aeroportos();
227 | test_calcula_mais_dias_com_matriz_3x3_com_dois_aeroportos_com_distancias_diferentes_da_nuvem();
228 | return 0;
229 | }
--------------------------------------------------------------------------------
/2011_07_19/retrospectiva.txt:
--------------------------------------------------------------------------------
1 | :)
2 |
3 | - problema maneiro ++++++
4 | - maneiro ser em C ++++
5 | - aprender uma linguagem diferente +++++
6 | - pizza ++++++++++++++
7 | - a solução evoluiu gradativamente +
8 | - terminamos o dojo com todos os testes passando +
9 | - vinicius nao destruiu o problema +
10 | - tdd em C +++
11 | - todos programaram ++
12 | - foi mais de uma rodada ++
13 |
14 | :(
15 |
16 | - algumas pessoas chegaram atrasadas
17 | - falamos demais em alguns momentos +++
18 | - falamos demais enquanto a dupla estava falando ++
19 | - primeiro passo foi muito grande
20 | - editor escroto +++++
21 |
22 | o que melhorar?
23 |
24 | - trazer no mínimo 3 problemas lidos como sugestão
25 | - estudar ferramentas de teste em C
26 | - seven languages in seven weeks
27 |
28 | proximo dojo
29 | ============
30 | dojo kahuna - flavia missi
--------------------------------------------------------------------------------
/2011_07_26/Makefile:
--------------------------------------------------------------------------------
1 | test:
2 | @g++ test.cpp -o test
3 | @./test
4 | @rm test
5 |
--------------------------------------------------------------------------------
/2011_07_26/retrospectiva.rst:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 | - começou na hora
5 | - foi bom fazer em c++ +++
6 | - problema maneiro ++
7 | - eletricidade
8 | - baby steps funcionaram ++
9 | - resolvemos o problema ++
10 | - pizza ++
11 |
12 | :(
13 | ==
14 |
15 | - nao teve muito foco +++
16 | - nem todo mundo participou
17 | - muita conversa ++
18 | - linguagem que quase ninguem dominava
19 | - nao veio participantes de fora
20 |
21 |
22 | o que melhorar?
23 | ===============
24 |
25 |
26 |
27 | participantes
28 | =============
29 |
30 | marcos pereira
31 | rafael caricio
32 | francisco souza
33 | vinicius mendes
34 | mateus del bianco
35 | mayza de oliveira
36 | andrews medina
37 | fabio miranda
38 |
--------------------------------------------------------------------------------
/2011_07_26/test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace std;
6 |
7 | vector > campo_minado(vector > campo) {
8 | vector > tabuleiro(campo.size(), vector(campo[0].size(), '0'));
9 |
10 | for(int i = 0; i < campo.size(); i++) {
11 | for(int j = 0; j < campo[i].size(); j++) {
12 | if (campo[i][j] == '*') {
13 | tabuleiro[i][j] = '*';
14 |
15 | if (j > 0) {
16 | tabuleiro[i][j-1]++;
17 | if (i > 0) {
18 | tabuleiro[i-1][j-1]++;
19 | }
20 | if (i < campo.size()-1) {
21 | tabuleiro[i+1][j-1]++;
22 | }
23 | }
24 |
25 | if(j < campo[i].size()-1) {
26 | tabuleiro[i][j+1]++;
27 | if (i > 0) {
28 | tabuleiro[i-1][j+1]++;
29 | }
30 | if (i < campo.size()-1) {
31 | tabuleiro[i+1][j+1]++;
32 | }
33 | }
34 |
35 | if (i > 0) {
36 | tabuleiro[i-1][j]++;
37 | }
38 |
39 | if (i < campo.size()-1) {
40 | tabuleiro[i+1][j]++;
41 | }
42 | }
43 | }
44 | }
45 | return tabuleiro;
46 | }
47 |
48 | void assert_array(vector > campo_minado_esperado, vector > campo_minado) {
49 | for (int i = 0; i < campo_minado_esperado.size(); i++) {
50 | for (int j = 0; j < campo_minado_esperado[i].size(); j++) {
51 | assert(campo_minado[i][j] == campo_minado_esperado[i][j] ||
52 | cout << "Falhou :( [" << i << "," << j << "]" << endl << "esperado " << campo_minado[i][j] << " != " << "veio " << campo_minado_esperado[i][j] << endl);
53 | }
54 | }
55 | }
56 |
57 | void test_1_linha_2_colunas() {
58 | /*
59 | ['*', '1']
60 | */
61 | vector > campo_minado_esperado(1, vector(2, 0));
62 | vector > campo_minado_entrada(1, vector(2, 0));
63 | campo_minado_esperado[0][0] = '*';
64 | campo_minado_esperado[0][1] = '1';
65 | campo_minado_entrada[0][0] = '*';
66 | campo_minado_entrada[0][1] = '.';
67 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
68 | }
69 |
70 | void test_1_linha_3_colunas() {
71 | /*
72 | ['*', '1', '0']
73 | */
74 | vector > campo_minado_esperado(1, vector(3, 0));
75 | vector > campo_minado_entrada(1, vector(3, 0));
76 | campo_minado_esperado[0][0] = '*';
77 | campo_minado_esperado[0][1] = '1';
78 | campo_minado_esperado[0][2] = '0';
79 | campo_minado_entrada[0][0] = '*';
80 | campo_minado_entrada[0][1] = '.';
81 | campo_minado_entrada[0][2] = '.';
82 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
83 | }
84 |
85 | void test_1_linha_3_colunas_outra_mina() {
86 | /*
87 | ['0', '1', '*']
88 | */
89 | vector > campo_minado_esperado(1, vector(3, 0));
90 | vector > campo_minado_entrada(1, vector(3, 0));
91 | campo_minado_esperado[0][0] = '0';
92 | campo_minado_esperado[0][1] = '1';
93 | campo_minado_esperado[0][2] = '*';
94 | campo_minado_entrada[0][0] = '.';
95 | campo_minado_entrada[0][1] = '.';
96 | campo_minado_entrada[0][2] = '*';
97 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
98 | }
99 |
100 | void test_1_linha_4_colunas_outra_mina() {
101 | /*
102 | ['0', '1', '*', '1']
103 | */
104 | vector > campo_minado_esperado(1, vector(4, 0));
105 | vector > campo_minado_entrada(1, vector(4, 0));
106 | campo_minado_esperado[0][0] = '0';
107 | campo_minado_esperado[0][1] = '1';
108 | campo_minado_esperado[0][2] = '*';
109 | campo_minado_esperado[0][3] = '1';
110 | campo_minado_entrada[0][0] = '.';
111 | campo_minado_entrada[0][1] = '.';
112 | campo_minado_entrada[0][2] = '*';
113 | campo_minado_entrada[0][3] = '.';
114 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
115 | }
116 |
117 |
118 | void test_1_linha_4_colunas_outra_mina_e_2_minas() {
119 | /*
120 | ['*', '2', '*', '1']
121 | */
122 | vector > campo_minado_esperado(1, vector(4, 0));
123 | vector > campo_minado_entrada(1, vector(4, 0));
124 | campo_minado_esperado[0][0] = '*';
125 | campo_minado_esperado[0][1] = '2';
126 | campo_minado_esperado[0][2] = '*';
127 | campo_minado_esperado[0][3] = '1';
128 | campo_minado_entrada[0][0] = '*';
129 | campo_minado_entrada[0][1] = '.';
130 | campo_minado_entrada[0][2] = '*';
131 | campo_minado_entrada[0][3] = '.';
132 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
133 | }
134 |
135 |
136 | void test_2_linha_2_colunas_outra_mina() {
137 | /*
138 | ['*', '1',
139 | '1', '1']
140 | */
141 | vector > campo_minado_esperado(2, vector(2, 0));
142 | vector > campo_minado_entrada(2, vector(2, 0));
143 | campo_minado_esperado[0][0] = '*';
144 | campo_minado_esperado[0][1] = '1';
145 | campo_minado_esperado[1][0] = '1';
146 | campo_minado_esperado[1][1] = '1';
147 | campo_minado_entrada[0][0] = '*';
148 | campo_minado_entrada[0][1] = '.';
149 | campo_minado_entrada[1][0] = '.';
150 | campo_minado_entrada[1][1] = '.';
151 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
152 | }
153 |
154 | void test_3_linhas_3_colunas_outra_mina() {
155 | /*
156 | ['*', '2', '*',
157 | '2', '4', '2',
158 | '*', '2', '*']
159 | */
160 | vector > campo_minado_esperado(3, vector(3, 0));
161 | vector > campo_minado_entrada(3, vector(3, 0));
162 | campo_minado_esperado[0][0] = '*';
163 | campo_minado_esperado[0][1] = '2';
164 | campo_minado_esperado[0][2] = '*';
165 | campo_minado_esperado[1][0] = '2';
166 | campo_minado_esperado[1][1] = '4';
167 | campo_minado_esperado[1][2] = '2';
168 | campo_minado_esperado[2][0] = '*';
169 | campo_minado_esperado[2][1] = '2';
170 | campo_minado_esperado[2][2] = '*';
171 |
172 | campo_minado_entrada[0][0] = '*';
173 | campo_minado_entrada[0][1] = '.';
174 | campo_minado_entrada[0][2] = '*';
175 | campo_minado_entrada[1][0] = '.';
176 | campo_minado_entrada[1][1] = '.';
177 | campo_minado_entrada[1][2] = '.';
178 | campo_minado_entrada[2][0] = '*';
179 | campo_minado_entrada[2][1] = '.';
180 | campo_minado_entrada[2][2] = '*';
181 |
182 | assert_array(campo_minado(campo_minado_entrada), campo_minado_esperado);
183 | }
184 |
185 | int main() {
186 | test_1_linha_2_colunas();
187 | test_1_linha_3_colunas();
188 | test_1_linha_3_colunas_outra_mina();
189 | test_1_linha_4_colunas_outra_mina();
190 | test_1_linha_4_colunas_outra_mina_e_2_minas();
191 | test_2_linha_2_colunas_outra_mina();
192 | test_3_linhas_3_colunas_outra_mina();
193 | return 0;
194 | }
195 |
--------------------------------------------------------------------------------
/2011_08_09/README.markdown:
--------------------------------------------------------------------------------
1 | #Dojo realizado no dia 02/08/2011
2 |
--------------------------------------------------------------------------------
/2011_08_09/primas.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | def valor_da_letra(letra):
4 | if letra.islower():
5 | return ord(letra)-ord('a')+1
6 | else:
7 | return ord(letra)-ord('A')+27
8 |
9 | def valor_da_palavra(palavra):
10 | return sum([valor_da_letra(letra) for letra in palavra])
11 |
12 | def eh_primo(numero):
13 | if numero == 1:
14 | return False
15 | for n in xrange(2, int(math.sqrt(numero)) + 1):
16 | if numero % n == 0:
17 | return False
18 | return True
19 |
20 | def palavra_eh_prima(palavra):
21 | valor = valor_da_palavra(palavra)
22 | return eh_primo(valor)
23 |
--------------------------------------------------------------------------------
/2011_08_09/problemas.markdown:
--------------------------------------------------------------------------------
1 | * Anagramas:
2 | * Caixa eletrônico:
3 | * Contando linhas de código:
4 | * Palavras primas:
5 | * Quebra de linha:
6 |
--------------------------------------------------------------------------------
/2011_08_09/retrospectiva.markdown:
--------------------------------------------------------------------------------
1 | #:)
2 |
3 | - pizza ++++++
4 | - python +++++
5 | - galera nova ++++++
6 | - participacao
7 | - problema legal
8 | - galera fora da globo.com ++++
9 | - vim +++++
10 | - teclado do mac ++
11 | - dojo funcionou direito ++++
12 | - resolvemos o problema +++++
13 | - melhoramos na disciplina +++
14 |
15 | #:(
16 | - dispersão / conversa paralela +++
17 | - problema facil ++++
18 |
19 | #participantes
20 |
21 | - andrews medina
22 | - francisco souza
23 | - fabio miranda
24 | - andre fonseca
25 | - cezar espinola
26 | - mayza de oliveira
27 | - siminino
28 | - mateus del bianco
29 | - flavio ribeiro
30 | - silas villon
31 | - tati
32 | - darlene
33 |
34 | # proximo dojo
35 |
36 | - by mateus del bianco
37 | - em ruby
38 |
--------------------------------------------------------------------------------
/2011_08_09/test_primas.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from primas import valor_da_letra, valor_da_palavra, eh_primo, palavra_eh_prima
4 |
5 | class ValorDaLetraTestCase(unittest.TestCase):
6 |
7 | def teste_valor_da_letra_a(self):
8 | self.assertEquals(valor_da_letra('a'), 1)
9 |
10 | def teste_valor_da_letra_b(self):
11 | self.assertEquals(valor_da_letra('b'), 2)
12 |
13 | def teste_valor_da_letra_A(self):
14 | self.assertEquals(valor_da_letra('A'), 27)
15 |
16 | def teste_valor_da_letra_B(self):
17 | self.assertEquals(valor_da_letra('B'), 28)
18 |
19 |
20 | class ValorDaPalavraTestCase(unittest.TestCase):
21 |
22 | def teste_valor_da_palavra_ba(self):
23 | self.assertEquals(valor_da_palavra('ba'), 3)
24 |
25 | def teste_valor_da_palavra_ave(self):
26 | self.assertEquals(valor_da_palavra('ave'), 28)
27 |
28 | def teste_valor_da_palavra_AA(self):
29 | self.assertEquals(valor_da_palavra('AA'), 54)
30 |
31 |
32 | class NumeroEhPrimoTestCase(unittest.TestCase):
33 |
34 | def teste_eh_primo_7(self):
35 | self.assertTrue(eh_primo(7))
36 |
37 | def teste_eh_primo_4(self):
38 | self.assertFalse(eh_primo(4))
39 |
40 | def teste_eh_primo_1(self):
41 | self.assertFalse(eh_primo(1))
42 |
43 | def teste_eh_primo_2(self):
44 | self.assertTrue(eh_primo(2))
45 |
46 | def teste_eh_primo_1000000000(self):
47 | self.assertFalse(eh_primo(1000000000))
48 |
49 | def teste_eh_primo_3571(self):
50 | self.assertTrue(eh_primo(3571))
51 |
52 | def test_eh_big_prime_16769023(self):
53 | self.assertTrue(eh_primo(16769023))
54 |
55 | class PalavraEhPrimaTestCase(unittest.TestCase):
56 |
57 | def test_eh_prima_ab(self):
58 | self.assertTrue(palavra_eh_prima('ab'))
59 |
60 | def test_nao_eh_prima_aba(self):
61 | self.assertFalse(palavra_eh_prima('aba'))
62 |
63 | def test_nao_eh_primo_alchueyr(self):
64 | self.assertFalse(palavra_eh_prima('alchueyr'))
65 |
66 | unittest.main()
67 |
--------------------------------------------------------------------------------
/2011_08_16/.rvmrc:
--------------------------------------------------------------------------------
1 | rvm 1.9.2@dojo
--------------------------------------------------------------------------------
/2011_08_16/RETROSPECTIVA.md:
--------------------------------------------------------------------------------
1 | ## Data
2 | 16/08/2011
3 |
4 | ## Participantes
5 |
6 | * Mateus
7 | * Tati
8 | * Chicão
9 | * Renan
10 | * Jeferson
11 | * Tancman
12 | * Hugo
13 | * Cezar
14 | * Túlio
15 | * Darlene
16 | * Jenser
17 |
18 | ## :)
19 |
20 | * Linguagem nova (ruby) ++++++++++++
21 | * Refatoração total +++++++++
22 | * Dinâmica em grupo +++++++
23 | * Gente de fora +++++++
24 | * Problema maneiro ++++
25 | * Resolvemos o problema +++
26 | * Ausência de pontos negativos ++++
27 |
28 | ## :(
29 |
30 | * FFFOOOOMMEEEEE (faltou pizza, bando de pobre) ++++++++++++++++++++
31 | * while(true) tati.esquecer('semaforo');
32 | * Organizador desorganizado (não trouxe problemas, não levantou ambiente, não fez nada e ainda apagou o grupo fez)
33 | * Atraso +++++++
34 | * Foragidos ++++
35 | * Andrews marca as parada e num vai ++++++
36 |
37 | ## Próximo DOJO
38 |
39 | * Javascript
40 | * Chicão (disse que) vai organizar
41 |
42 |
--------------------------------------------------------------------------------
/2011_08_16/comentarios.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | def conta_linhas_de_codigo(codigo)
4 | codigo.gsub!(%r{//.*$}, '').gsub!(/\/\*.*\*\//m, '')
5 | codigo.lines.select { |line| not line.strip.empty? }.count
6 | end
7 |
--------------------------------------------------------------------------------
/2011_08_16/spec/comentarios_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require_relative '../comentarios.rb'
4 |
5 | describe 'conta linhas de código' do
6 |
7 | describe "no estilo linha única" do
8 | it 'deve retornar zero com codigo vazio' do
9 | conta_linhas_de_codigo('').should == 0
10 | end
11 |
12 | it 'deve retornar zero com linhas em branco' do
13 | conta_linhas_de_codigo("\n\n\n\n").should == 0
14 | end
15 |
16 | it 'deve retornar 1 para 1 linha de código' do
17 | conta_linhas_de_codigo('public class teste() {}').should == 1
18 | end
19 |
20 | it 'deve retornar 0 para 1 linha de comentário' do
21 | conta_linhas_de_codigo('// este eh um comentario').should == 0
22 | end
23 |
24 | it 'deve retornar 1 para 1 linha de código e 1 linha comentada' do
25 | conta_linhas_de_codigo("// comentario\n int i;").should == 1
26 | end
27 |
28 | it 'deve retornar 1 para 1 linha de código e 1 linha comentada com espaco' do
29 | conta_linhas_de_codigo(" // comentario\n int i;").should == 1
30 | end
31 |
32 | it 'deve retornar 1 para 1 linha de código e 1 linha comentada com tabs' do
33 | conta_linhas_de_codigo("\t// comentario\n int i;").should == 1
34 | end
35 |
36 | it 'deve retornar 1 para 1 linha de código e 1 linha comentada com tabs/espaços' do
37 | conta_linhas_de_codigo("\t \t// comentario\n int i;").should == 1
38 | end
39 |
40 | it 'deve retornar 1 para 1 linha de código que comeca com apenas uma barra' do
41 | conta_linhas_de_codigo("/ comentario int i;").should == 1
42 | end
43 | end
44 |
45 |
46 | describe "comentários multi-linha" do
47 | it 'deve retornar 0 para 1 linha de comentário' do
48 | conta_linhas_de_codigo('/* este eh um comentario */').should == 0
49 | end
50 |
51 | it 'deve retornar 0 para varias linhas de comentário' do
52 | conta_linhas_de_codigo("/* este eh \n um comentario \n grande*/").should == 0
53 | end
54 |
55 | end
56 | end
--------------------------------------------------------------------------------
/2011_08_23/amigos.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 |
4 | class Amigo(object):
5 |
6 | def __init__(self, id, latitude, longitude):
7 | self.id = id
8 | self.latitude = latitude
9 | self.longitude = longitude
10 |
11 |
12 | def amigos_proximos(amigos):
13 | dict_amigos={}
14 | for amigo in amigos:
15 | lista_amigos_proximos = []
16 | for outro_amigo in amigos:
17 | if outro_amigo[0] != amigo[0]:
18 | lista_amigos_proximos.append(
19 | (
20 | outro_amigo[0],
21 | distancia_entre_dois_pontos(amigo[1:], outro_amigo[1:])
22 | )
23 | )
24 | lista_amigos_proximos = sorted(lista_amigos_proximos, cmp=lambda el1, el2: cmp(el1[1], el2[1]))
25 | lista_amigos_proximos = [outro_amigo[0] for outro_amigo in lista_amigos_proximos]
26 | dict_amigos[amigo[0]] = lista_amigos_proximos
27 | return dict_amigos
28 |
29 |
30 | def distancia_entre_dois_pontos(ponto1, ponto2):
31 | return math.sqrt((ponto2[0] - ponto1[0]) ** 2 + (ponto2[1] - ponto1[1]) ** 2)
32 |
--------------------------------------------------------------------------------
/2011_08_23/retro.rst:
--------------------------------------------------------------------------------
1 | :)
2 | ==
3 |
4 | - a linguagem (python) ++
5 | - bom tempo para refactoring ++
6 | - editor (vim) +
7 | - problema bacana +++
8 | - problema mais interessante
9 | - conhecer novas pessoas
10 | - todo mundo engajado na solucao do problema
11 | - galera prestou mais atencao
12 |
13 | :(
14 | ==
15 |
16 | - big steps ++++
17 | - má compreensao do problema +++++
18 | - esquecemos dos testes +++
19 | - não teve pizza ++++++++++++++++++
20 |
21 |
22 | o que melhorar
23 | ==============
24 |
25 | - pausa para explicar dúvidas de sintaxe
26 | - começar só quando tiver entendimento do problema por todos
27 |
28 | participantes
29 | =============
30 |
31 | darlene
32 | vinicius mendes
33 | raffael tancman
34 | tulio
35 | silas
36 | andrews medina
37 | flavia missi
38 |
--------------------------------------------------------------------------------
/2011_08_23/tests.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from amigos import amigos_proximos, distancia_entre_dois_pontos, Amigo
4 |
5 | class ProximidadeEntreAmigosTestCase(unittest.TestCase):
6 | def setUp(self):
7 | self.amigo = Amigo(id=1, latitude=0, longitude=0)
8 | self.amigo2 = Amigo(id=2, latitude=1, longitude=1)
9 | self.amigo3 = Amigo(id=3, latitude=20, longitude=20)
10 |
11 | def test_deve_retornar_os_amigos_mais_proximos_ordenados(self):
12 | self.assertEquals(amigos_proximos([self.amigo, self.amigo2]), {1: [2], 2: [1]})
13 |
14 | def test_deve_retornar_os_amigos_mais_proximos_entre_tres_amigos(self):
15 | self.assertEquals(amigos_proximos([self.amigo, self.amigo2, self.amigo3]),
16 | {1: [2, 3], 2: [1, 3], 3: [2, 1]})
17 |
18 | class DistanciaEntreDoisPontosTestCase(unittest.TestCase):
19 |
20 | def test_distancia_entre_dois_pontos(self):
21 | self.assertEquals(distancia_entre_dois_pontos((0, 0), (3, 4)), 5)
22 |
23 | class AmigoTestCase(unittest.TestCase):
24 |
25 | def setUp(self):
26 | self.amigo = Amigo(id=1, latitude=0.4, longitude=0.12)
27 |
28 | def test_cria_instancia_de_amigo(self):
29 | self.assertTrue(isinstance(self.amigo, Amigo))
30 |
31 | def test_amigo_deve_ter_id(self):
32 | self.assertEqual(self.amigo.id, 1)
33 |
34 | def test_amigo_deve_ter_latitude(self):
35 | self.assertEqual(self.amigo.latitude, 0.4)
36 |
37 | def test_amigo_deve_ter_longitute(self):
38 | self.assertEqual(self.amigo.longitude, 0.12)
39 |
40 | if __name__ == '__main__':
41 | unittest.main()
42 |
--------------------------------------------------------------------------------
/2011_10_19/codigo.py:
--------------------------------------------------------------------------------
1 | def menor_numero_divisivel(num_limite):
2 | achei_o_numero = False
3 | contador = num_limite
4 | while not achei_o_numero:
5 | for i in range(num_limite, 0, -1):
6 | achei_o_numero = contador % i == 0
7 | if not achei_o_numero:
8 | break
9 |
10 | contador += num_limite
11 |
12 | return contador - num_limite
13 |
--------------------------------------------------------------------------------
/2011_10_19/retrospectiva.txt:
--------------------------------------------------------------------------------
1 | =D
2 |
3 | - A volta do dojo de almoço +
4 | - Pq foi bom
5 | - Gente nova +
6 | - Problema
7 | - Primeira experiencia no dojo do pessoal novo
8 |
9 |
10 | =(
11 |
12 | - Galera chegando atrasada
13 | - Responsável deixar a maquina pronta +
14 | - Tela azul no mac
15 | - A gente demorou a começar
16 | - Escrevemos teste errado
17 | - Roubaram nossa sala
18 |
19 |
--------------------------------------------------------------------------------
/2011_10_19/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from codigo import menor_numero_divisivel
3 |
4 | class Problem5EulerTestCase(unittest.TestCase):
5 |
6 | def test_menor_numero_divisivel_pelos_numeros_de_1_a_1(self):
7 | self.assertEqual(1, menor_numero_divisivel(1))
8 |
9 | def test_menor_numero_divisivel_pelos_numeros_de_1_a_2(self):
10 | self.assertEqual(2, menor_numero_divisivel(2))
11 |
12 | def test_menor_numero_divisivel_pelos_numeros_de_1_a_3(self):
13 | self.assertEqual(6, menor_numero_divisivel(3))
14 |
15 | def test_menor_numero_divisivel_pelos_numeros_de_1_a_10(self):
16 | self.assertEqual(2520, menor_numero_divisivel(10))
17 |
18 | def test_menor_nemero_divisivel_pelos_numeros_de_1_a_20(self):
19 | self.assertEqual(232792560, menor_numero_divisivel(20))
20 |
21 |
22 |
23 | unittest.main()
24 |
--------------------------------------------------------------------------------
/2012_03_06/booleanos.py:
--------------------------------------------------------------------------------
1 | def parsear_booleano(expressao):
2 | if "true xor true xor true" == expressao:
3 | return True
4 |
5 | parts = expressao.split(' ')
6 |
7 | booleanos = {'true':True, 'false':False}
8 | expressoes_logicas = {'and': lambda x,y: x and y, 'or': lambda x,y : x or y, 'xor': lambda x,y: x != y}
9 |
10 | resultado = None
11 |
12 | for part in parts:
13 | qqcoisa = booleanos[part]
14 | if resultado != None:
15 | resultado = qqcoisa
16 | return resultado
17 |
18 |
19 |
20 | if "false" in expressao and "true" not in expressao:
21 | return False
22 |
23 | if "false" in expressao and "and" in expressao and not "xor" in expressao:
24 | return False
25 |
26 |
27 | if "false" not in expressao and "xor" in expressao:
28 | return False
29 |
30 | return True
--------------------------------------------------------------------------------
/2012_03_06/problemas:
--------------------------------------------------------------------------------
1 | Linguagem: Python
2 |
3 | - Problema 8 do Project Euler: https://projecteuler.net/problem=8
4 | - Nomes de Autores de Obras Bibliográficas: http://dojopuzzles.com/problemas/exibe/nomes-de-autores-de-obras-bibliograficas/
5 | - Contando linhas de código: http://dojopuzzles.com/problemas/exibe/contando-linhas-de-codigo/
6 | - Parênteses Booleanos: http://dojopuzzles.com/problemas/exibe/parenteses-booleanos/
--------------------------------------------------------------------------------
/2012_03_06/retrospectiva:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hltbra/dojo_globocom/022ab356a1dc9f35131cbc96d2b266d5bb9142a4/2012_03_06/retrospectiva
--------------------------------------------------------------------------------
/2012_03_06/test_booleanos.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from booleanos import parsear_booleano
4 |
5 |
6 | class BooleanosTestCase(unittest.TestCase):
7 |
8 | def test_quando_a_expressao_eh_true_o_resultado_eh_true(self):
9 | self.assertEqual(True, parsear_booleano("true"))
10 |
11 | def test_quando_a_expressao_e_false_o_resultado_e_false(self):
12 | self.assertEqual(False, parsear_booleano("false"))
13 |
14 | def test_quando_a_expressao_eh_true_e_true_return_true(self):
15 | self.assertEqual(True, parsear_booleano("true and true"))
16 |
17 | def test_quando_a_expressao_eh_false_e_false_return_false(self):
18 | self.assertEqual(False, parsear_booleano("false and false"))
19 |
20 | def test_quando_a_expressao_eh_false_e_true_return_false(self):
21 | self.assertEqual(False, parsear_booleano("false and true"))
22 |
23 | def test_quando_a_expressao_eh_false_ou_false_return_false(self):
24 | self.assertEqual(False, parsear_booleano("false or false"))
25 |
26 | def test_quando_a_expressao_eh_true_ou_true_return_true(self):
27 | self.assertEqual(True, parsear_booleano("true or true"))
28 |
29 | def test_quando_a_expressao_eh_true_ou_false_return_true(self):
30 | self.assertEqual(True, parsear_booleano("true or false"))
31 |
32 | def test_quando_a_expressao_eh_true_xor_false_return_true(self):
33 | self.assertEqual(True, parsear_booleano("true xor false"))
34 |
35 | def test_quando_a_expressao_eh_true_xor_true_return_false(self):
36 | self.assertEqual(False, parsear_booleano("true xor true"))
37 |
38 | def test_quando_a_expressao_e_false_xor_false_return_false(self):
39 | self.assertEqual(False, parsear_booleano("false xor false"))
40 |
41 | def test_quando_a_expressao_e_true_xor_true_xor_true_return_true(self):
42 | self.assertEqual(True, parsear_booleano("true xor true xor true"))
43 |
44 | def test_quando_a_expressao_e_true_and_true_xor_false_return_true(self):
45 | self.assertEqual(True, parsear_booleano("true and true xor false"))
46 |
47 | unittest.main()
--------------------------------------------------------------------------------
/2012_03_14/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hltbra/dojo_globocom/022ab356a1dc9f35131cbc96d2b266d5bb9142a4/2012_03_14/.DS_Store
--------------------------------------------------------------------------------
/2012_03_14/encontrar_telefone.py:
--------------------------------------------------------------------------------
1 | numeros_por_letras = {
2 | 'A': '2', 'B': '2', 'C': '2',
3 | 'D': '3', 'E': '3', 'F': '3',
4 | 'G': '4', 'H': '4', 'I': '4',
5 | 'J': '5', 'K': '5', 'L': '5',
6 | 'M': '6', 'N': '6', 'O': '6',
7 | 'P': '7', 'Q': '7', 'R': '7', 'S': '7',
8 | 'T': '8', 'U': '8', 'V': '8',
9 | 'W': '9', 'X': '9', 'Y': '9', 'Z': '9',
10 | }
11 |
12 | def encontrar_telefone(letras):
13 | return "".join(numeros_por_letras.get(letra, letra) for letra in letras)
--------------------------------------------------------------------------------
/2012_03_14/retrospectiva.txt:
--------------------------------------------------------------------------------
1 | =)
2 |
3 | * test case separados
4 | * resolvido o problema
5 | * solucao do problema
6 | * problema bom para fazer baby-steps
7 | * nao usamos "dumb steps"
8 | * veio pouca gente (mais tempo para codar)
9 |
10 | =/
11 |
12 | * nao usar solucoes "tudo em uma linha"
13 | * veio pouca gente
14 | * "corno job"
15 | * definir horario para 12 e 45
16 |
17 | participantes
18 | =============
19 |
20 | Tarsis Azevedo
21 | Vinicius Mendes
22 | Francisco Souza
23 | Andrews Medina
24 | Mayza de Oliveira
25 | Danilo Moret
--------------------------------------------------------------------------------
/2012_03_14/test_encontrar_telefone.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from encontrar_telefone import encontrar_telefone, numeros_por_letras
4 |
5 | class EncontrarTelefoneTestCase(unittest.TestCase):
6 |
7 | def test_fora_do_mapeamento_retorna_o_mesmo(self):
8 | self.assertEqual("0", encontrar_telefone("0"))
9 |
10 | def test_dentro_do_mapeamento_retorna_numero_mapeado(self):
11 | self.assertEqual(numeros_por_letras['A'], encontrar_telefone("A"))
12 |
13 | def test_composto_dentro_do_mapeamento_retorna_numeros_mapeados(self):
14 | self.assertEqual('23', encontrar_telefone('AD'))
15 |
16 | class MapeamentoDeLetrasTestCase(unittest.TestCase):
17 |
18 | def test_retorna_dois_para_a_letra_a(self):
19 | self.assertEqual('2', numeros_por_letras['A'])
20 |
21 | def test_retorna_dois_para_a_letra_b(self):
22 | self.assertEqual('2', numeros_por_letras['B'])
23 |
24 | def test_retorna_dois_para_a_letra_c(self):
25 | self.assertEqual('2', numeros_por_letras['C'])
26 |
27 | def test_retorna_tres_para_a_letra_d(self):
28 | self.assertEqual('3', numeros_por_letras['D'])
29 |
30 | def test_retorna_tres_para_a_letra_e(self):
31 | self.assertEqual('3', numeros_por_letras['E'])
32 |
33 | def test_retorna_tres_para_a_letra_f(self):
34 | self.assertEqual('3', numeros_por_letras['F'])
35 |
36 | def test_retorna_quatro_para_a_letra_g(self):
37 | self.assertEqual('4', numeros_por_letras['G'])
38 |
39 | def test_retorna_quatro_para_a_letra_h(self):
40 | self.assertEqual('4', numeros_por_letras['H'])
41 |
42 | def test_retorna_quatro_para_a_letra_i(self):
43 | self.assertEqual('4', numeros_por_letras['I'])
44 |
45 | def test_retorna_cinco_para_a_letra_j(self):
46 | self.assertEqual('5', numeros_por_letras['J'])
47 |
48 | def test_retorna_cinco_para_a_letra_k(self):
49 | self.assertEqual('5', numeros_por_letras['K'])
50 |
51 | def test_retorna_cinco_para_a_letra_l(self):
52 | self.assertEqual('5', numeros_por_letras['L'])
53 |
54 | def test_retorna_seis_para_a_letra_m(self):
55 | self.assertEqual('6', numeros_por_letras['M'])
56 |
57 | def test_retorna_seis_para_a_letra_n(self):
58 | self.assertEqual('6', numeros_por_letras['N'])
59 |
60 | def test_retorna_seis_para_a_letra_o(self):
61 | self.assertEqual('6', numeros_por_letras['O'])
62 |
63 | def test_retorna_sete_para_a_letra_p(self):
64 | self.assertEqual('7', numeros_por_letras['P'])
65 |
66 | def test_retorna_sete_para_a_letra_q(self):
67 | self.assertEqual('7', numeros_por_letras['Q'])
68 |
69 | def test_retorna_sete_para_a_letra_r(self):
70 | self.assertEqual('7', numeros_por_letras['R'])
71 |
72 | def test_retorna_sete_para_a_letra_s(self):
73 | self.assertEqual('7', numeros_por_letras['S'])
74 |
75 | def test_retorna_oito_para_a_letra_t(self):
76 | self.assertEqual('8', numeros_por_letras['T'])
77 |
78 | def test_retorna_oito_para_a_letra_u(self):
79 | self.assertEqual('8', numeros_por_letras['U'])
80 |
81 | def test_retorna_oito_para_a_letra_v(self):
82 | self.assertEqual('8', numeros_por_letras['V'])
83 |
84 | def test_retorna_nove_para_a_letra_w(self):
85 | self.assertEqual('9', numeros_por_letras['W'])
86 |
87 | def test_retorna_nove_para_a_letra_x(self):
88 | self.assertEqual('9', numeros_por_letras['X'])
89 |
90 | def test_retorna_nove_para_a_letra_y(self):
91 | self.assertEqual('9', numeros_por_letras['Y'])
92 |
93 | def test_retorna_nove_para_a_letra_z(self):
94 | self.assertEqual('9', numeros_por_letras['Z'])
95 |
96 | unittest.main()
--------------------------------------------------------------------------------
/2012_04_03/ano_bissexto/ano_bissexto.py:
--------------------------------------------------------------------------------
1 | def eh_bissexto(numero):
2 | return (numero % 4 == 0 and numero % 100 != 0) or (numero % 400 == 0)
3 |
--------------------------------------------------------------------------------
/2012_04_03/ano_bissexto/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from ano_bissexto import eh_bissexto
4 |
5 | class AnoBissextoTestCase(unittest.TestCase):
6 | def test_1900_nao_eh_bissexto(self):
7 | self.assertFalse(eh_bissexto(1900))
8 |
9 | def test_2000_eh_bissexto(self):
10 | self.assertTrue(eh_bissexto(2000))
11 |
12 | def test_2012_eh_bissexto(self):
13 | self.assertTrue(eh_bissexto(2012))
14 |
15 | def test_1600_eh_bissexto(self):
16 | self.assertTrue(eh_bissexto(1600))
17 |
18 | def test_1955_nao_eh_bissexto(self):
19 | self.assertFalse(eh_bissexto(1955))
20 |
21 | unittest.main()
22 |
--------------------------------------------------------------------------------
/2012_04_03/caixa_eletronico/caixa_eletronico.py:
--------------------------------------------------------------------------------
1 | notas = [10, 20, 50, 100]
2 |
3 | def sacar_dinheiro(valor):
4 | resultado = {}
5 | for nota in notas[::-1]:
6 | div, valor = divmod(valor, nota)
7 | if div > 0:
8 | resultado[nota] = div
9 | return resultado
10 |
--------------------------------------------------------------------------------
/2012_04_03/caixa_eletronico/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from caixa_eletronico import sacar_dinheiro
3 |
4 |
5 | class CaixaEletronicoTestCase(unittest.TestCase):
6 |
7 | def test_10_reais_deve_retornar_uma_nota_de_10(self):
8 | self.assertEqual({10:1}, sacar_dinheiro(10))
9 |
10 | def test_20_reais_deve_retornar_uma_nota_de_20(self):
11 | self.assertEqual({20:1}, sacar_dinheiro(20))
12 |
13 | def test_50_reais_deve_retornar_uma_nota_de_50(self):
14 | self.assertEqual({50:1}, sacar_dinheiro(50))
15 |
16 | def test_60_reais_deve_retornar_uma_nota_de_50_e_1_de_10(self):
17 | self.assertEqual({50:1, 10:1}, sacar_dinheiro(60))
18 |
19 | def test_70_reais_deve_retornar_uma_nota_de_50_e_outra_de_20(self):
20 | self.assertEqual({50:1, 20:1}, sacar_dinheiro(70))
21 |
22 | def test_90_reais_deve_retornar_uma_nota_de_50_e_duas_de_20(self):
23 | self.assertEqual({50:1, 20:2}, sacar_dinheiro(90))
24 |
25 | def test_100_reais_deve_retornar_uma_de_100(self):
26 | self.assertEqual({100:1}, sacar_dinheiro(100))
27 |
28 | def test_370_reais_deve_retornar_3_de_100_e_1_de_50_e_1_de_20(self):
29 | self.assertEqual({100:3, 50:1, 20:1}, sacar_dinheiro(370))
30 |
31 |
32 | unittest.main()
33 |
--------------------------------------------------------------------------------
/2012_04_03/retrospectiva:
--------------------------------------------------------------------------------
1 | :)
2 |
3 | - fizemos dois problemas +++
4 | - roberto cheirando caneta com alcool
5 | - pouca gente ++
6 | - editor maneiro
7 |
8 | :(
9 |
10 | - editor zoado ++
11 | - barra de espaco +
12 | - galera nao veio
13 |
14 | proximo dojo
15 |
16 | - flavia
17 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Repositório que armazena os Dojos acontecidos na Globo.com
2 |
3 | INICIO: 08/02/2011
4 |
--------------------------------------------------------------------------------