Nov 3, 2011 in Quick Tips by jandrews | No Comments
I am trying to figure out the best solution for calendaring for my wife and myself. Often she'll make plans, and tell me and well I won't put it in a calendar. I'll just forget about it. I don't make plans weeks in advance, I make them a few days in advance. I thought fine, I'll set up a google calendar we can share via iCal. I can set up my iPhone to read the calendar and I'll know when stuff is planned. Right? Well guess what it isn't so easy.
When you set up your gmail account on your iDevice it will set you up with 1 calendar. This is not what I want. I want more than 1 calendar. I want 2 or 3 maybe even 4 or 5. The solution is quite easy turn off Javascript and go to
. Select the calendars you want to use and then click save. Presto. I got this tip from
the difference is he states you need a calDav account set up, but it works just fine with a standard gmail option set up.
Oct 4, 2010 in PHP Development by jandrews | 2 Comments
I've only used Paypal IPN a couple times. Both time were in systems where the IPN was already set up. It didn't take much work for me to actually do anything from there. I am working on a new WordPress module. Part of which includes functionality where I needed to do some paypal processing. While searching through the internet I found a lot of sample code, but nothing that was a simple object. After some headaches caused by a typo, I have a php5 class for Paypal IPN validation.
define('PAYPAL_IPN_LISTENER_VERIFIED_STATUS','VERIFIED');
define('PAYPAL_IPN_LISTENER_INVALID_STATUS','INVALID');
class PaypalIPNListener
{
protected $status = PAYPAL_IPN_LISTENER_INVALID_STATUS;
protected $payment_status = false;
private $sandboxUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
private $productionUrl = "https://www.paypal.com/cgi-bin/webscr";
private $serviceUrl = null;
private $serviceData = "";
public function __construct($postData = array(), $sandbox=false)
{
// Set the initial serviceUrl
$serviceUrl = $productionUrl;
// If sandbox change the serviceUrl
if($sandbox == true) $serviceUrl = $sandboxUrl;
// Save the post data for later use.
$this->postData = $postData;
// If we are debugging switch the URL
$serviceUrl = ($sandbox) ? $sandboxUrl : $productionUrl;
// Add the validate notify command to the post data.
$postData['cmd'] = '_notify-validate';
// Create a querystring from the data.
foreach($postData as $key => $val)
{
if($serviceData != "") $responseData .="&";
$serviceData .= $key . "=" . urlencode($val);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->serviceUrl);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output = curl_exec($ch);
// If the payment is verified then set the status as verified.
if($output == "VERIFIED")
{
$this->status = PAYPAL_IPN_LISTENER_VERIFIED_STATUS;
$this->payment_status = $postData['payment_status'];
}
}
public function getPaymentStatus()
{
return $this->payment_status;
}
public function __toString()
{
return $this->status;
}
}
The code makes creating an IPN script simple for anyone.
// Create the IPN Listener object. (passing true as the 2nd parameter
// sets you up with the sandbox for development.
$ipn = new PaypalIPNListener($_POST, true);
Once you create the object there is nothing left for you to do for the validation process to begin. It has already begun, and ready for you to use. How do you use it? Like this.
// IPN Listener Object
$ipn = new PaypalIPNListener($_POST, true);
if($ipn == PAYPAL_IPN_LISTENER_VERIFIED_STATUS)
{
// Payment is verified. We use the magic method __toString to return the validation status.
// Then it's as simple as checking the $_POST data for the ['payment_status'] to make sure they
// weren't denied or that something didn't go wrong on paypals side.
}
else
{
// something went wrong with the validation process. You should handle it here.
// at least log it so that you have a record of the failed validation.
}
To go into production mode either pass "false" as the second parameter or remove it entirely only passing the post data. Once you do that you are GOOD TO GO!
Sep 18, 2010 in General Discussion by jandrews | 14 Comments
I currently live in Japan. Most of my friends are back in the USA. Luckily I have the internet. If not for the Internet I think I'd go stir crazy, plus I have no idea what I'd do for work. Anyway, many of my friends and family back home have the latest iPhones. I too have the latest iPhone here in Japan, and as long as we are connected to local wifi networks it is possible to do video chat with Facetime.
It all started a few weeks ago. My brother wanted to do Facetime, I personally didn't care. I had tried a couple times to instantiate the call, and gave up. My brother though was adamant about getting it to work.
When making a normal phone call to Japan from the United States you do as follows: 011 + 81 + phone number. Most Japanese phone numbers start with a 0, when calling Japan you remove that leading 0
When making a phone call to the united states from Japan you do as follows: 010 + 1 + phone number (including area code).
Why is this important? Well it is how my brother figured out how to call me. By adding 011 + 81 to the beginning of my phone number in the address book, he was able to initiate a Facetime call.
There is however an easier way which I figured out. In the address book on your phone when you edit the number, you'll notice it gives you the option to add either +, *, or #. The one we care about is the plug sign.
To call the US it's simply (plug sign) + 1 + number (including area code). So to dial a facetime user in Massachusetts it would be something like +1(978)555-1212
To call Japan it would be +81 (some long phone number).
It's that easy. Have fun doing your international video chat. If I ever get an iPod touch I'll do a tutorial on how to Facetime with that.
Tagged apple, facetime, international, iphone, video
Aug 21, 2010 in General Discussion by jandrews | 2 Comments
I am writing this because I am illiterate. You probably think I'm insane, since no illiterate person would know how to write an article. I am however not insane. I may be literate when it comes to reading and writing english, but when it comes to the language of Japan where I am currently living I am not very literate at all. The Japanese language is comprised of 3 character sets. Kana makes up 2 of them (hiragana and katakana) and Kanji the chinese language set makes up a majority of the language. See kana most used in 2 different ways. "katakana" is mostly used for foreign words with a few exceptions. "hiragana" is used for changing the tense on a word, and for linking words together via particles.
There are thousands of kanji characters and to be able to read most news papers you need to know the first basic 1000 of them. I myself maybe know 6-10 of them. As you can guess this makes for a very difficult time. Trying to read signs, relying on my wife to tell me what something in the grocery store is. Not being self sufficient is a very difficult feeling.
Back in the US when I would read signs I wouldn't think anything of it. This is that, that is this etc... Being unable to read signs now I understand what it must be like for the millions of illiterate people around the world. Who don't know how to read or write. Even worse those who live in developed countries where this skill is a necessity to get by on a day to day basis. I can only hope that society has something better to offer them, can give them a chance to learn a skill many of us take for granted on a daily basis.
As for me, I'll just have to study hard and hope that I can get up to the level where I can read a newspaper. Until then I'll continue to bang my head against the wall. :-p
I know a handful of symbols beyond basic hiragana, and my katakana
Aug 19, 2010 in General Discussion by jandrews | No Comments
This post has taken a while to come to a head. I try not to get into political conversations because when I do I get emotional. 20 years ago it was easy enough to stay away from but with the spawning of the internet age and social media it has been harder and harder not to be able to just get away from it.
Before the internet age it was easy. Didn't want to hear the rhetoric from the liberals or the conservatives you had to do 2 things. Turn off the TV and not buy a news paper. You may have to endure a little at work or school, but put on a set of headphones or walk away from the conversation and it was over.
Now however with the internet and social media it's becoming harder to get away from. You read a forum somewhere, and someone is bashing George W Bush, go to Facebook and you have some puts up a profile picture that says to "Spay and Neuter Liberals". Twitter people will retweet everything anything that is politically charged. Meanwhile while all you want to do is keep in touch with friends, family, and colleagues you are inundated with bullshit. Childish elementary school playground bullshit.
Sure the US Constitution gives you the right to say what you want. The fourth Amendment freedom of speech, but it is my opinion that people are taking that freedom for granted. Spewing whatever comes to mind, anything that may or may not offend their political rivals. To be honest it really demeans the meaning behind that freedom. We were given the freedom of speech to keep the political machine from becoming too powerful, not as a weapon to demean people who don't share the same beliefs as you, yet that is what is being done, and it's being done in such a way that makes the person wielding that freedom to be as immature as the playground bully.