Monday, May 28, 2012

Namecheap E-mail Forwarding to GMail

Alright, so I've seen several posts of this and experienced it myself and I couldn't seem to find an answer. Luckily, in mucking about I seemed to stumble about a solution that has worked thus far.


The Issue:

The issue was that if you registered for a Namecheap domain, and wanted basic e-mail forwarding, it didn't seem to work with GMail. No, I'm not talking about using Namecheap's e-mail servers, no I'm not talking about Google Apps for business, I'm talking basic forwarding of one e-mail address to another. For example, forwarding info@mydomain.com to myaddress@gmail.com. For some reason, it would work with e-mail service providers like Hotmail but not with GMail - and GMail really is my favourite.


The Solution:

Alright, the solution that has worked for me seems to lie in assigning an e-mail alias in GMail. But the only way you can do that is temporarily forward your e-mail to a non-GMail account.

So what you end up doing is temporarily forward your domain e-mail address to a non-GMail account, and then add an alias to the GMail account (which sends a verification e-mail to your non-GMail account). Once the GMail alias has been verified, now you can set your Domain to forward to your GMail account.

Here are the steps:

There are 3 accounts we're dealing with:

  • a. Domain account - in our example "info@yourdomain.com"
  • b. Non-GMail Account - in our example "me@hotmail.com"
  • c. GMail Account - in our example "me@gmail.com"


Register Your Domain and setup e-mail forwarding to non-Gmail Account

  1. Hit up www.namecheap.com and register your domain.
  2. In your domain settings, click on "E-mail Forwarding"
  3. Setup an entry to forward "info@yourdomain.com" to non-GMail account like "me@hotmail.com".


Test E-mail

  1. Send an e-mail to "info@yourdomain.com", you should get it in your hotmail.


Setup your GMail account

  1. Log into your gmail account, and go to settings.
  2. Under Accounts and Import, look for "Send mail as..."
  3. Add your "info@yourdomain.com" account.
  4. This will cause GMail to send a Verificaiton e-mail to "info@yourdomain.com" which should end up in your non-GMail account "me@hotmail.com".
  5. Enter the verification code
  6. Make "info@yourdomain.com" your default account.
  7. GMail is now setup send mail as "info@yourdomain.com" and for some reason this unblocks the namecheap forwarding.


Switch Forwarding E-mails to GMail Account

  1. Now that GMail doesn't block namecheap anymore, switch your e-mail forwarding entry "info@yourdomain.com" to forward to "me@gmail.com"

Sunday, April 29, 2012

Gitting to Know You

Hey everybody,

just a quick note, I've started some tutorial videos on GIT. If you're new to Git, check 'em out and spread the word.

http://www.caseyli.com/gittingtoknowyou

Saturday, December 24, 2011

JQTouch and Google Maps API Rendering Issues

Really quick one today. Today I implemented Google Maps into my JQTouch webapp using the Google Maps Javascript API V3.

