?!, IRC #ruby, >> and eval.in

Want to know what the “?!” bit in this line means in Ruby?

          if command[0] == ?!

To work it out, in IRC #ruby, use:

>> ?!

which executes it via eval.in. E.g.

http://eval.in/31279

In a nutshell, if you don’t want to go through all that, here’s what ?! does:

In newer Ruby’s:

?! => “!”

In older Ruby’s, ? used to return the ASCII code. So:

?! would return the ASCII code for ! (i.e. 33). 

Nowadays you’d do it using: 

?!.ord

which returns 33.

? is a literal in Ruby.

how do you change the syntax highlighting in Pry? Use Pry theme

Colours in Pry not quite how you want them?

Here’s how to change them:

To get rid of the warning message create a pryrc file and add a theme, e.g.

https://github.com/kyrylo/pry-theme

On the Mac, another alternative is to just change your Terminal preferences.

Questions on pry?

Hang out at #pry on irc.freenode.net

Automatic Post Tagger

Not quite as awesome as an automatic post categoriser but still pretty handy:

http://wordpress.org/extend/plugins/automatic-post-tagger/

 

Cinch – super simple IRC bots

Here’s an example of a simple IRC bot using Cinch:

require ‘cinch’

bot = Cinch::Bot.new do
configure do |c|
c.server = “irc.freenode.org”
c.channels = [“#cinch-bots”]
end

on :message, “hello” do |m|
m.reply “Hello, #{m.user.nick}”
end
end

bot.start

Just install using:

gem install cinch

https://github.com/cinchrb/cinch#readme

Getting Started (in Markdown): https://github.com/cinchrb/cinch/blob/master/docs/getting_started.md

and the docs: http://rubydoc.info/gems/cinch/frames

Other IRC Bot frameworks: https://www.ruby-toolbox.com/categories/irc_bots