SublimeText

Spell check in SublimeText

I am working on my Master Thesis using LaTeX and SublimeText.

Today, I found out that SublimeText allows you to check spelling. To enable spell-check: click F6 or go to View->’Spell Check’.

When spell-check is enabled, it displays red squiggles below the misspelled words. By right click on misspelled word you can correct the misspellings. You can also ignore it for all other occurrences of specific word (useful e.g. for Software Projects names).

SublimeText spell check correct

The spell check is performed based on chosen language/dictionary. You get two English dictionaries (en_US and en_GB) along with SublimeText installation. You can find more dictionaries on github repository: SublimeText / Dictionaries (check readme for installation instructions). To change dictionary: go to View->Dictionary.

SublimeText spell check dictionary

SublimeText is not only lightweight IDE. It can also serve as nice text editor.

I really like SublimeText and if you are not using it so far you should try it! There is nice series of posts Sublime is Sublime. Greg Young describe how to configure and take advantage of SublimeText as .NET developer (from color schemes to run unit tests, through git integration).


LaTeX with SublimeText and Skim

SublimeText with LaTeX Tools plugin

Recently I started writing my Master Thesis. I decided I will do it in LaTeX.

I work most of the time on MacBook. The most popular LaTeX distribution for Mac is MacTeX (for Windows: MiKTeX or TeXlive). Once I had this installed I needed editor. First I was using TeXworks, but it is not very decent environment. Nice thing about it is the built-in PDF viewer. Every time I rebuild the document it refresh generated pdf. However, it’s hard to manage documents with more than one .tex file. My Master Thesis consists multiple files and I end up editing files in SublimeText and building pdf with TeXworks. Not cool!

Today, one friend of mine showed me application, which detects .pdf updates automatically: Skim. I have also found LaTeXTools plugin for SublimeText. It allows to build .tex document with CMD+B (Mac) or CTRL+B (Windows/Linux). Moreover, Skim can be integrated with SublimeText in such a way that it checks for updates every time, you perform build in SublimeText.

LaTeX + SublimeText + Skim setup

  1. Install LaTeX distribution (for Mac OS X: MacTeX, for Windows: MiKTeX or TeXlive).
  2. Install SublimeText
    • Optionally: Install SublimeText Package Control (if you didn’t do that already) – it will be easier to install LaTeXTools package.
  3. Install LaTeXTools plugin. With SublimeText Package Control installed: click CMD+SHIFT+P (on Mac) or CTRL+SHIFT+P (Win/Linux). More details can be found here.
    • Mac users: You may need to install ‘latexmk’: sudo tlmgr install latexmk (more info can be found in LaTeXTools README).
  4. Install Skim (for Windows users: check Sumatra PDF).
  5. In Skim: go to Preferences->Sync and set ‘preset’ to SublimeText.

Skim preferences

After that you just need to build LaTeX document in SublimeText with CMD+B (Mac) or CTRL+B (Win/Linux). Open the generated .pdf in Skim, then every time you rebuild it in SublimeText – it will be refreshed automatically.

If you have multiple documents add %!TEX root = <master file name> at the beginning of every file.

It is much more convenient than using SublimeText and TeXworks for rebuilding pdf. Additionally, TeXworks’ PDF viewer is not very decent.

For LaTeX editing, I have found also TeXstudio. It looks good, but I didn’t test it so far.


The Story of dotNetConfPL

It is all about people and cooperation!

Long story short

April 25-26 – dotNetConf took place, online conference for .NET developers, organized by Scott Hanselman and Javier Lozano

April 27 – I text Pawel Sawicz, that we can organize something similar with Polish speakers and name it dotNetConfPL, he said: “it’s a good idea”. (motivation++)

April 28 – Pawel told me that Michal Franc is also interested and we created google doc to write down ideas and todos. (motivation++)

May 24 – We ask Scott Hanselman whether we can use dotNetConfPL as a name of the conference (because it’s very similar to name of his conference). He and Javier Lozano confirmed in the same day and wished us good luck. (motivation++)

June 6 – We sent e-mail to Maciej Aniserowicz, with a proposition to be a speaker at our conference.

June 7 – He responded: yes (we had first speaker!). (motivation++)

After that, we were inviting rest of speakers and most of them accepted our invitations. We really appreciate this, because they didn’t get any benefits from that.

July 14 – We announced dotNetConfPL on facebook and gain almost 50 registrations for the event within 1 hour! (motivation++)

The week of the conference

A few days before the conference we did initial testing with speakers. To check, whether their microphone, resolution, etc. is set properly. Sometimes we had issues with Google Hangouts. Solution for that was simply disconnect and create a new ‘hangout’. Our initial plan was to make only 1 hangout for entire conference, because each one has different link. We wanted to avoid forcing people to refresh the website or use of SignalR. However after that, we decided it will be better (safer and more flexible) to create separate ‘hangouts’ for each speaker and update link using SignalR.

Website for conference was created in ASP.NET MVC framework. The SignalR+CounchDB feature was implemented day before conference. After the conference I found interesting file in our solution:

dotnetconfpl - code

