skip to main | skip to sidebar
<< Dinks >>
  • Blog
  • Archives
  • Profile
  • Me On the web
  • Email

Sunday, January 15, 2012

FB Likes

I have been trying to get the Facebook Like to appear on an application. It was getting somewhat stressful because the Like would just not take the whole URL, but would take the base URL.


I started using the XFBML first because the way to integrate it is so nice. 


Add 


<html xmlns:fb="http://ogp.me/ns/fb#"> 


as the namespace and then use 


<fb:like href="http://google.com/" send="false" layout="button_count" width="450" show_faces="false"></fb:like>


Easy enough. The application used a lot of Ajax and therefore the these likes need some refreshing. To do this I used the Javascript method available


fb.xfbml.parse()


Function and it started working. But the likes were happening only for the base URL and not the href in the fb:like. This is when I saw the statement in the documentation which said 'The XFBML version defaults to the current page.' if href is used. 


urghh


I went on to use the iframe way so that I could get likes for the particular URL. It seems its important that the url end with '/' and only then Facebook identifies the absolute URL. 

Posted by Dinks V at 10:28 PM 0 comments

Labels: facebook, javascript, like, rails

Wednesday, December 28, 2011

Image Cropping With Rails 3

I was looking at some options for the Image Cropping functionality with Rails 3 and got many great solutions on the net. This Rails Cast is the best place to start if you have the images stored as local. If you have it as s3 storage there are some changes you need to make.

My main haml file has these contents -

#cropperpopup.lpopup.x 
  %a.ccloser 
  %p.large Image Cropper 
  .cropper 
    = image_tag @user.avatar.url(:medium), :id => :cropbox 
  = form_for @user, :html => {:class => 'edit_user_two'} do |f| 
    - for attrbt in [:crop_x, :crop_y, :crop_w, :crop_h] 
      = f.text_field attrbt, :id => attrbt, :class => :coordinate 
    = f.submit 'Crop'

When on calls the popup, one should call the code for the Jcrop method

$('img#cropbox').Jcrop({ 
  onChange: update_crop, 
  onSelect: update_crop, 
  setSelect: [0, 0, 168, 202], 
  aspectRatio: (168/202) });

My aspect ratio setting is with respect to the configurations I did for the has_attached_file :avatar.

The thing you will have to do specifically for s3 is in the avatar_geometry method.


def cropping? 
  !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? 
end 

def avatar_geometry(style = :medium) 
  @geometry ||= {} 
  path = (avatar.options[:storage]==:s3) ? avatar.url(style).split(' ').join('%20') : avatar.path(style) 
  @geometry[style] ||= Paperclip::Geometry.from_file(path) 
end

Inside the model.

I'm having issues with the cropper processor and its not cropping fine. Will have to fix that. This is the Cropper

module Paperclip 
  class Cropper < Thumbnail 
    def transformation_command 
     if crop_command 
       r = super 
       if r.class == Array 
         r = r.join(' ') 
       end 
       crop_command + r.sub(/ -crop \S+/, '').sub(/-resize \S+/, '') 
     else 
       super 
     end 
   end 
   def crop_command 
     target = @attachment.instance 
     if target.cropping? 
       "-resize \"168x202\" -crop #{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y} " 
     end 
    end 
  end 
end

Posted by Dinks V at 8:27 AM 0 comments

Labels: crop, javascript, paperclip, programming, rails, ruby

Tuesday, September 20, 2011

Orientation changes for iPad - Secha & PhoneGap

I was working on a mobile application developed for iPhone. The application was built using Sencha Touch and PhoneGap. Its great what these guys have done to bridge the gap between Objective C and HTML/JavaScript/CSS. The application now wants to be run on iPad.

The orientation was something that caused a problem here. The call back for the orientation, onorientationchange, was not being called for some reason. I went through most of the content in the web which described the problem. Solutions were limited.

I tried putting window.onorientationchange, added event listeners for orientation and even added Objective C code ! Did not work ...

Thats when onWindowResize came into picture. The code started working. But just once. You change orientation and that works just once. The code goes something like :

