Skip to content

Instantly share code, notes, and snippets.


Vincent Paca vincentpaca

View GitHub Profile
vincentpaca / mime_types.rb
Created November 9, 2011 18:40
Mime Types
View mime_types.rb
Mime::Type.register_alias "text/html", :mobile
vincentpaca / application_controller.rb
Created November 10, 2011 10:03
Application Controller
View application_controller.rb
before_filter :prepare_for_mobile
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
request.user_agent =~ /Mobile|webOS/
vincentpaca / mime_types.rb
Created November 10, 2011 10:04
Mime Types w/ Multiple aliases
View mime_types.rb
Mime::Type.register_alias "text/html", :mobile
Mime::Type.register_alias "text/html", :iPad
<!DOCTYPE html>
<%= 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 %>
<div class="home">
vincentpaca / mobile.js
Created November 12, 2011 10:25
View mobile.js
vincentpaca / log
Created January 2, 2012 07:58
Ruby 1.9.3p0 Rails 3.1.3 Rake breaks on rake db:migrate
View log
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
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 / config.yml
Created January 28, 2012 22:21
Bitly config
View config.yml
bitly_username: yourusername
bitly_key: yourkey
vincentpaca / bitly.rb
Created January 28, 2012 22:23
Bitly initializer
View bitly.rb
require Rails.root.join('config','initializers','load_config')
BITLY_CLIENT =['bitly_username'], APP_CONFIG['bitly_key'])
vincentpaca / gist:1696052
Created January 28, 2012 22:41
Bitly test
View gist:1696052
1.9.3p0 :002 > BITLY_CLIENT
=> #<Bitly::V3::Client:0xb653398 @default_query_opts={:login=>"yourusername", :apiKey=>"yourkey"}>
1.9.3p0 :001 > BITLY_CLIENT.shorten("")
=> #<Bitly::V3::Url:0xb5658c8 @client=#<Bitly::V3::Client:0xb653398 @default_query_opts={:login=>"yourusername", :apiKey=>"yourkey"}>, @short_url="", @long_url="", @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 / gist:1780816
Created February 9, 2012 16:02
Textmate + GEdit = GMate on Ubuntu, Ruby on Rails Text Editor
View gist:1780816
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