⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
require 'builder' | |
class Sitemap | |
STATIC_URLS = ['/home/about', | |
'/home/help', | |
'/home/contact_us', | |
'/home/terms'] | |
class << self |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
# .bashrc | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
## User specific aliases and functions | |
export COLUMNS |
class String | |
def to_bool | |
return true if self == true || self =~ (/(true|t|yes|y|1)$/i) | |
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i) | |
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") | |
end | |
end |
require 'rubygems' | |
require 'anemone' | |
#!/usr/bin/env ruby | |
# To use the anemone gem to crawl website make sure these are installed: | |
# 1) Redis (>= 2.0.0) | |
# 2) MongoDB | |
# 3) TokyoCabinet | |
# 4) PStore | |
# crawl website for specific info for Hazzo marketing purposes |
input { | |
exec { | |
type => "dstat" | |
command => "dstat -cdngypms --nocolor 1 0" | |
interval => 13 | |
} | |
exec { | |
type => "apache-benchmark" |
#Mobile Device Detection via User Agent RegEx
Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.
I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.
The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".
Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(
Number::pad = (digits, signed) -> | |
s = Math.abs(@).toString() | |
s = "0" + s while s.length < digits | |
(if @ < 0 then "-" else (if signed then "+" else "")) + s | |
Date.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] | |
Date.weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] | |
Date.formats = | |
"a": -> Date.weekdays[@getDay()].substring(0, 3) |