var or = function(){ 
    // alert( Ext.getOrientation()); 
    var width = (Ext.getOrientation()=="landscape") ? window.innerWidth-1 : window.innerWidth; 
    panel.setOrientation( Ext.getOrientation() , width , window.innerHeight ); 
    panel.el.parent().setSize(width, window.innerHeight); 
    // return 0; 
    panel.doComponentLayout(); 
} 
Ext.EventManager.onWindowResize(or);

The alert function caused a lot of issues for me. Firstly it creates an exception on the Objective C side. Signal Exception of some kind which says arguments are expected of a different kind. The setOrientation call is necessary for the panel to know the orientation. This did not update the width and height of the panel for some odd reason. So I did it manually by calling the setSize and to make sure I called the doComponentLayout.

Well, the code works now. This is for reference for all those people who have not still got the answers for this question.

Kudos !


Posted by Dinks V at 8:34 AM 0 comments

Labels: css, html, ipad, iphone, javascript, objectivec

Saturday, July 30, 2011

Rails Again

I started digging into Rails again. The stuff I started to do was quite straight forward. The DB access, change routes etc. But the things I want to talk about was Haml and Coffeescript.

Haml :
Wow ! Just Wow !
I always wanted a templating engine which I could use to write easy code. Writing HTML was never so fun. The syntax might seem to be complex but trust me it gets to be fun. 

Just add a
config.generators do |g|
      g.template_engine :haml
end
in application.rb after adding the haml gem and the haml-rails gem.

Coffeescript :
This is an intermediate compiler which converts a file into javascript. Eliminate your braces and semicolons with coffeescript. The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript implementation, and tends to run as fast or faster than the equivalent handwritten JavaScript.

You will have to install barista, bisttro_car, coffeescript and coffeescript-script gems. I found an article which would be useful here.

Have Fun coding !




Posted by Dinks V at 11:36 AM 0 comments

Labels: coffeescript, haml, programming, rails, ruby

Wednesday, July 27, 2011

Oatmeal

The oatmeal has been one of the best sites for satirical humour. Just pasting one of their comics :)

What would don draper do?


Posted by Dinks V at 12:12 AM 0 comments

Labels: oatmeal, satire

Sunday, June 19, 2011

Exciting but anxious

Its been some days since my wedding. Those moments where is some sense anxious. Some times one just feels if something went wrong. My being somewhat of a pessimist, had these kind of thoughts very frequently. The engagement, which happened long back, was pretty easy and I had a good time. People commented on me being too easy and laughing a lot. Therefore I decided to act matured. Dont like it, but still. Acting childish makes it easy being young at heart.

I smiled less during the wedding. The pics told it all. :)

I sweated like a pig, but the ceremony went fine. No hassles. No confusion. Everyone seemed to have a blast, even though the travel from my house to the temple was a long one.

After that started the visits to the relatives. Short ones except for Govindan's house. A dear friend, I felt it necessary for her to know the people who stayed there. Reshma's relatives were also visited.

Then it was off to Shimla. 10 hours of travel from Delhi to Shimla was tiresome, even if it were in a Swift Dezire. Shimla was not as cold as we expected. But the hotel stay was excellent. Great people at the Woodville Palace and excellent food.

More tours yet to come

Posted by Dinks V at 10:57 PM 0 comments

Labels: reshma, shimla, wedding

Monday, May 16, 2011

Bangalore Superfast Express timings changed ??


"  Train services partially cancelled
STAFF REPORTERSHARE  ·   PRINT   ·   T+ 
The following trains will be regulated/partially cancelled for 12 days from Monday. However, the trains will run on Wednesdays. This has been necessitated due to hoisting of girders for the superstructure of a railway overpass between Devaragudda and Byadagi stations, a release said.
Accordingly, the Hubli-Bangalore City Passenger (train no. 56516) will leave Hubli at 8.45 a.m. instead of 7.15 a.m. Bangalore City-Hubli Passenger (56911) will terminate at Harihar and be partially cancelled between Harihar and Hubli. Arsikere-Hubli Passenger (56273) will be regulated at Ranebennur from 9.25 a.m. to 10.50 a.m.
Change in serviceErnakulam-Bangalore City Bi-weekly Superfast Express (train no. 12863) will leave Ernakulam on Wednesdays and Mondays instead of Wednesdays and Sundays with effect from July 20.
In the return direction, Bangalore City-Ernakulam Bi-weekly Superfast Express (train no. 12864) will leave Bangalore on Thursdays and Tuesdays instead of Thursdays and Mondays with effect from July 21."

