1 2 3 4
require 'rubygems' require 'spec' ...
Ruby On Code to detect the web browser
by dcadenas.blogspot.com,
August 29, 2008 02:10
1 2 3
def test_web_browser() request.env["HTTP_USER_AGENT"].gsub(/\W/, '') end
Ruby On Code to detect the web browser
by chrismo,
August 29, 2008 01:46
Whoops - shorter regexp. I ...
1 2 3 4
def test_web_browser() return translate_user_agent(request.env["HTTP_USER_AGENT"]) end ...
Ruby On Code to detect the web browser
by chrismo,
August 29, 2008 01:43
Here's a more thorough vers...
1 2 3
def test_web_browser() request.env["HTTP_USER_AGENT"].gsub(/[^A-Za-z0-9]/, '') end
Ruby On Code to detect the web browser
by chrismo,
August 29, 2008 01:42
I submitted this earlier, b...
1 2 3
HTMLElement.prototype.disablehandlers = function () { ...
JavaScript On Setting focus after alert
by Arvid Jakobsson,
August 29, 2008 00:40
This might work, haven't te...
1 2 3
def user_agent_name user_agents = { ...
Ruby On Code to detect the web browser
by nachokb.blogspot.com,
August 28, 2008 22:25
Nicolás' first solution is ...
1 2 3 4
if __name__ == "__main__": try: if options.input_file: ...
Python On Your average file filter...
by Malte,
August 28, 2008 22:17
I agree with most changes h...
1 2 3 4
def test_web_browser ["Firefox/3", "Firefox/2", "MSIE 6", "MSIE 7", "Opera"].detect do |agent| request.user_agent =~ Regexp.new(agent) ...
Ruby On Code to detect the web browser
by foca,
August 28, 2008 22:07
Er, sorry, I rushed to post...
1 2 3 4
def test_web_browser %w(Firefox/3 Firefox/2 MSIE\ 6 MSIE\ 7 Opera).detect do |agent| request.user_agent =~ Regexp.new(agent) ...
Ruby On Code to detect the web browser
by Adam,
August 28, 2008 22:02
@Nicolás - I don't think th...
1 2 3 4
# Joe's solution doesn't work. It will always return either "Opera" or nil, you need to put "return" # at the beginning of each line. *This* is one of the cases where the return statement *is* required, # as you want to interrupt the flow of the code and return "early" instead of returning the return ...
Ruby On Code to detect the web browser
by Nicolás Sanguinetti,
August 28, 2008 21:57
Never. *Ever*, detect the u...
1 2 3 4
def test_web_browser() ua = request.env["HTTP_USER_AGENT"] "Firefox3" if ua[/Firefox\/3/]=="Firefox/3" ...
Ruby On Code to detect the web browser
by Joe Grossberg,
August 28, 2008 19:05
A few additional points:
*...
1 2 3 4
def test_web_browser catch(:match) do ["Firefox/3", "Firefox/2", "MSIE 6", "MSIE 7", "Opera"].each do |ua| ...
JavaScript On Setting focus after alert
by danielks,
August 28, 2008 13:08
I disable the events becaus...
1 2 3 4
if __name__ == '__main__': try: if options.input_file: ...
Python On Your average file filter...
by Dave Cridland,
August 28, 2008 07:56
Well, the finally block isn...
Ruby On simplify multiple gsub
by John Sietsma,
August 28, 2008 01:45
It depends what you're afte...
1 2 3 4
result = "" data.each_byte { |ch| result << ( subs[ch.chr] || ch ) ...
Ruby On simplify multiple gsub
by John Sietsma,
August 27, 2008 05:29
Use the speed of the dictio...

@chrismo: check that your c...