Grabbing a result from Google with Nokogiri

1. Install Nokogiri

gem install nokogiri

2. and use it like this

require 'open-uri'
require 'nokogiri'
require 'cgi'

url = "http://www.google.com/search?q=#{CGI.escape(query)}"
res = Nokogiri::HTML(open(url)).at("h3.r")

title = res.text
link = res.at('a')[:href]
desc = res.at("./following::div").children.first.text

These help:
Nokogiri tutorials: http://nokogiri.org/tutorials
and: http://stackoverflow.com/questions/14912392/how-do-i-parse-google-image-urls-using-ruby-and-nokogiri

How to develop / migrate apps for the iPhone 5

1. Set a 4-inch launch image for your app called Default-568h@2x.png

This is how you get 1136 px screen height (without it, you will get 960 px with black margins on top and bottom).

This should be enough.

2. If not, adjust your view layouts with proper auto resizing masks or look into Auto Layout if you only want to support >= iOS 6.

If you need to some specific resizing then check the height of [[UIScreen mainScreen] bounds] (or applicationFrame, but then you need to consider status bar height if it's present) as there seems to be no specific API for that.

http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution

 

Let an iPhone user know they can access your content via their device

Here's how:

1. Check if the user-agent matches an iPhone/iPod Touch

2. Check for an appInstalled cookie

3. If the cookie exists and is set to true, set window.location to your-uri:// (or do the redirect server side)

4. If the cookie doesn't exist, open a “Did you know this site has an iPhone application?” dialog with a “Yes, already got it”, “No, let's try it” or a “Leave me alone” button.

http://stackoverflow.com/questions/1108693/is-it-possible-to-register-a-httpdomain-based-url-scheme-for-iphone-apps-like/1109200#1109200

Pry – Part 5 – Pry at runtime

Assuming you’ve halted the runtime at the point where you invoked the Pry REPL (see Pry – Part 4), you should have the Pry REPL.

A. The main ways of navigating the stack are the ls and cd commands.

ls shows you methods, constants and variables.

cd moves you into the new context (object or scope).

1. ls

 ls -h
Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
       ls [-g] [-l]

ls shows you which methods, constants and variables are accessible to Pry. By
default it shows you the local variables defined in the current shell, and any
public methods or instance variables defined on the current object.

The colours used are configurable using Pry.config.ls.*_color, and the separator
is Pry.config.ls.separator.

Pry.config.ls.ceiling is used to hide methods defined higher up in the
inheritance chain, this is by default set to [Object, Module, Class] so that
methods defined on all Objects are omitted. The -v flag can be used to ignore
this setting and show all methods, while the -q can be used to set the ceiling
much lower and show only methods defined on the object or its direct class.

    -m, --methods               Show public methods defined on the Object (default)
    -M, --instance-methods      Show methods defined in a Module or Class
    -p, --ppp                   Show public, protected (in yellow) and private (in green) methods
    -q, --quiet                 Show only methods defined on object.singleton_class and object.class
    -v, --verbose               Show methods and constants on all super-classes (ignores Pry.config.ls.ceiling)
    -g, --globals               Show global variables, including those builtin to Ruby (in cyan)
    -l, --locals                Show hash of local vars, sorted by descending size
    -c, --constants             Show constants, highlighting classes (in blue), and exceptions (in purple).
                                Constants that are pending autoload? are also shown (in yellow)
    -i, --ivars                 Show instance variables (in blue) and class variables (in bright blue)
    -G, --grep                  Filter output by regular expression
    -h, --help                  Show this message.

2. cd

> cd -h
Usage: cd [OPTIONS] [--help]

Move into new context (object or scope). As in UNIX shells use `cd ..` to go
back, `cd /` to return to Pry top-level and `cd -` to toggle between last two
scopes. Complex syntax (e.g `cd ../@x/y`) also supported.

cd @x
cd ..
cd /
cd -

https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope

    -h, --help      Show this message.

B. Apart from navigating state, there are two other commands that are very useful, show-method and show-doc.

1. show-method
This shows the source for a method or class.

> show-method -h
Usage:   show-source [OPTIONS] [METH|CLASS]
Aliases: $, show-method

Show the source for a method or class. Tries instance methods first and then
methods by default.

show-source hi_method
show-source hi_method
show-source Pry#rep     # source for Pry#rep method
show-source Pry         # for Pry class
show-source Pry -a      # for all Pry class definitions (all monkey patches)
show-source Pry --super # for superclass of Pry (Object class)

https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method

    -s, --super             Select the 'super' method. Can be repeated to traverse the ancestors
    -l, --line-numbers      Show line numbers
    -b, --base-one          Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)
    -a, --all               Show all definitions and monkeypatches of the module/class
    -h, --help              Show this message.

2. show-doc shows the documentation by running the method comments through rdoc or yard

> show-method -h
Usage:   show-source [OPTIONS] [METH|CLASS]
Aliases: $, show-method

Show the source for a method or class. Tries instance methods first and then
methods by default.

show-source hi_method
show-source hi_method
show-source Pry#rep     # source for Pry#rep method
show-source Pry         # for Pry class
show-source Pry -a      # for all Pry class definitions (all monkey patches)
show-source Pry --super # for superclass of Pry (Object class)

https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method

    -s, --super             Select the 'super' method. Can be repeated to traverse the ancestors
    -l, --line-numbers      Show line numbers
    -b, --base-one          Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)
    -a, --all               Show all definitions and monkeypatches of the module/class
    -h, --help              Show this message.

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:

[~]$ gem install pry-theme
[~]$ pry
Can't find `Pry.config.theme` definition in your `~/.pryrc`.
Using "pry-classic" theme now.
[1] pry(main)> pry-theme -l

[github]
Based on github theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

[monokai]
Based on Wimer Hazenberg's theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

* [pry-classic]
Default Pry theme
---
class Theme
  def method
    @ivar, @@cvar, lvar = 10_000, 400.00, "string"
  end
end

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

Pry.config.theme="pry-modern"

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