Excerpt from the Hindu

What do I do so that this is taken off ???

Anybody agrees and knows what to do ?

Posted by Dinks V at 2:36 AM 0 comments

Older Posts Home
Subscribe to: Posts (Atom)

Dinks

Dinks
Dinesh Vasudevan

Search My Stuff

Loading...

Followers

Google +

Digg this

Add to Technorati Favorites

FeedBurner FeedCount

Counter -

website tracker

What Have I Done ?

  • ▼  2012 (1)
    • ▼  January (1)
      • FB Likes
  • ►  2011 (9)
    • ►  December (1)
      • Image Cropping With Rails 3
    • ►  September (1)
      • Orientation changes for iPad - Secha & PhoneGap
    • ►  July (2)
      • Rails Again
      • Oatmeal
    • ►  June (1)
      • Exciting but anxious
    • ►  May (1)
      • Bangalore Superfast Express timings changed ??
    • ►  February (2)
      • Web access in Vajra
      • World Cup Calendar
    • ►  January (1)
      • Delegation Drag
  • ►  2010 (26)
    • ►  October (2)
      • Backup the Pod
      • Mac on Lenovo
    • ►  September (1)
      • Pune Post
    • ►  August (2)
      • Minimum diff between dates of a week
      • Scratch
    • ►  July (1)
      • Inception
    • ►  June (3)
      • World Cup Frenzy Too
      • World Cup Frenzy
      • Javascript Debug
    • ►  May (2)
      • Dependencies
      • Back after a wait
    • ►  April (1)
      • Happy Birthday
    • ►  March (5)
      • Vella Kuuraan
      • Lists
      • Something that I stumbled Upon
      • Dark Side and the Bright Side - Goa
      • JS Snippets
    • ►  February (6)
      • The VIM
      • Class Path !?
      • Cook me up
      • The 18th again
      • Roamers
      • Wow Bash
    • ►  January (3)
      • Pre Initialization Technique
      • Rough Waves
      • Path to follow
  • ►  2009 (18)
    • ►  December (1)
      • Procedure
    • ►  November (2)
      • Yahoo !
      • Phew - Learning is hard
    • ►  October (3)
      • Wave similarities
      • Apache Passenger
      • A Collection of Interviews
    • ►  September (2)
      • The South Side
      • Rails Style
    • ►  August (1)
      • Talent
    • ►  July (2)
      • A Dedication
      • Ajaxified Will Paginate
    • ►  June (2)
      • The Face of the Web
      • Search search search
    • ►  May (1)
      • Jira Again
    • ►  April (1)
    • ►  March (2)
    • ►  January (1)
  • ►  2008 (51)
    • ►  December (4)
    • ►  November (3)
    • ►  October (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (2)
    • ►  June (5)
    • ►  May (1)
    • ►  April (7)
    • ►  March (7)
    • ►  February (8)
    • ►  January (5)
  • ►  2007 (10)
    • ►  December (2)
    • ►  November (4)
    • ►  October (2)
    • ►  September (1)
    • ►  August (1)

Talk To Me ..

Me on the net

  • Hindu 1
  • Hindu 2
  • IMDB
  • On Google
  • Pownce
  • Twitter

Twitter Updates

Twitter Friends

my StumbleUpon Favorites

Loading...

Video Bar

Loading...

dinks" shared items

My Box

Adsense

Wink Widget

people search by

FEEDJIT Live Traffic Feed

 

Subham

Free to comment.. I express my own experiences here ..