Hi, I'm Łukasz Niemier, 21 years old Ruby programmer from Poznań.

 

Easy full-text search with PostgreSQL and Rails

mikamayhem:

Solr, Sphinx, ElasticSearch are some of the big players when it comes to full-text search on the web: they’re great products for sure, but you need to add yet another server to your stack if you plan to use one of them.

But if you’re already using (or willing to use) PostgreSQL as your rails app…

Off-side rule?

Some days ago I have started thinking about “why I hate languages with blocks by indentation while I love Haml, Slim or Sass?”. Finally I found answer:

HTML is a tree structure, my code is not

What does it mean? That when I write my HTML I can think about it as a drawing a DOM tree. We have a root element <html> and then we create its children, and children of his children, and children of these children, so on… We can display this like tree, i.e.

DOM tree example image

So if we write our code using off-side rule, then we can display our tree in plain text

html
  head
    link href='style.css'
    meta encoding='utf-8'
    meta author='Łukasz Niemier'
  body
    div#header
    div#content
    div#footer

But we can’t do this with code, especially with asynchronous languages like JavaScript (and it off-side rule preprocessor CoffeeScript). There is no tree which can be display. In most cases we cannot predict flow of our JS code as most of it is written as callbacks and depends on user or server reaction. It only force indentation to be used.

But I am programmer and I know that indentation is important. I don’t always have time to create it by myself so in curly or keyworded languages I can use some external help. In Vim, i.e., there is nice functionality that after I press =G it will reindent file from line with cursor to end of file.

So conclusion is that I love writing my code indented, but not when I forced to, as my code isn’t tree and I cannot predict it flow (in CoffeeScript). In the other hand I love off-side HTML preprocessors as there I have my DOM tree displayed directly in my editor.

Go fishing

When I began using *nix 7 years ago (I have started with Ubuntu, now switched to Arch Linux) my default shell was bash. I don’t even know at the beginning that there are others shells. As I has been getting better and better in working with CLI I’ve started thinking how to get even better and how to make my work easier. Then I found zsh. It is quite awesome. Has a lot of impressive stuff like:

  • spell checking
  • case-independent suggestions
  • is more customizable
  • is POSIX compatible
  • and has a lot more great stuff

But after that I on some screencast (to be specify - this one) I have seen fish I get love in it. It isn’t POSIX so I need get used to it, but now I cannot work without it. Why?

Syntax coloring

First impression began when you discover that fish is coloring commands as you input. It look awesome and also is great help when you make a typo. You can prefectly see where it is.

Simpler syntax

When I was writeing sh scripts I never remember how to write conditions and loops. It was quite hard for me to remember that I can or cannot write if and then in one line without semicolon. Also if is closed with fi, case with esac and for with… done, wut?

Built-ins reduced to minimum

In bash and zsh we have enormous amount of built-ins: test, [[, regexps, arithmetic via $((...)), variable modification via ${var_name##.}, etc. In fish it was reduced to needed minimum. If we need to test something, we use [ command, compute some arithmetic expression - bc or dc, use regexp - grep, awk, sed, perl, etc. In bash it usually take a lot of time to run another process due it’s design, but fish use threads for different processes (not time-wasting fork) so it is fast and you don’t see any delay.

Variable is an array

In bash (and zsh) you have difference between scalar and vector (array) variables. The second one need to be enclosed in () and referencing to it’s elements was quite ugly ${arr[0]}.

var=some_value
arr=(a b c)

Also for beginners it can be hard to remember that there cannot be any whitespace before and after assignment sign, so:

var=data # work well
var = data # doesn't work

Fish don’t have scalars, everything is an one based array and one-element array can be treated as an scalar, also to set variable you use built-in command, not the assignment sign (which is quite confusing, but is more powerful than POSIX one).

set var some_value
set arr a b c

Booth above commands create local variable named by first argument, and containing the rest. As a good shell command, set has some flags that modify it’s behaviour.

Easy configuration and awesome help

Fish is created to be friendly for developers. It work on 256-colour terminals with nice colours and has great documentation available through help command.

Summary

If you are not afraid of changes, and want to check something new and awesome - go fish :)

giant robots smashing into other giant robots: Using rbenv to manage rubies and gems

thoughtbot:

We recently switched from RVM to rbenv for managing Ruby versions.

“Make each program do one thing well.” - Tenet #2 of The UNIX Philosophy

Why consider switching to rbenv?

The UNIX philosophy espouses an approach to software in which small, sharp tools are designed and used to address…

netguru:

We have fallen madly in love with Ruby some time ago. Take a go yourself but… look out, it’s highly addictive! Well, you have been warned… Now… Below you’ll find a handy collection of Ruby resources. Valentine’s Day sounds a good date for kicking off with Ruby.

Codecademy - http://www.codecademy.com/tracks/ruby
Hackety Hack - http://hackety.com/
LearnStreet - http://www.learnstreet.com/lessons/study/ruby
Learn Ruby The Hard Way - http://ruby.learncodethehardway.org/book/
Nettuts+ Ruby for Newbies Sessions - http://net.tutsplus.com/sessions/ruby-for-newbies/
ShowMeDo Ruby Videos, Tutorials &amp; Screencasts -http://showmedo.com/videotutorials/ruby
Try Ruby -http://tryruby.org
MacRuby - http://macruby.org/
Ruby Documentation - http://www.ruby-lang.org/en/ and http://ruby-doc.org
Ruby Kickstart - http://ruby-kickstart.com 
Ruby Koans - http://koans.heroku.com/
Ruby Monk – http://rubymonk.com/
Ruby Online Quiz/ Exam - http://rexaminator.com/
Ruby Regex – http://rubular.com/
Ruby Study Hall - http://www.rubystudyhall.com/
Ruby Quiz - http://rubyquiz.com/
Why’s Guide to Ruby - http://mislav.uniqpath.com/poignant-guide/
Ready for more? Take a look here ;D

Try Ruby, just do it!

netguru:

We have fallen madly in love with Ruby some time ago. Take a go yourself but… look out, it’s highly addictive! Well, you have been warned… Now… Below you’ll find a handy collection of Ruby resources. Valentine’s Day sounds a good date for kicking off with Ruby.

Ready for more? Take a look here ;D

Try Ruby, just do it!

Anonymous asked
Can You tell me what theme You're using in examples of code at this website?

Highlight.js with Monokai theme.