It is worth to mention that during the conference I was in Manhattan, KS, while Pawel and Michal were in Wroclaw, Poland. The image below, is my Command Center. ThinkPad X220 is connected with 2 monitors and through it I am connected to speakers. On MacBook I am connected via Skype with Michal and Pawel. On Surface I have live streaming (about 30 seconds delay) to be sure everything is working fine. The only issue I had, was not enough ears. I had only two: in one I was connected to the speaker, second – Michal and Pawel, and if I had third, I would be able to track the live streaming 🙂

dotNetConfPL - center

Sessions

All sessions were in Polish. If you don’t speak Polish, you can mute the sound, play this in background and watch 🙂 You won’t get full experience, but still can get a lot from each session!

What is cool, all of them are for beginners and non-beginners in the same time. Which means, everybody will learn something from each session. Additionally: all of them are in HD (720p). Google enabled it by the end of August.

Maciej Aniserowicz: Unit testing in .NET

Maciej shows TDD live example. From nothing to well-tested communication with external API.

Filip Wojcieszyn: scriptcs – C# on diet

Filip shows how to use C# in Console and/or in SublimeText.

Jakub Gutkowski: JavaScript for C# developer

Jakub shows differences between C# and JavaScript, and language flavors every developer should be aware of, which may cause hard to track bugs.

Tomasz Janczuk: Node.js, Edge.js and Windows Azure

This session blew my mind (and not only mine). Edge.js allows you to mix Node.js, C#, F#, IronPython, PowerShell and T-SQL code in one file!

Maciej Grabek: Windows Phone 8 Tips & Tricks

Maciej shows set of useful(8) tricks for WP8 developers. From displaying helper-grid during development, to how to get more ratings for your app.

Summary

Everything went well. We didn’t have any problems with streaming (thanks Google Hangouts) and website (thanks Windows Azure and SignalR). I noticed that sometimes, on my Surface RT, IE11 wasn’t refreshing the link. But, come on…it’s IE, so we can ignore it 🙂

We had room on JabbR for discussion and ask questions to speakers. For a few minutes, even David Fowler (one of SignalR developers) visited it.

I am very glad that many people attended the conference. We had more than 600 registrations, almost 100 people in JabbR room and around 100-200 online viewers. But many people were watching the conference together, and in this case 1 online viewer = more that 1 physical viewers.

dotNetConfPL - atCompany
dotNetConfPL - pizza

Thank you very much for all speakers! You did a great job guys, all sessions are international level!
Thanks to Michal and Pawel for organizing this conference with me.
Thanks to Scott Hanselman and Javier Lozano for inspiration.
And…thank you very much for all of you who were watching the conference and spreading the news!

EDIT:
Short list of tools/technologies we were using for the conference:

  • Google Hangouts
  • ASP.NET MVC
  • SignalR
  • CouchDB
  • Windows Azure (to be able to scale the instance, depends on the number of users)
  • Google Docs (as a database for most important information)
  • Trello (for tasks management)
  • AppHarbor (as test server)

Ninja Rails Developer

Warning: this configuration was tested only on MacOS X.

To create default project in Rails we just need to run command:

rails new my_app

However it creates project without many useful gems. I found nice Gem-set and some configuration hacks in Michael Hartl’s tutorial.

Instead of standard test framework (TestUnit) he use RSpec (which is more popular among Rails developers). To generate project without standard test, run command:

rails new my_app --skip-test-unit

Then use his Gemfile (this link is kept up to date). Copy it a paste into my_app/Gemfile. I recommend to uncomment everything (to use all Gems from the file).

Once Gemfile is modified, you need to install gems:

bundle install

Then you can run RSpec test:

bundle exec rspec

You may need to point the tests’ directory:

bundle exec rspec rspec/

It would be nice to run them with just ‘rspec’ command. To do that we need to run following commands (if we used RVM to install Rails):

rvm get head && rvm reload

cd ~/projects/my_app

bundle install --without production --binstubs=./bundler_stubs

After those steps you should be able to run RSpec with:

rspec

You should get a warning, that to maintain this possibility you need to add following line to ~/.bash_profile if it exists, otherwise add it to ~/.bash_login:

source ~/.profile

Michael Hartl’s Gem file contains ‘guard’. It allows us to run RSpec test each time, when we change some file (after save).

To initialize guard (if all above steps are performed, otherwise you need to add ‘bundle exec ‘ at the beginning):

guard init

It creates Guardfile in main project directory, which specify when tests should be run (which files should be monitored). To run guard:

guard

The last improvement is use the test server Spork. It allows to run tests faster. Without Spork, RSpec needs to reload entire Rails environment before run the tests (in each run). Spork loads the environment once, and then maintains a pool of processes for running future tests. Unfortunately it works only on POSIX systems (which means: doesn’t work on Windows).

To setup spork run:

spork --bootstrap

Then change spec/spec_helper.rb file to something like that:

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  RSpec.configure do |config|
    config.mock_with :rspec
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.use_transactional_fixtures = true
    config.infer_base_class_for_anonymous_controllers = false
  end
end

Spork.each_run do
  # This code will be run each time you run your specs.
