Hacking Gmail to push fetched email
Gmail has “fetch” capability which enables grabbing messages from other POP accounts at a rate of approximately once every hour.
Slow…I use this to automatically grab my work email from an exchange server, tag it, and forward it to my cell phone via text message (my # @ messaging.sprintpcs.com). This allows me to filter and log all messages in Gmail while pushing to mobile, albeit very slowly.
The Fix Part I
Gmail uses an ajax request to force a check on the email account when you click “Check Now” in Account Settings. By using firebug to grab the link that the GET request is sent to, we can just automate sending to that URI.
I did a quick jQuery script to send a GET to that URI at a timed interval. About 7 lines of code, and just let it run in a browser. It kinda worked I think. I can get my requests down to every 5 minutes. Considering it takes about a minute to check the mail, I guess that’s not to bad.Now, on to a real server side program that can completely automate this reliably! :D
Javascript Library. jQuery is amazing.
“How I built a full Oracle PL/SQL JDBC Java Application with GUI in 1 ½ days.”
Coming soon…
Shai Hulud - Misanthropy Pure
Thai grocery store
Syntax Test for Previous JS Code
Using GVim’s “Convert to HTML” feature, I easily converted my line-numbered and highlighted code to plain html for tumblr. While the mark-up is pretty ridiculous (a web developer/designer’s nightmare - full of font tags), it is a quick way to post code.
1 /* Function that returns a random index (int) of an array */
2 function getRandomIndex(array) {
3 /*rand is:
4 "The rounded int of a random decimal between 0 and 1 times
5 10 to the power of the ceiling of the array length divided by ten."
6 Thus, rand is a random number between 0 and 10 if length is less than 10
7 and a number between 0 and 100 if length is less than 100 etc...
8 */
9 var rand = Math.round(Math.random() *
10 Math.pow(10,Math.ceil(array.length/10)));
11
12 /* Get a random int using rand that is also
13 within the bounds of the array */
14 var index = rand % array.length;
15
16 return index;
17 }
Javascript Random Index Function
After seeing the same first testimonial repeatedly appear on Davidville’s front page, and very few of the other testimonials that followed, I thought of a basic function that would mix it up a bit. I think it could also be useful for a lot other applications that involve grabbing a random item.
/* Function that returns a random index (int) of an array */
function getRandomIndex(array) {
/*rand is:
"The rounded int of a random decimal between 0 and 1 times
10 to the power of the ceiling of the array length divided by ten."
Thus, rand is a random number between 0 and 10 if length is less than 10
and a number between 0 and 100 if length is less than 100 etc...
*/
var rand = Math.round(Math.random() *
Math.pow(10,Math.ceil(array.length/10)));
/* Get a random int using rand that is also
within the bounds of the array */
var index = rand % array.length;
return index;
}
I also wrote up a quick demo to demonstrate grabbing a random item from a random size array. It was some good practice with the DOM and avoiding the use of innerHTML.
Note to self: Find syntax highlighter to use for tumblr!
What problem are we solving here? Sometimes when you ask yourself this question you’ll find that you’re solving an imaginary problem. That’s when it’s time to stop and reevaluate what the hell you’re doing. (via Question your work - (37signals))
reblogged from slantback
