When the Nerds Go Marching In - Alexis C. Madrigal - The Atlantic
“ Harper Reed got the city of Chicago to create an open and real-time feed of its transit data by reverse engineering how they served bus location information. Why? Because it made his wife Hiromi’s commute a little easier. ”
“If you can just avoid dying, you get rich. That sounds like a joke, but it’s actually a pretty good description of what happens in a typical startup.” Paul Graham
“ The myth of the overnight success is just that – a myth. ”
Alexander Graham Bell knew this when he famously said, “It is the man who carefully advances step by step, with his mind becoming wider and wider … who is bound to succeed in the greatest degree.”
Thomas Edison knew this when he proclaimed, “Success is the product of the severest kind of mental and physical application.”
Amelia E. Barr knew this when she asserted, “Everything good needs time.”
(via explore-blog)Sempre tive dúvidas sobre como fazer testes, antes, depois ou durante, fazer mocks e stubs ou não, isolar a aplicação do banco ou não, usar factories ou não, são tantas variáveis, tantas opções, pra não dizer decisões, que realmente fica fácil de se perder.
Primeiro gostaria de fazer uma consideração, tudo que direi aqui é baseado no meu cotidiano com o desenvolvimento de aplicações web com ruby.
Então vamos ver como testar, ou melhor, vou mostrar como eu testo.
Eu testo por que assim eu me prendo a duas coisas, confiabilidade e foco. Testando eu fico mais seguro quanto aquilo que desenvolvo e caso outra pessoa queira trabalhar no projeto ela terá maior confiança sobre o funcionamento do mesmo. Além disso, fazendo os testes eu me atenho a realizar um pequeno avanço bem direcionado no projeto por iteração.
Os testes me auxiliam em ter uma meta durante o processo de desenvolvimento. Também me auxiliam a solucionar problemas, pois, com eles posso quebrar uma solução em pequenas soluções mais tangíveis.
De outra maneira, os testes me auxiliam tanto na análise bottom-up quanto na top-down durante o processo de resolução de um problema.
Eu prefiro testar meu código com testes automatizados, pratica bem comum entre desenvolvedores da linguagem ruby, pra isso utilizo o rspec de maneira bem próxima à apresentada abaixo:
#test_file.rb
describe ClassName do
describe "#instance_method" do
it "should do an amazing thing" do
ClassName.new.instance_method.should be_amazing
end
end
end
Simples e prático, depois para verificar que o teste está funcionando:
rspec test_file.rb
Nesse exemplo pode-se ver que estou descrevendo uma classe (ClassName) e seu o método (instance_method) que será testado. Também foi definida uma espectativa sobre esse método (should be amazing). Dessa forma se tem a estrutura básica de um teste.
A algum tempo atrás desenvolvi um crawler, é algo muito legal, e uma das características desse crawler era que ele precisava baixar photos. Para não bagunçar as responsabilidades do meu crawler resolvi implementar essa funcionalidade em uma outra classe que chamei de PhotoService.
De maneira resumida, essa classe receberia uma url e deveria retornar o nome do arquivo onde foi salva a foto. Sendo assim, ela me parece uma ótima candidata a ser apresentada aqui.
Que comecemos com os testes então:
#spec/photo_service_spec.rb
require_relative '../photo_service'
describe PhotoService do
let(:photo) { double("photo") }
describe "#dowload" do
it "should download the photo"
end
end
A estrutura do teste segue bem simples por enquanto, foi definida a classe que será testada e qual método será testado. A espectativa ainda não foi definida, porém já temos uma ideia daquilo que iremos fazer.
Em ruby podemos verificar que um arquivo existe usando File.exists? filename
Vamos refatorar nosso teste para atender as nossas espectativas.
#spec/photo_service_spec.rb
describe "#download" do
it "should download the photo" do
filename = PhotoService.new.download(url)
path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
File.exists?(File.join(path, filename)).should be_true
end
end
Alguns pontos a se ressaltar, a url ainda não foi definida e determinamos apenas a espectativa quanto a foto estar salva em disco.
Com isso já temos a meta final da nossa aplicação, vamos começar a montar os passos para atingir essa meta:
… continua no próximo capítulo.
Yes, lets imagine a world WITHOUT MUSLIMS, shall we?
Without Muslims you wouldn’t have:
- Coffee
Cameras
Experimental Physics
Chess
Soap
Shampoo
Perfume/spirits
Irrigation
Crank-shaft, internal combustion engine, valves, pistons
Combination locks
Architectural innovation (pointed arch -European Gothic cathedrals adopted this technique as it made the building much stronger, rose windows, dome buildings, round towers, etc.)
Surgical instruments
Anesthesia
Windmill
Treatment of Cowpox
Fountain pen
Numbering system
Algebra/Trigonometry
Modern Cryptology
3 course meal (soup, meat/fish, fruit/nuts)
Crystal glasses
Carpets
Checks
Gardens used for beauty and meditation instead of for herbs and kitchen.
- University
- Optics
- Music
- Toothbrush
- Hospitals
- Bathing
- Quilting
- Mariner’s Compass
- Soft drinks
- Pendulum
- Braille
- Cosmetics
- Plastic surgery
- Calligraphy
- Manufacturing of paper and cloth
It was a Muslim who realized that light ENTERS our eyes, unlike the Greeks who thought we EMITTED rays, and so invented a camera from this discovery.
It was a Muslim who first tried to FLY in 852, even though it is the Wright Brothers who have taken the credit.
It was a Muslim by the name of Jabir ibn Hayyan who was known as the founder of modern Chemistry. He transformed alchemy into chemistry. He invented: distillation, purification, oxidation, evaporation, and filtration. He also discovered sulfuric and nitric acid.
It is a Muslim, by the name of Al-Jazari who is known as the father of robotics.
It was a Muslim who was the architect for Henry V’s castle.
It was a Muslim who invented hollow needles to suck cataracts from eyes, a technique still used today.
It was a Muslim who actually discovered inoculation, not Jenner and Pasteur to treat cowpox. The West just brought it over from Turkey
It was Muslims who contributed much to mathematics like Algebra and Trigonometry, which was imported over to Europe 300 years later to Fibonnaci and the rest.
It was Muslims who discovered that the Earth was round 500 years before Galileo did.
The list goes on………..
Just imagine a world without Muslims. Now I think you probably meant, JUST IMAGINE A WORLD WITHOUT TERRORISTS. And then I would agree, the world would definitely be a better place without those pieces of filth. But to hold a whole group responsible for the actions of a few is ignorant and racist. No one would ever expect Christians or White people to be held responsible for the acts of Timothy McVeigh (Oklahoma bombing) or Andreas Brevik (Norway killing), or the gun man that shot Congresswoman Giffords in head, wounded 12 and killed 6 people, and rightly so because they had nothing to do with those incidents! Just like the rest of the 1.5 billion Muslims have nothing to do with this incident!
Sources:
http://www.independent.co.uk/news/science/how-islamic-inventors-changed-the-world-469452.html
http://articles.cnn.com/2010-01-29/world/muslim.inventions_1_hassani-inventions-muslim?_s=PM:WORLD
http://www.ummahedinburgh.co.uk/radio/files/Muslim-Invention-Article.pdf
Always reblog.
THIS.
And once again, learning more from tumblr than school and forcefully accepted understandings of the worldDamn it I was just talking about this
this is probably the best thing i’ve ever reblogged.
Sinatra is great for the micro-style, Rails is not. As long as you stay micro, Sinatra will beat Rails. If you go beyond micro, Rails will beat Sinatra.
DHH, 37signals
“In fact, most people tend to agree that Rails is better suited to big projects whereas Sinatra is a better fit for small micro apps or apis”
This article will guide you to setting up a hello world Rails app with Puma/Nginx and deploy it with Capistrano onto a linux system
“ [T]he most powerful thing a leader can do to foster effective collaboration is to create conditions that help members competently manage themselves. ”
“ Claro que é bom evitar uma posição determinista, a pobreza e a carência afetiva por si só não produzem criminosos. Mas a falta de estrutura familiar, de educação, a exposição maior à violência nas periferias e a falta de políticas públicas para esses jovens os tornam muito mais suscetíveis a cometer pequenos crimes ”