end

You also need to configure RSpec to automatically use Spork. To do that, modify .rspec file:

--color
--drb

To run Spork:

spork

You can test difference between running tests with and without spork.

time rspec

In my case it was 4.821s without Spork, and 0.784 with Spork.

The disadvantage of Spork is that after e.g. changes in database we need to restart it.

The screencast showing advanced setup by Michael Hartl is available for free here. If you use SublimeText (as I do), you can follow this screencast to adjust it for Rails development. After that you will be able even to run tests from SublimeText!


Getting started with Ruby on Rails

Ruby on Rails logo

Recently I decided to learn Ruby on Rails. When you start learning a new technology you are always looking for the best available materials (to learn as efficient as possible). I did the same (using Google and StackOverflow). Fortunately I found The Best Way to Learn Ruby on Rails and I followed the recommended steps. With small modifications (extensions).

First of all I extended first step. Instead of just going through “Try Ruby” exercises I also read first chapter of Seven Languages in Seven Weeks (which is about Ruby). It was very good move, because this book is written in the way to show the flavors of language by comparison with others. I am a .NET guy, who was coding in PHP, C++, Java and Python before. Because of that I was more interested in the differences between Ruby and these languages, than in programming from ground up. I also reviewed (not read) Humble Little Ruby Book. It is a little bit more deep, but it gives you solid Ruby basics.

I was working with Rails on Windows and on Mac. Installing on Windows is very easy when you use RubyInstaller. There is also version for Mac. However on Mac you can also install Rails using RVM. In that case I recommend you installation screncast by Michael Hartl. On Windows I used RubyInstaller, but on Mac I took advantage of Michael Hartl’s screencast. Additionally you may also need SQLite Database Browser to browse your database easily. I did not know about it at the beginning and I was using rails dbconsole. Browsing with SQLite Database Browser is much more comfortable!

When I had Rails installed I went through Jeffrey’s Introduction to Rails. During that I tried to follow him, by writing code on my machine, but many times he was too fast. I needed to pausing video very often and even scrolling back to see written command (he was changing screens to quickly). Anyway it was very nice introduction and I recommend it. But you can skip rewriting and trying code he is writing. Just watch it to get a flavor of Rails.

After that I went through Rails for Zombies tutorials. I was very lucky, because Code School had promotion in May 18-19, and they provided Rails for Zombies 2 for free in these days. These tutorials are very solid. The exercises force you to learn by typing, because you cannot proceed to next level, until you do not finish all tasks.

Agile Web Development with Rails cover

With all basics gained as described above I started a book: Agile Web Development with Rails. I really like this book. It has 3 parts:

  • Getting started (Rails installation, create first app, quick Rails architecture overview)
  • Building application (tutorial)
  • Rails in Depth

The longest part of the book is the tutorial(2nd). Through this part you are creating an complete application exploring different Rails features. Unfortunately this book is a little bit outdated. Authors use ruby version 1.8.7 and Rails 3.0.0. I installed most recent versions: ruby 1.9.3p392 and Rails 3.2.13. Sometimes you need to fix the code (e.g. Chapter 11 – Task F: Add a Dash of Ajax). During that I found Ruby on Rails documentation very useful.

The last part is going deep into Rails. I really recommend this part! It is not only about Rails, but also about Web Applications and MVC architecture in general: how browser works, how requests are handled by Rails app, session, cookies etc.

When I was in the middle of book I was a little bit angry (because it is outdated) and I switched to Ruby on Rails tutorial by Michael Hartl, which is strongly recommended on StackOverflow. Well…guys at SO are right. This is really good piece of knowledge not only about Rails, but also about using git, css, Bootstrap and Web Development in general. I really enjoyed it! If you do not want to buy videos, you can just read the free book (it is the same content as in videos and more). There are also nice videos describing advanced setup for Rails development on Mac and SublimeText configuration for Rails. Actually this tutorial covers Rails development from A to Z.

As a summary to the book and Michael Hartl’s tutorial I reviewed Rails Guides. It is a nice overview for most important rails features. Can be also used as a reference. Some of the RailsCasts are also useful.

I wanted to try a few different tutorials/books to see different approaches. E.g. Michael Hartl use rspec for unit tests, but the authors of Agile Web Development with Rails are using rails testing framework.

My adventure with Ruby (on Rails) lasts almost two months. Now I can admit that ROR is a very powerful and developer friendly framework. It contains many features, which are already grabbed by ASP.NET (e.g. migrations, bundling). What was surprising for me, you do not need IDE to develop Rails apps. I use SublimeText2 (awesome editor!) and it is really enough. Some Rails developers use VIM or Emacs. Of course there are some IDEs such as RubyMine or Aptana Studio. I tried both. RubyMine seems to be pretty cool…but I stick with SublimeText. Additionally, during Rails development you spend lot of time with console (to create/run/undo migrations, create models/controllers, run tests etc.).

If you want to start Rails development, my recommended steps are:

You might also find these tools/resources useful:

What I like in Ruby on Rails? The syntax, convention over configuration and lots of implemented features in the framework layer. Moreover: Rails are just cool.