January 2012
3 posts
Add facebook app to page tab
When Facebook remove the own apps page, he also kill easy opportunity to add this app to your facebook page tab.
Now, you can do it easy with this magick url:
https://www.facebook.com/dialog/pagetab?app_id=[APP_ID]&display=popup&next=https://[URL_TO_YOUR_APP_ON_YOUR_SERVER]
4 tags
Ruby wrapper for startmobile sms service →
This gem provide the easy way to send and check a single sms with startmobile.com.ua service.
Install
gem 'startmobile_sms'
Configure
StartmobileSms.setup do |config|
config.login = 'login'
config.password = 'password'
config.out_number = 'out_number'
end
Usage
# Send single sms (out_number is optional)
sms_id = StartmobileSms.send(:phone => '30971234567', :text => 'Hello!',...
Friendly_id. Don't change slug on update
If you don’t want to regenerate you slug when model change friendly_id field, use this hook:
# config/initializers/add_static_to_friendly_id.rb
module FriendlyId
module Static
def should_generate_new_friendly_id?
new_record?
end
end
end
# your model
class MyModel < ActiveRecord::Base
extend FriendlyId
friendly_id :something, :use => [:slugged, :static]
end
November 2011
1 post
5 tags
Select album photos likes from Facebook by FQL...
I have Facebook contest album with many photos. And I need to display rating of this photos by user likes.
This FQL query get a list of all likes (user_ids) by all photos:
SELECT user_id, object_id FROM like WHERE object_id IN (SELECT object_id FROM photo WHERE aid=’139307129471375_51887’ limit 5000) limit 100000
Then you can order results by object_id and sort...
August 2011
3 posts
Create nice design for you project without... →
Gem MetaWhere - nice sql quering →
Recover MySQL root Password →
After last Unbuntu update my Mysql server lost root password. This link save few hours of my day))
July 2011
1 post
5 tags
Group_by example in MongoMapper
This is simple way to make a request on a column grouping in MongoMapper like as GROUP_BY in SQL:
June 2011
1 post
Very nice tools for js development →
May 2011
1 post
Cyrillic length problem
Ruby 1.8.7 (Ruby Enterprise Edition):
“string”.length # => 6
“строка”.length # => 12
Solution:
“string”.split(//).size # => 6
“строка”.split(//).size # => 6
March 2011
4 posts
7 tags
Publish stream in Facebook & Twitter with OmniAuth
First of all, include OmniAuth to your rails app by this railscast or this.
Then add to Gemfile this gem:
gem ‘fb_graph’, ‘1.5.4’
After, you should turn on permission in your apps:
for Facebook:
for Twitter:
When your login from OmniAuth, social app ask your permission on update wall in Facebook and post tweet in Twitter.
Paste to you authentication model (my...
Overwrite Devise user update with current_password
If you don’t need to check current_password when user is updating itself, then you can overwrite standart Devise method update_with_password:
Using Redis with Ruby on Rails →
User Friendships && High Score Table
OmniAuth - Twitter: OAuth::Unauthorized (401...
Такое случается, когда в twitter app выбираем тип приложения Browser, но, при этом, не указываем Callback URL.
Свитер автоматом меняет тип приложения на Client, когда поле урла колбека пустое.
Так что Callback URL - обязательное поле.
February 2011
3 posts
5 tags
Rails 2 routes redirect
Редирект странички средствами Rails:
Caching Views is Not the View’s Job! →
Хорошая статья о том, как правильно кэшировать фрагменты (и не только) в Rails с помощью cells.
class CartCell < Cell::Rails
cache :show
def show(items)
@items = items
render
end
Building a Facebook Application →
Отлично иллюстрированый tutorial создания приложения на Facebook с помощью Heroku + Sinatra.