Skip to content

Instantly share code, notes, and snippets.

View vincentpaca's full-sized avatar

Vincent Paca vincentpaca

View GitHub Profile
@vincentpaca
vincentpaca / mime_types.rb
Created November 9, 2011 18:40
Mime Types
Mime::Type.register_alias "text/html", :mobile
@vincentpaca
vincentpaca / application_controller.rb
Created November 10, 2011 10:03
Application Controller
before_filter :prepare_for_mobile
private
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /Mobile|webOS/
end
@vincentpaca
vincentpaca / mime_types.rb
Created November 10, 2011 10:04
Mime Types w/ Multiple aliases
Mime::Type.register_alias "text/html", :mobile
Mime::Type.register_alias "text/html", :iPad
<!DOCTYPE html>
<html>
<head>
<title>Mobile</title>
<%= stylesheet_link_tag "/jqtouch/jqtouch.css", "/jqtouch/themes/jqt/theme.css" %>
<%= javascript_include_tag "/jqtouch/jquery-1.4.2.min.js", "/jqtouch/jqtouch.js", "mobile" %>
<%= csrf_meta_tag %>
</head>
<body>
<div class="home">
@vincentpaca
vincentpaca / mobile.js
Created November 12, 2011 10:25
Mobile
$.jQTouch({});
@vincentpaca
vincentpaca / log
Created January 2, 2012 07:58
Ruby 1.9.3p0 Rails 3.1.3 Rake 0.9.2.2 breaks on rake db:migrate
pax@ubuntu:~/projects/missionhub$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
pax@ubuntu:~/projects/missionhub$ rails -v
Rails 3.1.3
pax@ubuntu:~/projects/missionhub$ rake -V
rake, version 0.9.2.2
pax@ubuntu:~/projects/missionhub$ bundle exec rake db:migrate --trace
DEPRECATION WARNING: Yajl's JSON gem compatibility API is going to be removed in 2.0
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
@vincentpaca
vincentpaca / config.yml
Created January 28, 2012 22:21
Bitly config
development:
bitly_username: yourusername
bitly_key: yourkey
@vincentpaca
vincentpaca / bitly.rb
Created January 28, 2012 22:23
Bitly initializer
require Rails.root.join('config','initializers','load_config')
Bitly.use_api_version_3
BITLY_CLIENT = Bitly.new(APP_CONFIG['bitly_username'], APP_CONFIG['bitly_key'])
@vincentpaca
vincentpaca / gist:1696052
Created January 28, 2012 22:41
Bitly test
1.9.3p0 :002 > BITLY_CLIENT
=> #<Bitly::V3::Client:0xb653398 @default_query_opts={:login=>"yourusername", :apiKey=>"yourkey"}>
1.9.3p0 :001 > BITLY_CLIENT.shorten("http://google.com")
=> #<Bitly::V3::Url:0xb5658c8 @client=#<Bitly::V3::Client:0xb653398 @default_query_opts={:login=>"yourusername", :apiKey=>"yourkey"}>, @short_url="http://bit.ly/xFMlrA", @long_url="http://google.com/", @user_hash="xFMlrA", @global_hash="LmvF", @new_hash=false, @user_clicks=nil, @global_clicks=nil, @title=nil, @created_by=nil, @aggregate_link=nil, @clicks_by_minute=nil>
@vincentpaca
vincentpaca / gist:1780816
Created February 9, 2012 16:02
Textmate + GEdit = GMate on Ubuntu, Ruby on Rails Text Editor
sudo add-apt-repository ppa:ubuntu-on-rails/ppa
sudo apt-get update
sudo apt-get install gedit-gmate
sudo apt-get install gedit-plugins