Na początek instalujemy potrzebne biblioteki i narzędzia do skompilowania Rubiego i gemów domyślnie będących w zależnościach Railsów.
sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool nodejs
W przypadku korzystania z gemu ‚pg’ warto doinstalować:
sudo apt-get install libpq-dev
Następnie do pliku
.bashrc w katalogu domowym dodajemy następującą linijkę:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
W terminalu wczytujemy zmieniony
.bashrc za pomocą polecenia
Teraz opcjonalnie możemy stworzyć plik
.gemrc w katalogu domowym i dodać następujące linijki:
gem: --no-ri --no-rdoc
Dzięki temu przy instalacji gemów nie będzie generowana dokumentacja.
rvm use 2.1.2 --default
wskazujemy, że domyślnie chcemy korzystać z Rubiego 2.1.2.
gem do najnowszej wersji:
gem update --system
Warto zainstalować jeszcze Bundlera:
gem install bundler
Do zainstalowania pozostały jeszcze Railsy, co robimy poleceniem:
gem install rails
Po instalacji tworzymy testowy projekt, aby sprawdzić poprawność działania.
rails new projekt
Wchodzimy na stronę: http://localhost:3000, aby zobaczyć działającą aplikację.
I have to admit that I browsed Chapter 8 because it is documentation with some examples for methods.
Actually after all those chapters, the most intriguing are appendices: A (Awful Parts), B (Bad Parts). Most of them I am already familiar with, but it is good to be reminded.
Product page: http://shop.oreilly.com/product/9780596517748.do
Books consists of 2 „parts”. First 6 chapters are mostly introductory. They are answers for following question: what is design pattern? when should I use patterns? what is good structure of design pattern? when and how should I write my own patterns? what can I learn from anti-patterns? Then, there is part about design patterns. I really like Addy’s approach in book: every pattern has diagram (to visualize concept), code (to see real implementation), more examples (when pattern has some „flavours”), references (to read more), discussion (about advantages and disadvantages).
Product page: http://shop.oreilly.com/product/0636920025832.do
Be more security-aware developer/user
As a web developer I learned many things about security in the day-to-day practice. I admit that Hacking Web Apps is very good overview of different ways to hack web app with useful examples. Every chapter covers specific group of hacks (e.g. XSS, CSRF, SQL injection, logic attacks and so on) and countermeasures for them. Examples are pretty useful, ready to check on existing websites (of course those you own ;-)). No matter if you are developer or user, after reading this book you’ll be much more aware of security and privacy issues.
Product page: http://shop.oreilly.com/product/9781597499514.do
Recently I’m trying to upgrade one big project from Ruby 1.8.7 to 1.9.3.
It is bumpy road but here are some thoughts gathered during this time:
1. Make small steps – especially when pushing those changes to production. You’ll never know what are going to break.
2. When changing API endpoint find every call to that endpoint. Record HTTP requests & responses and test them.
3. Improve test coverage. The more good specs you have, the better.
4. Update only necessary gems to get your code working on Ruby 1.9.3.
5. Set up Continuous Integration server to run specs on both Ruby versions: 1.8.7 & 1.9.3.
6. Analyze & understand business logic in code. Use metric_fu, simplecov to know more about code.
7. Delete unused code.
On my OS X 10.8.5 I tried to do specific task: I want to set up FTP server where user has full access to that specific place — he can upload/download and remove files without any problems. After spending some time with this I came to solution to create new user in system and set configuration of
/etc/ftpd.conf to sth like that:
chroot REAL /path/to/directory
To start & stop FTP server I used those commands
sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
Good reference book
In my current project I use JSON heavily as representation when „talking to” servers. I decided to read that book and possibly get some insights how design better APIs.
First three chapters are reminder how HTTP works, its semantics a protocol and what exactly REST stands for. As an example authors use simple microblog service. Consecutive chapters cover hypermedia, the collection pattern, the design procedure and much more.
From my perspective the most interesting part (& most useful) were chapter devoted to the collection pattern and discussion about minimising semantic gap. From my developer’s point of view: using consistent, well-defined structure for JSON responses can simplify parsing and it’s easier to manage.
What I miss in this book are more complex „real-life” examples. I like academic discussions but I like practical examples more :)
Product page: http://shop.oreilly.com/product/0636920028468.do
Cook your iOS apps
I like cookbooks and iOS6 Programming Cookbook is no exception. Author covers a lot of practical knowledge: basics of Objective-C, UI solutions, Xcode features (e.g. Interface Builder, Storyboards), concurrency, gestures, maps, networking, graphics, motion and many more.
Vandad presents material clearly, solutions contains screenshots, schemes, references and code to understand and implement it.
iOS6 Programming Cookbook is good reference book and I can recommend it to every iOS developer/hobbyist.
Product page: http://shop.oreilly.com/product/0636920027683.do
Perl from the ground up
Learning Perl Video is almost 11 hours long lectures covering Perl from the ground up. Randal Schwartz presents concepts and quirks in Perl step by step. Videos are nicely divided by topics. Every video is shorter than 1 hours, so it’s optimal to pay attention to presented material and take break between videos.
Randal presents material clearly, tells some anecdotes but there are not too many examples. Hands-on experience seems to me vital when learning programming language and I checked many code snippets when I watched those lectures.
Product page: http://shop.oreilly.com/product/0636920014430.do
Scala in examples
Scala Cookbook is very practical book. Author presents every small example as problem to solve and possible solutions with discussion. I learned syntax for some concepts (like pattern matching, auxiliary constructors, executing external commands, lazy collections) I’ve seen in other programming languages. The book helped me better understand how implicits work.
Moreover, there are available bonus chapters providing recipes about XML, XPath, testing, debugging and Play framework.
Scala Cookbook is comprehensive book. It provides practical solution for typical developer’s problem and I recommend this book everybody interested in Scala.
Product page: http://shop.oreilly.com/product/0636920026914.do