Seemed easy enough except I was having a lot of rendering issues with the Google Maps (lots of gray areas where maps weren't rendering).

The key is, the Map constructor for Google Maps takes into account a div and renders a map in it. Let's call that the "map-div".

The issue was that I was using Javascript to render the map, then I called a jQT.goTo("#mappage") which changed the positioning of the map-div tag where the map was being rendered.

Quick solution: navigate to the page where the map-div is first - then do the Google Maps rendering. In my case, I had to call the jQT.goTo("#mappage") first, then I did my Google Maps rendering. Problem solved. Maps rendered gorgeously!

Friday, December 2, 2011

jQuery AJAX Post to a Rails Create Function

Alright, I was going to do this posting when I discovered my solution, but I got super busy and never got around to it.

Basically the problem I ran into was knowing how to call Rails Create function using JQuery AJAX. There were a few parameters I didn't know about - like what was the URL, what was the type of AJAX call, how did I pass the data etc.

So, my setup was that I had a controller for my sessions and I was using rails "resources" routing to generate the routes for it. The "create" action of the SessionsController required a "session" object that contained an "email" and a "password" and the session was expected to be incoming via the parameters. That is, the SessionController.create was looking for params[:session][:email] and params[:session][:password].

So how do I get all this to happen with an AJAX JQuery call:

$.ajax({
type: "POST",
url: "/sessions",
dataType : "json",
data: { session : { email : var_email, password : var_password } },
success : function(data, textStatus, jqXHR) {
},
error : function(jqXHR, textStatus, errorThrown) {
}
});

The thing that took me a while to figure out was the URL and the type and the data. Probably would have helped if I reviewed my "resources" routing in Rails and also new that you could pass a JSON object to a Rails controller.

Wednesday, November 30, 2011

jQTouch Dynamic Links and Event Handlers

Alright, so one of the biggest worries I had while developing the jQTouch UI for my recent app (the first app I've ever developed with jQTouch) was generating dynamic links and getting event handlers for dynamic links.

Here's the basic idea, I had a list of items that was returned from a AJAX call, and I wanted to generate a link for each of the items.

So easy enough:

jQuery.each(data, function(){
ihtml += "<li><a href='#'>" + data.item.name + "</a></li>"
}

So that generated the links which was all good. But then I came across the problem of how do I react to each link - or at least how do I handle a click of the link and figure out which link was clicked.

The way I did this was by giving the same "id" attribute to all of the links, but then I added a custom attribute called "item_id". So my link generation became:

jQuery.each(data, function(){
ihtml += ihtml += "<li><a href='#' id='itemlink' item_id='" + data.item.id + "'>" + data.item.name + "</a></li>"
}

So each link woud have the same "id", but they would have a different "item_id".

Then using the jQTouch call back events, I extracted that "item_id" when the link was clicked.

$("#itemlink").tap(function(e, info) {
loadItem($(e.target).attr("item_id"));
}

The $(e.target) essentially grabs the element that was tapped. Then you can call your standard element inspection methods on it like .attr("item_id").
And my loadItem function would be something like

function loadItem(item_id) {
/*make AJAX call using item_id */
}

So each link will react to this, but then the attr("item_id") will be different.

Hope that makes sense.

Heroku, jQTouch, iPhone Fullscreen Image Refresh Issues

Alright so today things were going pretty well with development on my open mic community app so I decided to work on some of the graphics. After spending some time deciding on what I wanted to change, I came up with some graphics I was happy with.

App Background: Ruby on Rails 3 app, hosted on Heroku with JQTouch for iPhone UI.

So I updated my local git repository, pushed it to github, and then to heroku. Since I've been testing my app a lot, I already had it added to my homescreen. So I hit the Homescreen icon which launched my fullscreen webapp - but my new images weren't showing up.

So to debug, I decided to launch safari and navigate to my page - the new images were showing up there. That's weird - because it was my understanding that the fullscreen iOS webapp was just Mobile Safari without the address bar and controls at the bottom.

So it's really weird that it was rendering the new images in Mobile Safari but not from my shortcut. So I decided to delete my homescreen shortcut. I navigated to my page (in Mobile Safari where the new images showed up) - and added a shortcut to my homescreen.

I tapped the homescreen icon - and still nothing! The old images were still coming up. I cleared my cache and HTML data - and still nothing.

I was getting quite frustrated and decided to leave it alone and figure it out later.

I came back to my app a few hours later - and boom - the new images had loaded!

So turns out it was just a matter of time. I have no idea what's being cached and where. Didn't seem to be an issue with Heroku nor with Rails since Mobile Safari was rendering it properly. It seems to be iOS's fullscreen app runner that was doing some caching somewhere.

So long story short - if this happens to you - just wait a while - the refresh should happen.

Tuesday, November 29, 2011

jQTouch, AJAX, Ruby on Rails

Alright, this is the beginning of my blog entries concerning software development as I get more and more passionate about it.
Today, I findings on jQTouch, AJAX, and Ruby on Rails.
jQTouch is a nice little javascript library that makes is super simple to develop webapps that look great on the iPhone. So much so that if a user adds your homepage to their homescreen, it looks so much like a native app it hurts! (well, it doesn't really, but it's quite nice).
There are other alternatives out there like iUI, jQuery Mobile and Sencha, but I decided that jQTouch was a good in-between of everything.
So the big problem I had today was that I was having a lot of issues getting the my webapp on the iPhone to make an AJAX call. When I ran the app in Chrome on several computers, there was no problem.
Quick App Summary: App built in Ruby on Rails 3, using jQTouch for the iPhone UI, and jQuery to make the AJAX calls.
I narrowed it down to it being a 406 error. Using the following code:

$.ajax({
url: '/sessions/test',
dataType: 'json',
success: function(data, textStatus, jqXHR){
alert(textStatus + ': ' + jqXHR.responseText);
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + ":" + errorThrown + ":" + jqXHR.status);
}
});

After that I realized my 406 error was actually stemming from how I interpreted iPhone requests.
In my Application controller, I had a bit of code that would basically look at the User Agent to determine whether or not I would use the regular Web Interface, or the Web Interface designed for the iPhone. To do this, I had a few methods like this:

def set_ios_format
if is_iphone_request? or request.format.to_sym == :iphone
request.format = if cookies["browser"] == "desktop"
then :html
else :iphone
end

# Handle AJAX Requests
if request.xhr?
request.format = :json
end
end
if is_ipad_request? or request.format.to_sym == :ipad
request.format = if cookies["browser"] == "desktop"
then :html
else :ipad
end
# Handle AJAX Requests
if request.xhr?
request.format = :json
end
end
end

You see that bit of code in there that says "Handle AJAX Requests" - this is what was missing. The problem is, when the iPhone was making an AJAX request, my Ruby on Rails code was treating that like a iPhone browser request - and setting the format to "iphone" which is an illegal format for the iPhone to accept via AJAX request.
So I do a quick check to see if the request is coming from a xhr, and if it is, set the format to "json" - could have set it to xml or whatever other AJAX response you want.
All was solved.