Skip to content

Instantly share code, notes, and snippets.

helpers do
def mobile_request?
mobile_user_agent_patterns.any? {|r| request.env['HTTP_USER_AGENT'] =~ r}
end
def mobile_user_agent_patterns
[
/AppleWebKit.*Mobile/,
/Android.*AppleWebKit/
]
end
/* This is a small patch to make callbacks work - I'll con Mr Speaker
into getting some proper scm on this sucker soon */
/*
Do 1UP style notification
version 0.1
As inspired by Jeremy Keith post: http://adactio.com/journal/1626/
*/
(function($) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
.wrapper { border: 1px solid black; }
.wrapper h3 a { float: right; width: auto; }
</style>
<!--[if lte IE 7]>
<style>
# cut out of a real app, so a bit bastardised and probably wouldn't run as it's own Sinatra app, but I think it pretty much covers the entire process of Twitter OAuth
require 'sinatra'
gem 'oauth'
require 'oauth/consumer'
module Twitter
class Application < Sinatra::Application
enable :sessions
# assume we're passing the values from the file below as arguments to the following:
# WTF is name always nil?
def filtered_filenames(paths)
paths ||= []
paths.collect { |path|
path[/.+\/(.+)$/, 1]
}.reject { |name|
name == "index.haml"
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>IE float bug</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<style type='text/css'>
body {
font-family: Helvetica, sans-serif; }
#container {
# So this is in my controller:
@items = Dir.glob("views/*/*")
# Its contents look like this:
# views/controls/actions.haml
# views/controls/buttons.haml
# views/controls/formForge.haml
# views/controls/hide-actions.haml
def f(ra,n)
r=0
ra.each {|x| r+=1 if x.include? n}
r
end
@lachlanhardy
lachlanhardy / .gitignore
Created August 5, 2008 12:06
Twitterific Power User settings
privatefilter.bash